diff --git a/Jenkinsfile2 b/Jenkinsfile2 index d7df07f06a..b95b3ff86b 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -218,12 +218,12 @@ def pre_test_win(){ if (env.CHANGE_URL =~ /\/TDengine\//) { bat ''' cd %WIN_INTERNAL_ROOT% - git pull + git pull origin ''' + env.CHANGE_TARGET + ''' ''' bat ''' cd %WIN_COMMUNITY_ROOT% git remote prune origin - git pull + git pull origin ''' + env.CHANGE_TARGET + ''' ''' bat ''' cd %WIN_COMMUNITY_ROOT% @@ -236,7 +236,7 @@ def pre_test_win(){ } else if (env.CHANGE_URL =~ /\/TDinternal\//) { bat ''' cd %WIN_INTERNAL_ROOT% - git pull + git pull origin ''' + env.CHANGE_TARGET + ''' ''' bat ''' cd %WIN_INTERNAL_ROOT% diff --git a/README.md b/README.md index a8126d74d4..1034a19f37 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,19 @@ [![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201) -English | [简体中文](README-CN.md) | [Lean more about TSDB](https://tdengine.com/tsdb) +English | [简体中文](README-CN.md) | [Learn more about TSDB](https://tdengine.com/tsdb/) # What is TDengine? TDengine is an open source, high-performance, cloud native [time-series database](https://tdengine.com/tsdb/) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. TDengine differentiates itself from other time-seires databases with the following advantages: -- **[High-Performance](https://tdengine.com/tdengine/high-performance-time-series-database/)**: 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/tdengine/high-performance-time-series-database/)**: 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. - **[Simplified Solution](https://tdengine.com/tdengine/simplified-time-series-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. - **[Cloud Native](https://tdengine.com/tdengine/cloud-native-time-series-database/)**: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for kubernetes deployment and full observability, TDengine is a cloud native Time-Series Database and can be deployed on public, private or hybrid clouds. -- **[Ease of Use](https://docs.tdengine.com/get-started/docker/)**: For administrators, TDengine significantly reduces the effort to deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access. +- **[Ease of Use](https://tdengine.com/tdengine/easy-time-series-data-platform/)**: For administrators, TDengine significantly reduces the effort to deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access. - **[Easy Data Analytics](https://tdengine.com/tdengine/time-series-data-analytics-made-easy/)**: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way. @@ -232,9 +232,9 @@ After building successfully, TDengine can be installed by sudo make install ``` -Users can find more information about directories installed on the system in the [directory and files](https://docs.taosdata.com/reference/directory/) section. +Users can find more information about directories installed on the system in the [directory and files](https://docs.tdengine.com/reference/directory/) section. -Installing from source code will also configure service management for TDengine.Users can also choose to [install from packages](https://docs.taosdata.com/get-started/package/) for it. +Installing from source code will also configure service management for TDengine.Users can also choose to [install from packages](https://docs.tdengine.com/get-started/package/) for it. To start the service after installation, in a terminal, use: diff --git a/cmake/cmake.version b/cmake/cmake.version index d5721f7671..fcb31adc39 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.1.1") + SET(TD_VER_NUMBER "3.0.1.2") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index eb0faf6d5d..16444c07f2 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG 71e7ccf + GIT_TAG be729ab SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 6fb2a69847..52e2c0944a 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG e7270c9 + GIT_TAG 8207c74 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in index 04b1262caf..ca8fff8da5 100644 --- a/cmake/taosws_CMakeLists.txt.in +++ b/cmake/taosws_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosws-rs ExternalProject_Add(taosws-rs GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git - GIT_TAG e771403 + GIT_TAG 1bdfca3 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/05-get-started/01-docker.md b/docs/en/05-get-started/01-docker.md index 6191492b37..be61dfeb8e 100644 --- a/docs/en/05-get-started/01-docker.md +++ b/docs/en/05-get-started/01-docker.md @@ -3,7 +3,11 @@ sidebar_label: Docker title: Quick Install on Docker --- -This document describes how to install TDengine in a Docker container and perform queries and inserts. To get started with TDengine in a non-containerized environment, see [Quick Install](../../get-started/package). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). +This document describes how to install TDengine in a Docker container and perform queries and inserts. + +- To get started with TDengine in a non-containerized environment, see [Quick Install from Package](../../get-started/package). +- For a fully managed solution, see the [TDengine Cloud documentation](/cloud/). +- If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). ## Run TDengine diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md index 292fa82183..da06aca148 100644 --- a/docs/en/05-get-started/03-package.md +++ b/docs/en/05-get-started/03-package.md @@ -7,7 +7,11 @@ import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import PkgListV3 from "/components/PkgListV3"; -For information about installing TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). +This document describes how to install TDengine on Linux and Windows and perform queries and inserts. + +- To get started with TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). +- For a fully managed solution, see the [TDengine Cloud documentation](/cloud/). +- If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine). The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface (CLI, taos), and some tools. Note that taosAdapter supports Linux only. In addition to connectors for multiple languages, TDengine also provides a [REST API](../../reference/rest-api) through [taosAdapter](../../reference/taosadapter). diff --git a/docs/en/05-get-started/index.md b/docs/en/05-get-started/index.md index cf475a8cd7..09875362f4 100644 --- a/docs/en/05-get-started/index.md +++ b/docs/en/05-get-started/index.md @@ -3,9 +3,9 @@ title: Get Started description: This article describes how to install TDengine and test its performance. --- -The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). +You can install and run TDengine on Linux and Windows machines as well as Docker containers. You can also deploy TDengine as a managed service with TDengine Cloud. -You can install and run TDengine on Linux and Windows machines as well as Docker containers. +The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). ```mdx-code-block import DocCardList from '@theme/DocCardList'; diff --git a/docs/en/07-develop/01-connect/_connect_cs.mdx b/docs/en/07-develop/01-connect/_connect_cs.mdx index f8d8e519fd..b81f49b2f0 100644 --- a/docs/en/07-develop/01-connect/_connect_cs.mdx +++ b/docs/en/07-develop/01-connect/_connect_cs.mdx @@ -1,8 +1,7 @@ ```csharp title="Native Connection" -{{#include docs/examples/csharp/ConnectExample.cs}} +{{#include docs/examples/csharp/connect/Program.cs}} ``` -:::info -C# connector supports only native connection for now. - -::: +```csharp title="WebSocket Connection" +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` diff --git a/docs/en/07-develop/03-insert-data/_cs_line.mdx b/docs/en/07-develop/03-insert-data/_cs_line.mdx index 71f46c62be..ae49901c3a 100644 --- a/docs/en/07-develop/03-insert-data/_cs_line.mdx +++ b/docs/en/07-develop/03-insert-data/_cs_line.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/InfluxDBLineExample.cs}} +{{#include docs/examples/csharp/influxdbLine/Program.cs}} ``` diff --git a/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx b/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx index 8d80d042c9..2627648616 100644 --- a/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx +++ b/docs/en/07-develop/03-insert-data/_cs_opts_json.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/OptsJsonExample.cs}} +{{#include docs/examples/csharp/optsJSON/Program.cs}} ``` diff --git a/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx index cff32abf1f..660db13fd1 100644 --- a/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx +++ b/docs/en/07-develop/03-insert-data/_cs_opts_telnet.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/OptsTelnetExample.cs}} +{{#include docs/examples/csharp/optsTelnet/Program.cs}} ``` diff --git a/docs/en/07-develop/03-insert-data/_cs_sql.mdx b/docs/en/07-develop/03-insert-data/_cs_sql.mdx index 1dc7bb3d13..42a6bc4315 100644 --- a/docs/en/07-develop/03-insert-data/_cs_sql.mdx +++ b/docs/en/07-develop/03-insert-data/_cs_sql.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/SQLInsertExample.cs}} +{{#include docs/examples/csharp/sqlInsert/Program.cs}} ``` diff --git a/docs/en/07-develop/03-insert-data/_cs_stmt.mdx b/docs/en/07-develop/03-insert-data/_cs_stmt.mdx index 229c874ab9..d8d73ca15e 100644 --- a/docs/en/07-develop/03-insert-data/_cs_stmt.mdx +++ b/docs/en/07-develop/03-insert-data/_cs_stmt.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/StmtInsertExample.cs}} +{{#include docs/examples/csharp/stmtInsert/Program.cs}} ``` diff --git a/docs/en/07-develop/04-query-data/_cs.mdx b/docs/en/07-develop/04-query-data/_cs.mdx index 4bb582ecbf..745ab36811 100644 --- a/docs/en/07-develop/04-query-data/_cs.mdx +++ b/docs/en/07-develop/04-query-data/_cs.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/QueryExample.cs}} +{{#include docs/examples/csharp/query/Program.cs}} ``` diff --git a/docs/en/07-develop/04-query-data/_cs_async.mdx b/docs/en/07-develop/04-query-data/_cs_async.mdx index 3ecf635fd3..19c8e58f32 100644 --- a/docs/en/07-develop/04-query-data/_cs_async.mdx +++ b/docs/en/07-develop/04-query-data/_cs_async.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/AsyncQueryExample.cs}} +{{#include docs/examples/csharp/asyncQuery/Program.cs}} ``` diff --git a/docs/en/07-develop/_sub_cs.mdx b/docs/en/07-develop/_sub_cs.mdx index a435ea0273..093b617e9b 100644 --- a/docs/en/07-develop/_sub_cs.mdx +++ b/docs/en/07-develop/_sub_cs.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/SubscribeDemo.cs}} +{{#include docs/examples/csharp/subscribe/Program.cs}} ``` \ No newline at end of file diff --git a/docs/en/12-taos-sql/01-data-type.md b/docs/en/12-taos-sql/01-data-type.md index 876de50f35..60046629a4 100644 --- a/docs/en/12-taos-sql/01-data-type.md +++ b/docs/en/12-taos-sql/01-data-type.md @@ -1,70 +1,70 @@ --- sidebar_label: Data Types title: Data Types -description: "TDengine supports a variety of data types including timestamp, float, JSON and many others." +description: 'TDengine supports a variety of data types including timestamp, float, JSON and many others.' --- ## Timestamp When using TDengine to store and query data, the most important part of the data is timestamp. Timestamp must be specified when creating and inserting data rows. Timestamp must follow the rules below: -- The format must be `YYYY-MM-DD HH:mm:ss.MS`, the default time precision is millisecond (ms), for example `2017-08-12 18:25:58.128` -- Internal function `now` can be used to get the current timestamp on the client side -- The current timestamp of the client side is applied when `now` is used to insert data +- The format must be `YYYY-MM-DD HH:mm:ss.MS`, the default time precision is millisecond (ms), for example `2017-08-12 18:25:58.128`. +- Internal function `NOW` can be used to get the current timestamp on the client side. +- The current timestamp of the client side is applied when `NOW` is used to insert data. - Epoch Time:timestamp can also be a long integer number, which means the number of seconds, milliseconds or nanoseconds, depending on the time precision, from UTC 1970-01-01 00:00:00. -- Add/subtract operations can be carried out on timestamps. For example `now-2h` means 2 hours prior to the time at which query is executed. The units of time in operations can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), or w(week). So `select * from t1 where ts > now-2w and ts <= now-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operations. +- Add/subtract operations can be carried out on timestamps. For example `NOW-2h` means 2 hours prior to the time at which query is executed. The units of time in operations can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), or w(week). So `SELECT * FROM t1 WHERE ts > NOW-2w AND ts <= NOW-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operations. Time precision in TDengine can be set by the `PRECISION` parameter when executing `CREATE DATABASE`. The default time precision is millisecond. In the statement below, the precision is set to nanonseconds. ```sql CREATE DATABASE db_name PRECISION 'ns'; ``` + ## Data Types In TDengine, the data types below can be used when specifying a column or tag. -| # | **type** | **Bytes** | **Description** | -| --- | :-------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 1 | TIMESTAMP | 8 | Default precision is millisecond, microsecond and nanosecond are also supported | -| 2 | INT | 4 | Integer, the value range is [-2^31, 2^31-1] | -| 3 | INT UNSIGNED| 4| unsigned integer, the value range is [0, 2^32-1] -| 4 | BIGINT | 8 | Long integer, the value range is [-2^63, 2^63-1] | -| 5 | BIGINT UNSIGNED | 8 | unsigned long integer, the value range is [0, 2^64-1] | -| 6 | FLOAT | 4 | Floating point number, the effective number of digits is 6-7, the value range is [-3.4E38, 3.4E38] | -| 7 | DOUBLE | 8 | Double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308] | -| 8 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. | -| 9 | SMALLINT | 2 | Short integer, the value range is [-32768, 32767] | -| 10 | INT UNSIGNED| 2| unsigned integer, the value range is [0, 65535]| -| 11 | TINYINT | 1 | Single-byte integer, the value range is [-128, 127] | -| 12 | TINYINT UNSIGNED | 1 | unsigned single-byte integer, the value range is [0, 255] | -| 13 | BOOL | 1 | Bool, the value range is {true, false} | -| 14 | NCHAR | User Defined| Multi-Byte string that can include multi byte characters like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. | -| 15 | JSON | | JSON type can only be used on tags. A tag of json type is excluded with any other tags of any other type | -| 16 | VARCHAR | User-defined | Alias of BINARY | - +| # | **type** | **Bytes** | **Description** | +| --- | :--------------: | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | TIMESTAMP | 8 | Default precision is millisecond, microsecond and nanosecond are also supported. | +| 2 | INT | 4 | Integer, the value range is [-2^31, 2^31-1]. | +| 3 | INT UNSIGNED | 4 | Unsigned integer, the value range is [0, 2^32-1]. | +| 4 | BIGINT | 8 | Long integer, the value range is [-2^63, 2^63-1]. | +| 5 | BIGINT UNSIGNED | 8 | unsigned long integer, the value range is [0, 2^64-1]. | +| 6 | FLOAT | 4 | Floating point number, the effective number of digits is 6-7, the value range is [-3.4E38, 3.4E38]. | +| 7 | DOUBLE | 8 | Double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308]. | +| 8 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. | +| 9 | SMALLINT | 2 | Short integer, the value range is [-32768, 32767]. | +| 10 | INT UNSIGNED | 2 | unsigned integer, the value range is [0, 65535]. | +| 11 | TINYINT | 1 | Single-byte integer, the value range is [-128, 127]. | +| 12 | TINYINT UNSIGNED | 1 | unsigned single-byte integer, the value range is [0, 255]. | +| 13 | BOOL | 1 | Bool, the value range is {true, false}. | +| 14 | NCHAR | User Defined | Multi-byte string that can include multi byte characters like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\'`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. | +| 15 | JSON | | JSON type can only be used on tags. A tag of json type is excluded with any other tags of any other type. | +| 16 | VARCHAR | User-defined | Alias of BINARY | :::note -- TDengine is case insensitive and treats any characters in the sql command as lower case by default, case sensitive strings must be quoted with single quotes. -- Only ASCII visible characters are suggested to be used in a column or tag of BINARY type. Multi-byte characters must be stored in NCHAR type. -- The length of BINARY can be up to 16374 bytes. The string value must be quoted with single quotes. You must specify a length in bytes for a BINARY value, for example binary(20) for up to twenty single-byte characters. If the data exceeds the specified length, an error will occur. The literal single quote inside the string must be preceded with back slash like `\'` + +- Only ASCII visible characters are suggested to be used in a column or tag of BINARY type. Multi-byte characters must be stored in NCHAR type. +- The length of BINARY can be up to 16,374 bytes. The string value must be quoted with single quotes. You must specify a length in bytes for a BINARY value, for example binary(20) for up to twenty single-byte characters. If the data exceeds the specified length, an error will occur. The literal single quote inside the string must be preceded with back slash like `\'` - Numeric values in SQL statements will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used, so attention must be paid to avoid overflow. For example, 9999999999999999999 will be considered as overflow because it exceeds the upper limit of long integer, but 9999999999999999999.0 will be considered as a legal float number. ::: - ## Constants + TDengine supports a variety of constants: -| # | **Syntax** | **Type** | **Description** | -| --- | :-------: | --------- | -------------------------------------- | -| 1 | [{+ \| -}]123 | BIGINT | Integer literals are of type BIGINT. Data that exceeds the length of the BIGINT type is truncated. | -| 2 | 123.45 | DOUBLE | Floating-point literals are of type DOUBLE. Numeric values will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used. | -| 3 | 1.2E3 | DOUBLE | Literals in scientific notation are of type DOUBLE. | -| 4 | 'abc' | BINARY | Content enclosed in single quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal single quote inside the string must be escaped with a backslash (\'). | -| 5 | 'abc' | BINARY | Content enclosed in double quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal double quote inside the string must be escaped with a backslash (\"). | -| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | The TIMESTAMP keyword indicates that the following string literal is interpreted as a timestamp. The string must be in YYYY-MM-DD HH:mm:ss.MS format. The precision is inherited from the database configuration. | -| 7 | {TRUE \| FALSE} | BOOL | Boolean literals are of type BOOL. | -| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | The preceding characters indicate null literals. These can be used with any data type. | +| # | **Syntax** | **Type** | **Description** | +| --- | :-----------------------------------------------: | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | [{+ \| -}]123 | BIGINT | Integer literals are of type BIGINT. Data that exceeds the length of the BIGINT type is truncated. | +| 2 | 123.45 | DOUBLE | Floating-point literals are of type DOUBLE. Numeric values will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used. | +| 3 | 1.2E3 | DOUBLE | Literals in scientific notation are of type DOUBLE. | +| 4 | 'abc' | BINARY | Content enclosed in single quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal single quote inside the string must be escaped with a backslash `\'`. | +| 5 | 'abc' | BINARY | Content enclosed in double quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal double quote inside the string must be escaped with a backslash `\"`. | +| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | The TIMESTAMP keyword indicates that the following string literal is interpreted as a timestamp. The string must be in YYYY-MM-DD HH:mm:ss.MS format. The precision is inherited from the database configuration. | +| 7 | {TRUE \| FALSE} | BOOL | Boolean literals are of type BOOL. | +| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | The preceding characters indicate null literals. These can be used with any data type. | :::note Numeric values will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used, so attention must be paid to avoid overflow. For example, 9999999999999999999 will be considered as overflow because it exceeds the upper limit of long integer, but 9999999999999999999.0 will be considered as a legal float number. diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md index e7d56fb3c7..da21896866 100644 --- a/docs/en/12-taos-sql/05-insert.md +++ b/docs/en/12-taos-sql/05-insert.md @@ -16,6 +16,8 @@ INSERT INTO [(field1_name, ...)] VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; + +INSERT INTO tb_name [(field1_name, ...)] subquery ``` **Timestamps** @@ -37,7 +39,7 @@ INSERT INTO 4. The FILE clause inserts tags or data from a comma-separates values (CSV) file. Do not include headers in your CSV files. -5. A single INSERT statement can write data to multiple tables. +5. A single `INSERT ... VALUES` statement and `INSERT ... FILE` statement can write data to multiple tables. 6. The INSERT statement is fully parsed before being executed, so that if any element of the statement fails, the entire statement will fail. For example, the following statement will not create a table because the latter part of the statement is invalid: @@ -47,6 +49,8 @@ INSERT INTO 7. However, an INSERT statement that writes data to multiple subtables can succeed for some tables and fail for others. This situation is caused because vnodes perform write operations independently of each other. One vnode failing to write data does not affect the ability of other vnodes to write successfully. +8. Data from TDengine can be inserted into a specified table using the `INSERT ... subquery` statement. Arbitrary query statements are supported. This syntax can only be used for subtables and normal tables, and does not support automatic table creation. + ## Insert a Record Single row or multiple rows specified with VALUES can be inserted into a specific table. A single row is inserted using the below statement. diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index 118a248373..786444ad77 100644 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -66,9 +66,9 @@ order_expr: A query can be performed on some or all columns. Data and tag columns can all be included in the SELECT list. -## Wildcards +### Wildcards -You can use an asterisk (\*) as a wildcard character to indicate all columns. For standard tables, the asterisk indicates only data columns. For supertables and subtables, tag columns are also included. +You can use an asterisk (\*) as a wildcard character to indicate all columns. For normal tables or sub-tables, the asterisk indicates only data columns. For supertables, tag columns are also included when using asterisk (\*). ```sql SELECT * FROM d1001; @@ -136,6 +136,8 @@ taos> SELECT ts, ts AS primary_key_ts FROM d1001; ### Pseudocolumns +**Pseudocolumn:** A pseudo-column behaves like a table column but is not actually stored in the table. You can select from pseudo-columns, but you cannot insert, update, or delete their values. A pseudo-column is also similar to a function without arguments. This section describes these pseudo-columns: + **TBNAME** The TBNAME pseudocolumn in a supertable contains the names of subtables within the supertable. diff --git a/docs/en/12-taos-sql/12-distinguished.md b/docs/en/12-taos-sql/12-distinguished.md index 98b782c3eb..296c237642 100644 --- a/docs/en/12-taos-sql/12-distinguished.md +++ b/docs/en/12-taos-sql/12-distinguished.md @@ -46,7 +46,7 @@ The following restrictions apply: ### Other Rules -- The window clause must occur after the PARTITION BY clause and before the GROUP BY clause. It cannot be used with a GROUP BY clause. +- The window clause must occur after the PARTITION BY clause. It cannot be used with a GROUP BY clause. - SELECT clauses on windows can contain only the following expressions: - Constants - Aggregate functions @@ -78,7 +78,7 @@ These pseudocolumns occur after the aggregation clause. 1. A huge volume of interpolation output may be returned using `FILL`, so it's recommended to specify the time range when using `FILL`. The maximum number of interpolation values that can be returned in a single query is 10,000,000. 2. The result set is in ascending order of timestamp when you aggregate by time window. -3. If aggregate by window is used on STable, the aggregate function is performed on all the rows matching the filter conditions. If `PARTITION BY` is not used in the query, the result set will be returned in strict ascending order of timestamp; otherwise the result set is not exactly in the order of ascending timestamp in each group. +3. If aggregate by window is used on STable, the aggregate function is performed on all the rows matching the filter conditions. If `PARTITION BY` is not used in the query, the result set will be returned in strict ascending order of timestamp; otherwise the result set will be returned in the order of ascending timestamp in each group. ::: @@ -120,6 +120,12 @@ In case of using integer, bool, or string to represent the status of a device at SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status); ``` +Only care about the information of the status window when the status is 2. For example: + +``` +SELECT * FROM (SELECT COUNT(*) AS cnt, FIRST(ts) AS fst, status FROM temp_tb_1 STATE_WINDOW(status)) t WHERE status = 2; +``` + ### Session Window The primary key, i.e. timestamp, is used to determine which session window a row belongs to. As shown in the figure below, if the limit of time interval for the session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30] because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds. diff --git a/docs/en/14-reference/03-connector/06-rust.mdx b/docs/en/14-reference/03-connector/06-rust.mdx index 530287e2a4..edc3016cde 100644 --- a/docs/en/14-reference/03-connector/06-rust.mdx +++ b/docs/en/14-reference/03-connector/06-rust.mdx @@ -116,7 +116,7 @@ The parameters are described as follows: - **protocol**: Specify which connection method to use. For example, `taos+ws://localhost:6041` uses Websocket to establish connections. - **username/password**: Username and password used to create connections. - **host/port**: Specifies the server and port to establish a connection. If you do not specify a hostname or port, native connections default to `localhost:6030` and Websocket connections default to `localhost:6041`. -- **database**: Specify the default database to connect to. +- **database**: Specify the default database to connect to. It's optional. - **params**:Optional parameters. A sample DSN description string is as follows: diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx index bc16cd086b..87a10e17ca 100644 --- a/docs/en/14-reference/03-connector/09-csharp.mdx +++ b/docs/en/14-reference/03-connector/09-csharp.mdx @@ -17,7 +17,7 @@ import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx" `TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data. -The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [REST API](/reference/rest-api/) documentation. +The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc.The `TDengine.Connector` also supports WebSocket and developers can build connection through DSN, which supports data writing, querying, and parameter binding, etc. This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying. @@ -35,6 +35,10 @@ Please refer to [version support list](/reference/connector#version-support) ## Supported features + + + + 1. Connection Management 2. General Query 3. Continuous Query @@ -42,6 +46,18 @@ Please refer to [version support list](/reference/connector#version-support) 5. Subscription 6. Schemaless + + + + +1. Connection Management +2. General Query +3. Continuous Query +4. Parameter Binding + + + + ## Installation Steps ### Pre-installation preparation @@ -74,12 +90,18 @@ cp -r src/ myProject cd myProject dotnet add exmaple.csproj reference src/TDengine.csproj ``` + ## Establish a Connection -``` C# + + + + + +``` csharp using TDengineDriver; namespace TDengineExample @@ -112,14 +134,62 @@ namespace TDengineExample ``` + + + + +The structure of the DSN description string is as follows: + +```text +[]://[[:@]:][/][?=[&=]] +|------------|---|-----------|-----------|------|------|------------|-----------------------| +| protocol | | username | password | host | port | database | params | +``` + +The parameters are described as follows: + +* **protocol**: Specify which connection method to use (support http/ws). For example, `ws://localhost:6041` uses Websocket to establish connections. +* **username/password**: Username and password used to create connections. +* **host/port**: Specifies the server and port to establish a connection. Websocket connections default to `localhost:6041`. +* **database**: Specify the default database to connect to. It's optional. +* **params**:Optional parameters. + +A sample DSN description string is as follows: + +```text +ws://localhost:6041/test +``` + +``` csharp +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` + + + + ## Usage examples ### Write data #### SQL Write + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsInsert/Program.cs}} +``` + + + + #### InfluxDB line protocol write @@ -132,12 +202,48 @@ namespace TDengineExample +#### Parameter Binding + + + + + +``` csharp +{{#include docs/examples/csharp/stmtInsert/Program.cs}} +``` + + + + + +```csharp +{{#include docs/examples/csharp/wsStmt/Program.cs}} +``` + + + + ### Query data #### Synchronous Query + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsQuery/Program.cs}} +``` + + + + #### Asynchronous query @@ -145,18 +251,21 @@ namespace TDengineExample ### More sample programs |Sample program |Sample program description | -|--------------------------------------------------------------------------------------------------------------------|------------ --------------------------------| +|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| | [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/Query/Query.cs) | Table creation, data insertion, and query examples with TDengine.Connector | | [JSON Tag](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/JSONTag) | Writing and querying JSON tag data with TDengine Connector | | [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/Stmt) | Parameter binding with TDengine Connector | | [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/schemaless) | Schemaless writes with TDengine Connector | | [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/AsyncQuery/QueryAsync.cs) | Asynchronous queries with TDengine Connector | -| [TMQ](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Data subscription with TDengine Connector | +| [Subscription](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Subscription example with TDengine Connector | +| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSample.cs) | WebSocket basic data in and out with TDengine connector | +| [WebSocket Parameter Binding](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSTMT.cs) | WebSocket parameter binding example | ## Important update records | TDengine.Connector | Description | |--------------------|--------------------------------| +| 3.0.1 | Support WebSocket and Cloud,With function query, insert, and parameter binding| | 3.0.0 | Supports TDengine 3.0.0.0. TDengine 2.x is not supported. Added `TDengine.Impl.GetData()` interface to deserialize query results. | | 1.0.7 | Fixed TDengine.Query() memory leak. | | 1.0.6 | Fix schemaless bug in 1.0.4 and 1.0.5. | diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index 02921c3f6a..5ab6f59454 100644 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -164,7 +164,7 @@ The parameters described in this document by the effect that they have on the sy | Attribute | Description | | -------- | -------------------- | | Applicable | Client only | -| 含义 | SMA index optimization policy | +| Meaning | SMA index optimization policy | | Unit | None | | Default Value | 0 | | Notes | @@ -325,7 +325,7 @@ The charset that takes effect is UTF-8. | Applicable | Server Only | | Meaning | Maximum number of vnodes per dnode | | Value Range | 0-4096 | -| Default Value | 256 | +| Default Value | 2x the CPU cores | ## Time Parameters @@ -697,152 +697,154 @@ To prevent system resource from being exhausted by multiple concurrent streams, | 15 | telemetryPort | No | Yes | | 16 | queryPolicy | No | Yes | | 17 | querySmaOptimize | No | Yes | -| 18 | queryBufferSize | Yes | Yes | -| 19 | maxNumOfDistinctRes | Yes | Yes | -| 20 | minSlidingTime | Yes | Yes | -| 21 | minIntervalTime | Yes | Yes | -| 22 | countAlwaysReturnValue | Yes | Yes | -| 23 | dataDir | Yes | Yes | -| 24 | minimalDataDirGB | Yes | Yes | -| 25 | supportVnodes | No | Yes | -| 26 | tempDir | Yes | Yes | -| 27 | minimalTmpDirGB | Yes | Yes | -| 28 | compressMsgSize | Yes | Yes | -| 29 | compressColData | Yes | Yes | -| 30 | smlChildTableName | Yes | Yes | -| 31 | smlTagName | Yes | Yes | -| 32 | smlDataFormat | No | Yes | -| 33 | statusInterval | Yes | Yes | -| 34 | shellActivityTimer | Yes | Yes | -| 35 | transPullupInterval | No | Yes | -| 36 | mqRebalanceInterval | No | Yes | -| 37 | ttlUnit | No | Yes | -| 38 | ttlPushInterval | No | Yes | -| 39 | numOfTaskQueueThreads | No | Yes | -| 40 | numOfRpcThreads | No | Yes | -| 41 | numOfCommitThreads | Yes | Yes | -| 42 | numOfMnodeReadThreads | No | Yes | -| 43 | numOfVnodeQueryThreads | No | Yes | -| 44 | numOfVnodeStreamThreads | No | Yes | -| 45 | numOfVnodeFetchThreads | No | Yes | -| 46 | numOfVnodeWriteThreads | No | Yes | -| 47 | numOfVnodeSyncThreads | No | Yes | -| 48 | numOfQnodeQueryThreads | No | Yes | -| 49 | numOfQnodeFetchThreads | No | Yes | -| 50 | numOfSnodeSharedThreads | No | Yes | -| 51 | numOfSnodeUniqueThreads | No | Yes | -| 52 | rpcQueueMemoryAllowed | No | Yes | -| 53 | logDir | Yes | Yes | -| 54 | minimalLogDirGB | Yes | Yes | -| 55 | numOfLogLines | Yes | Yes | -| 56 | asyncLog | Yes | Yes | -| 57 | logKeepDays | Yes | Yes | -| 58 | debugFlag | Yes | Yes | -| 59 | tmrDebugFlag | Yes | Yes | -| 60 | uDebugFlag | Yes | Yes | -| 61 | rpcDebugFlag | Yes | Yes | -| 62 | jniDebugFlag | Yes | Yes | -| 63 | qDebugFlag | Yes | Yes | -| 64 | cDebugFlag | Yes | Yes | -| 65 | dDebugFlag | Yes | Yes | -| 66 | vDebugFlag | Yes | Yes | -| 67 | mDebugFlag | Yes | Yes | -| 68 | wDebugFlag | Yes | Yes | -| 69 | sDebugFlag | Yes | Yes | -| 70 | tsdbDebugFlag | Yes | Yes | -| 71 | tqDebugFlag | No | Yes | -| 72 | fsDebugFlag | Yes | Yes | -| 73 | udfDebugFlag | No | Yes | -| 74 | smaDebugFlag | No | Yes | -| 75 | idxDebugFlag | No | Yes | -| 76 | tdbDebugFlag | No | Yes | -| 77 | metaDebugFlag | No | Yes | -| 78 | timezone | Yes | Yes | -| 79 | locale | Yes | Yes | -| 80 | charset | Yes | Yes | -| 81 | udf | Yes | Yes | -| 82 | enableCoreFile | Yes | Yes | -| 83 | arbitrator | Yes | No | -| 84 | numOfThreadsPerCore | Yes | No | -| 85 | numOfMnodes | Yes | No | -| 86 | vnodeBak | Yes | No | -| 87 | balance | Yes | No | -| 88 | balanceInterval | Yes | No | -| 89 | offlineThreshold | Yes | No | -| 90 | role | Yes | No | -| 91 | dnodeNopLoop | Yes | No | -| 92 | keepTimeOffset | Yes | No | -| 93 | rpcTimer | Yes | No | -| 94 | rpcMaxTime | Yes | No | -| 95 | rpcForceTcp | Yes | No | -| 96 | tcpConnTimeout | Yes | No | -| 97 | syncCheckInterval | Yes | No | -| 98 | maxTmrCtrl | Yes | No | -| 99 | monitorReplica | Yes | No | -| 100 | smlTagNullName | Yes | No | -| 101 | keepColumnName | Yes | No | -| 102 | ratioOfQueryCores | Yes | No | -| 103 | maxStreamCompDelay | Yes | No | -| 104 | maxFirstStreamCompDelay | Yes | No | -| 105 | retryStreamCompDelay | Yes | No | -| 106 | streamCompDelayRatio | Yes | No | -| 107 | maxVgroupsPerDb | Yes | No | -| 108 | maxTablesPerVnode | Yes | No | -| 109 | minTablesPerVnode | Yes | No | -| 110 | tableIncStepPerVnode | Yes | No | -| 111 | cache | Yes | No | -| 112 | blocks | Yes | No | -| 113 | days | Yes | No | -| 114 | keep | Yes | No | -| 115 | minRows | Yes | No | -| 116 | maxRows | Yes | No | -| 117 | quorum | Yes | No | -| 118 | comp | Yes | No | -| 119 | walLevel | Yes | No | -| 120 | fsync | Yes | No | -| 121 | replica | Yes | No | -| 122 | partitions | Yes | No | -| 123 | quorum | Yes | No | -| 124 | update | Yes | No | -| 125 | cachelast | Yes | No | -| 126 | maxSQLLength | Yes | No | -| 127 | maxWildCardsLength | Yes | No | -| 128 | maxRegexStringLen | Yes | No | -| 129 | maxNumOfOrderedRes | Yes | No | -| 130 | maxConnections | Yes | No | -| 131 | mnodeEqualVnodeNum | Yes | No | -| 132 | http | Yes | No | -| 133 | httpEnableRecordSql | Yes | No | -| 134 | httpMaxThreads | Yes | No | -| 135 | restfulRowLimit | Yes | No | -| 136 | httpDbNameMandatory | Yes | No | -| 137 | httpKeepAlive | Yes | No | -| 138 | enableRecordSql | Yes | No | -| 139 | maxBinaryDisplayWidth | Yes | No | -| 140 | stream | Yes | No | -| 141 | retrieveBlockingModel | Yes | No | -| 142 | tsdbMetaCompactRatio | Yes | No | -| 143 | defaultJSONStrType | Yes | No | -| 144 | walFlushSize | Yes | No | -| 145 | keepTimeOffset | Yes | No | -| 146 | flowctrl | Yes | No | -| 147 | slaveQuery | Yes | No | -| 148 | adjustMaster | Yes | No | -| 149 | topicBinaryLen | Yes | No | -| 150 | telegrafUseFieldNum | Yes | No | -| 151 | deadLockKillQuery | Yes | No | -| 152 | clientMerge | Yes | No | -| 153 | sdbDebugFlag | Yes | No | -| 154 | odbcDebugFlag | Yes | No | -| 155 | httpDebugFlag | Yes | No | -| 156 | monDebugFlag | Yes | No | -| 157 | cqDebugFlag | Yes | No | -| 158 | shortcutFlag | Yes | No | -| 159 | probeSeconds | Yes | No | -| 160 | probeKillSeconds | Yes | No | -| 161 | probeInterval | Yes | No | -| 162 | lossyColumns | Yes | No | -| 163 | fPrecision | Yes | No | -| 164 | dPrecision | Yes | No | -| 165 | maxRange | Yes | No | -| 166 | range | Yes | No | +| 18 | queryRsmaTolerance | No | Yes | +| 19 | queryBufferSize | Yes | Yes | +| 20 | maxNumOfDistinctRes | Yes | Yes | +| 21 | minSlidingTime | Yes | Yes | +| 22 | minIntervalTime | Yes | Yes | +| 23 | countAlwaysReturnValue | Yes | Yes | +| 24 | dataDir | Yes | Yes | +| 25 | minimalDataDirGB | Yes | Yes | +| 26 | supportVnodes | No | Yes | +| 27 | tempDir | Yes | Yes | +| 28 | minimalTmpDirGB | Yes | Yes | +| 29 | compressMsgSize | Yes | Yes | +| 30 | compressColData | Yes | Yes | +| 31 | smlChildTableName | Yes | Yes | +| 32 | smlTagName | Yes | Yes | +| 33 | smlDataFormat | No | Yes | +| 34 | statusInterval | Yes | Yes | +| 35 | shellActivityTimer | Yes | Yes | +| 36 | transPullupInterval | No | Yes | +| 37 | mqRebalanceInterval | No | Yes | +| 38 | ttlUnit | No | Yes | +| 39 | ttlPushInterval | No | Yes | +| 40 | numOfTaskQueueThreads | No | Yes | +| 41 | numOfRpcThreads | No | Yes | +| 42 | numOfCommitThreads | Yes | Yes | +| 43 | numOfMnodeReadThreads | No | Yes | +| 44 | numOfVnodeQueryThreads | No | Yes | +| 45 | numOfVnodeStreamThreads | No | Yes | +| 46 | numOfVnodeFetchThreads | No | Yes | +| 47 | numOfVnodeWriteThreads | No | Yes | +| 48 | numOfVnodeSyncThreads | No | Yes | +| 49 | numOfVnodeRsmaThreads | No | Yes | +| 50 | numOfQnodeQueryThreads | No | Yes | +| 51 | numOfQnodeFetchThreads | No | Yes | +| 52 | numOfSnodeSharedThreads | No | Yes | +| 53 | numOfSnodeUniqueThreads | No | Yes | +| 54 | rpcQueueMemoryAllowed | No | Yes | +| 55 | logDir | Yes | Yes | +| 56 | minimalLogDirGB | Yes | Yes | +| 57 | numOfLogLines | Yes | Yes | +| 58 | asyncLog | Yes | Yes | +| 59 | logKeepDays | Yes | Yes | +| 60 | debugFlag | Yes | Yes | +| 61 | tmrDebugFlag | Yes | Yes | +| 62 | uDebugFlag | Yes | Yes | +| 63 | rpcDebugFlag | Yes | Yes | +| 64 | jniDebugFlag | Yes | Yes | +| 65 | qDebugFlag | Yes | Yes | +| 66 | cDebugFlag | Yes | Yes | +| 67 | dDebugFlag | Yes | Yes | +| 68 | vDebugFlag | Yes | Yes | +| 69 | mDebugFlag | Yes | Yes | +| 70 | wDebugFlag | Yes | Yes | +| 71 | sDebugFlag | Yes | Yes | +| 72 | tsdbDebugFlag | Yes | Yes | +| 73 | tqDebugFlag | No | Yes | +| 74 | fsDebugFlag | Yes | Yes | +| 75 | udfDebugFlag | No | Yes | +| 76 | smaDebugFlag | No | Yes | +| 77 | idxDebugFlag | No | Yes | +| 78 | tdbDebugFlag | No | Yes | +| 79 | metaDebugFlag | No | Yes | +| 80 | timezone | Yes | Yes | +| 81 | locale | Yes | Yes | +| 82 | charset | Yes | Yes | +| 83 | udf | Yes | Yes | +| 84 | enableCoreFile | Yes | Yes | +| 85 | arbitrator | Yes | No | +| 86 | numOfThreadsPerCore | Yes | No | +| 87 | numOfMnodes | Yes | No | +| 88 | vnodeBak | Yes | No | +| 89 | balance | Yes | No | +| 90 | balanceInterval | Yes | No | +| 91 | offlineThreshold | Yes | No | +| 92 | role | Yes | No | +| 93 | dnodeNopLoop | Yes | No | +| 94 | keepTimeOffset | Yes | No | +| 95 | rpcTimer | Yes | No | +| 96 | rpcMaxTime | Yes | No | +| 97 | rpcForceTcp | Yes | No | +| 98 | tcpConnTimeout | Yes | No | +| 99 | syncCheckInterval | Yes | No | +| 100 | maxTmrCtrl | Yes | No | +| 101 | monitorReplica | Yes | No | +| 102 | smlTagNullName | Yes | No | +| 103 | keepColumnName | Yes | No | +| 104 | ratioOfQueryCores | Yes | No | +| 105 | maxStreamCompDelay | Yes | No | +| 106 | maxFirstStreamCompDelay | Yes | No | +| 107 | retryStreamCompDelay | Yes | No | +| 108 | streamCompDelayRatio | Yes | No | +| 109 | maxVgroupsPerDb | Yes | No | +| 110 | maxTablesPerVnode | Yes | No | +| 111 | minTablesPerVnode | Yes | No | +| 112 | tableIncStepPerVnode | Yes | No | +| 113 | cache | Yes | No | +| 114 | blocks | Yes | No | +| 115 | days | Yes | No | +| 116 | keep | Yes | No | +| 117 | minRows | Yes | No | +| 118 | maxRows | Yes | No | +| 119 | quorum | Yes | No | +| 120 | comp | Yes | No | +| 121 | walLevel | Yes | No | +| 122 | fsync | Yes | No | +| 123 | replica | Yes | No | +| 124 | partitions | Yes | No | +| 125 | quorum | Yes | No | +| 126 | update | Yes | No | +| 127 | cachelast | Yes | No | +| 128 | maxSQLLength | Yes | No | +| 129 | maxWildCardsLength | Yes | No | +| 130 | maxRegexStringLen | Yes | No | +| 131 | maxNumOfOrderedRes | Yes | No | +| 132 | maxConnections | Yes | No | +| 133 | mnodeEqualVnodeNum | Yes | No | +| 134 | http | Yes | No | +| 135 | httpEnableRecordSql | Yes | No | +| 136 | httpMaxThreads | Yes | No | +| 137 | restfulRowLimit | Yes | No | +| 138 | httpDbNameMandatory | Yes | No | +| 139 | httpKeepAlive | Yes | No | +| 140 | enableRecordSql | Yes | No | +| 141 | maxBinaryDisplayWidth | Yes | No | +| 142 | stream | Yes | No | +| 143 | retrieveBlockingModel | Yes | No | +| 144 | tsdbMetaCompactRatio | Yes | No | +| 145 | defaultJSONStrType | Yes | No | +| 146 | walFlushSize | Yes | No | +| 147 | keepTimeOffset | Yes | No | +| 148 | flowctrl | Yes | No | +| 149 | slaveQuery | Yes | No | +| 150 | adjustMaster | Yes | No | +| 151 | topicBinaryLen | Yes | No | +| 152 | telegrafUseFieldNum | Yes | No | +| 153 | deadLockKillQuery | Yes | No | +| 154 | clientMerge | Yes | No | +| 155 | sdbDebugFlag | Yes | No | +| 156 | odbcDebugFlag | Yes | No | +| 157 | httpDebugFlag | Yes | No | +| 158 | monDebugFlag | Yes | No | +| 159 | cqDebugFlag | Yes | No | +| 160 | shortcutFlag | Yes | No | +| 161 | probeSeconds | Yes | No | +| 162 | probeKillSeconds | Yes | No | +| 163 | probeInterval | Yes | No | +| 164 | lossyColumns | Yes | No | +| 165 | fPrecision | Yes | No | +| 166 | dPrecision | Yes | No | +| 167 | maxRange | Yes | No | +| 168 | range | Yes | No | diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md index e3901114d3..414986d107 100644 --- a/docs/en/28-releases/01-tdengine.md +++ b/docs/en/28-releases/01-tdengine.md @@ -6,6 +6,9 @@ description: TDengine release history, Release Notes and download links. import Release from "/components/ReleaseV3"; +## 3.0.1.2 + + ## 3.0.1.1 diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md index 228990df3b..086d3adea2 100644 --- a/docs/en/28-releases/02-tools.md +++ b/docs/en/28-releases/02-tools.md @@ -6,6 +6,10 @@ description: taosTools release history, Release Notes, download links. import Release from "/components/ReleaseV3"; +## 2.2.2 + + + ## 2.2.0 diff --git a/docs/examples/csharp/.gitignore b/docs/examples/csharp/.gitignore index b3aff79f37..c228f1be2a 100644 --- a/docs/examples/csharp/.gitignore +++ b/docs/examples/csharp/.gitignore @@ -1,4 +1,27 @@ -bin -obj .vs -*.sln \ No newline at end of file +asyncQuery/bin +connect/bin +influxdbLine/bin +optsJSON/bin +optsTelnet/bin +query/bin +sqlInsert/bin +stmtInsert/bin +subscribe/bin +wsConnect/bin +wsInsert/bin +wsQuery/bin +wsStmt/bin +asyncQuery/obj +connect/obj +influxdbLine/obj +optsJSON/obj +optsTelnet/obj +query/obj +sqlInsert/obj +stmtInsert/obj +subscribe/obj +wsConnect/obj +wsInsert/obj +wsQuery/obj +wsStmt/obj \ No newline at end of file diff --git a/docs/examples/csharp/QueryExample.cs b/docs/examples/csharp/QueryExample.cs deleted file mode 100644 index d75bb8d661..0000000000 --- a/docs/examples/csharp/QueryExample.cs +++ /dev/null @@ -1,82 +0,0 @@ -using TDengineDriver; -using TDengineDriver.Impl; -using System.Runtime.InteropServices; - -namespace TDengineExample -{ - internal class QueryExample - { - static void Main() - { - IntPtr conn = GetConnection(); - // run query - IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2"); - if (TDengine.ErrorNo(res) != 0) - { - Console.WriteLine("Failed to query since: " + TDengine.Error(res)); - TDengine.Close(conn); - TDengine.Cleanup(); - return; - } - - // get filed count - int fieldCount = TDengine.FieldCount(res); - Console.WriteLine("fieldCount=" + fieldCount); - - // print column names - List metas = LibTaos.GetMeta(res); - for (int i = 0; i < metas.Count; i++) - { - Console.Write(metas[i].name + "\t"); - } - Console.WriteLine(); - - // print values - List resData = LibTaos.GetData(res); - for (int i = 0; i < resData.Count; i++) - { - Console.Write($"|{resData[i].ToString()} \t"); - if (((i + 1) % metas.Count == 0)) - { - Console.WriteLine(""); - } - } - Console.WriteLine(); - - if (TDengine.ErrorNo(res) != 0) - { - Console.WriteLine($"Query is not complete, Error {TDengine.ErrorNo(res)} {TDengine.Error(res)}"); - } - // exit - TDengine.FreeResult(res); - TDengine.Close(conn); - TDengine.Cleanup(); - } - static IntPtr GetConnection() - { - string host = "localhost"; - short port = 6030; - string username = "root"; - string password = "taosdata"; - string dbname = "power"; - var conn = TDengine.Connect(host, username, password, dbname, port); - if (conn == IntPtr.Zero) - { - Console.WriteLine("Connect to TDengine failed"); - System.Environment.Exit(0); - } - else - { - Console.WriteLine("Connect to TDengine success"); - } - return conn; - } - } -} - -// output: -// Connect to TDengine success -// fieldCount=6 -// ts current voltage phase location groupid -// 1648432611249 10.3 219 0.31 California.SanFrancisco 2 -// 1648432611749 12.6 218 0.33 California.SanFrancisco 2 \ No newline at end of file diff --git a/docs/examples/csharp/SQLInsertExample.cs b/docs/examples/csharp/SQLInsertExample.cs deleted file mode 100644 index 3ce70fe914..0000000000 --- a/docs/examples/csharp/SQLInsertExample.cs +++ /dev/null @@ -1,70 +0,0 @@ -using TDengineDriver; - - -namespace TDengineExample -{ - internal class SQLInsertExample - { - - static void Main() - { - IntPtr conn = GetConnection(); - IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); - CheckRes(conn, res, "failed to create database"); - res = TDengine.Query(conn, "USE power"); - CheckRes(conn, res, "failed to change database"); - res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); - CheckRes(conn, res, "failed to create stable"); - var sql = "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + - "d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + - "d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + - "d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; - res = TDengine.Query(conn, sql); - CheckRes(conn, res, "failed to insert data"); - int affectedRows = TDengine.AffectRows(res); - Console.WriteLine("affectedRows " + affectedRows); - TDengine.FreeResult(res); - ExitProgram(conn, 0); - } - - static IntPtr GetConnection() - { - string host = "localhost"; - short port = 6030; - string username = "root"; - string password = "taosdata"; - string dbname = ""; - var conn = TDengine.Connect(host, username, password, dbname, port); - if (conn == IntPtr.Zero) - { - Console.WriteLine("Connect to TDengine failed"); - Environment.Exit(0); - } - else - { - Console.WriteLine("Connect to TDengine success"); - } - return conn; - } - - static void CheckRes(IntPtr conn, IntPtr res, String errorMsg) - { - if (TDengine.ErrorNo(res) != 0) - { - Console.Write(errorMsg + " since: " + TDengine.Error(res)); - ExitProgram(conn, 1); - } - } - - static void ExitProgram(IntPtr conn, int exitCode) - { - TDengine.Close(conn); - TDengine.Cleanup(); - Environment.Exit(exitCode); - } - } -} - -// output: -// Connect to TDengine success -// affectedRows 8 diff --git a/docs/examples/csharp/AsyncQueryExample.cs b/docs/examples/csharp/asyncQuery/Program.cs similarity index 81% rename from docs/examples/csharp/AsyncQueryExample.cs rename to docs/examples/csharp/asyncQuery/Program.cs index 0d47325932..864f06a15e 100644 --- a/docs/examples/csharp/AsyncQueryExample.cs +++ b/docs/examples/csharp/asyncQuery/Program.cs @@ -11,11 +11,17 @@ namespace TDengineExample static void Main() { IntPtr conn = GetConnection(); - QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback); - TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero); - Thread.Sleep(2000); - TDengine.Close(conn); - TDengine.Cleanup(); + try + { + QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback); + TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero); + Thread.Sleep(2000); + } + finally + { + TDengine.Close(conn); + } + } static void QueryCallback(IntPtr param, IntPtr taosRes, int code) @@ -27,11 +33,11 @@ namespace TDengineExample } else { - Console.WriteLine($"async query data failed, failed code {code}"); + throw new Exception($"async query data failed,code:{code},reason:{TDengine.Error(taosRes)}"); } } - // Iteratively call this interface until "numOfRows" is no greater than 0. + // Iteratively call this interface until "numOfRows" is no greater than 0. static void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows) { if (numOfRows > 0) @@ -43,7 +49,7 @@ namespace TDengineExample for (int i = 0; i < dataList.Count; i++) { - if (i != 0 && (i+1) % metaList.Count == 0) + if (i != 0 && (i + 1) % metaList.Count == 0) { Console.WriteLine("{0}\t|", dataList[i]); } @@ -63,7 +69,7 @@ namespace TDengineExample } else { - Console.WriteLine($"FetchRawBlockCallback callback error, error code {numOfRows}"); + throw new Exception($"FetchRawBlockCallback callback error, error code {numOfRows}"); } TDengine.FreeResult(taosRes); } @@ -79,8 +85,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - Environment.Exit(0); + throw new Exception("Connect to TDengine failed"); } else { diff --git a/docs/examples/csharp/asyncquery.csproj b/docs/examples/csharp/asyncQuery/asyncquery.csproj similarity index 98% rename from docs/examples/csharp/asyncquery.csproj rename to docs/examples/csharp/asyncQuery/asyncquery.csproj index 045969edd7..23e590cd25 100644 --- a/docs/examples/csharp/asyncquery.csproj +++ b/docs/examples/csharp/asyncQuery/asyncquery.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/ConnectExample.cs b/docs/examples/csharp/connect/Program.cs similarity index 90% rename from docs/examples/csharp/ConnectExample.cs rename to docs/examples/csharp/connect/Program.cs index f3548ee65d..955db40c7c 100644 --- a/docs/examples/csharp/ConnectExample.cs +++ b/docs/examples/csharp/connect/Program.cs @@ -16,7 +16,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); + throw new Exception("Connect to TDengine failed"); } else { diff --git a/docs/examples/csharp/connect.csproj b/docs/examples/csharp/connect/connect.csproj similarity index 100% rename from docs/examples/csharp/connect.csproj rename to docs/examples/csharp/connect/connect.csproj diff --git a/docs/examples/csharp/csharp.sln b/docs/examples/csharp/csharp.sln new file mode 100644 index 0000000000..560dde55cb --- /dev/null +++ b/docs/examples/csharp/csharp.sln @@ -0,0 +1,94 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "asyncquery", "asyncQuery\asyncquery.csproj", "{E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "connect", "connect\connect.csproj", "{CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "influxdbline", "influxdbLine\influxdbline.csproj", "{6A24FB80-1E3C-4E2D-A5AB-914FA583874D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "optsJSON", "optsJSON\optsJSON.csproj", "{6725A961-0C66-4196-AC98-8D3F3D757D6C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "optstelnet", "optsTelnet\optstelnet.csproj", "{B3B50D25-688B-44D4-8683-482ABC52FFCA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "query", "query\query.csproj", "{F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "stmtinsert", "stmtInsert\stmtinsert.csproj", "{B40D6BED-BE3C-4B44-9B12-28BE441311BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "subscribe", "subscribe\subscribe.csproj", "{C3D45A8E-AFC0-4547-9F3C-467B0B583DED}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsConnect", "wsConnect\wsConnect.csproj", "{51E19494-845E-49ED-97C7-749AE63111BD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsInsert", "wsInsert\wsInsert.csproj", "{13E2233B-4AFF-40D9-AF42-AB3F01617540}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsQuery", "wsQuery\wsQuery.csproj", "{0F394169-C456-442C-929D-C2D43A0EEC7B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wsStmt", "wsStmt\wsStmt.csproj", "{27B9C9AB-9055-4BF2-8A14-4E59F09D5985}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sqlinsert", "sqlInsert\sqlinsert.csproj", "{CD24BD12-8550-4627-A11D-707B446F48C3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2A5F00C-14E7-40E1-A2DE-6AB2975616D3}.Release|Any CPU.Build.0 = Release|Any CPU + {CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CCC5042D-93FC-4AE0-B2F6-7E692FD476B7}.Release|Any CPU.Build.0 = Release|Any CPU + {6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A24FB80-1E3C-4E2D-A5AB-914FA583874D}.Release|Any CPU.Build.0 = Release|Any CPU + {6725A961-0C66-4196-AC98-8D3F3D757D6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6725A961-0C66-4196-AC98-8D3F3D757D6C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6725A961-0C66-4196-AC98-8D3F3D757D6C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6725A961-0C66-4196-AC98-8D3F3D757D6C}.Release|Any CPU.Build.0 = Release|Any CPU + {B3B50D25-688B-44D4-8683-482ABC52FFCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3B50D25-688B-44D4-8683-482ABC52FFCA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3B50D25-688B-44D4-8683-482ABC52FFCA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3B50D25-688B-44D4-8683-482ABC52FFCA}.Release|Any CPU.Build.0 = Release|Any CPU + {F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2B7D13B-FE04-4C5C-BB6D-C12E0A9D9970}.Release|Any CPU.Build.0 = Release|Any CPU + {B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B40D6BED-BE3C-4B44-9B12-28BE441311BA}.Release|Any CPU.Build.0 = Release|Any CPU + {C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3D45A8E-AFC0-4547-9F3C-467B0B583DED}.Release|Any CPU.Build.0 = Release|Any CPU + {51E19494-845E-49ED-97C7-749AE63111BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51E19494-845E-49ED-97C7-749AE63111BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51E19494-845E-49ED-97C7-749AE63111BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51E19494-845E-49ED-97C7-749AE63111BD}.Release|Any CPU.Build.0 = Release|Any CPU + {13E2233B-4AFF-40D9-AF42-AB3F01617540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13E2233B-4AFF-40D9-AF42-AB3F01617540}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13E2233B-4AFF-40D9-AF42-AB3F01617540}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13E2233B-4AFF-40D9-AF42-AB3F01617540}.Release|Any CPU.Build.0 = Release|Any CPU + {0F394169-C456-442C-929D-C2D43A0EEC7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F394169-C456-442C-929D-C2D43A0EEC7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F394169-C456-442C-929D-C2D43A0EEC7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F394169-C456-442C-929D-C2D43A0EEC7B}.Release|Any CPU.Build.0 = Release|Any CPU + {27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27B9C9AB-9055-4BF2-8A14-4E59F09D5985}.Release|Any CPU.Build.0 = Release|Any CPU + {CD24BD12-8550-4627-A11D-707B446F48C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD24BD12-8550-4627-A11D-707B446F48C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD24BD12-8550-4627-A11D-707B446F48C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD24BD12-8550-4627-A11D-707B446F48C3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/docs/examples/csharp/InfluxDBLineExample.cs b/docs/examples/csharp/influxdbLine/Program.cs similarity index 73% rename from docs/examples/csharp/InfluxDBLineExample.cs rename to docs/examples/csharp/influxdbLine/Program.cs index 7b4453f4ac..fa3cb21fe0 100644 --- a/docs/examples/csharp/InfluxDBLineExample.cs +++ b/docs/examples/csharp/influxdbLine/Program.cs @@ -17,8 +17,7 @@ namespace TDengineExample IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("SchemalessInsert failed since " + TDengine.Error(res)); } else { @@ -26,7 +25,6 @@ namespace TDengineExample Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); } TDengine.FreeResult(res); - ExitProgram(conn, 0); } static IntPtr GetConnection() @@ -39,9 +37,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - TDengine.Cleanup(); - Environment.Exit(1); + throw new Exception("Connect to TDengine failed"); } else { @@ -55,23 +51,15 @@ namespace TDengineExample IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to create database, reason: " + TDengine.Error(res)); } res = TDengine.Query(conn, "USE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to change database, reason: " + TDengine.Error(res)); } } - static void ExitProgram(IntPtr conn, int exitCode) - { - TDengine.Close(conn); - TDengine.Cleanup(); - Environment.Exit(exitCode); - } } } diff --git a/docs/examples/csharp/influxdbline.csproj b/docs/examples/csharp/influxdbLine/influxdbline.csproj similarity index 100% rename from docs/examples/csharp/influxdbline.csproj rename to docs/examples/csharp/influxdbLine/influxdbline.csproj diff --git a/docs/examples/csharp/OptsJsonExample.cs b/docs/examples/csharp/optsJSON/Program.cs similarity index 53% rename from docs/examples/csharp/OptsJsonExample.cs rename to docs/examples/csharp/optsJSON/Program.cs index 2c41acc5c9..b67b5af62b 100644 --- a/docs/examples/csharp/OptsJsonExample.cs +++ b/docs/examples/csharp/optsJSON/Program.cs @@ -7,27 +7,31 @@ namespace TDengineExample static void Main() { IntPtr conn = GetConnection(); - PrepareDatabase(conn); - string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," + + try + { + PrepareDatabase(conn); + string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}, " + "{\"metric\": \"meters.current\", \"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"California.SanFrancisco\", \"groupid\": 2}}," + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": \"California.LosAngeles\", \"groupid\": 1}}]" }; - IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); - if (TDengine.ErrorNo(res) != 0) - { - Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); - ExitProgram(conn, 1); + IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (TDengine.ErrorNo(res) != 0) + { + throw new Exception("SchemalessInsert failed since " + TDengine.Error(res)); + } + else + { + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + } + TDengine.FreeResult(res); } - else + finally { - int affectedRows = TDengine.AffectRows(res); - Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + TDengine.Close(conn); } - TDengine.FreeResult(res); - ExitProgram(conn, 0); - } static IntPtr GetConnection() { @@ -39,9 +43,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - TDengine.Cleanup(); - Environment.Exit(1); + throw new Exception("Connect to TDengine failed"); } else { @@ -55,22 +57,13 @@ namespace TDengineExample IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to create database, reason: " + TDengine.Error(res)); } res = TDengine.Query(conn, "USE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to change database, reason: " + TDengine.Error(res)); } } - - static void ExitProgram(IntPtr conn, int exitCode) - { - TDengine.Close(conn); - TDengine.Cleanup(); - Environment.Exit(exitCode); - } } } diff --git a/docs/examples/csharp/optsjson.csproj b/docs/examples/csharp/optsJSON/optsJSON.csproj similarity index 100% rename from docs/examples/csharp/optsjson.csproj rename to docs/examples/csharp/optsJSON/optsJSON.csproj diff --git a/docs/examples/csharp/OptsTelnetExample.cs b/docs/examples/csharp/optsTelnet/Program.cs similarity index 59% rename from docs/examples/csharp/OptsTelnetExample.cs rename to docs/examples/csharp/optsTelnet/Program.cs index bb752db1af..e73ceb041a 100644 --- a/docs/examples/csharp/OptsTelnetExample.cs +++ b/docs/examples/csharp/optsTelnet/Program.cs @@ -7,8 +7,10 @@ namespace TDengineExample static void Main() { IntPtr conn = GetConnection(); - PrepareDatabase(conn); - string[] lines = { + try + { + PrepareDatabase(conn); + string[] lines = { "meters.current 1648432611249 10.3 location=California.SanFrancisco groupid=2", "meters.current 1648432611250 12.6 location=California.SanFrancisco groupid=2", "meters.current 1648432611249 10.8 location=California.LosAngeles groupid=3", @@ -18,20 +20,22 @@ namespace TDengineExample "meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3", "meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3", }; - IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); - if (TDengine.ErrorNo(res) != 0) - { - Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); - ExitProgram(conn, 1); + IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (TDengine.ErrorNo(res) != 0) + { + throw new Exception("SchemalessInsert failed since " + TDengine.Error(res)); + } + else + { + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + } + TDengine.FreeResult(res); } - else + catch { - int affectedRows = TDengine.AffectRows(res); - Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + TDengine.Close(conn); } - TDengine.FreeResult(res); - ExitProgram(conn, 0); - } static IntPtr GetConnection() { @@ -43,9 +47,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - TDengine.Cleanup(); - Environment.Exit(1); + throw new Exception("Connect to TDengine failed"); } else { @@ -59,22 +61,13 @@ namespace TDengineExample IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to create database, reason: " + TDengine.Error(res)); } res = TDengine.Query(conn, "USE test"); if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); - ExitProgram(conn, 1); + throw new Exception("failed to change database, reason: " + TDengine.Error(res)); } } - - static void ExitProgram(IntPtr conn, int exitCode) - { - TDengine.Close(conn); - TDengine.Cleanup(); - Environment.Exit(exitCode); - } } } diff --git a/docs/examples/csharp/optstelnet.csproj b/docs/examples/csharp/optsTelnet/optstelnet.csproj similarity index 100% rename from docs/examples/csharp/optstelnet.csproj rename to docs/examples/csharp/optsTelnet/optstelnet.csproj diff --git a/docs/examples/csharp/query/Program.cs b/docs/examples/csharp/query/Program.cs new file mode 100644 index 0000000000..84c7f9db1f --- /dev/null +++ b/docs/examples/csharp/query/Program.cs @@ -0,0 +1,80 @@ +using TDengineDriver; +using TDengineDriver.Impl; +using System.Runtime.InteropServices; + +namespace TDengineExample +{ + internal class QueryExample + { + static void Main() + { + IntPtr conn = GetConnection(); + try + { + // run query + IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2"); + if (TDengine.ErrorNo(res) != 0) + { + throw new Exception("Failed to query since: " + TDengine.Error(res)); + } + + // get filed count + int fieldCount = TDengine.FieldCount(res); + Console.WriteLine("fieldCount=" + fieldCount); + + // print column names + List metas = LibTaos.GetMeta(res); + for (int i = 0; i < metas.Count; i++) + { + Console.Write(metas[i].name + "\t"); + } + Console.WriteLine(); + + // print values + List resData = LibTaos.GetData(res); + for (int i = 0; i < resData.Count; i++) + { + Console.Write($"|{resData[i].ToString()} \t"); + if (((i + 1) % metas.Count == 0)) + { + Console.WriteLine(""); + } + } + Console.WriteLine(); + + // Free result after use + TDengine.FreeResult(res); + } + finally + { + TDengine.Close(conn); + } + + } + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = "power"; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + throw new Exception("Connect to TDengine failed"); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + } +} + +// output: +// Connect to TDengine success +// fieldCount=6 +// ts current voltage phase location groupid +// 1648432611249 10.3 219 0.31 California.SanFrancisco 2 +// 1648432611749 12.6 218 0.33 California.SanFrancisco 2 \ No newline at end of file diff --git a/docs/examples/csharp/query.csproj b/docs/examples/csharp/query/query.csproj similarity index 98% rename from docs/examples/csharp/query.csproj rename to docs/examples/csharp/query/query.csproj index 39fc135d5a..c97dbd3051 100644 --- a/docs/examples/csharp/query.csproj +++ b/docs/examples/csharp/query/query.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/sqlInsert/Program.cs b/docs/examples/csharp/sqlInsert/Program.cs new file mode 100644 index 0000000000..f23a6e1663 --- /dev/null +++ b/docs/examples/csharp/sqlInsert/Program.cs @@ -0,0 +1,69 @@ +using TDengineDriver; + + +namespace TDengineExample +{ + internal class SQLInsertExample + { + + static void Main() + { + IntPtr conn = GetConnection(); + try + { + IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); + CheckRes(conn, res, "failed to create database"); + res = TDengine.Query(conn, "USE power"); + CheckRes(conn, res, "failed to change database"); + res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); + CheckRes(conn, res, "failed to create stable"); + var sql = "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + res = TDengine.Query(conn, sql); + CheckRes(conn, res, "failed to insert data"); + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine("affectedRows " + affectedRows); + TDengine.FreeResult(res); + } + finally + { + TDengine.Close(conn); + } + + } + + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + throw new Exception("Connect to TDengine failed"); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + static void CheckRes(IntPtr conn, IntPtr res, String errorMsg) + { + if (TDengine.ErrorNo(res) != 0) + { + throw new Exception($"{errorMsg} since: {TDengine.Error(res)}"); + } + } + + } +} + +// output: +// Connect to TDengine success +// affectedRows 8 diff --git a/docs/examples/csharp/sqlinsert.csproj b/docs/examples/csharp/sqlInsert/sqlinsert.csproj similarity index 100% rename from docs/examples/csharp/sqlinsert.csproj rename to docs/examples/csharp/sqlInsert/sqlinsert.csproj diff --git a/docs/examples/csharp/StmtInsertExample.cs b/docs/examples/csharp/stmtInsert/Program.cs similarity index 52% rename from docs/examples/csharp/StmtInsertExample.cs rename to docs/examples/csharp/stmtInsert/Program.cs index 0a4098091f..87e1971feb 100644 --- a/docs/examples/csharp/StmtInsertExample.cs +++ b/docs/examples/csharp/stmtInsert/Program.cs @@ -9,45 +9,50 @@ namespace TDengineExample static void Main() { conn = GetConnection(); - PrepareSTable(); - // 1. init and prepare - stmt = TDengine.StmtInit(conn); - if (stmt == IntPtr.Zero) + try { - Console.WriteLine("failed to init stmt, " + TDengine.Error(stmt)); - ExitProgram(); - } - int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"); - CheckStmtRes(res, "failed to prepare stmt"); + PrepareSTable(); + // 1. init and prepare + stmt = TDengine.StmtInit(conn); + if (stmt == IntPtr.Zero) + { + throw new Exception("failed to init stmt."); + } + int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"); + CheckStmtRes(res, "failed to prepare stmt"); - // 2. bind table name and tags - TAOS_MULTI_BIND[] tags = new TAOS_MULTI_BIND[2] { TaosMultiBind.MultiBindBinary(new string[]{"California.SanFrancisco"}), TaosMultiBind.MultiBindInt(new int?[] {2}) }; - res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags); - CheckStmtRes(res, "failed to bind table name and tags"); + // 2. bind table name and tags + TAOS_MULTI_BIND[] tags = new TAOS_MULTI_BIND[2] { TaosMultiBind.MultiBindBinary(new string[] { "California.SanFrancisco" }), TaosMultiBind.MultiBindInt(new int?[] { 2 }) }; + res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags); + CheckStmtRes(res, "failed to bind table name and tags"); - // 3. bind values - TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] { + // 3. bind values + TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] { TaosMultiBind.MultiBindTimestamp(new long[2] { 1648432611249, 1648432611749}), TaosMultiBind.MultiBindFloat(new float?[2] { 10.3f, 12.6f}), TaosMultiBind.MultiBindInt(new int?[2] { 219, 218}), TaosMultiBind.MultiBindFloat(new float?[2]{ 0.31f, 0.33f}) }; - res = TDengine.StmtBindParamBatch(stmt, values); - CheckStmtRes(res, "failed to bind params"); + res = TDengine.StmtBindParamBatch(stmt, values); + CheckStmtRes(res, "failed to bind params"); - // 4. add batch - res = TDengine.StmtAddBatch(stmt); - CheckStmtRes(res, "failed to add batch"); + // 4. add batch + res = TDengine.StmtAddBatch(stmt); + CheckStmtRes(res, "failed to add batch"); - // 5. execute - res = TDengine.StmtExecute(stmt); - CheckStmtRes(res, "faild to execute"); + // 5. execute + res = TDengine.StmtExecute(stmt); + CheckStmtRes(res, "faild to execute"); + + // 6. free + TaosMultiBind.FreeTaosBind(tags); + TaosMultiBind.FreeTaosBind(values); + } + finally + { + TDengine.Close(conn); + } - // 6. free - TaosMultiBind.FreeTaosBind(tags); - TaosMultiBind.FreeTaosBind(values); - TDengine.Close(conn); - TDengine.Cleanup(); } static IntPtr GetConnection() @@ -60,8 +65,7 @@ namespace TDengineExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - Environment.Exit(0); + throw new Exception("Connect to TDengine failed"); } else { @@ -70,8 +74,6 @@ namespace TDengineExample return conn; } - - static void PrepareSTable() { IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); @@ -90,9 +92,8 @@ namespace TDengineExample int code = TDengine.StmtClose(stmt); if (code != 0) { - Console.WriteLine($"falied to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} "); + throw new Exception($"falied to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} "); } - ExitProgram(); } } @@ -100,16 +101,9 @@ namespace TDengineExample { if (TDengine.ErrorNo(res) != 0) { - Console.WriteLine(errorMsg + " since:" + TDengine.Error(res)); - ExitProgram(); + throw new Exception(errorMsg + " since:" + TDengine.Error(res)); } } - static void ExitProgram() - { - TDengine.Close(conn); - TDengine.Cleanup(); - Environment.Exit(1); - } } } diff --git a/docs/examples/csharp/stmtinsert.csproj b/docs/examples/csharp/stmtInsert/stmtinsert.csproj similarity index 100% rename from docs/examples/csharp/stmtinsert.csproj rename to docs/examples/csharp/stmtInsert/stmtinsert.csproj diff --git a/docs/examples/csharp/SubscribeDemo.cs b/docs/examples/csharp/subscribe/Program.cs similarity index 90% rename from docs/examples/csharp/SubscribeDemo.cs rename to docs/examples/csharp/subscribe/Program.cs index b62ff12e5e..1fba209f22 100644 --- a/docs/examples/csharp/SubscribeDemo.cs +++ b/docs/examples/csharp/subscribe/Program.cs @@ -11,11 +11,10 @@ namespace TMQExample { IntPtr conn = GetConnection(); string topic = "topic_example"; - Console.WriteLine($"create topic if not exist {topic} as select * from meters"); //create topic IntPtr res = TDengine.Query(conn, $"create topic if not exists {topic} as select * from meters"); - - if (res == IntPtr.Zero) + + if (TDengine.ErrorNo(res) != 0 ) { throw new Exception($"create topic failed, reason:{TDengine.Error(res)}"); } @@ -26,7 +25,7 @@ namespace TMQExample TDConnectUser = "root", TDConnectPasswd = "taosdata", MsgWithTableName = "true", - TDConnectIp = "127.0.0.1", + TDConnectIp = "127.0.0.1", }; // create consumer @@ -65,7 +64,6 @@ namespace TMQExample List topics = consumer.Subscription(); topics.ForEach(t => Console.WriteLine("topic name:{0}", t)); - // unsubscribe consumer.Unsubscribe(); @@ -73,7 +71,6 @@ namespace TMQExample consumer.Close(); TDengine.Close(conn); - } static IntPtr GetConnection() @@ -86,8 +83,7 @@ namespace TMQExample var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { - Console.WriteLine("Connect to TDengine failed"); - System.Environment.Exit(0); + throw new Exception("Connect to TDengine failed"); } else { diff --git a/docs/examples/csharp/subscribe.csproj b/docs/examples/csharp/subscribe/subscribe.csproj similarity index 98% rename from docs/examples/csharp/subscribe.csproj rename to docs/examples/csharp/subscribe/subscribe.csproj index eff29b3bf4..8ae1cf6bc6 100644 --- a/docs/examples/csharp/subscribe.csproj +++ b/docs/examples/csharp/subscribe/subscribe.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/wsConnect/Program.cs b/docs/examples/csharp/wsConnect/Program.cs new file mode 100644 index 0000000000..2e89372c3e --- /dev/null +++ b/docs/examples/csharp/wsConnect/Program.cs @@ -0,0 +1,25 @@ +using System; +using TDengineWS.Impl; + +namespace Examples +{ + public class WSConnExample + { + static void Main(string[] args) + { + string DSN = "ws://root:taosdata@127.0.0.1:6041/test"; + IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN); + if (wsConn == IntPtr.Zero) + { + throw new Exception($"get WS connection failed,reason:{LibTaosWS.WSErrorStr(IntPtr.Zero)} code:{LibTaosWS.WSErrorNo(IntPtr.Zero)}"); + } + else + { + Console.WriteLine("Establish connect success."); + } + + // close connection. + LibTaosWS.WSClose(wsConn); + } + } +} \ No newline at end of file diff --git a/docs/examples/csharp/wsConnect/wsConnect.csproj b/docs/examples/csharp/wsConnect/wsConnect.csproj new file mode 100644 index 0000000000..34951dc761 --- /dev/null +++ b/docs/examples/csharp/wsConnect/wsConnect.csproj @@ -0,0 +1,13 @@ + + + + Exe + net5.0 + enable + + + + + + + diff --git a/docs/examples/csharp/wsInsert/Program.cs b/docs/examples/csharp/wsInsert/Program.cs new file mode 100644 index 0000000000..4cd812cda9 --- /dev/null +++ b/docs/examples/csharp/wsInsert/Program.cs @@ -0,0 +1,58 @@ +using System; +using TDengineWS.Impl; + +namespace Examples +{ + public class WSInsertExample + { + static void Main(string[] args) + { + string DSN = "ws://root:taosdata@127.0.0.1:6041/test"; + IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN); + + // Assert if connection is validate + if (wsConn == IntPtr.Zero) + { + throw new Exception($"get WS connection failed,reason:{LibTaosWS.WSErrorStr(IntPtr.Zero)} code:{LibTaosWS.WSErrorNo(IntPtr.Zero)}"); + } + else + { + Console.WriteLine("Establish connect success."); + } + + string createTable = "CREATE STABLE test.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);"; + string insert = "INSERT INTO test.d1001 USING test.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)" + + "test.d1002 USING test.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)" + + "test.d1003 USING test.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "test.d1004 USING test.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + + IntPtr wsRes = LibTaosWS.WSQuery(wsConn, createTable); + ValidInsert("create table", wsRes); + LibTaosWS.WSFreeResult(wsRes); + + wsRes = LibTaosWS.WSQuery(wsConn, insert); + ValidInsert("insert data", wsRes); + LibTaosWS.WSFreeResult(wsRes); + + // close connection. + LibTaosWS.WSClose(wsConn); + } + + static void ValidInsert(string desc, IntPtr wsRes) + { + int code = LibTaosWS.WSErrorNo(wsRes); + if (code != 0) + { + throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}"); + } + else + { + Console.WriteLine("{0} success affect {2} rows, cost {1} nanoseconds", desc, LibTaosWS.WSTakeTiming(wsRes), LibTaosWS.WSAffectRows(wsRes)); + } + } + } + +} +// Establish connect success. +// create table success affect 0 rows, cost 3717542 nanoseconds +// insert data success affect 8 rows, cost 2613637 nanoseconds \ No newline at end of file diff --git a/docs/examples/csharp/wsInsert/wsInsert.csproj b/docs/examples/csharp/wsInsert/wsInsert.csproj new file mode 100644 index 0000000000..34951dc761 --- /dev/null +++ b/docs/examples/csharp/wsInsert/wsInsert.csproj @@ -0,0 +1,13 @@ + + + + Exe + net5.0 + enable + + + + + + + diff --git a/docs/examples/csharp/wsQuery/Program.cs b/docs/examples/csharp/wsQuery/Program.cs new file mode 100644 index 0000000000..de5591aa53 --- /dev/null +++ b/docs/examples/csharp/wsQuery/Program.cs @@ -0,0 +1,74 @@ +using System; +using TDengineWS.Impl; +using System.Collections.Generic; +using TDengineDriver; + +namespace Examples +{ + public class WSQueryExample + { + static void Main(string[] args) + { + string DSN = "ws://root:taosdata@127.0.0.1:6041/test"; + IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN); + if (wsConn == IntPtr.Zero) + { + throw new Exception($"get WS connection failed,reason:{LibTaosWS.WSErrorStr(IntPtr.Zero)} code:{LibTaosWS.WSErrorNo(IntPtr.Zero)}"); + } + else + { + Console.WriteLine("Establish connect success."); + } + + string select = "select * from test.meters"; + + // optional:wsRes = LibTaosWS.WSQuery(wsConn, select); + IntPtr wsRes = LibTaosWS.WSQueryTimeout(wsConn, select, 1); + // Assert if query execute success. + int code = LibTaosWS.WSErrorNo(wsRes); + if (code != 0) + { + throw new Exception($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}"); + } + + // get meta data + List metas = LibTaosWS.WSGetFields(wsRes); + // get retrieved data + List dataSet = LibTaosWS.WSGetData(wsRes); + + // do something with result. + foreach (var meta in metas) + { + Console.Write("{0} {1}({2}) \t|\t", meta.name, meta.TypeName(), meta.size); + } + Console.WriteLine(""); + + for (int i = 0; i < dataSet.Count;) + { + for (int j = 0; j < metas.Count; j++) + { + Console.Write("{0}\t|\t", dataSet[i]); + i++; + } + Console.WriteLine(""); + } + + // Free result after use. + LibTaosWS.WSFreeResult(wsRes); + + // close connection. + LibTaosWS.WSClose(wsConn); + } + } +} + +// Establish connect success. +// ts TIMESTAMP(8) | current FLOAT(4) | voltage INT(4) | phase FLOAT(4) | location BINARY(64) | groupid INT(4) | +// 1538548685000 | 10.8 | 223 | 0.29 | California.LosAngeles | 3 | +// 1538548686500 | 11.5 | 221 | 0.35 | California.LosAngeles | 3 | +// 1538548685500 | 11.8 | 221 | 0.28 | California.LosAngeles | 2 | +// 1538548696600 | 13.4 | 223 | 0.29 | California.LosAngeles | 2 | +// 1538548685000 | 10.3 | 219 | 0.31 | California.SanFrancisco | 2 | +// 1538548695000 | 12.6 | 218 | 0.33 | California.SanFrancisco | 2 | +// 1538548696800 | 12.3 | 221 | 0.31 | California.SanFrancisco | 2 | +// 1538548696650 | 10.3 | 218 | 0.25 | California.SanFrancisco | 3 | \ No newline at end of file diff --git a/docs/examples/csharp/wsQuery/wsQuery.csproj b/docs/examples/csharp/wsQuery/wsQuery.csproj new file mode 100644 index 0000000000..34951dc761 --- /dev/null +++ b/docs/examples/csharp/wsQuery/wsQuery.csproj @@ -0,0 +1,13 @@ + + + + Exe + net5.0 + enable + + + + + + + diff --git a/docs/examples/csharp/wsStmt/Program.cs b/docs/examples/csharp/wsStmt/Program.cs new file mode 100644 index 0000000000..54de77ec1f --- /dev/null +++ b/docs/examples/csharp/wsStmt/Program.cs @@ -0,0 +1,95 @@ +using System; +using TDengineWS.Impl; +using TDengineDriver; +using System.Runtime.InteropServices; + +namespace Examples +{ + public class WSStmtExample + { + static void Main(string[] args) + { + const string DSN = "ws://root:taosdata@127.0.0.1:6041/test"; + const string table = "meters"; + const string database = "test"; + const string childTable = "d1005"; + string insert = $"insert into ? using {database}.{table} tags(?,?) values(?,?,?,?)"; + const int numOfTags = 2; + const int numOfColumns = 4; + + // Establish connection + IntPtr wsConn = LibTaosWS.WSConnectWithDSN(DSN); + if (wsConn == IntPtr.Zero) + { + throw new Exception($"get WS connection failed,reason:{LibTaosWS.WSErrorStr(IntPtr.Zero)} code:{LibTaosWS.WSErrorNo(IntPtr.Zero)}"); + } + else + { + Console.WriteLine("Establish connect success..."); + } + + // init stmt + IntPtr wsStmt = LibTaosWS.WSStmtInit(wsConn); + if (wsStmt != IntPtr.Zero) + { + int code = LibTaosWS.WSStmtPrepare(wsStmt, insert); + ValidStmtStep(code, wsStmt, "WSStmtPrepare"); + + TAOS_MULTI_BIND[] wsTags = new TAOS_MULTI_BIND[] { WSMultiBind.WSBindNchar(new string[] { "California.SanDiego" }), WSMultiBind.WSBindInt(new int?[] { 4 }) }; + code = LibTaosWS.WSStmtSetTbnameTags(wsStmt, $"{database}.{childTable}", wsTags, numOfTags); + ValidStmtStep(code, wsStmt, "WSStmtSetTbnameTags"); + + TAOS_MULTI_BIND[] data = new TAOS_MULTI_BIND[4]; + data[0] = WSMultiBind.WSBindTimestamp(new long[] { 1538548687000, 1538548688000, 1538548689000, 1538548690000, 1538548691000 }); + data[1] = WSMultiBind.WSBindFloat(new float?[] { 10.30F, 10.40F, 10.50F, 10.60F, 10.70F }); + data[2] = WSMultiBind.WSBindInt(new int?[] { 223, 221, 222, 220, 219 }); + data[3] = WSMultiBind.WSBindFloat(new float?[] { 0.31F, 0.32F, 0.33F, 0.35F, 0.28F }); + code = LibTaosWS.WSStmtBindParamBatch(wsStmt, data, numOfColumns); + ValidStmtStep(code, wsStmt, "WSStmtBindParamBatch"); + + code = LibTaosWS.WSStmtAddBatch(wsStmt); + ValidStmtStep(code, wsStmt, "WSStmtAddBatch"); + + IntPtr stmtAffectRowPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32))); + code = LibTaosWS.WSStmtExecute(wsStmt, stmtAffectRowPtr); + ValidStmtStep(code, wsStmt, "WSStmtExecute"); + Console.WriteLine("WS STMT insert {0} rows...", Marshal.ReadInt32(stmtAffectRowPtr)); + Marshal.FreeHGlobal(stmtAffectRowPtr); + + LibTaosWS.WSStmtClose(wsStmt); + + // Free unmanaged memory + WSMultiBind.WSFreeTaosBind(wsTags); + WSMultiBind.WSFreeTaosBind(data); + + //check result with SQL "SELECT * FROM test.d1005;" + } + else + { + throw new Exception("Init STMT failed..."); + } + + // close connection. + LibTaosWS.WSClose(wsConn); + } + + static void ValidStmtStep(int code, IntPtr wsStmt, string desc) + { + if (code != 0) + { + throw new Exception($"{desc} failed,reason: {LibTaosWS.WSErrorStr(wsStmt)}, code: {code}"); + } + else + { + Console.WriteLine("{0} success...", desc); + } + } + } +} + +// WSStmtPrepare success... +// WSStmtSetTbnameTags success... +// WSStmtBindParamBatch success... +// WSStmtAddBatch success... +// WSStmtExecute success... +// WS STMT insert 5 rows... \ No newline at end of file diff --git a/docs/examples/csharp/wsStmt/wsStmt.csproj b/docs/examples/csharp/wsStmt/wsStmt.csproj new file mode 100644 index 0000000000..34951dc761 --- /dev/null +++ b/docs/examples/csharp/wsStmt/wsStmt.csproj @@ -0,0 +1,13 @@ + + + + Exe + net5.0 + enable + + + + + + + diff --git a/docs/zh/07-develop/01-connect/_connect_cs.mdx b/docs/zh/07-develop/01-connect/_connect_cs.mdx index 13b8a5dff2..169bf37a63 100644 --- a/docs/zh/07-develop/01-connect/_connect_cs.mdx +++ b/docs/zh/07-develop/01-connect/_connect_cs.mdx @@ -1,8 +1,8 @@ ```csharp title="原生连接" -{{#include docs/examples/csharp/ConnectExample.cs}} +{{#include docs/examples/csharp/connect/Program.cs}} ``` -:::info -C# 连接器目前只支持原生连接。 +```csharp title="WebSocket 连接" +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` -::: diff --git a/docs/zh/07-develop/03-insert-data/_cs_line.mdx b/docs/zh/07-develop/03-insert-data/_cs_line.mdx index 71f46c62be..ae49901c3a 100644 --- a/docs/zh/07-develop/03-insert-data/_cs_line.mdx +++ b/docs/zh/07-develop/03-insert-data/_cs_line.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/InfluxDBLineExample.cs}} +{{#include docs/examples/csharp/influxdbLine/Program.cs}} ``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx b/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx index 8d80d042c9..2627648616 100644 --- a/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx +++ b/docs/zh/07-develop/03-insert-data/_cs_opts_json.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/OptsJsonExample.cs}} +{{#include docs/examples/csharp/optsJSON/Program.cs}} ``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx b/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx index cff32abf1f..660db13fd1 100644 --- a/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx +++ b/docs/zh/07-develop/03-insert-data/_cs_opts_telnet.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/OptsTelnetExample.cs}} +{{#include docs/examples/csharp/optsTelnet/Program.cs}} ``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_sql.mdx b/docs/zh/07-develop/03-insert-data/_cs_sql.mdx index 1dc7bb3d13..42a6bc4315 100644 --- a/docs/zh/07-develop/03-insert-data/_cs_sql.mdx +++ b/docs/zh/07-develop/03-insert-data/_cs_sql.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/SQLInsertExample.cs}} +{{#include docs/examples/csharp/sqlInsert/Program.cs}} ``` diff --git a/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx b/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx index 229c874ab9..d8d73ca15e 100644 --- a/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx +++ b/docs/zh/07-develop/03-insert-data/_cs_stmt.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/StmtInsertExample.cs}} +{{#include docs/examples/csharp/stmtInsert/Program.cs}} ``` diff --git a/docs/zh/07-develop/04-query-data/_cs.mdx b/docs/zh/07-develop/04-query-data/_cs.mdx index 4bb582ecbf..745ab36811 100644 --- a/docs/zh/07-develop/04-query-data/_cs.mdx +++ b/docs/zh/07-develop/04-query-data/_cs.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/QueryExample.cs}} +{{#include docs/examples/csharp/query/Program.cs}} ``` diff --git a/docs/zh/07-develop/04-query-data/_cs_async.mdx b/docs/zh/07-develop/04-query-data/_cs_async.mdx index 3ecf635fd3..19c8e58f32 100644 --- a/docs/zh/07-develop/04-query-data/_cs_async.mdx +++ b/docs/zh/07-develop/04-query-data/_cs_async.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/AsyncQueryExample.cs}} +{{#include docs/examples/csharp/asyncQuery/Program.cs}} ``` diff --git a/docs/zh/07-develop/_sub_cs.mdx b/docs/zh/07-develop/_sub_cs.mdx index a435ea0273..093b617e9b 100644 --- a/docs/zh/07-develop/_sub_cs.mdx +++ b/docs/zh/07-develop/_sub_cs.mdx @@ -1,3 +1,3 @@ ```csharp -{{#include docs/examples/csharp/SubscribeDemo.cs}} +{{#include docs/examples/csharp/subscribe/Program.cs}} ``` \ No newline at end of file diff --git a/docs/zh/08-connector/02-rest-api.mdx b/docs/zh/08-connector/02-rest-api.mdx index e254244657..12a9cf5347 100644 --- a/docs/zh/08-connector/02-rest-api.mdx +++ b/docs/zh/08-connector/02-rest-api.mdx @@ -4,7 +4,7 @@ sidebar_label: REST API description: 详细介绍 TDengine 提供的 RESTful API. --- -为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST 连接器的使用参见 [视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 +为支持各种不同类型平台的开发,TDengine 提供符合 RESTful 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST API 的使用参见 [视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 :::note 与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。支持在 RESTful URL 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 URL 中指定的这个 db_name。 @@ -18,7 +18,7 @@ RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安 在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。 -下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常,验证前请确认 taosAdapter 服务已开启,在 Linux 系统上此服务默认由 systemd 管理,使用命令 `systemctl start taosadapter` 启动。 +下面以 Ubuntu 环境中使用 `curl` 工具(请确认已经安装)来验证 RESTful 接口是否工作正常,验证前请确认 taosAdapter 服务已开启,在 Linux 系统上此服务默认由 systemd 管理,使用命令 `systemctl start taosadapter` 启动。 下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号: diff --git a/docs/zh/08-connector/05-schemaless-api.mdx b/docs/zh/08-connector/05-schemaless-api.mdx new file mode 100644 index 0000000000..f6d7e09212 --- /dev/null +++ b/docs/zh/08-connector/05-schemaless-api.mdx @@ -0,0 +1,38 @@ +--- +title: Schemaless API +sidebar_label: Schemaless API +description: 详细介绍 TDengine 提供的 Schemaless API. +--- + +TDengine 提供了兼容 InfluxDB (v1) 和 OpenTSDB 行协议的 Schemaless API。支持 InfluxDB(v1) 或 OpenTSDB 行协议写入数据的第三方软件无需修改代码,只要修改配置的 EndPoint URL 就可以直接把数据写入 TDengine 数据库。 + +### 兼容 InfluxDB 行协议写入的方法 + +您可以配置任何支持使用 InfluxDB(v1) 行协议的应用访问地址 `http://:6041/` 来写入 InfluxDB 兼容格式的数据到 TDengine。EndPoint 如下: +```text +/influxdb/v1/write??... +``` + +支持 InfluxDB 查询参数如下: + +- `db` 指定 TDengine 使用的数据库名 +- `precision` TDengine 使用的时间精度 +- `u` TDengine 用户名 +- `p` TDengine 密码 + +注意: 目前不支持 InfluxDB 的 token 验证方式,仅支持 Basic 验证和查询参数验证。 + +参考链接:[InfluxDB v1 写接口](https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/) + +### 兼容 OpenTSDB 行协议写入的方法 + +您可以配置任何支持 OpenTSDB 行协议的应用访问地址 `http://:6041/` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下: + +```text +/opentsdb/v1/put/json/ +/opentsdb/v1/put/telnet/ +``` + +参考链接: + - [OpenTSDB JSON](http://opentsdb.net/docs/build/html/api_http/put.html) + - [OpenTSDB Telnet](http://opentsdb.net/docs/build/html/api_telnet/put.html) diff --git a/docs/zh/08-connector/03-cpp.mdx b/docs/zh/08-connector/10-cpp.mdx similarity index 100% rename from docs/zh/08-connector/03-cpp.mdx rename to docs/zh/08-connector/10-cpp.mdx diff --git a/docs/zh/08-connector/04-java.mdx b/docs/zh/08-connector/14-java.mdx similarity index 100% rename from docs/zh/08-connector/04-java.mdx rename to docs/zh/08-connector/14-java.mdx diff --git a/docs/zh/08-connector/05-go.mdx b/docs/zh/08-connector/20-go.mdx similarity index 100% rename from docs/zh/08-connector/05-go.mdx rename to docs/zh/08-connector/20-go.mdx diff --git a/docs/zh/08-connector/06-rust.mdx b/docs/zh/08-connector/26-rust.mdx similarity index 99% rename from docs/zh/08-connector/06-rust.mdx rename to docs/zh/08-connector/26-rust.mdx index b838e5c5a2..f6b99beed3 100644 --- a/docs/zh/08-connector/06-rust.mdx +++ b/docs/zh/08-connector/26-rust.mdx @@ -116,7 +116,7 @@ DSN 描述字符串基本结构如下: - **protocol**: 显示指定以何种方式建立连接,例如:`taos+ws://localhost:6041` 指定以 Websocket 方式建立连接。 - **username/password**: 用于创建连接的用户名及密码。 - **host/port**: 指定创建连接的服务器及端口,当不指定服务器地址及端口时(`taos://`),原生连接默认为 `localhost:6030`,Websocket 连接默认为 `localhost:6041` 。 -- **database**: 指定默认连接的数据库名。 +- **database**: 指定默认连接的数据库名,可选参数。 - **params**:其他可选参数。 一个完整的 DSN 描述字符串示例如下: diff --git a/docs/zh/08-connector/07-python.mdx b/docs/zh/08-connector/30-python.mdx similarity index 100% rename from docs/zh/08-connector/07-python.mdx rename to docs/zh/08-connector/30-python.mdx diff --git a/docs/zh/08-connector/08-node.mdx b/docs/zh/08-connector/35-node.mdx similarity index 100% rename from docs/zh/08-connector/08-node.mdx rename to docs/zh/08-connector/35-node.mdx diff --git a/docs/zh/08-connector/09-csharp.mdx b/docs/zh/08-connector/40-csharp.mdx similarity index 69% rename from docs/zh/08-connector/09-csharp.mdx rename to docs/zh/08-connector/40-csharp.mdx index 4e49d84835..e99f41ae9c 100644 --- a/docs/zh/08-connector/09-csharp.mdx +++ b/docs/zh/08-connector/40-csharp.mdx @@ -17,7 +17,7 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx" `TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。 -`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、订阅、schemaless 数据写入、参数绑定接口数据写入等功能 `TDengine.Connector` 目前暂未提供 REST 连接方式,用户可以参考 [REST API](../rest-api/) 文档自行编写。 +`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、数据订阅、schemaless 数据写入、参数绑定接口数据写入等功能。 `TDengine.Connector` 还支持 WebSocket,通过 DSN 建立 WebSocket 连接,提供数据写入、查询、参数绑定接口数据写入等功能。 本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。 @@ -35,12 +35,29 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx" ## 支持的功能特性 + + + + 1. 连接管理 2. 普通查询 3. 连续查询 4. 参数绑定 -5. 订阅功能 +5. 数据订阅(TMQ) 6. Schemaless + + + + + +1. 连接管理 +2. 普通查询 +3. 连续查询 +4. 参数绑定 + + + + ## 安装步骤 @@ -79,7 +96,13 @@ dotnet add exmaple.csproj reference src/TDengine.csproj ## 建立连接 -``` C# + + + + +使用 host、username、password、port 等信息建立连接。 + +``` csharp using TDengineDriver; namespace TDengineExample @@ -109,17 +132,63 @@ namespace TDengineExample } } } - ``` + + + + +使用 DSN 建立 WebSocket 连接 DSN 连接。 描述字符串基本结构如下: + +```text +[]://[[:@]:][/][?=[&=]] +|------------|---|-----------|-----------|------|------|------------|-----------------------| +| protocol | | username | password | host | port | database | params | +``` + +各部分意义见下表: + +* **protocol**: 显示指定以何种方式建立连接,例如:`ws://localhost:6041` 指定以 Websocket 方式建立连接(支持http/ws)。 + +* **username/password**: 用于创建连接的用户名及密码(默认`root/taosdata`)。 + +* **host/port**: 指定创建连接的服务器及端口,WebSocket 连接默认为 `localhost:6041` 。 + +* **database**: 指定默认连接的数据库名,可选参数。 + +* **params**:其他可选参数。 + +``` csharp +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` + + + + ## 使用示例 ### 写入数据 #### SQL 写入 + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsInsert/Program.cs}} +``` + + + + + #### InfluxDB 行协议写入 @@ -132,12 +201,50 @@ namespace TDengineExample +#### 参数绑定 + + + + + +``` csharp +{{#include docs/examples/csharp/stmtInsert/Program.cs}} +``` + + + + + +```csharp +{{#include docs/examples/csharp/wsStmt/Program.cs}} +``` + + + + + ### 查询数据 #### 同步查询 + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsQuery/Program.cs}} +``` + + + + + #### 异步查询 @@ -151,12 +258,15 @@ namespace TDengineExample | [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/Stmt) | 使用 TDengine.Connector 实现的参数绑定插入和查询的示例 | | [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/schemaless) | 使用 TDengine.Connector 实现的使用 schemaless 写入的示例 | | [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/AsyncQuery/QueryAsync.cs) | 使用 TDengine.Connector 实现的异步查询的示例 | -| [TMQ](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | 使用 TDengine.Connector 实现的订阅数据的示例 | +| [数据订阅(TMQ)](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | 使用 TDengine.Connector 实现的订阅数据的示例 | +| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSample.cs) | 使用 TDengine.Connector 的 WebSocket 基本的示例 | +| [Basic WebSocket STMT](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSTMT.cs) | 使用 TDengine.Connector 的 WebSocket STMT 基本的示例 | ## 重要更新记录 | TDengine.Connector | 说明 | |--------------------|--------------------------------| +| 3.0.1 | 支持 WebSocket 和 Cloud,查询,插入,参数绑定。 | | 3.0.0 | 支持 TDengine 3.0.0.0,不兼容 2.x。新增接口TDengine.Impl.GetData(),解析查询结果。 | | 1.0.7 | 修复 TDengine.Query()内存泄露。 | | 1.0.6 | 修复 schemaless 在 1.0.4 和 1.0.5 中失效 bug。 | diff --git a/docs/zh/08-connector/10-php.mdx b/docs/zh/08-connector/45-php.mdx similarity index 100% rename from docs/zh/08-connector/10-php.mdx rename to docs/zh/08-connector/45-php.mdx diff --git a/docs/zh/12-taos-sql/01-data-type.md b/docs/zh/12-taos-sql/01-data-type.md index ee7b3a4715..128fa20930 100644 --- a/docs/zh/12-taos-sql/01-data-type.md +++ b/docs/zh/12-taos-sql/01-data-type.md @@ -1,7 +1,7 @@ --- sidebar_label: 数据类型 title: 数据类型 -description: "TDengine 支持的数据类型: 时间戳、浮点型、JSON 类型等" +description: 'TDengine 支持的数据类型: 时间戳、浮点型、JSON 类型等' --- ## 时间戳 @@ -9,64 +9,65 @@ description: "TDengine 支持的数据类型: 时间戳、浮点型、JSON 类 使用 TDengine,最重要的是时间戳。创建并插入记录、查询历史记录的时候,均需要指定时间戳。时间戳有如下规则: - 时间格式为 `YYYY-MM-DD HH:mm:ss.MS`,默认时间分辨率为毫秒。比如:`2017-08-12 18:25:58.128` -- 内部函数 now 是客户端的当前时间 -- 插入记录时,如果时间戳为 now,插入数据时使用提交这条记录的客户端的当前时间 -- Epoch Time:时间戳也可以是一个长整数,表示从 UTC 时间 1970-01-01 00:00:00 开始的毫秒数。相应地,如果所在 Database 的时间精度设置为“微秒”,则长整型格式的时间戳含义也就对应于从 UTC 时间 1970-01-01 00:00:00 开始的微秒数;纳秒精度逻辑类似。 -- 时间可以加减,比如 now-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `select * from t1 where ts > now-2w and ts <= now-1w`,表示查询两周前整整一周的数据。在指定降采样操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n (自然月) 和 y (自然年)。 +- 内部函数 NOW 是客户端的当前时间 +- 插入记录时,如果时间戳为 NOW,插入数据时使用提交这条记录的客户端的当前时间 +- Epoch Time:时间戳也可以是一个长整数,表示从 UTC 时间 1970-01-01 00:00:00 开始的毫秒数。相应地,如果所在 Database 的时间精度设置为“微秒”,则长整型格式的时间戳含义也就对应于从 UTC 时间 1970-01-01 00:00:00 开始的微秒数;纳秒精度逻辑相同。 +- 时间可以加减,比如 NOW-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `SELECT * FROM t1 WHERE ts > NOW-2w AND ts <= NOW-1w`,表示查询两周前整整一周的数据。在指定降采样操作(Down Sampling)的时间窗口(Interval)时,时间单位还可以使用 n(自然月)和 y(自然年)。 -TDengine 缺省的时间戳精度是毫秒,但通过在 `CREATE DATABASE` 时传递的 PRECISION 参数也可以支持微秒和纳秒。 +TDengine 缺省的时间戳精度是毫秒,但通过在 `CREATE DATABASE` 时传递的 `PRECISION` 参数也可以支持微秒和纳秒。 ```sql CREATE DATABASE db_name PRECISION 'ns'; ``` + ## 数据类型 在 TDengine 中,普通表的数据模型中可使用以下数据类型。 -| # | **类型** | **Bytes** | **说明** | -| --- | :-------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 1 | TIMESTAMP | 8 | 时间戳。缺省精度毫秒,可支持微秒和纳秒,详细说明见上节。 | -| 2 | INT | 4 | 整型,范围 [-2^31, 2^31-1] | -| 3 | INT UNSIGNED| 4| 无符号整数,[0, 2^32-1] -| 4 | BIGINT | 8 | 长整型,范围 [-2^63, 2^63-1] | -| 5 | BIGINT UNSIGNED | 8 | 长整型,范围 [0, 2^64-1] | -| 6 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] | -| 7 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] | -| 8 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。 | -| 9 | SMALLINT | 2 | 短整型, 范围 [-32768, 32767] | -| 10 | SMALLINT UNSIGNED | 2| 无符号短整型,范围 [0, 65535] | -| 11 | TINYINT | 1 | 单字节整型,范围 [-128, 127] | -| 12 | TINYINT UNSIGNED | 1 | 无符号单字节整型,范围 [0, 255] | -| 13 | BOOL | 1 | 布尔型,{true, false} | -| 14 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 | -| 15 | JSON | | json 数据类型, 只有 tag 可以是 json 格式 | -| 16 | VARCHAR | 自定义 | BINARY类型的别名 | - +| # | **类型** | **Bytes** | **说明** | +| --- | :---------------: | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | TIMESTAMP | 8 | 时间戳。缺省精度毫秒,可支持微秒和纳秒,详细说明见上节。 | +| 2 | INT | 4 | 整型,范围 [-2^31, 2^31-1] | +| 3 | INT UNSIGNED | 4 | 无符号整数,[0, 2^32-1] | +| 4 | BIGINT | 8 | 长整型,范围 [-2^63, 2^63-1] | +| 5 | BIGINT UNSIGNED | 8 | 长整型,范围 [0, 2^64-1] | +| 6 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] | +| 7 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] | +| 8 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 NCHAR | +| 9 | SMALLINT | 2 | 短整型, 范围 [-32768, 32767] | +| 10 | SMALLINT UNSIGNED | 2 | 无符号短整型,范围 [0, 65535] | +| 11 | TINYINT | 1 | 单字节整型,范围 [-128, 127] | +| 12 | TINYINT UNSIGNED | 1 | 无符号单字节整型,范围 [0, 255] | +| 13 | BOOL | 1 | 布尔型,{true, false} | +| 14 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 NCHAR 字符占用 4 字节的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\'`。NCHAR 使用时须指定字符串大小,类型为 NCHAR(10) 的列表示此列的字符串最多存储 10 个 NCHAR 字符,会固定占用 40 字节的空间。如果用户字符串长度超出声明长度,将会报错。 | +| 15 | JSON | | JSON 数据类型, 只有 Tag 可以是 JSON 格式 | +| 16 | VARCHAR | 自定义 | BINARY 类型的别名 | :::note -- TDengine 对 SQL 语句中的英文字符不区分大小写,自动转化为小写执行。因此用户大小写敏感的字符串及密码,需要使用单引号将字符串引起来。 + - 虽然 BINARY 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 BINARY 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 NCHAR 类型进行保存。如果强行使用 BINARY 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏等情况。 -- BINARY 类型理论上最长可以有 16374 字节。binary 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 binary(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 byte 的存储空间,总共固定占用 20 bytes 的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 +- BINARY 类型理论上最长可以有 16,374 字节。BINARY 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 BINARY(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 字节的存储空间,总共固定占用 20 字节的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\'`。 - SQL 语句中的数值类型将依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型,因此在使用时要注意相应类型越界的情况。例如,9999999999999999999 会认为超过长整型的上边界而溢出,而 9999999999999999999.0 会被认为是有效的浮点数。 ::: - ## 常量 -TDengine支持多个类型的常量,细节如下表: -| # | **语法** | **类型** | **说明** | -| --- | :-------: | --------- | -------------------------------------- | -| 1 | [{+ \| -}]123 | BIGINT | 整型数值的字面量的类型均为BIGINT。如果用户输入超过了BIGINT的表示范围,TDengine 按BIGINT对数值进行截断。| -| 2 | 123.45 | DOUBLE | 浮点数值的字面量的类型均为DOUBLE。TDengine依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型。| -| 3 | 1.2E3 | DOUBLE | 科学计数法的字面量的类型为DOUBLE。| -| 4 | 'abc' | BINARY | 单引号括住的内容为字符串字面值,其类型为BINARY,BINARY的size为实际的字符个数。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 \'。| -| 5 | "abc" | BINARY | 双引号括住的内容为字符串字面值,其类型为BINARY,BINARY的size为实际的字符个数。对于字符串内的双引号,可以用转义字符反斜线加单引号来表示,即 \"。 | -| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | TIMESTAMP关键字表示后面的字符串字面量需要被解释为TIMESTAMP类型。字符串需要满足YYYY-MM-DD HH:mm:ss.MS格式,其时间分辨率为当前数据库的时间分辨率。 | -| 7 | {TRUE \| FALSE} | BOOL | 布尔类型字面量。 | -| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | 空值字面量。可以用于任意类型。| +TDengine 支持多个类型的常量,细节如下表: + +| # | **语法** | **类型** | **说明** | +| --- | :-----------------------------------------------: | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | [{+ \| -}]123 | BIGINT | 整型数值的字面量的类型均为 BIGINT。如果用户输入超过了 BIGINT 的表示范围,TDengine 按 BIGINT 对数值进行截断。 | +| 2 | 123.45 | DOUBLE | 浮点数值的字面量的类型均为 DOUBLE。TDengine 依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型。 | +| 3 | 1.2E3 | DOUBLE | 科学计数法的字面量的类型为 DOUBLE。 | +| 4 | 'abc' | BINARY | 单引号括住的内容为字符串字面值,其类型为 BINARY,BINARY 的 Size 为实际的字符个数。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\'`。 | +| 5 | "abc" | BINARY | 双引号括住的内容为字符串字面值,其类型为 BINARY,BINARY 的 Size 为实际的字符个数。对于字符串内的双引号,可以用转义字符反斜线加单引号来表示,即 `\"`。 | +| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | TIMESTAMP 关键字表示后面的字符串字面量需要被解释为 TIMESTAMP 类型。字符串需要满足 YYYY-MM-DD HH:mm:ss.MS 格式,其时间分辨率为当前数据库的时间分辨率。 | +| 7 | {TRUE \| FALSE} | BOOL | 布尔类型字面量。 | +| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | 空值字面量。可以用于任意类型。 | :::note -- TDengine依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型,因此在使用时要注意相应类型越界的情况。例如,9999999999999999999会认为超过长整型的上边界而溢出,而9999999999999999999.0会被认为是有效的浮点数。 + +- TDengine 依据是否存在小数点,或使用科学计数法表示,来判断数值类型是否为整型或者浮点型,因此在使用时要注意相应类型越界的情况。例如,9999999999999999999 会认为超过长整型的上边界而溢出,而 9999999999999999999.0 会被认为是有效的浮点数。 ::: diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index 59af9c55ed..5e64827a8f 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -17,6 +17,8 @@ INSERT INTO [(field1_name, ...)] VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path ...]; + +INSERT INTO tb_name [(field1_name, ...)] subquery ``` **关于时间戳** @@ -38,7 +40,7 @@ INSERT INTO 4. FILE 语法表示数据来自于 CSV 文件(英文逗号分隔、英文单引号括住每个值),CSV 文件无需表头。 -5. 无论使用哪种语法,均可以在一条 INSERT 语句中同时向多个表插入数据。 +5. `INSERT ... VALUES` 语句和 `INSERT ... FILE` 语句均可以在一条 INSERT 语句中同时向多个表插入数据。 6. INSERT 语句是完整解析后再执行的,对如下语句,不会再出现数据错误但建表成功的情况: @@ -48,6 +50,8 @@ INSERT INTO 7. 对于向多个子表插入数据的情况,依然会有部分数据写入失败,部分数据写入成功的情况。这是因为多个子表可能分布在不同的 VNODE 上,客户端将 INSERT 语句完整解析后,将数据发往各个涉及的 VNODE 上,每个 VNODE 独立进行写入操作。如果某个 VNODE 因为某些原因(比如网络问题或磁盘故障)导致写入失败,并不会影响其他 VNODE 节点的写入。 +8. 可以使用 `INSERT ... subquery` 语句将 TDengine 中的数据插入到指定表中。subquery 可以是任意的查询语句。此语法只能用于子表和普通表,且不支持自动建表。 + ## 插入一条记录 指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录: diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index c49351b0c9..394e4a99d5 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -69,7 +69,7 @@ order_expr: ### 通配符 -通配符 \* 可以用于代指全部列。对于普通表,结果中只有普通列。对于超级表和子表,还包含了 TAG 列。 +通配符 \* 可以用于代指全部列。对于普通表和子表,结果中只有普通列。对于超级表,还包含了 TAG 列。 ```sql SELECT * FROM d1001; @@ -137,6 +137,8 @@ taos> SELECT ts, ts AS primary_key_ts FROM d1001; ### 伪列 +**伪列**: 伪列的行为表现与普通数据列相似但其并不实际存储在表中。可以查询伪列,但不能对其做插入、更新和删除的操作。伪列有点像没有参数的函数。下面介绍是可用的伪列: + **TBNAME** `TBNAME` 可以视为超级表中一个特殊的标签,代表子表的表名。 diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 86e9aaa80f..9726406b4d 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -1233,7 +1233,7 @@ SELECT SERVER_VERSION(); ### SERVER_STATUS ```sql -SELECT SERVER_VERSION(); +SELECT SERVER_STATUS(); ``` **说明**:返回服务端当前的状态。 diff --git a/docs/zh/12-taos-sql/12-distinguished.md b/docs/zh/12-taos-sql/12-distinguished.md index 268712e757..861ef4ebb7 100644 --- a/docs/zh/12-taos-sql/12-distinguished.md +++ b/docs/zh/12-taos-sql/12-distinguished.md @@ -46,7 +46,7 @@ SELECT select_list FROM tb_name ### 窗口子句的规则 -- 窗口子句位于数据切分子句之后,GROUP BY 子句之前,且不可以和 GROUP BY 子句一起使用。 +- 窗口子句位于数据切分子句之后,不可以和 GROUP BY 子句一起使用。 - 窗口子句将数据按窗口进行切分,对每个窗口进行 SELECT 列表中的表达式的计算,SELECT 列表中的表达式只能包含: - 常量。 - _wstart伪列、_wend伪列和_wduration伪列。 @@ -71,7 +71,7 @@ FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填 1. 使用 FILL 语句的时候可能生成大量的填充输出,务必指定查询的时间区间。针对每次查询,系统可返回不超过 1 千万条具有插值的结果。 2. 在时间维度聚合中,返回的结果中时间序列严格单调递增。 -3. 如果查询对象是超级表,则聚合函数会作用于该超级表下满足值过滤条件的所有表的数据。如果查询中没有使用 PARTITION BY 语句,则返回的结果按照时间序列严格单调递增;如果查询中使用了 PARTITION BY 语句分组,则返回结果中每个 PARTITION 内不按照时间序列严格单调递增。 +3. 如果查询对象是超级表,则聚合函数会作用于该超级表下满足值过滤条件的所有表的数据。如果查询中没有使用 PARTITION BY 语句,则返回的结果按照时间序列严格单调递增;如果查询中使用了 PARTITION BY 语句分组,则返回结果中每个 PARTITION 内按照时间序列严格单调递增。 ::: @@ -113,6 +113,12 @@ SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m); SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status); ``` +仅关心 status 为 2 时的状态窗口的信息。例如: + +``` +SELECT * FROM (SELECT COUNT(*) AS cnt, FIRST(ts) AS fst, status FROM temp_tb_1 STATE_WINDOW(status)) t WHERE status = 2; +``` + ### 会话窗口 会话窗口根据记录的时间戳主键的值来确定是否属于同一个会话。如下图所示,如果设置时间戳的连续的间隔小于等于 12 秒,则以下 6 条记录构成 2 个会话窗口,分别是:[2019-04-28 14:22:10,2019-04-28 14:22:30]和[2019-04-28 14:23:10,2019-04-28 14:23:30]。因为 2019-04-28 14:22:30 与 2019-04-28 14:23:10 之间的时间间隔是 40 秒,超过了连续时间间隔(12 秒)。 diff --git a/docs/zh/14-reference/04-taosadapter.md b/docs/zh/14-reference/04-taosadapter.md index 71bf5f4223..82efcab06f 100644 --- a/docs/zh/14-reference/04-taosadapter.md +++ b/docs/zh/14-reference/04-taosadapter.md @@ -196,7 +196,7 @@ AllowWebSockets - `u` TDengine 用户名 - `p` TDengine 密码 -注意: 目前不支持 InfluxDB 的 token 验证方式只支持 Basic 验证和查询参数验证。 +注意: 目前不支持 InfluxDB 的 token 验证方式,仅支持 Basic 验证和查询参数验证。 ### OpenTSDB diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 7b31e10572..179a3c6df0 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -325,7 +325,7 @@ charset 的有效值是 UTF-8。 | 适用范围 | 仅服务端适用 | | 含义 | dnode 支持的最大 vnode 数目 | | 取值范围 | 0-4096 | -| 缺省值 | 256 | +| 缺省值 | CPU 核数的 2 倍 | ## 时间相关 @@ -668,153 +668,154 @@ charset 的有效值是 UTF-8。 | 15 | telemetryPort | 否 | 是 | | 16 | queryPolicy | 否 | 是 | | 17 | querySmaOptimize | 否 | 是 | -| 18 | queryBufferSize | 是 | 是 | -| 19 | maxNumOfDistinctRes | 是 | 是 | -| 20 | minSlidingTime | 是 | 是 | -| 21 | minIntervalTime | 是 | 是 | -| 22 | countAlwaysReturnValue | 是 | 是 | -| 23 | dataDir | 是 | 是 | -| 24 | minimalDataDirGB | 是 | 是 | -| 25 | supportVnodes | 否 | 是 | -| 26 | tempDir | 是 | 是 | -| 27 | minimalTmpDirGB | 是 | 是 | -| 28 | compressMsgSize | 是 | 是 | -| 29 | compressColData | 是 | 是 | -| 30 | smlChildTableName | 是 | 是 | -| 31 | smlTagName | 是 | 是 | -| 32 | smlDataFormat | 否 | 是 | -| 33 | statusInterval | 是 | 是 | -| 34 | shellActivityTimer | 是 | 是 | -| 35 | transPullupInterval | 否 | 是 | -| 36 | mqRebalanceInterval | 否 | 是 | -| 37 | ttlUnit | 否 | 是 | -| 38 | ttlPushInterval | 否 | 是 | -| 39 | numOfTaskQueueThreads | 否 | 是 | -| 40 | numOfRpcThreads | 否 | 是 | -| 41 | numOfCommitThreads | 是 | 是 | -| 42 | numOfMnodeReadThreads | 否 | 是 | -| 43 | numOfVnodeQueryThreads | 否 | 是 | -| 44 | numOfVnodeStreamThreads | 否 | 是 | -| 45 | numOfVnodeFetchThreads | 否 | 是 | -| 46 | numOfVnodeWriteThreads | 否 | 是 | -| 47 | numOfVnodeSyncThreads | 否 | 是 | -| 48 | numOfVnodeRsmaThreads | 否 | 是 | -| 49 | numOfQnodeQueryThreads | 否 | 是 | -| 50 | numOfQnodeFetchThreads | 否 | 是 | -| 51 | numOfSnodeSharedThreads | 否 | 是 | -| 52 | numOfSnodeUniqueThreads | 否 | 是 | -| 53 | rpcQueueMemoryAllowed | 否 | 是 | -| 54 | logDir | 是 | 是 | -| 55 | minimalLogDirGB | 是 | 是 | -| 56 | numOfLogLines | 是 | 是 | -| 57 | asyncLog | 是 | 是 | -| 58 | logKeepDays | 是 | 是 | -| 59 | debugFlag | 是 | 是 | -| 60 | tmrDebugFlag | 是 | 是 | -| 61 | uDebugFlag | 是 | 是 | -| 62 | rpcDebugFlag | 是 | 是 | -| 63 | jniDebugFlag | 是 | 是 | -| 64 | qDebugFlag | 是 | 是 | -| 65 | cDebugFlag | 是 | 是 | -| 66 | dDebugFlag | 是 | 是 | -| 67 | vDebugFlag | 是 | 是 | -| 68 | mDebugFlag | 是 | 是 | -| 69 | wDebugFlag | 是 | 是 | -| 70 | sDebugFlag | 是 | 是 | -| 71 | tsdbDebugFlag | 是 | 是 | -| 72 | tqDebugFlag | 否 | 是 | -| 73 | fsDebugFlag | 是 | 是 | -| 74 | udfDebugFlag | 否 | 是 | -| 75 | smaDebugFlag | 否 | 是 | -| 76 | idxDebugFlag | 否 | 是 | -| 77 | tdbDebugFlag | 否 | 是 | -| 78 | metaDebugFlag | 否 | 是 | -| 79 | timezone | 是 | 是 | -| 80 | locale | 是 | 是 | -| 81 | charset | 是 | 是 | -| 82 | udf | 是 | 是 | -| 83 | enableCoreFile | 是 | 是 | -| 84 | arbitrator | 是 | 否 | -| 85 | numOfThreadsPerCore | 是 | 否 | -| 86 | numOfMnodes | 是 | 否 | -| 87 | vnodeBak | 是 | 否 | -| 88 | balance | 是 | 否 | -| 89 | balanceInterval | 是 | 否 | -| 90 | offlineThreshold | 是 | 否 | -| 91 | role | 是 | 否 | -| 92 | dnodeNopLoop | 是 | 否 | -| 93 | keepTimeOffset | 是 | 否 | -| 94 | rpcTimer | 是 | 否 | -| 95 | rpcMaxTime | 是 | 否 | -| 96 | rpcForceTcp | 是 | 否 | -| 97 | tcpConnTimeout | 是 | 否 | -| 98 | syncCheckInterval | 是 | 否 | -| 99 | maxTmrCtrl | 是 | 否 | -| 100 | monitorReplica | 是 | 否 | -| 101 | smlTagNullName | 是 | 否 | -| 102 | keepColumnName | 是 | 否 | -| 103 | ratioOfQueryCores | 是 | 否 | -| 104 | maxStreamCompDelay | 是 | 否 | -| 105 | maxFirstStreamCompDelay | 是 | 否 | -| 106 | retryStreamCompDelay | 是 | 否 | -| 107 | streamCompDelayRatio | 是 | 否 | -| 108 | maxVgroupsPerDb | 是 | 否 | -| 109 | maxTablesPerVnode | 是 | 否 | -| 110 | minTablesPerVnode | 是 | 否 | -| 111 | tableIncStepPerVnode | 是 | 否 | -| 112 | cache | 是 | 否 | -| 113 | blocks | 是 | 否 | -| 114 | days | 是 | 否 | -| 115 | keep | 是 | 否 | -| 116 | minRows | 是 | 否 | -| 117 | maxRows | 是 | 否 | -| 118 | quorum | 是 | 否 | -| 119 | comp | 是 | 否 | -| 120 | walLevel | 是 | 否 | -| 121 | fsync | 是 | 否 | -| 122 | replica | 是 | 否 | -| 123 | partitions | 是 | 否 | -| 124 | quorum | 是 | 否 | -| 125 | update | 是 | 否 | -| 126 | cachelast | 是 | 否 | -| 127 | maxSQLLength | 是 | 否 | -| 128 | maxWildCardsLength | 是 | 否 | -| 129 | maxRegexStringLen | 是 | 否 | -| 130 | maxNumOfOrderedRes | 是 | 否 | -| 131 | maxConnections | 是 | 否 | -| 132 | mnodeEqualVnodeNum | 是 | 否 | -| 133 | http | 是 | 否 | -| 134 | httpEnableRecordSql | 是 | 否 | -| 135 | httpMaxThreads | 是 | 否 | -| 136 | restfulRowLimit | 是 | 否 | -| 137 | httpDbNameMandatory | 是 | 否 | -| 138 | httpKeepAlive | 是 | 否 | -| 139 | enableRecordSql | 是 | 否 | -| 140 | maxBinaryDisplayWidth | 是 | 否 | -| 141 | stream | 是 | 否 | -| 142 | retrieveBlockingModel | 是 | 否 | -| 143 | tsdbMetaCompactRatio | 是 | 否 | -| 144 | defaultJSONStrType | 是 | 否 | -| 145 | walFlushSize | 是 | 否 | -| 146 | keepTimeOffset | 是 | 否 | -| 147 | flowctrl | 是 | 否 | -| 148 | slaveQuery | 是 | 否 | -| 149 | adjustMaster | 是 | 否 | -| 150 | topicBinaryLen | 是 | 否 | -| 151 | telegrafUseFieldNum | 是 | 否 | -| 152 | deadLockKillQuery | 是 | 否 | -| 153 | clientMerge | 是 | 否 | -| 154 | sdbDebugFlag | 是 | 否 | -| 155 | odbcDebugFlag | 是 | 否 | -| 156 | httpDebugFlag | 是 | 否 | -| 157 | monDebugFlag | 是 | 否 | -| 158 | cqDebugFlag | 是 | 否 | -| 159 | shortcutFlag | 是 | 否 | -| 160 | probeSeconds | 是 | 否 | -| 161 | probeKillSeconds | 是 | 否 | -| 162 | probeInterval | 是 | 否 | -| 163 | lossyColumns | 是 | 否 | -| 164 | fPrecision | 是 | 否 | -| 165 | dPrecision | 是 | 否 | -| 166 | maxRange | 是 | 否 | -| 167 | range | 是 | 否 | +| 18 | queryRsmaTolerance | 否 | 是 | +| 19 | queryBufferSize | 是 | 是 | +| 20 | maxNumOfDistinctRes | 是 | 是 | +| 21 | minSlidingTime | 是 | 是 | +| 22 | minIntervalTime | 是 | 是 | +| 23 | countAlwaysReturnValue | 是 | 是 | +| 24 | dataDir | 是 | 是 | +| 25 | minimalDataDirGB | 是 | 是 | +| 26 | supportVnodes | 否 | 是 | +| 27 | tempDir | 是 | 是 | +| 28 | minimalTmpDirGB | 是 | 是 | +| 29 | compressMsgSize | 是 | 是 | +| 30 | compressColData | 是 | 是 | +| 31 | smlChildTableName | 是 | 是 | +| 32 | smlTagName | 是 | 是 | +| 33 | smlDataFormat | 否 | 是 | +| 34 | statusInterval | 是 | 是 | +| 35 | shellActivityTimer | 是 | 是 | +| 36 | transPullupInterval | 否 | 是 | +| 37 | mqRebalanceInterval | 否 | 是 | +| 38 | ttlUnit | 否 | 是 | +| 39 | ttlPushInterval | 否 | 是 | +| 40 | numOfTaskQueueThreads | 否 | 是 | +| 41 | numOfRpcThreads | 否 | 是 | +| 42 | numOfCommitThreads | 是 | 是 | +| 43 | numOfMnodeReadThreads | 否 | 是 | +| 44 | numOfVnodeQueryThreads | 否 | 是 | +| 45 | numOfVnodeStreamThreads | 否 | 是 | +| 46 | numOfVnodeFetchThreads | 否 | 是 | +| 47 | numOfVnodeWriteThreads | 否 | 是 | +| 48 | numOfVnodeSyncThreads | 否 | 是 | +| 49 | numOfVnodeRsmaThreads | 否 | 是 | +| 50 | numOfQnodeQueryThreads | 否 | 是 | +| 51 | numOfQnodeFetchThreads | 否 | 是 | +| 52 | numOfSnodeSharedThreads | 否 | 是 | +| 53 | numOfSnodeUniqueThreads | 否 | 是 | +| 54 | rpcQueueMemoryAllowed | 否 | 是 | +| 55 | logDir | 是 | 是 | +| 56 | minimalLogDirGB | 是 | 是 | +| 57 | numOfLogLines | 是 | 是 | +| 58 | asyncLog | 是 | 是 | +| 59 | logKeepDays | 是 | 是 | +| 60 | debugFlag | 是 | 是 | +| 61 | tmrDebugFlag | 是 | 是 | +| 62 | uDebugFlag | 是 | 是 | +| 63 | rpcDebugFlag | 是 | 是 | +| 64 | jniDebugFlag | 是 | 是 | +| 65 | qDebugFlag | 是 | 是 | +| 66 | cDebugFlag | 是 | 是 | +| 67 | dDebugFlag | 是 | 是 | +| 68 | vDebugFlag | 是 | 是 | +| 69 | mDebugFlag | 是 | 是 | +| 70 | wDebugFlag | 是 | 是 | +| 71 | sDebugFlag | 是 | 是 | +| 72 | tsdbDebugFlag | 是 | 是 | +| 73 | tqDebugFlag | 否 | 是 | +| 74 | fsDebugFlag | 是 | 是 | +| 75 | udfDebugFlag | 否 | 是 | +| 76 | smaDebugFlag | 否 | 是 | +| 77 | idxDebugFlag | 否 | 是 | +| 78 | tdbDebugFlag | 否 | 是 | +| 79 | metaDebugFlag | 否 | 是 | +| 80 | timezone | 是 | 是 | +| 81 | locale | 是 | 是 | +| 82 | charset | 是 | 是 | +| 83 | udf | 是 | 是 | +| 84 | enableCoreFile | 是 | 是 | +| 85 | arbitrator | 是 | 否 | +| 86 | numOfThreadsPerCore | 是 | 否 | +| 87 | numOfMnodes | 是 | 否 | +| 88 | vnodeBak | 是 | 否 | +| 89 | balance | 是 | 否 | +| 90 | balanceInterval | 是 | 否 | +| 91 | offlineThreshold | 是 | 否 | +| 92 | role | 是 | 否 | +| 93 | dnodeNopLoop | 是 | 否 | +| 94 | keepTimeOffset | 是 | 否 | +| 95 | rpcTimer | 是 | 否 | +| 96 | rpcMaxTime | 是 | 否 | +| 97 | rpcForceTcp | 是 | 否 | +| 98 | tcpConnTimeout | 是 | 否 | +| 99 | syncCheckInterval | 是 | 否 | +| 100 | maxTmrCtrl | 是 | 否 | +| 101 | monitorReplica | 是 | 否 | +| 102 | smlTagNullName | 是 | 否 | +| 103 | keepColumnName | 是 | 否 | +| 104 | ratioOfQueryCores | 是 | 否 | +| 105 | maxStreamCompDelay | 是 | 否 | +| 106 | maxFirstStreamCompDelay | 是 | 否 | +| 107 | retryStreamCompDelay | 是 | 否 | +| 108 | streamCompDelayRatio | 是 | 否 | +| 109 | maxVgroupsPerDb | 是 | 否 | +| 110 | maxTablesPerVnode | 是 | 否 | +| 111 | minTablesPerVnode | 是 | 否 | +| 112 | tableIncStepPerVnode | 是 | 否 | +| 113 | cache | 是 | 否 | +| 114 | blocks | 是 | 否 | +| 115 | days | 是 | 否 | +| 116 | keep | 是 | 否 | +| 117 | minRows | 是 | 否 | +| 118 | maxRows | 是 | 否 | +| 119 | quorum | 是 | 否 | +| 120 | comp | 是 | 否 | +| 121 | walLevel | 是 | 否 | +| 122 | fsync | 是 | 否 | +| 123 | replica | 是 | 否 | +| 124 | partitions | 是 | 否 | +| 125 | quorum | 是 | 否 | +| 126 | update | 是 | 否 | +| 127 | cachelast | 是 | 否 | +| 128 | maxSQLLength | 是 | 否 | +| 129 | maxWildCardsLength | 是 | 否 | +| 130 | maxRegexStringLen | 是 | 否 | +| 131 | maxNumOfOrderedRes | 是 | 否 | +| 132 | maxConnections | 是 | 否 | +| 133 | mnodeEqualVnodeNum | 是 | 否 | +| 134 | http | 是 | 否 | +| 135 | httpEnableRecordSql | 是 | 否 | +| 136 | httpMaxThreads | 是 | 否 | +| 137 | restfulRowLimit | 是 | 否 | +| 138 | httpDbNameMandatory | 是 | 否 | +| 139 | httpKeepAlive | 是 | 否 | +| 140 | enableRecordSql | 是 | 否 | +| 141 | maxBinaryDisplayWidth | 是 | 否 | +| 142 | stream | 是 | 否 | +| 143 | retrieveBlockingModel | 是 | 否 | +| 144 | tsdbMetaCompactRatio | 是 | 否 | +| 145 | defaultJSONStrType | 是 | 否 | +| 146 | walFlushSize | 是 | 否 | +| 147 | keepTimeOffset | 是 | 否 | +| 148 | flowctrl | 是 | 否 | +| 149 | slaveQuery | 是 | 否 | +| 150 | adjustMaster | 是 | 否 | +| 151 | topicBinaryLen | 是 | 否 | +| 152 | telegrafUseFieldNum | 是 | 否 | +| 153 | deadLockKillQuery | 是 | 否 | +| 154 | clientMerge | 是 | 否 | +| 155 | sdbDebugFlag | 是 | 否 | +| 156 | odbcDebugFlag | 是 | 否 | +| 157 | httpDebugFlag | 是 | 否 | +| 158 | monDebugFlag | 是 | 否 | +| 159 | cqDebugFlag | 是 | 否 | +| 160 | shortcutFlag | 是 | 否 | +| 161 | probeSeconds | 是 | 否 | +| 162 | probeKillSeconds | 是 | 否 | +| 163 | probeInterval | 是 | 否 | +| 164 | lossyColumns | 是 | 否 | +| 165 | fPrecision | 是 | 否 | +| 166 | dPrecision | 是 | 否 | +| 167 | maxRange | 是 | 否 | +| 168 | range | 是 | 否 | diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md index 59a241b6c8..b05cf7a942 100644 --- a/docs/zh/28-releases/01-tdengine.md +++ b/docs/zh/28-releases/01-tdengine.md @@ -6,6 +6,9 @@ description: TDengine 发布历史、Release Notes 及下载链接 import Release from "/components/ReleaseV3"; +## 3.0.1.2 + + ## 3.0.1.1 diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md index 9ff8f42224..f793981d06 100644 --- a/docs/zh/28-releases/02-tools.md +++ b/docs/zh/28-releases/02-tools.md @@ -6,6 +6,10 @@ description: taosTools 的发布历史、Release Notes 和下载链接 import Release from "/components/ReleaseV3"; +## 2.2.2 + + + ## 2.2.0 diff --git a/examples/lua/OpenResty/so/luaconnector51.so b/examples/lua/OpenResty/so/luaconnector51.so index 442de6e39f..168d3a9d24 100755 Binary files a/examples/lua/OpenResty/so/luaconnector51.so and b/examples/lua/OpenResty/so/luaconnector51.so differ diff --git a/examples/lua/lua51/lua_connector51.c b/examples/lua/lua51/lua_connector51.c index 578622bf1f..4c702b2aae 100644 --- a/examples/lua/lua51/lua_connector51.c +++ b/examples/lua/lua51/lua_connector51.c @@ -2,7 +2,7 @@ #include #include #include -#include "../../../../include/client/taos.h" +#include "taos.h" #include "lauxlib.h" #include "lua.h" #include "lualib.h" @@ -35,7 +35,7 @@ static int l_connect(lua_State *L){ } lua_getfield(L, 1, "port"); - if (lua_isnumber(L,-1)){ + if (lua_isnumber(L, -1)){ port = lua_tonumber(L, -1); //printf("port = %d\n", port); } @@ -60,7 +60,6 @@ static int l_connect(lua_State *L){ lua_settop(L,0); - taos_init(); lua_newtable(L); int table_index = lua_gettop(L); @@ -102,7 +101,7 @@ static int l_query(lua_State *L){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); return 1; @@ -113,7 +112,6 @@ static int l_query(lua_State *L){ int rows = 0; int num_fields = taos_field_count(result); const TAOS_FIELD *fields = taos_fetch_fields(result); - //char temp[256]; const int affectRows = taos_affected_rows(result); // printf(" affect rows:%d\r\n", affectRows); @@ -122,7 +120,7 @@ static int l_query(lua_State *L){ lua_pushinteger(L, affectRows); lua_setfield(L, table_index, "affected"); lua_newtable(L); - + while ((row = taos_fetch_row(result))) { //printf("row index:%d\n",rows); rows++; @@ -136,7 +134,7 @@ static int l_query(lua_State *L){ } lua_pushstring(L,fields[i].name); - + int32_t* length = taos_fetch_lengths(result); switch (fields[i].type) { case TSDB_DATA_TYPE_TINYINT: lua_pushinteger(L,*((char *)row[i])); @@ -158,7 +156,8 @@ static int l_query(lua_State *L){ break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); + //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); + lua_pushlstring(L,(char *)row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: lua_pushinteger(L,*((int64_t *)row[i])); @@ -166,6 +165,7 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_BOOL: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_NULL: default: lua_pushnil(L); break; @@ -235,112 +235,6 @@ static int l_async_query(lua_State *L){ return 1; } -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); @@ -367,8 +261,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index 3c13b196b9..ce13ab3829 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -5,7 +5,7 @@ #include #include #include -#include "taos.h" +#include struct cb_param{ lua_State* state; @@ -60,6 +60,8 @@ static int l_connect(lua_State *L){ lua_settop(L,0); + taos_init(); + lua_newtable(L); int table_index = lua_gettop(L); diff --git a/examples/lua/test.lua b/examples/lua/test.lua index 89c0904c6a..3d725cc6a3 100644 --- a/examples/lua/test.lua +++ b/examples/lua/test.lua @@ -9,6 +9,50 @@ local config = { max_packet_size = 1024 * 1024 } +function dump(obj) + local getIndent, quoteStr, wrapKey, wrapVal, dumpObj + getIndent = function(level) + return string.rep("\t", level) + end + quoteStr = function(str) + return '"' .. string.gsub(str, '"', '\\"') .. '"' + end + wrapKey = function(val) + if type(val) == "number" then + return "[" .. val .. "]" + elseif type(val) == "string" then + return "[" .. quoteStr(val) .. "]" + else + return "[" .. tostring(val) .. "]" + end + end + wrapVal = function(val, level) + if type(val) == "table" then + return dumpObj(val, level) + elseif type(val) == "number" then + return val + elseif type(val) == "string" then + return quoteStr(val) + else + return tostring(val) + end + end + dumpObj = function(obj, level) + if type(obj) ~= "table" then + return wrapVal(obj) + end + level = level + 1 + local tokens = {} + tokens[#tokens + 1] = "{" + for k, v in pairs(obj) do + tokens[#tokens + 1] = getIndent(level) .. wrapKey(k) .. " = " .. wrapVal(v, level) .. "," + end + tokens[#tokens + 1] = getIndent(level - 1) .. "}" + return table.concat(tokens, "\n") + end + return dumpObj(obj, 0) +end + local conn local res = driver.connect(config) if res.code ~=0 then @@ -37,7 +81,7 @@ else print("select db--- pass.") end -res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))") +res = driver.query(conn,"create table m1 (ts timestamp, speed int, owner binary(20), mark nchar(30))") if res.code ~=0 then print("create table---failed: "..res.error) return @@ -45,7 +89,7 @@ else print("create table--- pass.") end -res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001',0,'robotspace'), ('2019-09-01 00:00:00.002',1,'Hilink'),('2019-09-01 00:00:00.003',2,'Harmony')") +res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace', '世界人民大团结万岁'), ('2019-09-01 00:00:00.002', 1, 'Hilink', '⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕'),('2019-09-01 00:00:00.003', 2, 'Harmony', '₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵')") if res.code ~=0 then print("insert records failed: "..res.error) return @@ -64,21 +108,25 @@ if res.code ~=0 then return else if (#(res.item) == 3) then - print("select--- pass") + print("select--- pass") + print(res.item[1].mark) + print(res.item[2].mark) + print(res.item[3].mark) + else print("select--- failed: expect 3 affected records, actually received "..#(res.item)) end end -res = driver.query(conn,"CREATE TABLE thermometer (ts timestamp, degree double) TAGS(location binary(20), type int)") +res = driver.query(conn,"create table thermometer (ts timestamp, degree double) tags(location binary(20), type int)") if res.code ~=0 then print(res.error) return else print("create super table--- pass") end -res = driver.query(conn,"CREATE TABLE therm1 USING thermometer TAGS ('beijing', 1)") +res = driver.query(conn,"create table therm1 using thermometer tags ('beijing', 1)") if res.code ~=0 then print(res.error) return @@ -86,7 +134,7 @@ else print("create table--- pass") end -res = driver.query(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.001', 20),('2019-09-01 00:00:00.002', 21)") +res = driver.query(conn,"insert into therm1 values ('2019-09-01 00:00:00.001', 20),('2019-09-01 00:00:00.002', 21)") if res.code ~=0 then print(res.error) @@ -99,14 +147,14 @@ else end end -res = driver.query(conn,"SELECT COUNT(*) count, AVG(degree) AS av, MAX(degree), MIN(degree) FROM thermometer WHERE location='beijing' or location='tianjin' GROUP BY location, type") +res = driver.query(conn,"select count(*) as cnt, avg(degree) as av, max(degree), min(degree) from thermometer where location='beijing' or location='tianjin' group by location, type") if res.code ~=0 then print("select from super table--- failed:"..res.error) return else print("select from super table--- pass") for i = 1, #(res.item) do - print("res:"..res.item[i].count) + print("res:"..res.item[i].cnt) end end @@ -127,30 +175,13 @@ end driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) +res = driver.query(conn, "create stream stream_avg_degree into avg_degree as select avg(degree) from thermometer interval(5s) sliding(1s)") -function stream_callback(t) - print("------------------------") - print("continuous query result:") - for key, value in pairs(t) do - print("key:"..key..", value:"..value) - end -end - -local stream -res = driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0, stream_callback) -if res.code ~=0 then - print("open stream--- failed:"..res.error) - return -else - print("open stream--- pass") - stream = res.stream -end - -print("From now on we start continous insert in an definite (infinite if you want) loop.") +print("From now on we start continous insert in an definite loop, pls wait for about 10 seconds and check stream table for result.") local loop_index = 0 -while loop_index < 30 do +while loop_index < 10 do local t = os.time()*1000 - local v = loop_index + local v = math.random(20) res = driver.query(conn,string.format("INSERT INTO therm1 VALUES (%d, %d)",t,v)) if res.code ~=0 then @@ -162,7 +193,5 @@ while loop_index < 30 do os.execute("sleep " .. 1) loop_index = loop_index + 1 end - -driver.close_stream(stream) - +driver.query(conn,"DROP STREAM IF EXISTS avg_therm_s") driver.close(conn) diff --git a/include/client/taos.h b/include/client/taos.h index 49cfbb52b8..270b647a77 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -254,7 +254,7 @@ enum tmq_res_t { TMQ_RES_INVALID = -1, TMQ_RES_DATA = 1, TMQ_RES_TABLE_META = 2, - TMQ_RES_TAOSX = 3, + TMQ_RES_METADATA = 3, }; typedef struct tmq_raw_data { diff --git a/include/common/tcommon.h b/include/common/tcommon.h index ba4baa0130..2544cedda7 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -116,6 +116,7 @@ enum { STREAM_INPUT__DATA_RETRIEVE, STREAM_INPUT__GET_RES, STREAM_INPUT__CHECKPOINT, + STREAM_INPUT__REF_DATA_BLOCK, STREAM_INPUT__DESTROY, }; diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 2de4ffdc17..9b69bec5b3 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -94,7 +94,10 @@ extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in // query client extern int32_t tsQueryPolicy; extern int32_t tsQuerySmaOptimize; +extern int32_t tsQueryRsmaTolerance; extern bool tsQueryPlannerTrace; +extern int32_t tsQueryNodeChunkSize; +extern bool tsQueryUseNodeAllocator; // client extern int32_t tsMinSlidingTime; @@ -120,6 +123,7 @@ extern SDiskCfg tsDiskCfg[]; // udf extern bool tsStartUdfd; +extern char tsUdfdResFuncs[]; // schemaless extern char tsSmlChildTableName[]; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 85a81e1767..c19c6cba02 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2965,7 +2965,7 @@ static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicE } static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { - // taosMemoryFree(pSubTopicEp->schema.pSchema); + if (pSubTopicEp->schema.nCols) taosMemoryFreeClear(pSubTopicEp->schema.pSchema); taosArrayDestroy(pSubTopicEp->vgs); } diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 3e170d5098..0111b03aac 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -234,96 +234,100 @@ #define TK_CURRENT_USER 216 #define TK_COUNT 217 #define TK_LAST_ROW 218 -#define TK_BETWEEN 219 -#define TK_IS 220 -#define TK_NK_LT 221 -#define TK_NK_GT 222 -#define TK_NK_LE 223 -#define TK_NK_GE 224 -#define TK_NK_NE 225 -#define TK_MATCH 226 -#define TK_NMATCH 227 -#define TK_CONTAINS 228 -#define TK_IN 229 -#define TK_JOIN 230 -#define TK_INNER 231 -#define TK_SELECT 232 -#define TK_DISTINCT 233 -#define TK_WHERE 234 -#define TK_PARTITION 235 -#define TK_BY 236 -#define TK_SESSION 237 -#define TK_STATE_WINDOW 238 -#define TK_SLIDING 239 -#define TK_FILL 240 -#define TK_VALUE 241 -#define TK_NONE 242 -#define TK_PREV 243 -#define TK_LINEAR 244 -#define TK_NEXT 245 -#define TK_HAVING 246 -#define TK_RANGE 247 -#define TK_EVERY 248 -#define TK_ORDER 249 -#define TK_SLIMIT 250 -#define TK_SOFFSET 251 -#define TK_LIMIT 252 -#define TK_OFFSET 253 -#define TK_ASC 254 -#define TK_NULLS 255 -#define TK_ABORT 256 -#define TK_AFTER 257 -#define TK_ATTACH 258 -#define TK_BEFORE 259 -#define TK_BEGIN 260 -#define TK_BITAND 261 -#define TK_BITNOT 262 -#define TK_BITOR 263 -#define TK_BLOCKS 264 -#define TK_CHANGE 265 -#define TK_COMMA 266 -#define TK_COMPACT 267 -#define TK_CONCAT 268 -#define TK_CONFLICT 269 -#define TK_COPY 270 -#define TK_DEFERRED 271 -#define TK_DELIMITERS 272 -#define TK_DETACH 273 -#define TK_DIVIDE 274 -#define TK_DOT 275 -#define TK_EACH 276 -#define TK_END 277 -#define TK_FAIL 278 -#define TK_FILE 279 -#define TK_FOR 280 -#define TK_GLOB 281 -#define TK_ID 282 -#define TK_IMMEDIATE 283 -#define TK_IMPORT 284 -#define TK_INITIALLY 285 -#define TK_INSTEAD 286 -#define TK_ISNULL 287 -#define TK_KEY 288 -#define TK_NK_BITNOT 289 -#define TK_NK_SEMI 290 -#define TK_NOTNULL 291 -#define TK_OF 292 -#define TK_PLUS 293 -#define TK_PRIVILEGE 294 -#define TK_RAISE 295 -#define TK_REPLACE 296 -#define TK_RESTRICT 297 -#define TK_ROW 298 -#define TK_SEMI 299 -#define TK_STAR 300 -#define TK_STATEMENT 301 -#define TK_STRING 302 -#define TK_TIMES 303 -#define TK_UPDATE 304 -#define TK_VALUES 305 -#define TK_VARIABLE 306 -#define TK_VIEW 307 -#define TK_WAL 308 +#define TK_CASE 219 +#define TK_END 220 +#define TK_WHEN 221 +#define TK_THEN 222 +#define TK_ELSE 223 +#define TK_BETWEEN 224 +#define TK_IS 225 +#define TK_NK_LT 226 +#define TK_NK_GT 227 +#define TK_NK_LE 228 +#define TK_NK_GE 229 +#define TK_NK_NE 230 +#define TK_MATCH 231 +#define TK_NMATCH 232 +#define TK_CONTAINS 233 +#define TK_IN 234 +#define TK_JOIN 235 +#define TK_INNER 236 +#define TK_SELECT 237 +#define TK_DISTINCT 238 +#define TK_WHERE 239 +#define TK_PARTITION 240 +#define TK_BY 241 +#define TK_SESSION 242 +#define TK_STATE_WINDOW 243 +#define TK_SLIDING 244 +#define TK_FILL 245 +#define TK_VALUE 246 +#define TK_NONE 247 +#define TK_PREV 248 +#define TK_LINEAR 249 +#define TK_NEXT 250 +#define TK_HAVING 251 +#define TK_RANGE 252 +#define TK_EVERY 253 +#define TK_ORDER 254 +#define TK_SLIMIT 255 +#define TK_SOFFSET 256 +#define TK_LIMIT 257 +#define TK_OFFSET 258 +#define TK_ASC 259 +#define TK_NULLS 260 +#define TK_ABORT 261 +#define TK_AFTER 262 +#define TK_ATTACH 263 +#define TK_BEFORE 264 +#define TK_BEGIN 265 +#define TK_BITAND 266 +#define TK_BITNOT 267 +#define TK_BITOR 268 +#define TK_BLOCKS 269 +#define TK_CHANGE 270 +#define TK_COMMA 271 +#define TK_COMPACT 272 +#define TK_CONCAT 273 +#define TK_CONFLICT 274 +#define TK_COPY 275 +#define TK_DEFERRED 276 +#define TK_DELIMITERS 277 +#define TK_DETACH 278 +#define TK_DIVIDE 279 +#define TK_DOT 280 +#define TK_EACH 281 +#define TK_FAIL 282 +#define TK_FILE 283 +#define TK_FOR 284 +#define TK_GLOB 285 +#define TK_ID 286 +#define TK_IMMEDIATE 287 +#define TK_IMPORT 288 +#define TK_INITIALLY 289 +#define TK_INSTEAD 290 +#define TK_ISNULL 291 +#define TK_KEY 292 +#define TK_NK_BITNOT 293 +#define TK_NK_SEMI 294 +#define TK_NOTNULL 295 +#define TK_OF 296 +#define TK_PLUS 297 +#define TK_PRIVILEGE 298 +#define TK_RAISE 299 +#define TK_REPLACE 300 +#define TK_RESTRICT 301 +#define TK_ROW 302 +#define TK_SEMI 303 +#define TK_STAR 304 +#define TK_STATEMENT 305 +#define TK_STRING 306 +#define TK_TIMES 307 +#define TK_UPDATE 308 +#define TK_VALUES 309 +#define TK_VARIABLE 310 +#define TK_VIEW 311 +#define TK_WAL 312 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 65ddc180d6..60c7b18367 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -78,7 +78,6 @@ enum { MAIN_SCAN = 0x0u, REVERSE_SCAN = 0x1u, // todo remove it REPEAT_SCAN = 0x2u, // repeat scan belongs to the master scan - MERGE_STAGE = 0x20u, }; typedef struct SPoint1 { @@ -156,11 +155,6 @@ typedef struct SqlFunctionCtx { char udfName[TSDB_FUNC_NAME_LEN]; } SqlFunctionCtx; -enum { - TEXPR_BINARYEXPR_NODE = 0x1, - TEXPR_UNARYEXPR_NODE = 0x2, -}; - typedef struct tExprNode { int32_t nodeType; union { @@ -182,8 +176,9 @@ struct SScalarParam { SColumnInfoData *columnData; SHashObj *pHashFilter; int32_t hashValueType; - void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value + void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value int32_t numOfRows; + int32_t numOfQualified; // number of qualified elements in the final results }; void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); @@ -201,8 +196,6 @@ int32_t taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // udf api -struct SUdfInfo; - /** * create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf * @return error code @@ -226,6 +219,7 @@ int32_t udfStartUdfd(int32_t startDnodeId); * @return */ int32_t udfStopUdfd(); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 6500d3d183..301e11fd17 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -103,6 +103,8 @@ typedef enum ENodeType { QUERY_NODE_STREAM_OPTIONS, QUERY_NODE_LEFT_VALUE, QUERY_NODE_COLUMN_REF, + QUERY_NODE_WHEN_THEN, + QUERY_NODE_CASE_WHEN, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR = 100, @@ -275,6 +277,17 @@ typedef struct SNodeList { SListCell* pTail; } SNodeList; +typedef struct SNodeAllocator SNodeAllocator; + +int32_t nodesInitAllocatorSet(); +void nodesDestroyAllocatorSet(); +int32_t nodesCreateAllocator(int64_t queryId, int32_t chunkSize, int64_t* pAllocatorId); +int32_t nodesAcquireAllocator(int64_t allocatorId); +int32_t nodesReleaseAllocator(int64_t allocatorId); +int64_t nodesMakeAllocatorWeakRef(int64_t allocatorId); +int64_t nodesReleaseAllocatorWeakRef(int64_t allocatorId); +void nodesDestroyAllocator(int64_t allocatorId); + SNode* nodesMakeNode(ENodeType type); void nodesDestroyNode(SNode* pNode); diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index e90c994e8f..9b150159fd 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -241,6 +241,19 @@ typedef struct SFillNode { STimeWindow timeRange; } SFillNode; +typedef struct SWhenThenNode { + SExprNode node; // QUERY_NODE_WHEN_THEN + SNode* pWhen; + SNode* pThen; +} SWhenThenNode; + +typedef struct SCaseWhenNode { + SExprNode node; // QUERY_NODE_CASE_WHEN + SNode* pCase; + SNode* pElse; + SNodeList* pWhenThenList; +} SCaseWhenNode; + typedef struct SSelectStmt { ENodeType type; // QUERY_NODE_SELECT_STMT bool isDistinct; diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 95bde85864..b1a937910d 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -56,6 +56,7 @@ typedef struct SParseContext { bool nodeOffline; SArray* pTableMetaPos; // sql table pos => catalog data pos SArray* pTableVgroupPos; // sql table pos => catalog data pos + int64_t allocatorId; } SParseContext; int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery); diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index e03ac3811a..e52fe39527 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -39,6 +39,7 @@ typedef struct SPlanContext { int32_t msgLen; const char* pUser; bool sysInfo; + int64_t allocatorId; } SPlanContext; // Create the physical plan for the query, according to the AST. diff --git a/include/libs/scalar/filter.h b/include/libs/scalar/filter.h index 1f1d9dea93..e02b4a6172 100644 --- a/include/libs/scalar/filter.h +++ b/include/libs/scalar/filter.h @@ -31,13 +31,17 @@ enum { FLT_OPTION_NEED_UNIQE = 4, }; +#define FILTER_RESULT_ALL_QUALIFIED 0x1 +#define FILTER_RESULT_NONE_QUALIFIED 0x2 +#define FILTER_RESULT_PARTIAL_QUALIFIED 0x3 + typedef struct SFilterColumnParam { int32_t numOfCols; SArray *pDataBlock; } SFilterColumnParam; extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options); -extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t **p, SColumnDataAgg *statis, int16_t numOfCols); +extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* pFilterResStatus); extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param); extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param); extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict); diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 70bd7b0c78..077c23c1b5 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -68,6 +68,7 @@ typedef struct SSchedulerReq { SRequestConnInfo *pConn; SArray *pNodeList; SQueryPlan *pDag; + int64_t allocatorRefId; const char *sql; int64_t startTs; schedulerExecFp execFp; diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index df19544396..849d83a58b 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -34,7 +34,7 @@ typedef struct { TXN txn; } SStreamState; -SStreamState* streamStateOpen(char* path, SStreamTask* pTask); +SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath); void streamStateClose(SStreamState* pState); int32_t streamStateBegin(SStreamState* pState); int32_t streamStateCommit(SStreamState* pState); @@ -44,7 +44,6 @@ typedef struct { TBC* pCur; } SStreamStateCur; -#if 1 int32_t streamStateFuncPut(SStreamState* pState, const STupleKey* key, const void* value, int32_t vLen); int32_t streamStateFuncGet(SStreamState* pState, const STupleKey* key, void** pVal, int32_t* pVLen); int32_t streamStateFuncDel(SStreamState* pState, const STupleKey* key); @@ -69,8 +68,6 @@ int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur); int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur); int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur); -#endif - #ifdef __cplusplus } #endif diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 554d66d621..bdc12f7e3f 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -125,6 +125,14 @@ typedef struct { SArray* blocks; // SArray } SStreamDataBlock; +// ref data block, for delete +typedef struct { + int8_t type; + int64_t ver; + int32_t* dataRef; + SSDataBlock* pBlock; +} SStreamRefDataBlock; + typedef struct { int8_t type; } SStreamCheckpoint; @@ -339,7 +347,8 @@ static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem qDebug("task %d %p submit enqueue %p %p %p", pTask->taskId, pTask, pItem, pSubmitClone, pSubmitClone->data); taosWriteQitem(pTask->inputQueue->queue, pSubmitClone); // qStreamInput(pTask->exec.executor, pSubmitClone); - } else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) { + } else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE || + pItem->type == STREAM_INPUT__REF_DATA_BLOCK) { taosWriteQitem(pTask->inputQueue->queue, pItem); // qStreamInput(pTask->exec.executor, pItem); } else if (pItem->type == STREAM_INPUT__CHECKPOINT) { @@ -492,7 +501,9 @@ typedef struct { int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq); int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq); -void tFreeStreamDispatchReq(SStreamDispatchReq* pReq); +void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq); + +void tDeleteStreamDispatchReq(SStreamDispatchReq* pReq); int32_t streamSetupTrigger(SStreamTask* pTask); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index e6a4dd1d49..285e079b3e 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -22,6 +22,7 @@ extern "C" { #include "cJSON.h" #include "tdef.h" +#include "tlrucache.h" #include "tmsgcb.h" extern bool gRaftDetailLog; @@ -153,7 +154,8 @@ typedef struct SSyncFSM { // abstract definition of log store in raft // SWal implements it typedef struct SSyncLogStore { - void* data; + SLRUCache* pCache; + void* data; // append one log entry int32_t (*appendEntry)(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 01d42d6950..837d0c6303 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -552,7 +552,6 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x2653) #define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655) #define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656) - #define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657) #define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658) #define TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2659) @@ -565,6 +564,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661) #define TSDB_CODE_PAR_GET_META_ERROR TAOS_DEF_ERROR_CODE(0, 0x2662) #define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663) +#define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner @@ -619,6 +619,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156) #define TSDB_CODE_RSMA_INVALID_SCHEMA TAOS_DEF_ERROR_CODE(0, 0x3157) #define TSDB_CODE_RSMA_REGEX_MATCH TAOS_DEF_ERROR_CODE(0, 0x3158) +#define TSDB_CODE_RSMA_STREAM_STATE_OPEN TAOS_DEF_ERROR_CODE(0, 0x3159) +#define TSDB_CODE_RSMA_STREAM_STATE_COMMIT TAOS_DEF_ERROR_CODE(0, 0x3160) //index #define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200) diff --git a/include/util/tdef.h b/include/util/tdef.h index 9aa6985e29..43fd31afa7 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -225,7 +225,8 @@ typedef enum ELogicConditionType { #define TSDB_APP_NAME_LEN TSDB_UNI_LEN #define TSDB_TB_COMMENT_LEN 1025 -#define TSDB_QUERY_ID_LEN 26 +#define TSDB_QUERY_ID_LEN 26 +#define TSDB_TRANS_OPER_LEN 16 /** * In some scenarios uint16_t (0~65535) is used to store the row len. diff --git a/packaging/testpackage.sh b/packaging/testpackage.sh index 794b3968fe..20f93ecaec 100755 --- a/packaging/testpackage.sh +++ b/packaging/testpackage.sh @@ -202,8 +202,8 @@ elif [[ ${packgeName} =~ "tar" ]];then cd ${oriInstallPath}/${originTdpPath} && tar xf ${subFile} fi - cd ${oriInstallPath}/${originTdpPath} && tree > ${installPath}/base_${originversion}_checkfile - cd ${installPath}/${tdPath} && tree > ${installPath}/now_${version}_checkfile + cd ${oriInstallPath}/${originTdpPath} && tree -I "driver" > ${installPath}/base_${originversion}_checkfile + cd ${installPath}/${tdPath} && tree -I "driver" > ${installPath}/now_${version}_checkfile cd ${installPath} diff ${installPath}/base_${originversion}_checkfile ${installPath}/now_${version}_checkfile > ${installPath}/diffFile.log @@ -215,6 +215,7 @@ elif [[ ${packgeName} =~ "tar" ]];then exit -1 else echoColor G "The number and names of files are the same as previous installation packages" + rm -rf ${installPath}/diffFile.log fi echoColor YD "===== install Package of tar =====" cd ${installPath}/${tdPath} @@ -251,6 +252,9 @@ if [[ ${packgeName} =~ "server" ]] ;then systemctl restart taosd fi +rm -rf ${installPath}/${packgeName} +rm -rf ${installPath}/${tdPath}/ + # if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then # echoColor G "===== install taos-tools when package is lite or client =====" # cd ${installPath} diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index b8fa9580e7..535a436c6c 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -52,17 +52,17 @@ enum { RES_TYPE__QUERY = 1, RES_TYPE__TMQ, RES_TYPE__TMQ_META, - RES_TYPE__TAOSX, + RES_TYPE__TMQ_METADATA, }; #define SHOW_VARIABLES_RESULT_COLS 2 #define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ || *(int8_t*)res == RES_TYPE__TAOSX) -#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) -#define TD_RES_TMQ_TAOSX(res) (*(int8_t*)res == RES_TYPE__TAOSX) +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) +#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) +#define TD_RES_TMQ_METADATA(res) (*(int8_t*)res == RES_TYPE__TMQ_METADATA) typedef struct SAppInstInfo SAppInstInfo; @@ -250,6 +250,8 @@ typedef struct SRequestObj { bool inRetry; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t retry; + int64_t allocatorRefId; + SQuery* pQuery; } SRequestObj; typedef struct SSyncQueryParam { diff --git a/source/client/src/TMQConnector.c b/source/client/src/TMQConnector.c index fcf6957df9..26bf55055f 100644 --- a/source/client/src/TMQConnector.c +++ b/source/client/src/TMQConnector.c @@ -212,7 +212,7 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN tmq_commit_async(tmq, res, commit_cb, consumer); } -JNIEXPORT int JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp(JNIEnv *env, jobject jobj, jlong jtmq) { +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp(JNIEnv *env, jobject jobj, jlong jtmq) { tmq_t *tmq = (tmq_t *)jtmq; if (tmq == NULL) { jniError("jobj:%p, tmq is closed", jobj); @@ -222,7 +222,7 @@ JNIEXPORT int JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp( return tmq_unsubscribe((tmq_t *)tmq); } -JNIEXPORT int JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConsumerCloseImp(JNIEnv *env, jobject jobj, +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConsumerCloseImp(JNIEnv *env, jobject jobj, jlong jtmq) { tmq_t *tmq = (tmq_t *)jtmq; if (tmq == NULL) { diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 9a0639e1b6..6a4ef3d821 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -289,6 +289,7 @@ void *createRequest(uint64_t connId, int32_t type) { pRequest->body.resInfo.convertUcs4 = true; // convert ucs4 by default pRequest->type = type; + pRequest->allocatorRefId = -1; pRequest->pDb = getDbOfConnection(pTscObj); pRequest->pTscObj = pTscObj; @@ -350,6 +351,8 @@ void doDestroyRequest(void *p) { taosArrayDestroy(pRequest->tableList); taosArrayDestroy(pRequest->dbList); taosArrayDestroy(pRequest->targetTableList); + qDestroyQuery(pRequest->pQuery); + nodesDestroyAllocator(pRequest->allocatorRefId); destroyQueryExecRes(&pRequest->body.resInfo.execRes); @@ -412,6 +415,7 @@ void taos_init_imp(void) { initTaskQueue(); fmFuncMgtInit(); + nodesInitAllocatorSet(); clientConnRefPool = taosOpenRef(200, destroyTscObj); clientReqRefPool = taosOpenRef(40960, doDestroyRequest); diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 7ce80553a0..acf87f2aca 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -274,13 +274,13 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) { SClientHbBatchRsp pRsp = {0}; if (TSDB_CODE_SUCCESS == code) { tDeserializeSClientHbBatchRsp(pMsg->pData, pMsg->len, &pRsp); - } - int32_t now = taosGetTimestampSec(); - int32_t delta = abs(now - pRsp.svrTimestamp); - if (delta > timestampDeltaLimit) { - code = TSDB_CODE_TIME_UNSYNCED; - tscError("time diff: %ds is too big", delta); + int32_t now = taosGetTimestampSec(); + int32_t delta = abs(now - pRsp.svrTimestamp); + if (delta > timestampDeltaLimit) { + code = TSDB_CODE_TIME_UNSYNCED; + tscError("time diff: %ds is too big", delta); + } } int32_t rspNum = taosArrayGetSize(pRsp.rsps); @@ -878,12 +878,18 @@ int hbMgrInit() { clientHbMgr.appHbMgrs = taosArrayInit(0, sizeof(void *)); TdThreadMutexAttr attr = {0}; - taosThreadMutexAttrSetType(&attr, PTHREAD_MUTEX_RECURSIVE); + int ret = taosThreadMutexAttrInit(&attr); assert(ret == 0); - taosThreadMutexInit(&clientHbMgr.lock, &attr); - taosThreadMutexAttrDestroy(&attr); + ret = taosThreadMutexAttrSetType(&attr, PTHREAD_MUTEX_RECURSIVE); + assert(ret == 0); + + ret = taosThreadMutexInit(&clientHbMgr.lock, &attr); + assert(ret == 0); + + ret = taosThreadMutexAttrDestroy(&attr); + assert(ret == 0); // init handle funcs hbMgrInitHandle(); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 9ff436f64e..865ab8f611 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -189,11 +189,25 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, tscError("%d failed to add to request container, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); + taosMemoryFree(param); destroyRequest(*pRequest); *pRequest = NULL; return TSDB_CODE_TSC_OUT_OF_MEMORY; } + (*pRequest)->allocatorRefId = -1; + if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) { + if (TSDB_CODE_SUCCESS != + nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) { + tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self, + (*pRequest)->requestId, pTscObj->id, sql); + + destroyRequest(*pRequest); + *pRequest = NULL; + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + } + tscDebugL("0x%" PRIx64 " SQL: %s, reqId:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId); return TSDB_CODE_SUCCESS; } @@ -438,6 +452,7 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t } pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD)); pResInfo->userFields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD)); + ASSERT(numOfCols == pResInfo->numOfCols); for (int32_t i = 0; i < pResInfo->numOfCols; ++i) { pResInfo->fields[i].bytes = pSchema[i].bytes; @@ -703,6 +718,8 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList }; int32_t code = schedulerExecJob(&req, &pRequest->body.queryJob); + + destroyQueryExecRes(&pRequest->body.resInfo.execRes); memcpy(&pRequest->body.resInfo.execRes, &res, sizeof(res)); if (code != TSDB_CODE_SUCCESS) { @@ -1044,7 +1061,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM .pMsg = pRequest->msgBuf, .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, .pUser = pRequest->pTscObj->user, - .sysInfo = pRequest->pTscObj->sysInfo}; + .sysInfo = pRequest->pTscObj->sysInfo, + .allocatorId = pRequest->allocatorRefId}; SAppInstInfo* pAppInfo = getAppInfo(pRequest); SQueryPlan* pDag = NULL; @@ -1070,6 +1088,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM .pConn = &conn, .pNodeList = pNodeList, .pDag = pDag, + .allocatorRefId = pRequest->allocatorRefId, .sql = pRequest->sqlstr, .startTs = pRequest->metric.start, .execFp = schedulerExecCb, diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index d35d74b488..650b16f855 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -66,6 +66,7 @@ void taos_cleanup(void) { fmFuncMgtDestroy(); qCleanupKeywordsTable(); + nodesDestroyAllocatorSet(); id = clientConnRefPool; clientConnRefPool = -1; @@ -149,7 +150,7 @@ int taos_errno(TAOS_RES *res) { return terrno; } - if (TD_RES_TMQ(res)) { + if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { return 0; } @@ -163,7 +164,7 @@ const char *taos_errstr(TAOS_RES *res) { return (const char *)tstrerror(terrno); } - if (TD_RES_TMQ(res)) { + if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { return "success"; } @@ -185,7 +186,7 @@ void taos_free_result(TAOS_RES *res) { SRequestObj *pRequest = (SRequestObj *)res; tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId); destroyRequest(pRequest); - } else if (TD_RES_TMQ_TAOSX(res)) { + } else if (TD_RES_TMQ_METADATA(res)) { SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res; if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree); if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen); @@ -265,7 +266,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { return doFetchRows(pRequest, true, true); #endif - } else if (TD_RES_TMQ(res)) { + } else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { SMqRspObj *msg = ((SMqRspObj *)res); SReqResultInfo *pResultInfo; if (msg->resIter == -1) { @@ -438,7 +439,7 @@ const char *taos_data_type(int type) { const char *taos_get_client_info() { return version; } int taos_affected_rows(TAOS_RES *res) { - if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) { + if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) { return 0; } @@ -455,7 +456,7 @@ int taos_result_precision(TAOS_RES *res) { if (TD_RES_QUERY(res)) { SRequestObj *pRequest = (SRequestObj *)res; return pRequest->body.resInfo.precision; - } else if (TD_RES_TMQ(res)) { + } else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { SReqResultInfo *info = tmqGetCurResInfo(res); return info->precision; } @@ -488,7 +489,7 @@ int taos_select_db(TAOS *taos, const char *db) { } void taos_stop_query(TAOS_RES *res) { - if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) { + if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) { return; } @@ -560,7 +561,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) { (*rows) = pResultInfo->row; (*numOfRows) = pResultInfo->numOfRows; return pRequest->code; - } else if (TD_RES_TMQ(res)) { + } else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, true); if (pResultInfo == NULL) return -1; @@ -579,7 +580,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { return 0; } - if (TD_RES_TMQ(res)) { + if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, false); if (pResultInfo == NULL) { (*numOfRows) = 0; @@ -670,7 +671,6 @@ typedef struct SqlParseWrapper { SParseContext *pCtx; SCatalogReq catalogReq; SRequestObj *pRequest; - SQuery *pQuery; } SqlParseWrapper; static void destoryTablesReq(void *p) { @@ -696,8 +696,8 @@ static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) { void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { SqlParseWrapper *pWrapper = (SqlParseWrapper *)param; - SQuery *pQuery = pWrapper->pQuery; SRequestObj *pRequest = pWrapper->pRequest; + SQuery *pQuery = pRequest->pQuery; pRequest->metric.ctgEnd = taosGetTimestampUs(); @@ -726,10 +726,10 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { tscDebug("0x%" PRIx64 " analysis semantics completed, start async query, reqId:0x%" PRIx64, pRequest->self, pRequest->requestId); launchAsyncQuery(pRequest, pQuery, pResultMeta); - qDestroyQuery(pQuery); } else { destorySqlParseWrapper(pWrapper); - qDestroyQuery(pQuery); + qDestroyQuery(pRequest->pQuery); + pRequest->pQuery = NULL; if (NEED_CLIENT_HANDLE_ERROR(code)) { tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); @@ -776,7 +776,8 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt) { .enableSysInfo = pTscObj->sysInfo, .async = true, .svrVer = pTscObj->sVer, - .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes)}; + .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes), + .allocatorId = pRequest->allocatorRefId}; return TSDB_CODE_SUCCESS; } @@ -801,12 +802,10 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { goto _error; } - SQuery *pQuery = NULL; - pRequest->metric.syntaxStart = taosGetTimestampUs(); SCatalogReq catalogReq = {.forceUpdate = updateMetaForce, .qNodeRequired = qnodeRequired(pRequest)}; - code = qParseSqlSyntax(pCxt, &pQuery, &catalogReq); + code = qParseSqlSyntax(pCxt, &pRequest->pQuery, &catalogReq); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -816,9 +815,9 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { if (!updateMetaForce) { STscObj *pTscObj = pRequest->pTscObj; SAppClusterSummary *pActivity = &pTscObj->pAppInfo->summary; - if (NULL == pQuery->pRoot) { + if (NULL == pRequest->pQuery->pRoot) { atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1); - } else if (QUERY_NODE_SELECT_STMT == pQuery->pRoot->type) { + } else if (QUERY_NODE_SELECT_STMT == pRequest->pQuery->pRoot->type) { atomic_add_fetch_64((int64_t *)&pActivity->numOfQueryReq, 1); } } @@ -830,7 +829,6 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { } pWrapper->pCtx = pCxt; - pWrapper->pQuery = pQuery; pWrapper->pRequest = pRequest; pWrapper->catalogReq = catalogReq; diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index a7a16d484c..cdf977bea3 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -34,6 +34,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { removeMeta(pRequest->pTscObj, pRequest->targetTableList); } + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); if (pRequest->body.queryFp != NULL) { pRequest->body.queryFp(pRequest->body.param, pRequest, code); @@ -46,6 +47,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); setErrno(pRequest, code); tsem_post(&pRequest->body.rspSem); @@ -62,6 +64,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { if (delta > timestampDeltaLimit) { code = TSDB_CODE_TIME_UNSYNCED; tscError("time diff:%ds is too big", delta); + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); setErrno(pRequest, code); tsem_post(&pRequest->body.rspSem); @@ -70,6 +73,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { /*assert(connectRsp.epSet.numOfEps > 0);*/ if (connectRsp.epSet.numOfEps == 0) { + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); setErrno(pRequest, TSDB_CODE_MND_APP_ERROR); tsem_post(&pRequest->body.rspSem); @@ -114,6 +118,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { pTscObj->pAppInfo->numOfConns); taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); tsem_post(&pRequest->body.rspSem); return 0; } @@ -137,6 +142,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) { // todo rsp with the vnode id list SRequestObj* pRequest = param; taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); } @@ -173,6 +179,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); setErrno(pRequest, code); if (pRequest->body.queryFp != NULL) { @@ -220,6 +227,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { setConnectionDB(pRequest->pTscObj, db); taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { pRequest->body.queryFp(pRequest->body.param, pRequest, pRequest->code); @@ -237,7 +245,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); } else { SMCreateStbRsp createRsp = {0}; - SDecoder coder = {0}; + SDecoder coder = {0}; tDecoderInit(&coder, pMsg->pData, pMsg->len); tDecodeSMCreateStbRsp(&coder, &createRsp); tDecoderClear(&coder); @@ -246,6 +254,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { pRequest->body.resInfo.execRes.res = createRsp.pMeta; } + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); if (pRequest->body.queryFp != NULL) { @@ -262,7 +271,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { code = ret; } } - + pRequest->body.queryFp(pRequest->body.param, pRequest, code); } else { tsem_post(&pRequest->body.rspSem); @@ -284,6 +293,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) { } taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { pRequest->body.queryFp(pRequest->body.param, pRequest, code); @@ -309,6 +319,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) { } taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { SExecResult* pRes = &pRequest->body.resInfo.execRes; @@ -420,6 +431,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { } taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { pRequest->body.queryFp(pRequest->body.param, pRequest, code); diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index c135965f07..eb7b45cc05 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -30,7 +30,7 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch char* string = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { - return string; + return NULL; } cJSON* type = cJSON_CreateString("create"); cJSON_AddItemToObject(json, "type", type); @@ -39,10 +39,10 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch // sprintf(uid, "%"PRIi64, id); // cJSON* id_ = cJSON_CreateString(uid); // cJSON_AddItemToObject(json, "id", id_); - cJSON* tableName = cJSON_CreateString(name); - cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString(t == TSDB_NORMAL_TABLE ? "normal" : "super"); cJSON_AddItemToObject(json, "tableType", tableType); + cJSON* tableName = cJSON_CreateString(name); + cJSON_AddItemToObject(json, "tableName", tableName); // cJSON* version = cJSON_CreateNumber(1); // cJSON_AddItemToObject(json, "version", version); @@ -112,10 +112,10 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { // cJSON_AddItemToObject(json, "uid", uid); SName name = {0}; tNameFromString(&name, req.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - cJSON* tableName = cJSON_CreateString(name.tname); - cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString("super"); cJSON_AddItemToObject(json, "tableType", tableType); + cJSON* tableName = cJSON_CreateString(name.tname); + cJSON_AddItemToObject(json, "tableName", tableName); cJSON* alterType = cJSON_CreateNumber(req.alterType); cJSON_AddItemToObject(json, "alterType", alterType); @@ -199,8 +199,6 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE); - tDecoderClear(&coder); - return string; _err: tDecoderClear(&coder); @@ -221,32 +219,22 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen); - tDecoderClear(&coder); - return string; _err: tDecoderClear(&coder); return string; } -static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* tagName, int64_t id, uint8_t tagNum) { - char* string = NULL; - SArray* pTagVals = NULL; - cJSON* json = cJSON_CreateObject(); - if (json == NULL) { - return string; - } - cJSON* type = cJSON_CreateString("create"); - cJSON_AddItemToObject(json, "type", type); - // char cid[32] = {0}; - // sprintf(cid, "%"PRIi64, id); - // cJSON* cid_ = cJSON_CreateString(cid); - // cJSON_AddItemToObject(json, "id", cid_); +static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq){ + STag* pTag = (STag*)pCreateReq->ctb.pTag; + char* sname = pCreateReq->ctb.name; + char* name = pCreateReq->name; + SArray* tagName = pCreateReq->ctb.tagName; + int64_t id = pCreateReq->uid; + uint8_t tagNum = pCreateReq->ctb.tagNum; cJSON* tableName = cJSON_CreateString(name); cJSON_AddItemToObject(json, "tableName", tableName); - cJSON* tableType = cJSON_CreateString("child"); - cJSON_AddItemToObject(json, "tableType", tableType); cJSON* using = cJSON_CreateString(sname); cJSON_AddItemToObject(json, "using", using); cJSON* tagNumJson = cJSON_CreateNumber(tagNum); @@ -255,6 +243,7 @@ static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* // cJSON_AddItemToObject(json, "version", version); cJSON* tags = cJSON_CreateArray(); + SArray* pTagVals = NULL; int32_t code = tTagToValArray(pTag, &pTagVals); if (code) { goto end; @@ -313,11 +302,37 @@ static char* buildCreateCTableJson(STag* pTag, char* sname, char* name, SArray* cJSON_AddItemToArray(tags, tag); } -end: + end: cJSON_AddItemToObject(json, "tags", tags); + taosArrayDestroy(pTagVals); +} + +static char* buildCreateCTableJson(SVCreateTbReq* pCreateReq, int32_t nReqs) { + char* string = NULL; + cJSON* json = cJSON_CreateObject(); + if (json == NULL) { + return NULL; + } + cJSON* type = cJSON_CreateString("create"); + cJSON_AddItemToObject(json, "type", type); + // char cid[32] = {0}; + // sprintf(cid, "%"PRIi64, id); + // cJSON* cid_ = cJSON_CreateString(cid); + // cJSON_AddItemToObject(json, "id", cid_); + + cJSON* tableType = cJSON_CreateString("child"); + cJSON_AddItemToObject(json, "tableType", tableType); + + buildChildElement(json, pCreateReq); + cJSON* createList = cJSON_CreateArray(); + for(int i = 0; nReqs > 1 && i < nReqs; i++){ + cJSON* create = cJSON_CreateObject(); + buildChildElement(create, pCreateReq + i); + cJSON_AddItemToArray(createList, create); + } + cJSON_AddItemToObject(json, "createList", createList); string = cJSON_PrintUnformatted(json); cJSON_Delete(json); - taosArrayDestroy(pTagVals); return string; } @@ -335,21 +350,58 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { } // loop to create table - for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { - pCreateReq = req.pReqs + iReq; + if (req.nReqs > 0) { + pCreateReq = req.pReqs; if (pCreateReq->type == TSDB_CHILD_TABLE) { - string = buildCreateCTableJson((STag*)pCreateReq->ctb.pTag, pCreateReq->ctb.name, pCreateReq->name, - pCreateReq->ctb.tagName, pCreateReq->uid, pCreateReq->ctb.tagNum); + string = buildCreateCTableJson(req.pReqs, req.nReqs); } else if (pCreateReq->type == TSDB_NORMAL_TABLE) { - string = - buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); + string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } } +_exit: + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosMemoryFreeClear(pCreateReq->comment); + if (pCreateReq->type == TSDB_CHILD_TABLE) { + taosArrayDestroy(pCreateReq->ctb.tagName); + } + } tDecoderClear(&decoder); + return string; +} + +static char* processAutoCreateTable(STaosxRsp* rsp) { + ASSERT(rsp->createTableNum != 0); + + SDecoder* decoder = taosMemoryCalloc(rsp->createTableNum, sizeof(SDecoder)); + SVCreateTbReq* pCreateReq = taosMemoryCalloc(rsp->createTableNum, sizeof(SVCreateTbReq)); + char* string = NULL; + + // loop to create table + for (int32_t iReq = 0; iReq < rsp->createTableNum; iReq++) { + // decode + void** data = taosArrayGet(rsp->createTableReq, iReq); + int32_t *len = taosArrayGet(rsp->createTableLen, iReq); + tDecoderInit(&decoder[iReq], *data, *len); + if (tDecodeSVCreateTbReq(&decoder[iReq], pCreateReq + iReq) < 0) { + goto _exit; + } + + ASSERT(pCreateReq[iReq].type == TSDB_CHILD_TABLE); + } + string = buildCreateCTableJson(pCreateReq, rsp->createTableNum); _exit: - tDecoderClear(&decoder); + for(int i = 0; i < rsp->createTableNum; i++){ + tDecoderClear(&decoder[i]); + taosMemoryFreeClear(pCreateReq[i].comment); + if (pCreateReq[i].type == TSDB_CHILD_TABLE) { + taosArrayDestroy(pCreateReq[i].ctb.tagName); + } + } + taosMemoryFree(decoder); + taosMemoryFree(pCreateReq); return string; } @@ -374,10 +426,10 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "type", type); // cJSON* uid = cJSON_CreateNumber(id); // cJSON_AddItemToObject(json, "uid", uid); - cJSON* tableName = cJSON_CreateString(vAlterTbReq.tbName); - cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString(vAlterTbReq.action == TSDB_ALTER_TABLE_UPDATE_TAG_VAL ? "child" : "normal"); cJSON_AddItemToObject(json, "tableType", tableType); + cJSON* tableName = cJSON_CreateString(vAlterTbReq.tbName); + cJSON_AddItemToObject(json, "tableName", tableName); cJSON* alterType = cJSON_CreateNumber(vAlterTbReq.action); cJSON_AddItemToObject(json, "alterType", alterType); @@ -462,6 +514,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { string = cJSON_PrintUnformatted(json); _exit: + cJSON_Delete(json); tDecoderClear(&decoder); return string; } @@ -485,14 +538,15 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) { } cJSON* type = cJSON_CreateString("drop"); cJSON_AddItemToObject(json, "type", type); - cJSON* tableName = cJSON_CreateString(req.name); - cJSON_AddItemToObject(json, "tableName", tableName); cJSON* tableType = cJSON_CreateString("super"); cJSON_AddItemToObject(json, "tableType", tableType); + cJSON* tableName = cJSON_CreateString(req.name); + cJSON_AddItemToObject(json, "tableName", tableName); string = cJSON_PrintUnformatted(json); _exit: + cJSON_Delete(json); tDecoderClear(&decoder); return string; } @@ -533,6 +587,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) { string = cJSON_PrintUnformatted(json); _exit: + cJSON_Delete(json); tDecoderClear(&decoder); return string; } @@ -549,6 +604,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -637,6 +693,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -717,6 +774,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -830,6 +888,14 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { code = pRequest->code; end: + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosMemoryFreeClear(pCreateReq->comment); + if (pCreateReq->type == TSDB_CHILD_TABLE) { + taosArrayDestroy(pCreateReq->ctb.tagName); + } + } + taosHashCleanup(pVgroupHashmap); destroyRequest(pRequest); tDecoderClear(&coder); @@ -860,7 +926,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { if (code != TSDB_CODE_SUCCESS) { goto end; } - + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -1033,6 +1099,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -1152,6 +1219,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { uError("WriteRaw:not use db"); code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -1339,6 +1407,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { return terrno; } + pRequest->syncQuery = true; rspObj.resIter = -1; rspObj.resType = RES_TYPE__TMQ; @@ -1529,6 +1598,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { subReq->length += sizeof(SSubmitBlk) + schemaLen + totalLen; subReq->numOfBlocks++; taosMemoryFreeClear(pTableMeta); + rspObj.resInfo.pRspMsg = NULL; + doFreeReqResultInfo(&rspObj.resInfo); } pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); @@ -1578,6 +1649,313 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { code = pRequest->code; end: + tDeleteSMqDataRsp(&rspObj.rsp); + rspObj.resInfo.pRspMsg = NULL; + doFreeReqResultInfo(&rspObj.resInfo); + tDecoderClear(&decoder); + qDestroyQuery(pQuery); + destroyRequest(pRequest); + taosHashCleanup(pVgHash); + taosMemoryFreeClear(pTableMeta); + return code; +} + +static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) { + int32_t code = TSDB_CODE_SUCCESS; + SHashObj* pVgHash = NULL; + SQuery* pQuery = NULL; + SMqTaosxRspObj rspObj = {0}; + SDecoder decoder = {0}; + STableMeta* pTableMeta = NULL; + + terrno = TSDB_CODE_SUCCESS; + SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT); + if (!pRequest) { + uError("WriteRaw:createRequest error request is null"); + return terrno; + } + + pRequest->syncQuery = true; + rspObj.resIter = -1; + rspObj.resType = RES_TYPE__TMQ_METADATA; + + tDecoderInit(&decoder, data, dataLen); + code = tDecodeSTaosxRsp(&decoder, &rspObj.rsp); + if (code != 0) { + uError("WriteRaw:decode smqDataRsp error"); + code = TSDB_CODE_INVALID_MSG; + goto end; + } + + if (!pRequest->pDb) { + uError("WriteRaw:not use db"); + code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; + goto end; + } + + pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + taosHashSetFreeFp(pVgHash, destroyVgHash); + struct SCatalog* pCatalog = NULL; + code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw: get gatlog error"); + goto end; + } + + SRequestConnInfo conn = {0}; + conn.pTrans = pRequest->pTscObj->pAppInfo->pTransporter; + conn.requestId = pRequest->requestId; + conn.requestObjRefId = pRequest->self; + conn.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp); + + printf("raw data block num:%d\n", rspObj.rsp.blockNum); + while (++rspObj.resIter < rspObj.rsp.blockNum) { + SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); + if (!rspObj.rsp.withSchema) { + uError("WriteRaw:no schema, iter:%d", rspObj.resIter); + goto end; + } + SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter); + setResSchemaInfo(&rspObj.resInfo, pSW->pSchema, pSW->nCols); + + code = setQueryResultFromRsp(&rspObj.resInfo, pRetrieve, false, false); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw: setQueryResultFromRsp error"); + goto end; + } + + const char* tbName = (const char*)taosArrayGetP(rspObj.rsp.blockTbName, rspObj.resIter); + if (!tbName) { + uError("WriteRaw: tbname is null"); + code = TSDB_CODE_TMQ_INVALID_MSG; + goto end; + } + + printf("raw data tbname:%s\n", tbName); + SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; + strcpy(pName.dbname, pRequest->pDb); + strcpy(pName.tname, tbName); + + VgData vgData = {0}; + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &(vgData.vg)); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName); + goto end; + } + + // find schema data info + int32_t schemaLen = 0; + void* schemaData = NULL; + for(int j = 0; j < rspObj.rsp.createTableNum; j++){ + void** dataTmp = taosArrayGet(rspObj.rsp.createTableReq, j); + int32_t* lenTmp = taosArrayGet(rspObj.rsp.createTableLen, j); + + SDecoder decoderTmp = {0}; + SVCreateTbReq pCreateReq = {0}; + + tDecoderInit(&decoderTmp, *dataTmp, *lenTmp); + if (tDecodeSVCreateTbReq(&decoderTmp, &pCreateReq) < 0) { + tDecoderClear(&decoderTmp); + taosMemoryFreeClear(pCreateReq.comment); + taosArrayDestroy(pCreateReq.ctb.tagName); + goto end; + } + + ASSERT (pCreateReq.type == TSDB_CHILD_TABLE); + if(strcmp(tbName, pCreateReq.name) == 0){ + schemaLen = *lenTmp; + schemaData = *dataTmp; + strcpy(pName.tname, pCreateReq.ctb.name); + tDecoderClear(&decoderTmp); + taosMemoryFreeClear(pCreateReq.comment); + taosArrayDestroy(pCreateReq.ctb.tagName); + break; + } + tDecoderClear(&decoderTmp); + taosMemoryFreeClear(pCreateReq.comment); + taosArrayDestroy(pCreateReq.ctb.tagName); + } + + code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); + code = TSDB_CODE_SUCCESS; + continue; + } + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbName); + goto end; + } + + uint16_t fLen = 0; + int32_t rowSize = 0; + int16_t nVar = 0; + for (int i = 0; i < pTableMeta->tableInfo.numOfColumns; i++) { + SSchema* schema = &pTableMeta->schema[i]; + fLen += TYPE_BYTES[schema->type]; + rowSize += schema->bytes; + if (IS_VAR_DATA_TYPE(schema->type)) { + nVar++; + } + } + + int32_t rows = rspObj.resInfo.numOfRows; + int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) + + (int32_t)TD_BITMAP_BYTES(pTableMeta->tableInfo.numOfColumns - 1); + + int32_t submitLen = sizeof(SSubmitBlk) + schemaLen + rows * extendedRowSize; + + SSubmitReq* subReq = NULL; + SSubmitBlk* blk = NULL; + void* hData = taosHashGet(pVgHash, &vgData.vg.vgId, sizeof(vgData.vg.vgId)); + if (hData) { + vgData = *(VgData*)hData; + + int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen; + void* tmp = taosMemoryRealloc(vgData.data, totalLen); + if (tmp == NULL) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto end; + } + vgData.data = tmp; + ((VgData*)hData)->data = tmp; + subReq = (SSubmitReq*)(vgData.data); + blk = POINTER_SHIFT(vgData.data, subReq->length); + } else { + int32_t totalLen = sizeof(SSubmitReq) + submitLen; + void* tmp = taosMemoryCalloc(1, totalLen); + if (tmp == NULL) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto end; + } + vgData.data = tmp; + taosHashPut(pVgHash, (const char*)&vgData.vg.vgId, sizeof(vgData.vg.vgId), (char*)&vgData, sizeof(vgData)); + subReq = (SSubmitReq*)(vgData.data); + subReq->length = sizeof(SSubmitReq); + subReq->numOfBlocks = 0; + + blk = POINTER_SHIFT(vgData.data, sizeof(SSubmitReq)); + } + + // pSW->pSchema should be same as pTableMeta->schema + // ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns); + uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid); + uint64_t uid = pTableMeta->uid; + int16_t sver = pTableMeta->sversion; + + void* blkSchema = POINTER_SHIFT(blk, sizeof(SSubmitBlk)); + if(schemaData){ + memcpy(blkSchema, schemaData, schemaLen); + } + STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen); + + SRowBuilder rb = {0}; + tdSRowInit(&rb, sver); + tdSRowSetTpInfo(&rb, pTableMeta->tableInfo.numOfColumns, fLen); + int32_t totalLen = 0; + + SHashObj* schemaHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + for (int i = 0; i < pSW->nCols; i++) { + SSchema* schema = &pSW->pSchema[i]; + taosHashPut(schemaHash, schema->name, strlen(schema->name), &i, sizeof(int32_t)); + } + + for (int32_t j = 0; j < rows; j++) { + tdSRowResetBuf(&rb, rowData); + + doSetOneRowPtr(&rspObj.resInfo); + rspObj.resInfo.current += 1; + + int32_t offset = 0; + for (int32_t k = 0; k < pTableMeta->tableInfo.numOfColumns; k++) { + const SSchema* pColumn = &pTableMeta->schema[k]; + int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name)); + if (!index) { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); + } else { + char* colData = rspObj.resInfo.row[*index]; + if (!colData) { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); + } else { + if (IS_VAR_DATA_TYPE(pColumn->type)) { + colData -= VARSTR_HEADER_SIZE; + } + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, offset, k); + } + } + + offset += TYPE_BYTES[pColumn->type]; + } + tdSRowEnd(&rb); + int32_t rowLen = TD_ROW_LEN(rowData); + rowData = POINTER_SHIFT(rowData, rowLen); + totalLen += rowLen; + } + + taosHashCleanup(schemaHash); + blk->uid = htobe64(uid); + blk->suid = htobe64(suid); + blk->sversion = htonl(sver); + blk->schemaLen = htonl(schemaLen); + blk->numOfRows = htonl(rows); + blk->dataLen = htonl(totalLen); + subReq->length += sizeof(SSubmitBlk) + schemaLen + totalLen; + subReq->numOfBlocks++; + taosMemoryFreeClear(pTableMeta); + rspObj.resInfo.pRspMsg = NULL; + doFreeReqResultInfo(&rspObj.resInfo); + } + + pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY); + if (NULL == pQuery) { + uError("create SQuery error"); + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE; + pQuery->haveResultSet = false; + pQuery->msgType = TDMT_VND_SUBMIT; + pQuery->pRoot = (SNode*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT); + if (NULL == pQuery->pRoot) { + uError("create pQuery->pRoot error"); + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + SVnodeModifOpStmt* nodeStmt = (SVnodeModifOpStmt*)(pQuery->pRoot); + nodeStmt->payloadType = PAYLOAD_TYPE_KV; + + int32_t numOfVg = taosHashGetSize(pVgHash); + nodeStmt->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); + + VgData* vData = (VgData*)taosHashIterate(pVgHash, NULL); + while (vData) { + SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); + if (NULL == dst) { + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + goto end; + } + dst->vg = vData->vg; + SSubmitReq* subReq = (SSubmitReq*)(vData->data); + dst->numOfTables = subReq->numOfBlocks; + dst->size = subReq->length; + dst->pData = (char*)subReq; + vData->data = NULL; // no need free + subReq->header.vgId = htonl(dst->vg.vgId); + subReq->version = htonl(1); + subReq->header.contLen = htonl(subReq->length); + subReq->length = htonl(subReq->length); + subReq->numOfBlocks = htonl(subReq->numOfBlocks); + taosArrayPush(nodeStmt->pDataBlocks, &dst); + vData = (VgData*)taosHashIterate(pVgHash, vData); + } + + launchQueryImpl(pRequest, pQuery, true, NULL); + code = pRequest->code; + + end: + tDeleteSTaosxRsp(&rspObj.rsp); + rspObj.resInfo.pRspMsg = NULL; + doFreeReqResultInfo(&rspObj.resInfo); tDecoderClear(&decoder); qDestroyQuery(pQuery); destroyRequest(pRequest); @@ -1587,10 +1965,15 @@ end: } char* tmq_get_json_meta(TAOS_RES* res) { - if (!TD_RES_TMQ_META(res)) { + if (!TD_RES_TMQ_META(res) && !TD_RES_TMQ_METADATA(res)) { return NULL; } + if(TD_RES_TMQ_METADATA(res)){ + SMqTaosxRspObj* pMetaDataRspObj = (SMqTaosxRspObj*)res; + return processAutoCreateTable(&pMetaDataRspObj->rsp); + } + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_CREATE_STB) { return processCreateStb(&pMetaRspObj->metaRsp); @@ -1638,6 +2021,25 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = buf; raw->raw_len = len; raw->raw_type = RES_TYPE__TMQ; + } else if (TD_RES_TMQ_METADATA(res)) { + SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res); + + int32_t len = 0; + int32_t code = 0; + tEncodeSize(tEncodeSTaosxRsp, &rspObj->rsp, len, code); + if (code < 0) { + return -1; + } + + void* buf = taosMemoryCalloc(1, len); + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, len); + tEncodeSTaosxRsp(&encoder, &rspObj->rsp); + tEncoderClear(&encoder); + + raw->raw = buf; + raw->raw_len = len; + raw->raw_type = RES_TYPE__TMQ_METADATA; } else { return TSDB_CODE_TMQ_INVALID_MSG; } @@ -1645,7 +2047,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { } void tmq_free_raw(tmq_raw_data raw) { - if (raw.raw_type == RES_TYPE__TMQ) { + if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) { taosMemoryFree(raw.raw); } } @@ -1671,6 +2073,8 @@ int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) { return taosDeleteData(taos, raw.raw, raw.raw_len); } else if (raw.raw_type == RES_TYPE__TMQ) { return tmqWriteRawDataImpl(taos, raw.raw, raw.raw_len); + } else if (raw.raw_type == RES_TYPE__TMQ_METADATA) { + return tmqWriteRawMetaDataImpl(taos, raw.raw, raw.raw_len); } return TSDB_CODE_INVALID_PARA; } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 9f9a14952e..c9c02a77e1 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -515,6 +515,10 @@ int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_comm SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; topic = pMetaRspObj->topic; vgId = pMetaRspObj->vgId; + } else if(TD_RES_TMQ_METADATA(msg)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)msg; + topic = pRspObj->topic; + vgId = pRspObj->vgId; } else { return TSDB_CODE_TMQ_INVALID_MSG; } @@ -841,7 +845,7 @@ void tmqFreeImpl(void* handle) { int32_t sz = taosArrayGetSize(tmq->clientTopics); for (int32_t i = 0; i < sz; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (pTopic->schema.nCols) taosMemoryFree(pTopic->schema.pSchema); + if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema); int32_t vgSz = taosArrayGetSize(pTopic->vgs); taosArrayDestroy(pTopic->vgs); } @@ -1077,6 +1081,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tsem_destroy(&pParam->rspSem); taosMemoryFree(pParam); taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; return -1; } @@ -1115,6 +1120,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tmqEpoch); tsem_post(&tmq->rspSem); taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); return 0; } @@ -1128,6 +1134,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM); if (pRspWrapper == NULL) { taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); tscWarn("msg discard from vgId:%d, epoch %d since out of memory", vgId, epoch); goto CREATE_MSG_FAIL; } @@ -1164,6 +1171,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { } taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); @@ -1218,6 +1226,8 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { SMqClientTopic topic = {0}; SMqSubTopicEp* pTopicEp = taosArrayGet(pRsp->topics, i); topic.schema = pTopicEp->schema; + pTopicEp->schema.nCols = 0; + pTopicEp->schema.pSchema = NULL; tstrncpy(topic.topicName, pTopicEp->topic, TSDB_TOPIC_FNAME_LEN); tstrncpy(topic.db, pTopicEp->db, TSDB_DB_FNAME_LEN); @@ -1251,7 +1261,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { int32_t sz = taosArrayGetSize(tmq->clientTopics); for (int32_t i = 0; i < sz; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (pTopic->schema.nCols) taosMemoryFree(pTopic->schema.pSchema); + if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema); int32_t vgSz = taosArrayGetSize(pTopic->vgs); taosArrayDestroy(pTopic->vgs); } @@ -1465,16 +1475,16 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper) { SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj)); - pRspObj->resType = RES_TYPE__TAOSX; + pRspObj->resType = RES_TYPE__TMQ_METADATA; tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN); tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN); pRspObj->vgId = pWrapper->vgHandle->vgId; pRspObj->resIter = -1; - memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqTaosxRspObj)); + memcpy(&pRspObj->rsp, &pWrapper->taosxRsp, sizeof(STaosxRsp)); pRspObj->resInfo.totalRows = 0; pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI; - if (!pWrapper->dataRsp.withSchema) { + if (!pWrapper->taosxRsp.withSchema) { setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols); } @@ -1648,8 +1658,14 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { rspWrapper = NULL; continue; } + // build rsp - SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper); + void* pRsp = NULL; + if(pollRspWrapper->taosxRsp.createTableNum == 0){ + pRsp = tmqBuildRspFromWrapper(pollRspWrapper); + }else{ + pRsp = tmqBuildTaosxRspFromWrapper(pollRspWrapper); + } taosFreeQitem(pollRspWrapper); return pRsp; } else { @@ -1769,11 +1785,11 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) { } else if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) { - return TMQ_RES_TAOSX; + return TMQ_RES_DATA; } return TMQ_RES_TABLE_META; - } else if (TD_RES_TMQ_TAOSX(res)) { - return TMQ_RES_DATA; + } else if (TD_RES_TMQ_METADATA(res)) { + return TMQ_RES_METADATA; } else { return TMQ_RES_INVALID; } @@ -1786,6 +1802,9 @@ const char* tmq_get_topic_name(TAOS_RES* res) { } else if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; return strchr(pMetaRspObj->topic, '.') + 1; + } else if (TD_RES_TMQ_METADATA(res)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; + return strchr(pRspObj->topic, '.') + 1; } else { return NULL; } @@ -1798,6 +1817,9 @@ const char* tmq_get_db_name(TAOS_RES* res) { } else if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; return strchr(pMetaRspObj->db, '.') + 1; + } else if (TD_RES_TMQ_METADATA(res)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; + return strchr(pRspObj->db, '.') + 1; } else { return NULL; } @@ -1810,6 +1832,9 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) { } else if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; return pMetaRspObj->vgId; + } else if (TD_RES_TMQ_METADATA(res)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; + return pRspObj->vgId; } else { return -1; } @@ -1823,7 +1848,14 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); - } + } else if (TD_RES_TMQ_METADATA(res)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; + if (!pRspObj->rsp.withTbName || pRspObj->rsp.blockTbName == NULL || pRspObj->resIter < 0 || + pRspObj->resIter >= pRspObj->rsp.blockNum) { + return NULL; + } + return (const char*)taosArrayGetP(pRspObj->rsp.blockTbName, pRspObj->resIter); + } return NULL; } diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 496806d877..a45f7b2913 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -227,8 +227,9 @@ static const SSysDbTableSchema transSchema[] = { {.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, - {.name = "db1", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, - {.name = "db2", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "oper", .bytes = TSDB_TRANS_OPER_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "stable", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "failed_times", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "last_action_info", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 16b8e55cf7..23cc868658 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1278,7 +1278,9 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) { colDataAssign(pDst, pSrc, src->info.rows, &src->info); } + uint32_t cap = dst->info.capacity; dst->info = src->info; + dst->info.capacity = cap; return 0; } @@ -1302,8 +1304,9 @@ int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src) { colDataAssign(pDst, pSrc, src->info.rows, &src->info); } - + uint32_t cap = dst->info.capacity; dst->info = src->info; + dst->info.capacity = cap; return TSDB_CODE_SUCCESS; } @@ -1333,6 +1336,8 @@ SSDataBlock* createSpecialDataBlock(EStreamType type) { // group id taosArrayPush(pBlock->pDataBlock, &infoData); + infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP; + infoData.info.bytes = sizeof(TSKEY); // calculate start ts taosArrayPush(pBlock->pDataBlock, &infoData); // calculate end ts @@ -1446,6 +1451,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { int32_t payloadSize = pageSize - blockDataGetSerialMetaSize(numOfCols); int32_t rowSize = pBlock->info.rowSize; int32_t nRows = payloadSize / rowSize; + ASSERT(nRows >= 1); // the true value must be less than the value of nRows int32_t additional = 0; @@ -2279,4 +2285,3 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) { ASSERT(pStart - pData == dataLen); return pStart; } - diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 562364d544..e2e59108aa 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -58,7 +58,7 @@ int32_t tsNumOfMnodeFetchThreads = 1; int32_t tsNumOfMnodeReadThreads = 1; int32_t tsNumOfVnodeQueryThreads = 4; int32_t tsNumOfVnodeStreamThreads = 2; -int32_t tsNumOfVnodeFetchThreads = 4; +int32_t tsNumOfVnodeFetchThreads = 1; int32_t tsNumOfVnodeWriteThreads = 2; int32_t tsNumOfVnodeSyncThreads = 2; int32_t tsNumOfVnodeRsmaThreads = 2; @@ -91,7 +91,10 @@ bool tsSmlDataFormat = // query int32_t tsQueryPolicy = 1; int32_t tsQuerySmaOptimize = 0; +int32_t tsQueryRsmaTolerance = 1000; // the tolerance time (ms) to judge from which level to query rsma data. bool tsQueryPlannerTrace = false; +int32_t tsQueryNodeChunkSize = 32 * 1024; +bool tsQueryUseNodeAllocator = true; /* * denote if the server needs to compress response message at the application layer to client, including query rsp, @@ -162,7 +165,8 @@ int32_t tsMqRebalanceInterval = 2; int32_t tsTtlUnit = 86400; int32_t tsTtlPushInterval = 86400; int32_t tsGrantHBInterval = 60; -int32_t tsUptimeInterval = 300; // seconds +int32_t tsUptimeInterval = 300; // seconds +char tsUdfdResFuncs[1024] = ""; // udfd resident funcs that teardown when udfd exits #ifndef _STORAGE int32_t taosSetTfsCfg(SConfig *pCfg) { @@ -284,6 +288,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, 1) != 0) return -1; if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1; if (cfgAddBool(pCfg, "queryPlannerTrace", tsQueryPlannerTrace, true) != 0) return -1; + if (cfgAddInt32(pCfg, "queryNodeChunkSize", tsQueryNodeChunkSize, 1024, 128 * 1024, true) != 0) return -1; + if (cfgAddBool(pCfg, "queryUseNodeAllocator", tsQueryUseNodeAllocator, true) != 0) return -1; if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1; if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; @@ -365,9 +371,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4); if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1; - tsNumOfVnodeFetchThreads = tsNumOfCores / 4; - tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4); - if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 4, 1024, 0) != 0) return -1; + tsNumOfVnodeFetchThreads = 1; + if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1024, 0) != 0) return -1; tsNumOfVnodeWriteThreads = tsNumOfCores; tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1); @@ -385,9 +390,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4); if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1; -// tsNumOfQnodeFetchThreads = tsNumOfCores / 2; -// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); -// if (cfgAddInt32(pCfg, "numOfQnodeFetchThreads", tsNumOfQnodeFetchThreads, 1, 1024, 0) != 0) return -1; + // tsNumOfQnodeFetchThreads = tsNumOfCores / 2; + // tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); + // if (cfgAddInt32(pCfg, "numOfQnodeFetchThreads", tsNumOfQnodeFetchThreads, 1, 1024, 0) != 0) return -1; tsNumOfSnodeSharedThreads = tsNumOfCores / 4; tsNumOfSnodeSharedThreads = TRANGE(tsNumOfSnodeSharedThreads, 2, 4); @@ -419,8 +424,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, 1) != 0) return -1; if (cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushInterval, 1, 100000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "uptimeInterval", tsUptimeInterval, 1, 100000, 1) != 0) return -1; + if (cfgAddInt32(pCfg, "queryRsmaTolerance", tsQueryRsmaTolerance, 0, 900000, 0) != 0) return -1; if (cfgAddBool(pCfg, "udf", tsStartUdfd, 0) != 0) return -1; + if (cfgAddString(pCfg, "udfdResFuncs", tsUdfdResFuncs, 0) != 0) return -1; GRANT_CFG_ADD; return 0; } @@ -527,15 +534,15 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } -/* - pItem = cfgGetItem(tsCfg, "numOfQnodeFetchThreads"); - if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { - tsNumOfQnodeFetchThreads = numOfCores / 2; - tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); - pItem->i32 = tsNumOfQnodeFetchThreads; - pItem->stype = stype; - } -*/ + /* + pItem = cfgGetItem(tsCfg, "numOfQnodeFetchThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfQnodeFetchThreads = numOfCores / 2; + tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); + pItem->i32 = tsNumOfQnodeFetchThreads; + pItem->stype = stype; + } + */ pItem = cfgGetItem(tsCfg, "numOfSnodeSharedThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { @@ -643,6 +650,8 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; + tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32; + tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval; return 0; } @@ -693,7 +702,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32; tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32; tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32; -// tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32; + // tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32; tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32; tsNumOfSnodeUniqueThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; @@ -715,8 +724,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32; tsTtlPushInterval = cfgGetItem(pCfg, "ttlPushInterval")->i32; tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32; + tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32; tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; + tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs)); if (tsQueryBufferSize >= 0) { tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; @@ -941,10 +952,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32; } else if (strcasecmp("numOfQnodeQueryThreads", name) == 0) { tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32; -/* - } else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) { - tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32; -*/ + /* + } else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) { + tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32; + */ } else if (strcasecmp("numOfSnodeSharedThreads", name) == 0) { tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32; } else if (strcasecmp("numOfSnodeUniqueThreads", name) == 0) { @@ -976,6 +987,12 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32; } else if (strcasecmp("queryPlannerTrace", name) == 0) { tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; + } else if (strcasecmp("queryNodeChunkSize", name) == 0) { + tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32; + } else if (strcasecmp("queryUseNodeAllocator", name) == 0) { + tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval; + } else if (strcasecmp("queryRsmaTolerance", name) == 0) { + tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32; } break; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index bae43ae5c4..e4f3a89272 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -6031,12 +6031,18 @@ int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp) { void tDeleteSTaosxRsp(STaosxRsp *pRsp) { taosArrayDestroy(pRsp->blockDataLen); + pRsp->blockDataLen = NULL; taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); + pRsp->blockData = NULL; taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSSchemaWrapper); + pRsp->blockSchema = NULL; taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree); + pRsp->blockTbName = NULL; taosArrayDestroy(pRsp->createTableLen); + pRsp->createTableLen = NULL; taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree); + pRsp->createTableReq = NULL; } int32_t tEncodeSSingleDeleteReq(SEncoder *pEncoder, const SSingleDeleteReq *pReq) { diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h index ebbb9fa5d4..30f5483198 100644 --- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h +++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h @@ -74,6 +74,7 @@ typedef struct { TdThread thread; SVnodeMgmt *pMgmt; SWrapperCfg *pCfgs; + SVnodeObj **ppVnodes; } SVnodeThread; // vmInt.c diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 1f981cc9e0..f0c43d8b36 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -218,14 +218,14 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) { dInfo("start to close all vnodes"); int32_t numOfVnodes = 0; - SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); + SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); for (int32_t i = 0; i < numOfVnodes; ++i) { - vmCloseVnode(pMgmt, pVnodes[i]); + vmCloseVnode(pMgmt, ppVnodes[i]); } - if (pVnodes != NULL) { - taosMemoryFree(pVnodes); + if (ppVnodes != NULL) { + taosMemoryFree(ppVnodes); } if (pMgmt->hash != NULL) { @@ -331,22 +331,92 @@ static int32_t vmRequire(const SMgmtInputOpt *pInput, bool *required) { return 0; } -static int32_t vmStart(SVnodeMgmt *pMgmt) { - int32_t numOfVnodes = 0; - SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); +static void *vmRestoreVnodeInThread(void *param) { + SVnodeThread *pThread = param; + SVnodeMgmt *pMgmt = pThread->pMgmt; - for (int32_t i = 0; i < numOfVnodes; ++i) { - SVnodeObj *pVnode = pVnodes[i]; - vnodeStart(pVnode->pImpl); + dInfo("thread:%d, start to restore %d vnodes", pThread->threadIndex, pThread->vnodeNum); + setThreadName("restore-vnodes"); + + for (int32_t v = 0; v < pThread->vnodeNum; ++v) { + SVnodeObj *pVnode = pThread->ppVnodes[v]; + + char stepDesc[TSDB_STEP_DESC_LEN] = {0}; + snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to restore, %d of %d have been restored", pVnode->vgId, + pMgmt->state.openVnodes, pMgmt->state.totalVnodes); + tmsgReportStartup("vnode-restore", stepDesc); + + int32_t code = vnodeStart(pVnode->pImpl); + if (code != 0) { + dError("vgId:%d, failed to restore vnode by thread:%d", pVnode->vgId, pThread->threadIndex); + pThread->failed++; + } else { + dDebug("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); + pThread->opened++; + atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); + } } + dInfo("thread:%d, numOfVnodes:%d, restored:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, + pThread->failed); + return NULL; +} + +static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) { + int32_t numOfVnodes = 0; + SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); + + int32_t threadNum = tsNumOfCores / 2; + if (threadNum < 1) threadNum = 1; + int32_t vnodesPerThread = numOfVnodes / threadNum + 1; + + SVnodeThread *threads = taosMemoryCalloc(threadNum, sizeof(SVnodeThread)); + for (int32_t t = 0; t < threadNum; ++t) { + threads[t].threadIndex = t; + threads[t].pMgmt = pMgmt; + threads[t].ppVnodes = taosMemoryCalloc(vnodesPerThread, sizeof(SVnode *)); + } + + for (int32_t v = 0; v < numOfVnodes; ++v) { + int32_t t = v % threadNum; + SVnodeThread *pThread = &threads[t]; + pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v]; + } + + pMgmt->state.openVnodes = 0; + dInfo("restore %d vnodes with %d threads", numOfVnodes, threadNum); + + for (int32_t t = 0; t < threadNum; ++t) { + SVnodeThread *pThread = &threads[t]; + if (pThread->vnodeNum == 0) continue; + + TdThreadAttr thAttr; + taosThreadAttrInit(&thAttr); + taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + if (taosThreadCreate(&pThread->thread, &thAttr, vmRestoreVnodeInThread, pThread) != 0) { + dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(errno)); + } + + taosThreadAttrDestroy(&thAttr); + } + + for (int32_t t = 0; t < threadNum; ++t) { + SVnodeThread *pThread = &threads[t]; + if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) { + taosThreadJoin(pThread->thread, NULL); + taosThreadClear(&pThread->thread); + } + taosMemoryFree(pThread->ppVnodes); + } + taosMemoryFree(threads); + for (int32_t i = 0; i < numOfVnodes; ++i) { - SVnodeObj *pVnode = pVnodes[i]; + SVnodeObj *pVnode = ppVnodes[i]; vmReleaseVnode(pMgmt, pVnode); } - if (pVnodes != NULL) { - taosMemoryFree(pVnodes); + if (ppVnodes != NULL) { + taosMemoryFree(ppVnodes); } return 0; @@ -360,7 +430,7 @@ SMgmtFunc vmGetMgmtFunc() { SMgmtFunc mgmtFunc = {0}; mgmtFunc.openFp = vmInit; mgmtFunc.closeFp = (NodeCloseFp)vmCleanup; - mgmtFunc.startFp = (NodeStartFp)vmStart; + mgmtFunc.startFp = (NodeStartFp)vmStartVnodes; mgmtFunc.stopFp = (NodeStopFp)vmStop; mgmtFunc.requiredFp = vmRequire; mgmtFunc.getHandlesFp = vmGetMsgHandles; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index b91b82b72e..f57943b9dd 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -270,7 +270,7 @@ int32_t dmInitClient(SDnode *pDnode) { SRpcInit rpcInit = {0}; rpcInit.label = "DND-C"; - rpcInit.numOfThreads = 1; + rpcInit.numOfThreads = 4; rpcInit.cfp = (RpcCfp)dmProcessRpcMsg; rpcInit.sessions = 1024; rpcInit.connType = TAOS_CONN_CLIENT; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index cd08ee4ad5..c3d03a6c5e 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -165,12 +165,13 @@ typedef struct { SEpSet lastEpset; tmsg_t lastMsgType; tmsg_t originRpcType; - char dbname1[TSDB_TABLE_FNAME_LEN]; - char dbname2[TSDB_TABLE_FNAME_LEN]; + char dbname[TSDB_TABLE_FNAME_LEN]; + char stbname[TSDB_TABLE_FNAME_LEN]; int32_t startFunc; int32_t stopFunc; int32_t paramLen; void* param; + char opername[TSDB_TRANS_OPER_LEN]; SArray* pRpcArray; } STrans; @@ -540,7 +541,7 @@ typedef struct { } SMqConsumerEp; SMqConsumerEp* tCloneSMqConsumerEp(const SMqConsumerEp* pEp); -void tDeleteSMqConsumerEp(SMqConsumerEp* pEp); +void tDeleteSMqConsumerEp(void* pEp); int32_t tEncodeSMqConsumerEp(void** buf, const SMqConsumerEp* pEp); void* tDecodeSMqConsumerEp(const void* buf, SMqConsumerEp* pEp); diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index faf656a251..2372fa30e5 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -61,7 +61,8 @@ void mndCleanupTrans(SMnode *pMnode); STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId); void mndReleaseTrans(SMnode *pMnode, STrans *pTrans); -STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq); +STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq, + const char *opername); void mndTransDrop(STrans *pTrans); int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw); int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw); @@ -71,7 +72,7 @@ int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction); int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction); void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen); void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *param, int32_t paramLen); -void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2); +void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname); void mndTransSetSerial(STrans *pTrans); void mndTransSetOper(STrans *pTrans, EOperType oper); diff --git a/source/dnode/mnode/impl/src/mndAcct.c b/source/dnode/mnode/impl/src/mndAcct.c index 33f0bb7a34..e0713e1570 100644 --- a/source/dnode/mnode/impl/src/mndAcct.c +++ b/source/dnode/mnode/impl/src/mndAcct.c @@ -81,7 +81,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) { mDebug("acct:%s, will be created when deploying, raw:%p", acctObj.acct, pRaw); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-acct"); if (pTrans == NULL) { mError("acct:%s, failed to create since %s", acctObj.acct, terrstr()); return -1; diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index aafcd19992..6cabf6d57a 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -246,7 +246,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, bnodeObj.createdTime = taosGetTimestampMs(); bnodeObj.updateTime = bnodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-bnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create bnode:%d", pTrans->id, pCreate->dnodeId); @@ -354,7 +354,7 @@ static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBn static int32_t mndDropBnode(SMnode *pMnode, SRpcMsg *pReq, SBnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-bnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop bnode:%d", pTrans->id, pObj->id); diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index 7d633f90bd..5ba39b4f1a 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -235,7 +235,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) { mDebug("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-cluster"); if (pTrans == NULL) { mError("cluster:%" PRId64 ", failed to create since %s", clusterObj.id, terrstr()); return -1; @@ -316,7 +316,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) { } mTrace("update cluster uptime to %" PRId64, clusterObj.upTime); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "update-uptime"); if (pTrans == NULL) return -1; SSdbRaw *pCommitRaw = mndClusterActionEncode(&clusterObj); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 614348c209..e0dbc26122 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -109,7 +109,7 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) { mndReleaseConsumer(pMnode, pConsumer); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "lost-csm"); if (pTrans == NULL) goto FAIL; if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; @@ -142,7 +142,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) { mndReleaseConsumer(pMnode, pConsumer); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "recover-csm"); if (pTrans == NULL) goto FAIL; if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; @@ -197,11 +197,12 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { SMqConsumerLostMsg *pLostMsg = rpcMallocCont(sizeof(SMqConsumerLostMsg)); pLostMsg->consumerId = pConsumer->consumerId; - SRpcMsg *pRpcMsg = taosMemoryCalloc(1, sizeof(SRpcMsg)); - pRpcMsg->msgType = TDMT_MND_MQ_CONSUMER_LOST; - pRpcMsg->pCont = pLostMsg; - pRpcMsg->contLen = sizeof(SMqConsumerLostMsg); - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, pRpcMsg); + SRpcMsg pRpcMsg = { + .msgType = TDMT_MND_MQ_CONSUMER_LOST, + .pCont = pLostMsg, + .contLen = sizeof(SMqConsumerLostMsg), + }; + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); } if (status == MQ_CONSUMER_STATUS__LOST_REBD || status == MQ_CONSUMER_STATUS__READY) { // do nothing @@ -280,11 +281,12 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); pRecoverMsg->consumerId = consumerId; - SRpcMsg *pRpcMsg = taosMemoryCalloc(1, sizeof(SRpcMsg)); - pRpcMsg->msgType = TDMT_MND_MQ_CONSUMER_RECOVER; - pRpcMsg->pCont = pRecoverMsg; - pRpcMsg->contLen = sizeof(SMqConsumerRecoverMsg); - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, pRpcMsg); + SRpcMsg pRpcMsg = { + .msgType = TDMT_MND_MQ_CONSUMER_RECOVER, + .pCont = pRecoverMsg, + .contLen = sizeof(SMqConsumerRecoverMsg), + }; + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); } mndReleaseConsumer(pMnode, pConsumer); @@ -318,11 +320,12 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); pRecoverMsg->consumerId = consumerId; - SRpcMsg *pRpcMsg = taosMemoryCalloc(1, sizeof(SRpcMsg)); - pRpcMsg->msgType = TDMT_MND_MQ_CONSUMER_RECOVER; - pRpcMsg->pCont = pRecoverMsg; - pRpcMsg->contLen = sizeof(SMqConsumerRecoverMsg); - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, pRpcMsg); + SRpcMsg pRpcMsg = { + .msgType = TDMT_MND_MQ_CONSUMER_RECOVER, + .pCont = pRecoverMsg, + .contLen = sizeof(SMqConsumerRecoverMsg), + }; + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); } #endif @@ -462,7 +465,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { int32_t newTopicNum = taosArrayGetSize(newSub); // check topic existance - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pMsg, "subscribe"); if (pTrans == NULL) goto SUBSCRIBE_OVER; for (int32_t i = 0; i < newTopicNum; i++) { @@ -487,6 +490,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); tstrncpy(pConsumerNew->clientId, subscribe.clientId, 256); pConsumerNew->updateType = CONSUMER_UPDATE__MODIFY; + taosArrayDestroy(pConsumerNew->rebNewTopics); pConsumerNew->rebNewTopics = newSub; subscribe.topicNames = NULL; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index d42ba1f7ff..39ec3484db 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -541,7 +541,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, } int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-db"); if (pTrans == NULL) goto _OVER; // mndTransSetSerial(pTrans); mDebug("trans:%d, used to create db:%s", pTrans->id, pCreate->db); @@ -773,7 +773,7 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * } static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *pNew) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "alter-db"); if (pTrans == NULL) return -1; mDebug("trans:%d, used to alter db:%s", pTrans->id, pOld->name); @@ -1027,7 +1027,7 @@ static int32_t mndBuildDropDbRsp(SDbObj *pDb, int32_t *pRspLen, void **ppRsp, bo static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "drop-db"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop db:%s", pTrans->id, pDb->name); diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index e6f1a40993..50d26ce9a5 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -145,7 +145,10 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) { } void tDeleteSMqVgEp(SMqVgEp *pVgEp) { - if (pVgEp->qmsg) taosMemoryFree(pVgEp->qmsg); + if (pVgEp) { + taosMemoryFreeClear(pVgEp->qmsg); + taosMemoryFree(pVgEp); + } } int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) { @@ -200,18 +203,10 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L } void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) { - if (pConsumer->currentTopics) { - taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree); - } - if (pConsumer->rebNewTopics) { - taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree); - } - if (pConsumer->rebRemovedTopics) { - taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree); - } - if (pConsumer->assignedTopics) { - taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree); - } + taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree); + taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree); + taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree); + taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree); } int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) { @@ -343,8 +338,8 @@ SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) { return pConsumerEpNew; } -void tDeleteSMqConsumerEp(SMqConsumerEp *pConsumerEp) { - // +void tDeleteSMqConsumerEp(void *data) { + SMqConsumerEp *pConsumerEp = (SMqConsumerEp*)data; taosArrayDestroyP(pConsumerEp->vgs, (FDelete)tDeleteSMqVgEp); } @@ -428,6 +423,13 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) { } void tDeleteSubscribeObj(SMqSubscribeObj *pSub) { + void *pIter = NULL; + while (1) { + pIter = taosHashIterate(pSub->consumerHash, pIter); + if (pIter == NULL) break; + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + taosArrayDestroyP(pConsumerEp->vgs, (FDelete)tDeleteSMqVgEp); + } taosHashCleanup(pSub->consumerHash); taosArrayDestroyP(pSub->unassignedVgs, (FDelete)tDeleteSMqVgEp); } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 26b4080d14..c6fdf23023 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -104,7 +104,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create dnode:%s on first deploy", pTrans->id, dnodeObj.ep); @@ -488,7 +488,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); - pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create dnode:%s", pTrans->id, dnodeObj.ep); @@ -667,7 +667,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM SSdbRaw *pRaw = NULL; STrans *pTrans = NULL; - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-dnode"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id); diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index e6f4b48524..429d840202 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -219,7 +219,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre } memcpy(func.pCode, pCreate->pCode, func.codeSize); - pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create func:%s", pTrans->id, pCreate->name); @@ -249,7 +249,7 @@ _OVER: static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-func"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop user:%s", pTrans->id, pFunc->name); diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 71bda4d4f3..a41f958c0f 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -91,7 +91,7 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) { mInfo("mnode:%d, will be created when deploying, raw:%p", mnodeObj.id, pRaw); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-mnode"); if (pTrans == NULL) { mError("mnode:%d, failed to create since %s", mnodeObj.id, terrstr()); return -1; @@ -362,7 +362,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, mnodeObj.createdTime = taosGetTimestampMs(); mnodeObj.updateTime = mnodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "create-mnode"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mInfo("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId); @@ -571,7 +571,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) { int32_t code = -1; STrans *pTrans = NULL; - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "drop-mnode"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mInfo("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id); diff --git a/source/dnode/mnode/impl/src/mndOffset.c b/source/dnode/mnode/impl/src/mndOffset.c index 037a46345f..797aa88670 100644 --- a/source/dnode/mnode/impl/src/mndOffset.c +++ b/source/dnode/mnode/impl/src/mndOffset.c @@ -181,7 +181,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) { tDecodeSMqCMCommitOffsetReq(&decoder, &commitOffsetReq); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "commit-offset"); for (int32_t i = 0; i < commitOffsetReq.num; i++) { SMqOffset *pOffset = &commitOffsetReq.offsets[i]; diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index f057f6190d..cd6e91b154 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -248,7 +248,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, qnodeObj.createdTime = taosGetTimestampMs(); qnodeObj.updateTime = qnodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-qnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create qnode:%d", pTrans->id, pCreate->dnodeId); @@ -364,7 +364,7 @@ int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pO static int32_t mndDropQnode(SMnode *pMnode, SRpcMsg *pReq, SQnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-qnode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 8638cc5118..3fdd3995f9 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -587,7 +587,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea nodesDestroyNode((SNode *)pPlan); int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "create-sma"); if (pTrans == NULL) goto _OVER; mndTransSetDbName(pTrans, pDb->name, NULL); mndTransSetSerial(pTrans); @@ -799,7 +799,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p pStb = mndAcquireStb(pMnode, pSma->stb); if (pStb == NULL) goto _OVER; - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "drop-sma"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop sma:%s", pTrans->id, pSma->name); diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index d18a233d29..5f4231aa6a 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -253,7 +253,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, snodeObj.createdTime = taosGetTimestampMs(); snodeObj.updateTime = snodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-snode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create snode:%d", pTrans->id, pCreate->dnodeId); @@ -375,7 +375,7 @@ int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pO static int32_t mndDropSnode(SMnode *pMnode, SRpcMsg *pReq, SSnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-snode"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop snode:%d", pTrans->id, pObj->id); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index dc8285740a..ecb24becba 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -800,7 +800,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea SStbObj stbObj = {0}; int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stb"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name); @@ -1187,6 +1187,7 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, if (pCol->colId > 0 && pCol->colId == colId) { sdbRelease(pSdb, pTopic); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC; mError("topic:%s, check colId:%d conflicted", pTopic->name, pCol->colId); return -1; @@ -1197,6 +1198,7 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, NEXT: sdbRelease(pSdb, pTopic); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); } return 0; } @@ -1228,6 +1230,7 @@ static int32_t mndCheckAlterColForStream(SMnode *pMnode, const char *stbFullName if (pCol->colId > 0 && pCol->colId == colId) { sdbRelease(pSdb, pStream); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); terrno = TSDB_CODE_MND_STREAM_MUST_BE_DELETED; mError("stream:%s, check colId:%d conflicted", pStream->name, pCol->colId); return -1; @@ -1238,6 +1241,7 @@ static int32_t mndCheckAlterColForStream(SMnode *pMnode, const char *stbFullName NEXT: sdbRelease(pSdb, pStream); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); } return 0; } @@ -1275,6 +1279,7 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName, if ((pCol->colId) > 0 && (pCol->colId == colId)) { sdbRelease(pSdb, pSma); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA; mError("tsma:%s, check colId:%d conflicted", pSma->name, pCol->colId); return -1; @@ -1285,6 +1290,7 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName, NEXT: sdbRelease(pSdb, pSma); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); } return 0; } @@ -1774,8 +1780,8 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i return 0; } -int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, void **pCont, int32_t *pLen) { - int32_t ret = -1; +int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, void **pCont, int32_t *pLen) { + int32_t ret = -1; SDbObj *pDb = mndAcquireDb(pMnode, dbFName); if (NULL == pDb) { return -1; @@ -1785,11 +1791,11 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, vo if (NULL == pObj) { goto _OVER; } - - SEncoder ec = {0}; - uint32_t contLen = 0; + + SEncoder ec = {0}; + uint32_t contLen = 0; SMCreateStbRsp stbRsp = {0}; - SName name = {0}; + SName name = {0}; tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); stbRsp.pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp)); @@ -1821,12 +1827,12 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, vo *pLen = contLen; ret = 0; - + _OVER: if (pObj) { mndReleaseStb(pMnode, pObj); } - + if (pDb) { mndReleaseDb(pMnode, pDb); } @@ -1834,11 +1840,10 @@ _OVER: return ret; } - static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb, bool needRsp, void *alterOriData, int32_t alterOriDataLen) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "alter-stb"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to alter stb:%s", pTrans->id, pStb->name); @@ -2037,7 +2042,7 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "drop-stb"); if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name); @@ -2091,6 +2096,7 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName, if (pCol->tableId == suid) { sdbRelease(pSdb, pTopic); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); return -1; } else { goto NEXT; @@ -2099,6 +2105,7 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName, NEXT: sdbRelease(pSdb, pTopic); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); } return 0; } @@ -2136,6 +2143,7 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, if (pCol->tableId == suid) { sdbRelease(pSdb, pStream); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); return -1; } else { goto NEXT; @@ -2144,6 +2152,7 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, NEXT: sdbRelease(pSdb, pStream); nodesDestroyNode(pAst); + nodesDestroyList(pNodeList); } return 0; } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index dd7a9e71ea..a039b54b80 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -666,12 +666,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { goto _OVER; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stream"); if (pTrans == NULL) { mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr()); goto _OVER; } - mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); + mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); // hack way mDebug("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name); // create stb for stream @@ -759,7 +759,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "drop-stream"); if (pTrans == NULL) { mError("stream:%s, failed to drop since %s", dropReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 8a968712e0..43eae3f60c 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -441,7 +441,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "persist-reb"); mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL); if (pTrans == NULL) return -1; @@ -490,8 +490,12 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu mndReleaseConsumer(pMnode, pConsumerOld); if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { ASSERT(0); + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); goto REB_FAIL; } + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); } // 3.3 set removed consumer @@ -509,8 +513,12 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu mndReleaseConsumer(pMnode, pConsumerOld); if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { ASSERT(0); + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); goto REB_FAIL; } + tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); } #if 0 if (consumerNum) { @@ -666,7 +674,7 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pReq) { return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-cgroup"); if (pTrans == NULL) { mError("cgroup: %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr()); mndReleaseSubscribe(pMnode, pSub); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7b36966d6c..8fe2d1af15 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -224,6 +224,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { if (taosDecodeSSchemaWrapper(buf, &pTopic->schema) == NULL) { goto TOPIC_DECODE_OVER; } + taosMemoryFree(buf); } else { pTopic->schema.nCols = 0; pTopic->schema.version = 0; @@ -266,6 +267,11 @@ static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic) { static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) { mTrace("topic:%s, perform delete action", pTopic->name); + taosMemoryFreeClear(pTopic->sql); + taosMemoryFreeClear(pTopic->ast); + taosMemoryFreeClear(pTopic->physicalPlan); + if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema); + taosArrayDestroy(pTopic->ntbColIds); return 0; } @@ -347,6 +353,7 @@ static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) { } } } + nodesDestroyList(pNodeList); return 0; } @@ -416,6 +423,8 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * taosMemoryFree(topicObj.sql); return -1; } + nodesDestroyNode(pAst); + nodesDestroyNode((SNode *)pPlan); } else if (pCreate->subType == TOPIC_SUB_TYPE__TABLE) { SStbObj *pStb = mndAcquireStb(pMnode, pCreate->subStbName); if (pStb == NULL) { @@ -431,7 +440,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * /*topicObj.withTbName = 1;*/ /*topicObj.withSchema = 1;*/ - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-topic"); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); taosMemoryFreeClear(topicObj.ast); @@ -512,6 +521,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * } taosMemoryFreeClear(topicObj.physicalPlan); + taosMemoryFreeClear(topicObj.sql); + taosMemoryFreeClear(topicObj.ast); + taosArrayDestroy(topicObj.ntbColIds); + if (topicObj.schema.nCols) taosMemoryFreeClear(topicObj.schema.pSchema); mndTransDrop(pTrans); return TSDB_CODE_ACTION_IN_PROGRESS; } @@ -650,7 +663,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "drop-topic"); mndTransSetDbName(pTrans, pTopic->db, NULL); if (pTrans == NULL) { mError("topic:%s, failed to drop since %s", pTopic->name, terrstr()); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 030f4542b9..9d918e2abd 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -25,7 +25,7 @@ #define TRANS_VER_NUMBER 1 #define TRANS_ARRAY_SIZE 8 -#define TRANS_RESERVE_SIZE 64 +#define TRANS_RESERVE_SIZE 48 static SSdbRaw *mndTransActionEncode(STrans *pTrans); static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw); @@ -127,8 +127,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT8(pRaw, dataPos, 0, _OVER) SDB_SET_INT16(pRaw, dataPos, pTrans->originRpcType, _OVER) SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_INT32(pRaw, dataPos, pTrans->redoActionPos, _OVER) int32_t redoActionNum = taosArrayGetSize(pTrans->redoActions); @@ -223,6 +223,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER) } + SDB_SET_BINARY(pRaw, dataPos, pTrans->opername, TSDB_TRANS_OPER_LEN, _OVER) SDB_SET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -289,8 +290,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { pTrans->oper = oper; SDB_GET_INT16(pRaw, dataPos, &pTrans->originRpcType, _OVER) SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname1, TSDB_TABLE_FNAME_LEN, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname2, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pTrans->stbname, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_INT32(pRaw, dataPos, &pTrans->redoActionPos, _OVER) SDB_GET_INT32(pRaw, dataPos, &redoActionNum, _OVER) SDB_GET_INT32(pRaw, dataPos, &undoActionNum, _OVER) @@ -305,6 +306,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { if (pTrans->commitActions == NULL) goto _OVER; for (int32_t i = 0; i < redoActionNum; ++i) { + memset(&action, 0, sizeof(action)); SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) @@ -340,6 +342,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { } for (int32_t i = 0; i < undoActionNum; ++i) { + memset(&action, 0, sizeof(action)); SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) @@ -375,6 +378,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { } for (int32_t i = 0; i < commitActionNum; ++i) { + memset(&action, 0, sizeof(action)); SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) @@ -417,6 +421,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER); } + SDB_GET_BINARY(pRaw, dataPos, pTrans->opername, TSDB_TRANS_OPER_LEN, _OVER); SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER) terrno = 0; @@ -455,6 +460,20 @@ static const char *mndTransStr(ETrnStage stage) { } } +static void mndSetTransLastAction(STrans *pTrans, STransAction *pAction) { + if (pAction != NULL) { + pTrans->lastAction = pAction->id; + pTrans->lastMsgType = pAction->msgType; + pTrans->lastEpset = pAction->epSet; + pTrans->lastErrorNo = pAction->errCode; + } else { + pTrans->lastAction = 0; + pTrans->lastMsgType = 0; + memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset)); + pTrans->lastErrorNo = 0; + } +} + static void mndTransTestStartFunc(SMnode *pMnode, void *param, int32_t paramLen) { mInfo("test trans start, param:%s, len:%d", (char *)param, paramLen); } @@ -582,7 +601,8 @@ void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) { sdbRelease(pSdb, pTrans); } -STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq) { +STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, const SRpcMsg *pReq, + const char *opername) { STrans *pTrans = taosMemoryCalloc(1, sizeof(STrans)); if (pTrans == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -590,6 +610,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, return NULL; } + if (opername != NULL) { + tstrncpy(pTrans->opername, opername, TSDB_TRANS_OPER_LEN); + } + pTrans->id = sdbGetMaxId(pMnode->pSdb, SDB_TRANS); pTrans->stage = TRN_STAGE_PREPARE; pTrans->policy = policy; @@ -706,7 +730,7 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c if (pIter == NULL) break; if (pTrans->oper == oper) { - if (strcasecmp(dbname, pTrans->dbname1) == 0) { + if (strcasecmp(dbname, pTrans->dbname) == 0) { mInfo("trans:%d, db:%s oper:%d matched with input", pTrans->id, dbname, oper); if (pTrans->pRpcArray == NULL) { pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo)); @@ -725,12 +749,12 @@ int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, c return code; } -void mndTransSetDbName(STrans *pTrans, const char *dbname1, const char *dbname2) { - if (dbname1 != NULL) { - tstrncpy(pTrans->dbname1, dbname1, TSDB_TABLE_FNAME_LEN); +void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) { + if (dbname != NULL) { + tstrncpy(pTrans->dbname, dbname, TSDB_TABLE_FNAME_LEN); } - if (dbname2 != NULL) { - tstrncpy(pTrans->dbname2, dbname2, TSDB_TABLE_FNAME_LEN); + if (stbname != NULL) { + tstrncpy(pTrans->stbname, stbname, TSDB_TABLE_FNAME_LEN); } } @@ -759,9 +783,9 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { return 0; } -static bool mndCheckDbConflict(const char *db, STrans *pTrans) { - if (db[0] == 0) return false; - if (strcasecmp(db, pTrans->dbname1) == 0 || strcasecmp(db, pTrans->dbname2) == 0) return true; +static bool mndCheckDbConflict(const char *conflict, STrans *pTrans) { + if (conflict[0] == 0) return false; + if (strcasecmp(conflict, pTrans->dbname) == 0 || strcasecmp(conflict, pTrans->stbname) == 0) return true; return false; } @@ -780,28 +804,28 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { if (pNew->conflict == TRN_CONFLICT_DB) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true; - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->dbname, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; } } if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) { if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; if (pTrans->conflict == TRN_CONFLICT_DB) { - if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true; - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->dbname, pTrans)) conflict = true; + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; } if (pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true; // for stb + if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; // for stb } } if (conflict) { - mError("trans:%d, db1:%s db2:%s type:%d, can't execute since conflict with trans:%d db1:%s db2:%s type:%d", - pNew->id, pNew->dbname1, pNew->dbname2, pNew->conflict, pTrans->id, pTrans->dbname1, pTrans->dbname2, + mError("trans:%d, db:%s stb:%s type:%d, can't execute since conflict with trans:%d db:%s stb:%s type:%d", + pNew->id, pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pTrans->conflict); } else { - mDebug("trans:%d, db1:%s db2:%s type:%d, not conflict with trans:%d db1:%s db2:%s type:%d", pNew->id, - pNew->dbname1, pNew->dbname2, pNew->conflict, pTrans->id, pTrans->dbname1, pTrans->dbname2, + mDebug("trans:%d, db:%s stb:%s type:%d, not conflict with trans:%d db:%s stb:%s type:%d", pNew->id, + pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pTrans->conflict); } sdbRelease(pMnode->pSdb, pTrans); @@ -812,7 +836,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { - if (strlen(pTrans->dbname1) == 0 && strlen(pTrans->dbname2) == 0) { + if (strlen(pTrans->dbname) == 0 && strlen(pTrans->stbname) == 0) { terrno = TSDB_CODE_MND_TRANS_CONFLICT; mError("trans:%d, failed to prepare conflict db not set", pTrans->id); return -1; @@ -913,12 +937,12 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { if (pTrans->originRpcType == TDMT_MND_CREATE_DB) { mInfo("trans:%d, origin msgtype:%s", pTrans->id, TMSG_INFO(pTrans->originRpcType)); - SDbObj *pDb = mndAcquireDb(pMnode, pTrans->dbname1); + SDbObj *pDb = mndAcquireDb(pMnode, pTrans->dbname); if (pDb != NULL) { for (int32_t j = 0; j < 12; j++) { bool ready = mndIsDbReady(pMnode, pDb); if (!ready) { - mInfo("trans:%d, db:%s not ready yet, wait %d times", pTrans->id, pTrans->dbname1, j); + mInfo("trans:%d, db:%s not ready yet, wait %d times", pTrans->id, pTrans->dbname, j); taosMsleep(1000); } else { break; @@ -929,7 +953,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { } else if (pTrans->originRpcType == TDMT_MND_CREATE_STB) { void *pCont = NULL; int32_t contLen = 0; - if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname1, pTrans->dbname2, &pCont, &contLen) != 0) { + if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen) != 0) { mndTransSetRpcRsp(pTrans, pCont, contLen); } } @@ -1037,18 +1061,12 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi mInfo("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id, sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status)); - pTrans->lastAction = pAction->id; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastEpset = pAction->epSet; - pTrans->lastErrorNo = 0; + mndSetTransLastAction(pTrans, pAction); } else { pAction->errCode = (terrno != 0) ? terrno : code; mError("trans:%d, %s:%d failed to write sdb since %s, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr(), sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status)); - pTrans->lastAction = pAction->id; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastEpset = pAction->epSet; - pTrans->lastErrorNo = pAction->errCode; + mndSetTransLastAction(pTrans, pAction); } return code; @@ -1082,15 +1100,10 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio if (code == 0) { pAction->msgSent = 1; pAction->msgReceived = 0; - pAction->errCode = 0; + pAction->errCode = TSDB_CODE_ACTION_IN_PROGRESS; mInfo("trans:%d, %s:%d is sent, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, detail); - pTrans->lastAction = pAction->id; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastEpset = pAction->epSet; - if (pTrans->lastErrorNo == 0) { - pTrans->lastErrorNo = TSDB_CODE_ACTION_IN_PROGRESS; - } + mndSetTransLastAction(pTrans, pAction); } else { pAction->msgSent = 0; pAction->msgReceived = 0; @@ -1098,10 +1111,7 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio mError("trans:%d, %s:%d not send since %s, %s", pTrans->id, mndTransStr(pAction->stage), pAction->id, terrstr(), detail); - pTrans->lastAction = pAction->id; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastEpset = pAction->epSet; - pTrans->lastErrorNo = pAction->errCode; + mndSetTransLastAction(pTrans, pAction); } return code; @@ -1112,10 +1122,7 @@ static int32_t mndTransExecNullMsg(SMnode *pMnode, STrans *pTrans, STransAction pAction->errCode = 0; mInfo("trans:%d, %s:%d confirm action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id); - pTrans->lastAction = pAction->id; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastEpset = pAction->epSet; - pTrans->lastErrorNo = 0; + mndSetTransLastAction(pTrans, pAction); return 0; } @@ -1161,25 +1168,19 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA errCode = pAction->errCode; pErrAction = pAction; } + } else { + pErrAction = pAction; } } + mndSetTransLastAction(pTrans, pErrAction); + if (numOfExecuted == numOfActions) { if (errCode == 0) { - pTrans->lastAction = 0; - pTrans->lastMsgType = 0; - memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset)); - pTrans->lastErrorNo = 0; mInfo("trans:%d, all %d actions execute successfully", pTrans->id, numOfActions); return 0; } else { mError("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode & 0XFFFF); - if (pErrAction != NULL) { - pTrans->lastAction = pErrAction->id; - pTrans->lastMsgType = pErrAction->msgType; - pTrans->lastEpset = pErrAction->epSet; - pTrans->lastErrorNo = pErrAction->errCode; - } mndTransResetActions(pMnode, pTrans, pArray); terrno = errCode; return errCode; @@ -1220,6 +1221,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (numOfActions == 0) return code; if (pTrans->redoActionPos >= numOfActions) return code; + mInfo("trans:%d, execute %d actions serial", pTrans->id, numOfActions); + for (int32_t action = pTrans->redoActionPos; action < numOfActions; ++action) { STransAction *pAction = taosArrayGet(pTrans->redoActions, pTrans->redoActionPos); @@ -1248,16 +1251,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (code == 0) { pTrans->failedTimes = 0; - pTrans->lastAction = action; - pTrans->lastMsgType = 0; - pTrans->lastErrorNo = 0; - memset(&pTrans->lastEpset, 0, sizeof(pTrans->lastEpset)); - } else { - pTrans->lastAction = action; - pTrans->lastMsgType = pAction->msgType; - pTrans->lastErrorNo = code; - pTrans->lastEpset = pAction->epSet; } + mndSetTransLastAction(pTrans, pAction); if (mndCannotExecuteTransAction(pMnode)) break; @@ -1599,15 +1594,20 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)stage, false); - char dbname1[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(dbname1, mndGetDbStr(pTrans->dbname1), pShow->pMeta->pSchemas[cols].bytes); + char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)dbname1, false); + colDataAppend(pColInfo, numOfRows, (const char *)opername, false); - char dbname2[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(dbname2, mndGetDbStr(pTrans->dbname2), pShow->pMeta->pSchemas[cols].bytes); + char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)dbname2, false); + colDataAppend(pColInfo, numOfRows, (const char *)dbname, false); + + char stbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)stbname, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 5da119bb30..c4adb03e21 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -81,7 +81,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char mDebug("user:%s, will be created when deploying, raw:%p", userObj.user, pRaw); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "create-user"); if (pTrans == NULL) { mError("user:%s, failed to create since %s", userObj.user, terrstr()); return -1; @@ -299,7 +299,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate userObj.sysInfo = pCreate->sysInfo; userObj.enable = pCreate->enable; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-user"); if (pTrans == NULL) { mError("user:%s, failed to create since %s", pCreate->user, terrstr()); return -1; @@ -383,7 +383,7 @@ _OVER: } static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpcMsg *pReq) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "alter-user"); if (pTrans == NULL) { mError("user:%s, failed to alter since %s", pOld->user, terrstr()); return -1; @@ -598,7 +598,7 @@ _OVER: } static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "drop-user"); if (pTrans == NULL) { mError("user:%s, failed to drop since %s", pUser->user, terrstr()); return -1; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index a95bdef323..cc9ed5f9ba 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1223,7 +1223,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSdbRaw *pRaw = NULL; STrans *pTrans = NULL; - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "red-vgroup"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mDebug("trans:%d, used to redistribute vgroup, vgId:%d", pTrans->id, pVgroup->vgId); @@ -1606,7 +1606,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj STrans *pTrans = NULL; SArray *pArray = mndBuildDnodesArray(pMnode, 0); - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mDebug("trans:%d, used to split vgroup, vgId:%d", pTrans->id, pVgroup->vgId); @@ -1774,7 +1774,7 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { pBalancedVgroups = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (pBalancedVgroups == NULL) goto _OVER; - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "balance-vgroup"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); mDebug("trans:%d, used to balance vgroup", pTrans->id); diff --git a/source/dnode/mnode/impl/test/trans/trans2.cpp b/source/dnode/mnode/impl/test/trans/trans2.cpp index aee8aa2748..60be7cfbc0 100644 --- a/source/dnode/mnode/impl/test/trans/trans2.cpp +++ b/source/dnode/mnode/impl/test/trans/trans2.cpp @@ -115,7 +115,7 @@ class MndTestTrans2 : public ::testing::Test { userObj.superUser = 1; SRpcMsg rpcMsg = {0}; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, conflict, &rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, conflict, &rpcMsg, ""); SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj); mndTransAppendRedolog(pTrans, pRedoRaw); sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); @@ -148,7 +148,7 @@ class MndTestTrans2 : public ::testing::Test { userObj.superUser = 1; SRpcMsg rpcMsg = {0}; - STrans *pTrans = mndTransCreate(pMnode, policy, conflict, &rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, policy, conflict, &rpcMsg, ""); SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj); mndTransAppendRedolog(pTrans, pRedoRaw); sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); @@ -220,7 +220,7 @@ class MndTestTrans2 : public ::testing::Test { userObj.superUser = 1; SRpcMsg rpcMsg = {0}; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, &rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, &rpcMsg, ""); SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj); mndTransAppendRedolog(pTrans, pRedoRaw); sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 7a99d26683..1f7a059ffc 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -51,7 +51,6 @@ target_sources( "src/tsdb/tsdbCacheRead.c" "src/tsdb/tsdbRetention.c" "src/tsdb/tsdbDiskData.c" - "src/tsdb/tsdbCompress.c" "src/tsdb/tsdbCompact.c" "src/tsdb/tsdbMergeTree.c" diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 9931462e5f..dade85b12d 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -146,6 +146,7 @@ struct SRSmaInfoItem { uint16_t nScanned; int32_t maxDelay; // ms tmr_h tmrId; + void *pStreamState; }; struct SRSmaInfo { @@ -224,8 +225,10 @@ int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type); int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer); -void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName); -void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName); +void tdRSmaQTaskInfoGetFileName(int32_t vgId, int64_t version, char *outputName); +void tdRSmaQTaskInfoGetFullName(int32_t vgId, int64_t version, const char *path, char *outputName); +void tdRSmaQTaskInfoGetFullPath(int32_t vgId, int8_t level, const char *path, char *outputName); +void tdRSmaQTaskInfoGetFullPathEx(int32_t vgId, tb_uid_t suid, int8_t level, const char *path, char *outputName); static FORCE_INLINE void tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) { int32_t ref = T_REF_INC(pRSmaInfo); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 0e85e7bfb6..4c8045d651 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -184,7 +184,7 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg); -SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid, +SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pSchema, SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, SBatchDeleteReq* pDeleteReq); // sma diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index a34569b08e..24ade017d3 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -319,8 +319,12 @@ _query: pSchema = tCloneSSchemaWrapper(&meNew.stbEntry.schemaRow); tDecoderClear(&dcNew); tdbTbcClose(pCur); + tdbFree(pKey); + tdbFree(pVal); goto _exit; } + tdbFree(pKey); + tdbFree(pVal); tdbTbcClose(pCur); } } else if (me.type == TSDB_CHILD_TABLE) { @@ -347,11 +351,13 @@ _query: tDecoderClear(&dc); _exit: + tDecoderClear(&dc); metaULock(pMeta); tdbFree(pData); return pSchema; _err: + tDecoderClear(&dc); metaULock(pMeta); tdbFree(pData); return NULL; @@ -383,10 +389,8 @@ int metaTtlSmaller(SMeta *pMeta, uint64_t ttl, SArray *uidList) { ttlKey = *(STtlIdxKey *)pKey; taosArrayPush(uidList, &ttlKey.uid); } - tdbTbcClose(pCur); - tdbFree(pKey); - + tdbTbcClose(pCur); return 0; } diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 0edbd092e6..9fdbe50f88 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -353,6 +353,8 @@ int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t metaDebug("tmqsnap init idVersion uid:%" PRIi64 " version:%" PRIi64 " index:%d", *uid, idData->version, idData->index); } + tdbFree(pKey); + tdbFree(pVal); return TDB_CODE_SUCCESS; } @@ -528,6 +530,7 @@ int32_t getMetafromSnapShot(SSnapContext* ctx, void **pBuf, int32_t *contLen, in } } } + taosArrayDestroy(pTagVals); } // SIdInfo* sidInfo = (SIdInfo*)taosHashGet(ctx->idVersion, &me.ctbEntry.suid, sizeof(tb_uid_t)); // if(sidInfo->version >= idInfo->version){ diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 22ec8118a2..932afe8937 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -362,8 +362,9 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { // update uid index metaUpdateUidIdx(pMeta, &nStbEntry); - if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); metaULock(pMeta); + + if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); tDecoderClear(&dc); tdbTbcClose(pTbDbc); tdbTbcClose(pUidIdxc); @@ -922,6 +923,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA taosArrayDestroy(pTagArray); } + metaWLock(pMeta); + // save to table.db metaSaveToTbDb(pMeta, &ctbEntry); @@ -936,6 +939,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, ((STag *)(ctbEntry.ctbEntry.pTags))->len, &pMeta->txn); + metaULock(pMeta); + tDecoderClear(&dc1); tDecoderClear(&dc2); if (ctbEntry.ctbEntry.pTags) taosMemoryFree((void *)ctbEntry.ctbEntry.pTags); @@ -1192,10 +1197,11 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { const void *pTagData = NULL; // int32_t nTagData = 0; SDecoder dc = {0}; - + int32_t ret = 0; // get super table if (tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData) != 0) { - return -1; + ret = -1; + goto end; } tbDbKey.uid = pCtbEntry->ctbEntry.suid; tbDbKey.version = ((SUidIdxVal *)pData)[0].version; @@ -1221,17 +1227,20 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { // nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len; pTagData = pCtbEntry->ctbEntry.pTags; nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len; - return metaSaveJsonVarToIdx(pMeta, pCtbEntry, pTagColumn); + ret = metaSaveJsonVarToIdx(pMeta, pCtbEntry, pTagColumn); + goto end; } if (metaCreateTagIdxKey(pCtbEntry->ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, pCtbEntry->uid, &pTagIdxKey, &nTagIdxKey) < 0) { - return -1; + ret = -1; + goto end; } tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn); +end: metaDestroyTagIdxKey(pTagIdxKey); tDecoderClear(&dc); tdbFree(pData); - return 0; + return ret; } static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 07ec7d0694..2b44cdcef1 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -295,12 +295,17 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { } /** - * @brief step 3: consume the SubmitReq in buffer + * @brief step 3: commit should wait for all SubmitReq in buffer be consumed * 1) This is high cost task and should not put in asyncPreCommit originally. * 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently. */ - if (tdRSmaProcessExecImpl(pSma, RSMA_EXEC_COMMIT) < 0) { - return TSDB_CODE_FAILED; + nLoops = 0; + while (atomic_load_64(&pRSmaStat->nBufItems) > 0) { + ++nLoops; + if (nLoops > 1000) { + sched_yield(); + nLoops = 0; + } } smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma), diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index b870ea1b62..ccf4ebb39f 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -278,7 +278,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { smaDebug("vgId:%d, destroy rsma stat %p", SMA_VID(pSma), pRSmaStat); // step 1: set rsma trigger stat cancelled atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); - tsem_destroy(&(pStat->notEmpty)); // step 2: destroy the rsma info and associated fetch tasks taosHashCleanup(RSMA_INFO_HASH(pStat)); @@ -306,6 +305,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { tdRSmaFSClose(RSMA_FS(pStat)); // step 6: free pStat + tsem_destroy(&(pStat->notEmpty)); taosMemoryFreeClear(pStat); } } diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c index 8e8611f0e8..a5f4e8d2e8 100644 --- a/source/dnode/vnode/src/sma/smaFS.c +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -150,6 +150,8 @@ static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **outpu regex_t regex; int code = 0; + terrno = TSDB_CODE_SUCCESS; + tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir); if (!taosCheckExistFile(dir)) { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 468ce5e2d1..8d1525e081 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -92,6 +92,18 @@ void tdRSmaQTaskInfoGetFullName(int32_t vgId, int64_t version, const char *path, tdGetVndFileName(vgId, path, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, version, outputName); } +void tdRSmaQTaskInfoGetFullPath(int32_t vgId, int8_t level, const char *path, char *outputName) { + tdGetVndDirName(vgId, path, VNODE_RSMA_DIR, true, outputName); + int32_t rsmaLen = strlen(outputName); + snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8, level); +} + +void tdRSmaQTaskInfoGetFullPathEx(int32_t vgId, tb_uid_t suid, int8_t level, const char *path, char *outputName) { + tdGetVndDirName(vgId, path, VNODE_RSMA_DIR, true, outputName); + int32_t rsmaLen = strlen(outputName); + snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi64 "%s%" PRIi8, suid, TD_DIRSEP, level); +} + static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { return lenWithHead - RSMA_QTASKINFO_HEAD_LEN; } @@ -130,6 +142,10 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) { taosTmrStopA(&pItem->tmrId); } + if (isDeepFree && pItem->pStreamState) { + streamStateClose(pItem->pStreamState); + } + if (isDeepFree && pInfo->taskInfo[i]) { tdRSmaQTaskInfoFree(&pInfo->taskInfo[i], SMA_VID(pSma), i + 1); } else { @@ -290,12 +306,33 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat SRetention *pRetention = SMA_RETENTION(pSma); STsdbCfg *pTsdbCfg = SMA_TSDB_CFG(pSma); SVnode *pVnode = pSma->pVnode; + char taskInfDir[TSDB_FILENAME_LEN] = {0}; + void *pStreamState = NULL; + + // set the backend of stream state + tdRSmaQTaskInfoGetFullPathEx(TD_VID(pVnode), pRSmaInfo->suid, idx + 1, tfsGetPrimaryPath(pVnode->pTfs), taskInfDir); + if (!taosCheckExistFile(taskInfDir)) { + char *s = strdup(taskInfDir); + if (taosMulMkDir(taosDirName(s)) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + taosMemoryFree(s); + return TSDB_CODE_FAILED; + } + taosMemoryFree(s); + } + pStreamState = streamStateOpen(taskInfDir, NULL, true); + if (!pStreamState) { + terrno = TSDB_CODE_RSMA_STREAM_STATE_OPEN; + return TSDB_CODE_FAILED; + } + + SReadHandle handle = { .meta = pVnode->pMeta, .vnode = pVnode, .initTqReader = 1, + .pStateBackend = pStreamState, }; - pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); if (!pRSmaInfo->taskInfo[idx]) { terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; @@ -303,6 +340,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat } SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]); pItem->triggerStat = TASK_TRIGGER_STAT_ACTIVE; // fetch the data when reboot + pItem->pStreamState = pStreamState; if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) { int64_t msInterval = convertTimeFromPrecisionToUnit(pRetention[idx + 1].freq, pTsdbCfg->precision, TIME_UNIT_MILLISECOND); @@ -322,7 +360,6 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat pItem->fetchLevel = pItem->level; taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); - smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 ", finally maxdelay:%" PRIi32, @@ -1226,16 +1263,17 @@ int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) if (tdRSmaRestoreQTaskInfoInit(pSma, &nTables) < 0) { goto _err; } - if (nTables <= 0) { smaDebug("vgId:%d, no need to restore rsma task %" PRIi8 " since no tables", SMA_VID(pSma), type); return TSDB_CODE_SUCCESS; } +#if 0 // step 2: retrieve qtaskinfo items from the persistence file(rsma/qtaskinfo) and restore if (tdRSmaRestoreQTaskInfoReload(pSma, type, qtaskFileVer) < 0) { goto _err; } +#endif // step 3: reload ts data from checkpoint if (tdRSmaRestoreTSDataReload(pSma) < 0) { @@ -1440,6 +1478,50 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIte return TSDB_CODE_SUCCESS; } +int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { + SSma *pSma = pRSmaStat->pSma; + SVnode *pVnode = pSma->pVnode; + int32_t vid = SMA_VID(pSma); + + if (taosHashGetSize(pInfoHash) <= 0) { + return TSDB_CODE_SUCCESS; + } + + int64_t fsMaxVer = tdRSmaFSMaxVer(pSma, pRSmaStat); + if (pRSmaStat->commitAppliedVer <= fsMaxVer) { + smaDebug("vgId:%d, rsma persist, no need as applied %" PRIi64 " not larger than fsMaxVer %" PRIi64, vid, + pRSmaStat->commitAppliedVer, fsMaxVer); + return TSDB_CODE_SUCCESS; + } + + void *infoHash = NULL; + while ((infoHash = taosHashIterate(pInfoHash, infoHash))) { + SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash; + + if (RSMA_INFO_IS_DEL(pRSmaInfo)) { + continue; + } + + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pRSmaInfo, i); + if (pItem && pItem->pStreamState) { + if (streamStateCommit(pItem->pStreamState) < 0) { + terrno = TSDB_CODE_RSMA_STREAM_STATE_COMMIT; + goto _err; + } + smaDebug("vgId:%d, rsma persist, stream state commit success, table %" PRIi64 " level %d", vid, pRSmaInfo->suid, + i + 1); + } + } + } + + return TSDB_CODE_SUCCESS; +_err: + smaError("vgId:%d, rsma persist failed since %s", vid, terrstr()); + return TSDB_CODE_FAILED; +} + +#if 0 int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { SSma *pSma = pRSmaStat->pSma; SVnode *pVnode = pSma->pVnode; @@ -1459,7 +1541,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { int64_t fsMaxVer = tdRSmaFSMaxVer(pSma, pRSmaStat); if (pRSmaStat->commitAppliedVer <= fsMaxVer) { smaDebug("vgId:%d, rsma persist, no need as applied %" PRIi64 " not larger than fsMaxVer %" PRIi64, vid, - pRSmaStat->commitAppliedVer, fsMaxVer); + pRSmaStat->commitAppliedVer, fsMaxVer); return TSDB_CODE_SUCCESS; } @@ -1579,6 +1661,8 @@ _err: return TSDB_CODE_FAILED; } +#endif + /** * @brief trigger to get rsma result in async mode * @@ -1822,7 +1906,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { while (true) { // step 1: rsma exec - consume data in buffer queue for all suids - if (type == RSMA_EXEC_OVERFLOW || type == RSMA_EXEC_COMMIT) { + if (type == RSMA_EXEC_OVERFLOW) { void *pIter = NULL; while ((pIter = taosHashIterate(infoHash, pIter))) { SRSmaInfo *pInfo = *(SRSmaInfo **)pIter; @@ -1878,42 +1962,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); } } - if (type == RSMA_EXEC_COMMIT) { - if (atomic_load_64(&pRSmaStat->nBufItems) <= 0) { - break; - } else { - // commit should wait for all items be consumed - continue; - } - } - } -#if 0 - else if (type == RSMA_EXEC_COMMIT) { - while (pIter) { - SRSmaInfo *pInfo = *(SRSmaInfo **)pIter; - if (taosQueueItemSize(pInfo->iQueue)) { - if (atomic_val_compare_exchange_8(&pInfo->assigned, 0, 1) == 0) { - taosReadAllQitems(pInfo->iQueue, pInfo->iQall); // queue has mutex lock - int32_t qallItemSize = taosQallItemSize(pInfo->iQall); - if (qallItemSize > 0) { - atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); - nIdle = 0; - - // batch exec - tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type); - } - - // tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr); - atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); - } - } - ASSERT(taosQueueItemSize(pInfo->iQueue) == 0); - pIter = taosHashIterate(infoHash, pIter); - } - break; - } -#endif - else { + } else { ASSERT(0); } @@ -1926,7 +1975,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { if ((pEnv->flag & SMA_ENV_FLG_CLOSE) && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) { smaDebug("vgId:%d, exec task end, flag:%" PRIi8 ", nBufItems:%" PRIi64, SMA_VID(pSma), pEnv->flag, - atomic_load_64(&pRSmaStat->nBufItems)); + atomic_load_64(&pRSmaStat->nBufItems)); break; } } diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index e2cb51f586..6c32fbbc84 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -204,7 +204,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char } SBatchDeleteReq deleteReq; - SSubmitReq *pSubmitReq = tqBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, true, + SSubmitReq *pSubmitReq = tqBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq); if (!pSubmitReq) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index c8841e5e16..76f3c1b12d 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -51,6 +51,20 @@ void tqCleanUp() { } } +static void destroySTqHandle(void* data) { + STqHandle* pData = (STqHandle*)data; + qDestroyTask(pData->execHandle.task); + if (pData->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + } else if (pData->execHandle.subType == TOPIC_SUB_TYPE__DB) { + tqCloseReader(pData->execHandle.pExecReader); + walCloseReader(pData->pWalReader); + taosHashCleanup(pData->execHandle.execDb.pFilterOutTbUid); + } else if (pData->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { + walCloseReader(pData->pWalReader); + tqCloseReader(pData->execHandle.pExecReader); + } +} + STQ* tqOpen(const char* path, SVnode* pVnode) { STQ* pTq = taosMemoryCalloc(1, sizeof(STQ)); if (pTq == NULL) { @@ -62,6 +76,8 @@ STQ* tqOpen(const char* path, SVnode* pVnode) { pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK); + taosHashSetFreeFp(pTq->pHandle, destroySTqHandle); + pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); pTq->pCheckInfo = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK); @@ -141,11 +157,8 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - if (pRsp->withSchema) { - ASSERT(taosArrayGetSize(pRsp->blockSchema) == pRsp->blockNum); - } else { - ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0); - } + ASSERT(!pRsp->withSchema); + ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0); if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { if (pRsp->blockNum > 0) { @@ -466,6 +479,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew); +#if 1 + +#endif if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { code = -1; } @@ -520,6 +536,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { int64_t fetchVer = fetchOffsetNew.version + 1; pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); if (pCkHead == NULL) { + tDeleteSTaosxRsp(&taosxRsp); return -1; } @@ -580,14 +597,17 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { code = -1; taosMemoryFree(pCkHead); + tDeleteSTaosxRsp(&taosxRsp); return code; } code = 0; if (pCkHead) taosMemoryFree(pCkHead); + tDeleteSTaosxRsp(&taosxRsp); return code; } } } + tDeleteSTaosxRsp(&taosxRsp); return 0; } @@ -647,7 +667,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe tqError("vgId:%d, build new consumer handle %s for consumer %d, but old consumerId is %ld", req.vgId, req.subKey, req.newConsumerId, req.oldConsumerId); } - ASSERT(req.newConsumerId != -1); + if (req.newConsumerId == -1) { + tqError("vgId:%d, tq invalid rebalance request, new consumerId %ld", req.vgId, req.newConsumerId); + return 0; + } STqHandle tqHandle = {0}; pHandle = &tqHandle; /*taosInitRWLatch(&pExec->lock);*/ @@ -760,7 +783,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) { // expand executor if (pTask->taskLevel == TASK_LEVEL__SOURCE) { - pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask); + pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false); if (pTask->pState == NULL) { return -1; } @@ -774,7 +797,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) { pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle); ASSERT(pTask->exec.executor); } else if (pTask->taskLevel == TASK_LEVEL__AGG) { - pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask); + pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false); if (pTask->pState == NULL) { return -1; } @@ -859,6 +882,9 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { taosArrayDestroy(pRes->uidList); + int32_t* pRef = taosMemoryMalloc(sizeof(int32_t)); + *pRef = 1; + void* pIter = NULL; while (1) { pIter = taosHashIterate(pTq->pStreamMeta->pTasks, pIter); @@ -868,6 +894,33 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { qDebug("delete req enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver); + if (!failed) { + SStreamRefDataBlock* pRefBlock = taosAllocateQitem(sizeof(SStreamRefDataBlock), DEF_QITEM); + pRefBlock->type = STREAM_INPUT__REF_DATA_BLOCK; + pRefBlock->pBlock = pDelBlock; + pRefBlock->dataRef = pRef; + atomic_add_fetch_32(pRefBlock->dataRef, 1); + + if (streamTaskInput(pTask, (SStreamQueueItem*)pRefBlock) < 0) { + qError("stream task input del failed, task id %d", pTask->taskId); + continue; + } + if (streamSchedExec(pTask) < 0) { + qError("stream task launch failed, task id %d", pTask->taskId); + continue; + } + } else { + streamTaskInputFail(pTask); + } + } + int32_t ref = atomic_sub_fetch_32(pRef, 1); + ASSERT(ref >= 0); + if (ref == 0) { + taosMemoryFree(pDelBlock); + taosMemoryFree(pRef); + } + +#if 0 SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); pStreamBlock->type = STREAM_INPUT__DATA_BLOCK; pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock)); @@ -891,6 +944,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { } } blockDataDestroy(pDelBlock); +#endif return 0; } @@ -1028,6 +1082,7 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) { SDecoder decoder; tDecoderInit(&decoder, msgBody, msgLen); tDecodeStreamRetrieveReq(&decoder, &req); + tDecoderClear(&decoder); int32_t taskId = req.dstTaskId; SStreamTask* pTask = streamMetaGetTask(pTq->pStreamMeta, taskId); if (pTask) { @@ -1036,6 +1091,7 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) { .code = 0, }; streamProcessRetrieveReq(pTask, &req, &rsp); + tDeleteStreamRetrieveReq(&req); return 0; } else { return -1; diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index d00907f677..a24f920235 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -243,14 +243,15 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp } if (pHandle->fetchMeta) { SSubmitBlk* pBlk = pReader->pBlock; - if (pBlk->schemaLen > 0) { + int32_t schemaLen = htonl(pBlk->schemaLen); + if (schemaLen > 0) { if (pRsp->createTableNum == 0) { pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); pRsp->createTableReq = taosArrayInit(0, sizeof(void*)); } - void* createReq = taosMemoryCalloc(1, pBlk->schemaLen); - memcpy(createReq, pBlk->data, pBlk->schemaLen); - taosArrayPush(pRsp->createTableLen, &pBlk->schemaLen); + void* createReq = taosMemoryCalloc(1, schemaLen); + memcpy(createReq, pBlk->data, schemaLen); + taosArrayPush(pRsp->createTableLen, &schemaLen); taosArrayPush(pRsp->createTableReq, &createReq); pRsp->createTableNum++; } @@ -277,14 +278,15 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp } if (pHandle->fetchMeta) { SSubmitBlk* pBlk = pReader->pBlock; - if (pBlk->schemaLen > 0) { + int32_t schemaLen = htonl(pBlk->schemaLen); + if (schemaLen > 0) { if (pRsp->createTableNum == 0) { pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); pRsp->createTableReq = taosArrayInit(0, sizeof(void*)); } - void* createReq = taosMemoryCalloc(1, pBlk->schemaLen); - memcpy(createReq, pBlk->data, pBlk->schemaLen); - taosArrayPush(pRsp->createTableLen, &pBlk->schemaLen); + void* createReq = taosMemoryCalloc(1, schemaLen); + memcpy(createReq, pBlk->data, schemaLen); + taosArrayPush(pRsp->createTableLen, &schemaLen); taosArrayPush(pRsp->createTableReq, &createReq); pRsp->createTableNum++; } diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 5c1d5d65b4..7097591c35 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -145,8 +145,10 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore) { ASSERT(0); tqError("write offset incomplete, len %d, write len %" PRId64, bodyLen, writeLen); taosHashCancelIterate(pStore->pHash, pIter); + taosMemoryFree(buf); return -1; } + taosMemoryFree(buf); } // close and rename file taosCloseFile(&pFile); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 375130fa2c..8e5f328efa 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -80,6 +80,13 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ void* buf = taosMemoryMalloc(tlen); if (NULL == buf) { taosArrayDestroy(reqNew.pArray); + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosMemoryFreeClear(pCreateReq->comment); + if (pCreateReq->type == TSDB_CHILD_TABLE) { + taosArrayDestroy(pCreateReq->ctb.tagName); + } + } goto end; } SEncoder coderNew = {0}; @@ -91,6 +98,14 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ taosMemoryFree(buf); taosArrayDestroy(reqNew.pArray); } + + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosMemoryFreeClear(pCreateReq->comment); + if (pCreateReq->type == TSDB_CHILD_TABLE) { + taosArrayDestroy(pCreateReq->ctb.tagName); + } + } } else if (msgType == TDMT_VND_ALTER_TABLE) { SVAlterTbReq req = {0}; diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 522bf46aa1..16c2a5d033 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -48,7 +48,7 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl return 0; } -SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pTSchema, bool createTb, +SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchema* pTSchema, SSchemaWrapper* pTagSchemaWrapper, bool createTb, int64_t suid, const char* stbFullName, SBatchDeleteReq* pDeleteReq) { SSubmitReq* ret = NULL; SArray* schemaReqs = NULL; @@ -89,6 +89,32 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem return NULL; } + SArray *tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); + char tagNameStr[TSDB_COL_NAME_LEN] = {0}; + strcpy(tagNameStr, "group_id"); + taosArrayPush(tagName, tagNameStr); + +// STag* pTag = NULL; +// taosArrayClear(tagArray); +// SArray *tagName = taosArrayInit(1, TSDB_COL_NAME_LEN); +// for(int j = 0; j < pTagSchemaWrapper->nCols; j++){ +// STagVal tagVal = { +// .cid = pTagSchemaWrapper->pSchema[j].colId, +// .type = pTagSchemaWrapper->pSchema[j].type, +// .i64 = (int64_t)pDataBlock->info.groupId, +// }; +// taosArrayPush(tagArray, &tagVal); +// taosArrayPush(tagName, pTagSchemaWrapper->pSchema[j].name); +// } +// +// tTagNew(tagArray, 1, false, &pTag); +// if (pTag == NULL) { +// terrno = TSDB_CODE_OUT_OF_MEMORY; +// taosArrayDestroy(tagArray); +// taosArrayDestroy(tagName); +// return NULL; +// } + SVCreateTbReq createTbReq = {0}; SName name = {0}; tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); @@ -99,6 +125,8 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem createTbReq.type = TSDB_CHILD_TABLE; createTbReq.ctb.suid = suid; createTbReq.ctb.pTag = (uint8_t*)pTag; + createTbReq.ctb.tagNum = taosArrayGetSize(tagArray); + createTbReq.ctb.tagName = tagName; int32_t code; int32_t schemaLen; @@ -113,6 +141,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem void* schemaStr = taosMemoryMalloc(schemaLen); if (schemaStr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tdDestroySVCreateTbReq(&createTbReq); return NULL; } taosArrayPush(schemaReqs, &schemaStr); @@ -123,6 +152,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem code = tEncodeSVCreateTbReq(&encoder, &createTbReq); if (code < 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tdDestroySVCreateTbReq(&createTbReq); return NULL; } tEncoderClear(&encoder); @@ -231,7 +261,7 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { ASSERT(pTask->tbSink.pTSchema); deleteReq.deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq)); - SSubmitReq* submitReq = tqBlockToSubmit(pVnode, pRes, pTask->tbSink.pTSchema, true, pTask->tbSink.stbUid, + SSubmitReq* submitReq = tqBlockToSubmit(pVnode, pRes, pTask->tbSink.pTSchema, pTask->tbSink.pSchemaWrapper, true, pTask->tbSink.stbUid, pTask->tbSink.stbFullName, &deleteReq); tqDebug("vgId:%d, task %d convert blocks over, put into write-queue", TD_VID(pVnode), pTask->taskId); @@ -274,7 +304,6 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { }; if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) { - rpcFreeCont(submitReq); tqDebug("failed to put into write-queue since %s", terrstr()); } } diff --git a/source/dnode/vnode/src/tsdb/tsdbCompress.c b/source/dnode/vnode/src/tsdb/tsdbCompress.c deleted file mode 100644 index 76be7c1070..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbCompress.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "tsdb.h" - -// Integer ===================================================== -typedef struct { - int8_t rawCopy; - int64_t prevVal; - int32_t nVal; - int32_t nBuf; - uint8_t *pBuf; -} SIntCompressor; - -#define I64_SAFE_ADD(a, b) (((a) >= 0 && (b) <= INT64_MAX - (b)) || ((a) < 0 && (b) >= INT64_MIN - (a))) -#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL) - -static int32_t tsdbCmprI64(SIntCompressor *pCompressor, int64_t val) { - int32_t code = 0; - - // raw copy - if (pCompressor->rawCopy) { - memcpy(pCompressor->pBuf + pCompressor->nBuf, &val, sizeof(val)); - pCompressor->nBuf += sizeof(val); - pCompressor->nVal++; - goto _exit; - } - - if (!I64_SAFE_ADD(val, pCompressor->prevVal)) { - pCompressor->rawCopy = 1; - // TODO: decompress and copy - pCompressor->nVal++; - goto _exit; - } - - int64_t diff = val - pCompressor->prevVal; - uint8_t zigzag = ZIGZAGE(int64_t, diff); - - if (zigzag >= SIMPLE8B_MAX) { - pCompressor->rawCopy = 1; - // TODO: decompress and copy - pCompressor->nVal++; - goto _exit; - } - -_exit: - return code; -} - -// Timestamp ===================================================== - -// Float ===================================================== \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 45fe29f0fa..5f03a82bc0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -320,6 +320,7 @@ void tLDataIterNextBlock(SLDataIter *pIter) { pIter->pSttBlk = NULL; if (index != -1) { + pIter->iSttBlk = index; pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk); } } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 14dbfbd63e..ca6f6346a6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -193,6 +193,8 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader); static int32_t doBuildDataBlock(STsdbReader* pReader); static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader); +static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo); +static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader); static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); } @@ -893,7 +895,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn if (pData->cid < pColData->info.colId) { colIndex += 1; } else if (pData->cid == pColData->info.colId) { - if (pData->flag == HAS_NONE || pData->flag == HAS_NULL) { + if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL|HAS_NONE)) { colDataAppendNNULL(pColData, 0, remain); } else { if (IS_NUMERIC_TYPE(pColData->info.type) && asc) { @@ -1537,7 +1539,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* minKey = k.ts; } - if (minKey > key && pBlockData->nRow > 0) { + if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) { minKey = key; } } else { @@ -1550,7 +1552,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* minKey = k.ts; } - if (minKey < key && pBlockData->nRow > 0) { + if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) { minKey = key; } } @@ -1688,7 +1690,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - if (pBlockData->nRow > 0) { + if (hasDataInFileBlock(pBlockData, pDumpInfo)) { // no last block available, only data block exists if (!hasDataInLastBlock(pLastBlockReader)) { return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); @@ -1753,7 +1755,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* tsLast = getCurrentKeyInLastBlock(pLastBlockReader); } - int64_t key = pBlockData->aTSKEY[pDumpInfo->rowIndex]; + int64_t key = hasDataInFileBlock(pBlockData, pDumpInfo)? pBlockData->aTSKEY[pDumpInfo->rowIndex]:INT64_MIN; TSDBKEY k = TSDBROW_KEY(pRow); TSDBKEY ik = TSDBROW_KEY(piRow); @@ -1769,7 +1771,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = ik.ts; } - if (minKey > key && pBlockData->nRow > 0) { + if (minKey > key && hasDataInFileBlock(pBlockData, pDumpInfo)) { minKey = key; } @@ -1786,7 +1788,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = ik.ts; } - if (minKey < key && pBlockData->nRow > 0) { + if (minKey < key && hasDataInFileBlock(pBlockData, pDumpInfo)) { minKey = key; } @@ -2021,6 +2023,13 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) { } static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; } +bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) { + if (pBlockData->nRow > 0) { + ASSERT(pBlockData->nRow == pDumpInfo->totalRows); + } + + return pBlockData->nRow > 0 && (!pDumpInfo->allDumped); +} int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader) { @@ -2052,7 +2061,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - int64_t key = (pBlockData->nRow > 0) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN; + int64_t key = (pBlockData->nRow > 0 && (!pDumpInfo->allDumped)) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN; if (pBlockScanInfo->iter.hasVal && pBlockScanInfo->iiter.hasVal) { return doMergeMultiLevelRows(pReader, pBlockScanInfo, pBlockData, pLastBlockReader); } else { @@ -2664,8 +2673,11 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret int8_t* pLevel) { if (VND_IS_RSMA(pVnode)) { int8_t level = 0; - int64_t now = taosGetTimestamp(pVnode->config.tsdbCfg.precision); - int64_t offset = TSDB_TICK_PER_SECOND(pVnode->config.tsdbCfg.precision); + int8_t precision = pVnode->config.tsdbCfg.precision; + int64_t now = taosGetTimestamp(precision); + int64_t offset = tsQueryRsmaTolerance * ((precision == TSDB_TIME_PRECISION_MILLI) ? 1 + : (precision == TSDB_TIME_PRECISION_MICRO) ? 1000 + : 1000000); for (int8_t i = 0; i < TSDB_RETENTION_MAX; ++i) { SRetention* pRetention = retentions + level; @@ -3290,9 +3302,31 @@ void* tsdbGetIvtIdx(SMeta* pMeta) { uint64_t getReaderMaxVersion(STsdbReader* pReader) { return pReader->verRange.maxVer; } + +static int32_t doOpenReaderImpl(STsdbReader* pReader) { + SDataBlockIter* pBlockIter = &pReader->status.blockIter; + + initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); + resetDataBlockIterator(&pReader->status.blockIter, pReader->order); + + // no data in files, let's try buffer in memory + if (pReader->status.fileIter.numOfFiles == 0) { + pReader->status.loadFromFile = false; + return TSDB_CODE_SUCCESS; + } else { + return initForFirstBlockInFile(pReader, pBlockIter); + } +} + // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader, const char* idstr) { + STimeWindow window = pCond->twindows; + if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { + pCond->twindows.skey += 1; + pCond->twindows.ekey -= 1; + } + int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, 4096, idstr); if (code != TSDB_CODE_SUCCESS) { goto _err; @@ -3300,21 +3334,20 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl // check for query time window STsdbReader* pReader = *ppReader; - if (isEmptyQueryTimeWindow(&pReader->window)) { + if (isEmptyQueryTimeWindow(&pReader->window) && pCond->type == TIMEWINDOW_RANGE_CONTAINED) { tsdbDebug("%p query window not overlaps with the data set, no result returned, %s", pReader, pReader->idStr); return TSDB_CODE_SUCCESS; } if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { // update the SQueryTableDataCond to create inner reader - STimeWindow w = pCond->twindows; - int32_t order = pCond->order; + int32_t order = pCond->order; if (order == TSDB_ORDER_ASC) { - pCond->twindows.ekey = pCond->twindows.skey; + pCond->twindows.ekey = window.skey; pCond->twindows.skey = INT64_MIN; pCond->order = TSDB_ORDER_DESC; } else { - pCond->twindows.skey = pCond->twindows.ekey; + pCond->twindows.skey = window.ekey; pCond->twindows.ekey = INT64_MAX; pCond->order = TSDB_ORDER_ASC; } @@ -3326,12 +3359,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl } if (order == TSDB_ORDER_ASC) { - pCond->twindows.skey = w.ekey; + pCond->twindows.skey = window.ekey; pCond->twindows.ekey = INT64_MAX; } else { pCond->twindows.skey = INT64_MIN; - pCond->twindows.ekey = w.ekey; + pCond->twindows.ekey = window.ekey; } + pCond->order = order; + code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr); if (code != TSDB_CODE_SUCCESS) { goto _err; @@ -3340,20 +3375,22 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl // NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here. if (pCond->suid != 0) { - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, /*pCond->endVersion*/ -1); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, -1); if (pReader->pSchema == NULL) { tsdbError("failed to get table schema, suid:%"PRIu64", ver:%"PRId64" , %s", pReader->suid, -1, pReader->idStr); } } else if (taosArrayGetSize(pTableList) > 0) { STableKeyInfo* pKey = taosArrayGet(pTableList, 0); - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, /*pCond->endVersion*/ -1); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, -1); if (pReader->pSchema == NULL) { tsdbError("failed to get table schema, uid:%"PRIu64", ver:%"PRId64" , %s", pKey->uid, -1, pReader->idStr); } } + STsdbReader* p = pReader->innerReader[0] != NULL? pReader->innerReader[0]:pReader; + int32_t numOfTables = taosArrayGetSize(pTableList); - pReader->status.pTableMap = createDataBlockScanInfo(pReader, pTableList->pData, numOfTables); + pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList->pData, numOfTables); if (pReader->status.pTableMap == NULL) { tsdbReaderClose(pReader); *ppReader = NULL; @@ -3368,40 +3405,36 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl } if (pReader->type == TIMEWINDOW_RANGE_CONTAINED) { - SDataBlockIter* pBlockIter = &pReader->status.blockIter; - - initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader); - resetDataBlockIterator(&pReader->status.blockIter, pReader->order); - - // no data in files, let's try buffer in memory - if (pReader->status.fileIter.numOfFiles == 0) { - pReader->status.loadFromFile = false; - } else { - code = initForFirstBlockInFile(pReader, pBlockIter); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + code = doOpenReaderImpl(pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; } } else { - STsdbReader* pPrevReader = pReader->innerReader[0]; - SDataBlockIter* pBlockIter = &pPrevReader->status.blockIter; + STsdbReader* pPrevReader = pReader->innerReader[0]; + STsdbReader* pNextReader = pReader->innerReader[1]; - code = tsdbTakeReadSnap(pPrevReader->pTsdb, &pPrevReader->pReadSnap, pReader->idStr); + // we need only one row + pPrevReader->capacity = 1; + pPrevReader->status.pTableMap = pReader->status.pTableMap; + pPrevReader->pReadSnap = pReader->pReadSnap; + + pNextReader->capacity = 1; + pNextReader->status.pTableMap = pReader->status.pTableMap; + pNextReader->pReadSnap = pReader->pReadSnap; + + code = doOpenReaderImpl(pPrevReader); if (code != TSDB_CODE_SUCCESS) { - goto _err; + return code; } - initFilesetIterator(&pPrevReader->status.fileIter, pPrevReader->pReadSnap->fs.aDFileSet, pPrevReader); - resetDataBlockIterator(&pPrevReader->status.blockIter, pPrevReader->order); + code = doOpenReaderImpl(pNextReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } - // no data in files, let's try buffer in memory - if (pPrevReader->status.fileIter.numOfFiles == 0) { - pPrevReader->status.loadFromFile = false; - } else { - code = initForFirstBlockInFile(pPrevReader, pBlockIter); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + code = doOpenReaderImpl(pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; } } @@ -3418,6 +3451,19 @@ void tsdbReaderClose(STsdbReader* pReader) { return; } + { + if (pReader->innerReader[0] != NULL) { + pReader->innerReader[0]->status.pTableMap = NULL; + pReader->innerReader[0]->pReadSnap = NULL; + + pReader->innerReader[1]->status.pTableMap = NULL; + pReader->innerReader[1]->pReadSnap = NULL; + + tsdbReaderClose(pReader->innerReader[0]); + tsdbReaderClose(pReader->innerReader[1]); + } + } + SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; taosMemoryFreeClear(pSupInfo->plist); @@ -3508,32 +3554,32 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return false; } - if (pReader->innerReader[0] != NULL) { + if (pReader->innerReader[0] != NULL && pReader->step == 0) { bool ret = doTsdbNextDataBlock(pReader->innerReader[0]); + resetDataBlockScanInfo(pReader->innerReader[0]->status.pTableMap, pReader->innerReader[0]->window.ekey); + pReader->step = EXTERNAL_ROWS_PREV; + if (ret) { - pReader->step = EXTERNAL_ROWS_PREV; return ret; } - - tsdbReaderClose(pReader->innerReader[0]); - pReader->innerReader[0] = NULL; } - pReader->step = EXTERNAL_ROWS_MAIN; + if (pReader->step == EXTERNAL_ROWS_PREV) { + pReader->step = EXTERNAL_ROWS_MAIN; + } + bool ret = doTsdbNextDataBlock(pReader); if (ret) { return ret; } - if (pReader->innerReader[1] != NULL) { + if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) { + resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey); bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]); + pReader->step = EXTERNAL_ROWS_NEXT; if (ret1) { - pReader->step = EXTERNAL_ROWS_NEXT; return ret1; } - - tsdbReaderClose(pReader->innerReader[1]); - pReader->innerReader[1] = NULL; } return false; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 65d4e9aaf1..a941b5955c 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -676,6 +676,18 @@ static void vnodeLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsm static void vnodeRestoreFinish(struct SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; + + do { + int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE); + if (itemSize == 0) { + vInfo("vgId:%d, apply queue is empty, restore finish", pVnode->config.vgId); + break; + } else { + vInfo("vgId:%d, restore not finish since %d items in apply queue", pVnode->config.vgId); + taosMsleep(10); + } + } while (true); + pVnode->restored = true; vDebug("vgId:%d, sync restore finished", pVnode->config.vgId); } diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 585b33930c..3c4cc9f7a2 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -13,15 +13,15 @@ * along with this program. If not, see . */ -#include "trpc.h" -#include "query.h" -#include "tname.h" #include "catalogInt.h" +#include "query.h" #include "systable.h" +#include "tname.h" #include "tref.h" +#include "trpc.h" -int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbMetaTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_META; @@ -45,13 +45,14 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbMetasTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbMetasTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_META_BATCH; @@ -69,14 +70,14 @@ int32_t ctgInitGetTbMetasTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", - pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbMetaNum); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbMetaNum); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - char *dbFName = (char*)param; +int32_t ctgInitGetDbVgTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + char* dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_VGROUP; @@ -94,13 +95,14 @@ int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - char *dbFName = (char*)param; +int32_t ctgInitGetDbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + char* dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_CFG; @@ -118,13 +120,14 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - char *dbFName = (char*)param; +int32_t ctgInitGetDbInfoTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + char* dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_INFO; @@ -142,14 +145,14 @@ int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } - -int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbHashTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_HASH; @@ -173,13 +176,14 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tableName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tableName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbHashsTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbHashsTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_HASH_BATCH; @@ -197,14 +201,13 @@ int32_t ctgInitGetTbHashsTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", - pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbHashNum); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbHashNum); return TSDB_CODE_SUCCESS; } - -int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) { +int32_t ctgInitGetQnodeTask(SCtgJob* pJob, int32_t taskIdx, void* param) { SCtgTask task = {0}; task.type = CTG_TASK_GET_QNODE; @@ -219,7 +222,7 @@ int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) { return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) { +int32_t ctgInitGetDnodeTask(SCtgJob* pJob, int32_t taskIdx, void* param) { SCtgTask task = {0}; task.type = CTG_TASK_GET_DNODE; @@ -234,8 +237,8 @@ int32_t ctgInitGetDnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) { return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - char *name = (char*)param; +int32_t ctgInitGetIndexTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + char* name = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_INDEX; @@ -253,13 +256,14 @@ int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, indexFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, indexFName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - char *name = (char*)param; +int32_t ctgInitGetUdfTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + char* name = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_UDF; @@ -277,14 +281,15 @@ int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, udfName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, udfName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SUserAuthInfo *user = (SUserAuthInfo*)param; - SCtgTask task = {0}; +int32_t ctgInitGetUserTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SUserAuthInfo* user = (SUserAuthInfo*)param; + SCtgTask task = {0}; task.type = CTG_TASK_GET_USER; task.taskId = taskIdx; @@ -301,12 +306,13 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, user:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), user->user); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, user:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), user->user); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetSvrVerTask(SCtgJob *pJob, int32_t taskIdx, void* param) { +int32_t ctgInitGetSvrVerTask(SCtgJob* pJob, int32_t taskIdx, void* param) { SCtgTask task = {0}; task.type = CTG_TASK_GET_SVR_VER; @@ -320,8 +326,8 @@ int32_t ctgInitGetSvrVerTask(SCtgJob *pJob, int32_t taskIdx, void* param) { return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbIndexTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_INDEX; @@ -344,13 +350,14 @@ int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { - SName *name = (SName*)param; +int32_t ctgInitGetTbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) { + SName* name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_CFG; @@ -373,13 +380,13 @@ int32_t ctgInitGetTbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } - -int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, const SCatalogReq* pReq) { +int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, const SCatalogReq* pReq) { SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); SHashObj* pTb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (NULL == pDb || NULL == pTb) { @@ -427,7 +434,7 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con for (int32_t i = 0; i < pJob->tbCfgNum; ++i) { SName* name = taosArrayGet(pReq->pTableCfg, i); - char dbFName[TSDB_DB_FNAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(name, dbFName); taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN); } @@ -455,7 +462,6 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con taosHashCleanup(pTb); - for (int32_t i = 0; i < pJob->tbIndexNum; ++i) { SName* name = taosArrayGet(pReq->pTableIndex, i); ctgDropTbIndexEnqueue(pCtg, name, true); @@ -464,7 +470,7 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con return TSDB_CODE_SUCCESS; } -int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *taskId) { +int32_t ctgInitTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1); CTG_LOCK(CTG_WRITE, &pJob->taskLock); @@ -478,7 +484,8 @@ int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *tas return TSDB_CODE_SUCCESS; } -int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param) { +int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, + void* param) { int32_t code = 0; int32_t tbMetaNum = (int32_t)ctgGetTablesReqNum(pReq->pTableMeta); int32_t dbVgNum = (int32_t)taosArrayGetSize(pReq->pDbVgroup); @@ -494,7 +501,8 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex); int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg); - int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum; + int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + + userNum + dbInfoNum + tbIndexNum + tbCfgNum; *job = taosMemoryCalloc(1, sizeof(SCtgJob)); if (NULL == *job) { @@ -502,13 +510,13 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgJob *pJob = *job; + SCtgJob* pJob = *job; pJob->subTaskNum = taskNum; pJob->queryId = pConn->requestId; pJob->userFp = fp; - pJob->pCtg = pCtg; - pJob->conn = *pConn; + pJob->pCtg = pCtg; + pJob->conn = *pConn; pJob->userParam = param; pJob->tbMetaNum = tbMetaNum; @@ -526,7 +534,8 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const pJob->svrVerNum = svrVerNum; #if CTG_BATCH_FETCH - pJob->pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + pJob->pBatchs = + taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (NULL == pJob->pBatchs) { ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); @@ -625,10 +634,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const taosAcquireRef(gCtgMgmt.jobPool, pJob->refId); - qDebug("QID:0x%" PRIx64 ", jobId: 0x%" PRIx64 " initialized, task num %d, forceUpdate %d", pJob->queryId, pJob->refId, taskNum, pReq->forceUpdate); + qDebug("QID:0x%" PRIx64 ", jobId: 0x%" PRIx64 " initialized, task num %d, forceUpdate %d", pJob->queryId, pJob->refId, + taskNum, pReq->forceUpdate); return TSDB_CODE_SUCCESS; - _return: ctgFreeJob(*job); @@ -658,7 +667,6 @@ int32_t ctgDumpTbMetasRes(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } - int32_t ctgDumpDbVgRes(SCtgTask* pTask) { SCtgJob* pJob = pTask->pJob; if (NULL == pJob->jobRes.pDbVgroup) { @@ -772,7 +780,6 @@ int32_t ctgDumpDnodeRes(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } - int32_t ctgDumpDbCfgRes(SCtgTask* pTask) { SCtgJob* pJob = pTask->pJob; if (NULL == pJob->jobRes.pDbCfg) { @@ -848,15 +855,15 @@ int32_t ctgDumpSvrVer(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgCallSubCb(SCtgTask *pTask) { +int32_t ctgCallSubCb(SCtgTask* pTask) { int32_t code = 0; CTG_LOCK(CTG_WRITE, &pTask->lock); int32_t parentNum = taosArrayGetSize(pTask->pParents); for (int32_t i = 0; i < parentNum; ++i) { - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); - SCtgTask* pParent = taosArrayGetP(pTask->pParents, i); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgTask* pParent = taosArrayGetP(pTask->pParents, i); pParent->subRes.code = pTask->code; if (TSDB_CODE_SUCCESS == pTask->code) { @@ -866,7 +873,7 @@ int32_t ctgCallSubCb(SCtgTask *pTask) { } } - SCtgMsgCtx *pParMsgCtx = CTG_GET_TASK_MSGCTX(pParent, -1); + SCtgMsgCtx* pParMsgCtx = CTG_GET_TASK_MSGCTX(pParent, -1); pParMsgCtx->pBatchs = pMsgCtx->pBatchs; CTG_ERR_JRET(pParent->subRes.fp(pParent)); @@ -895,7 +902,7 @@ int32_t ctgCallUserCb(void* param) { int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { SCtgJob* pJob = pTask->pJob; - int32_t code = 0; + int32_t code = 0; if (CTG_TASK_DONE == pTask->status) { return TSDB_CODE_SUCCESS; @@ -910,7 +917,8 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { int32_t taskDone = atomic_add_fetch_32(&pJob->taskDone, 1); if (taskDone < taosArrayGetSize(pJob->pTasks)) { - qDebug("QID:0x%" PRIx64 " task done: %d, total: %d", pJob->queryId, taskDone, (int32_t)taosArrayGetSize(pJob->pTasks)); + qDebug("QID:0x%" PRIx64 " task done: %d, total: %d", pJob->queryId, taskDone, + (int32_t)taosArrayGetSize(pJob->pTasks)); return TSDB_CODE_SUCCESS; } @@ -920,25 +928,25 @@ _return: pJob->jobResCode = code; - //taosSsleep(2); - //qDebug("QID:0x%" PRIx64 " ctg after sleep", pJob->queryId); + // taosSsleep(2); + // qDebug("QID:0x%" PRIx64 " ctg after sleep", pJob->queryId); taosAsyncExec(ctgCallUserCb, pJob, NULL); CTG_RET(code); } -int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgDBCache *dbCache = NULL; - SCtgTask* pTask = tReq->pTask; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgDBCache* dbCache = NULL; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); - SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; - SName* pName = ctx->pName; - int32_t flag = ctx->flag; - int32_t* vgId = &ctx->vgId; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; + SName* pName = ctx->pName; + int32_t flag = ctx->flag; + int32_t* vgId = &ctx->vgId; CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); @@ -1057,25 +1065,25 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); } -/* - else if (CTG_IS_META_CTABLE(pOut->metaType)) { - SName stbName = *pName; - strcpy(stbName.tname, pOut->tbName); - SCtgTbMetaCtx stbCtx = {0}; - stbCtx.flag = flag; - stbCtx.pName = &stbName; + /* + else if (CTG_IS_META_CTABLE(pOut->metaType)) { + SName stbName = *pName; + strcpy(stbName.tname, pOut->tbName); + SCtgTbMetaCtx stbCtx = {0}; + stbCtx.flag = flag; + stbCtx.pName = &stbName; - CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta)); - if (NULL == pOut->tbMeta) { - ctgDebug("stb no longer exist, stbName:%s", stbName.tname); - CTG_ERR_JRET(ctgRelaunchGetTbMetaTask(pTask)); + CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta)); + if (NULL == pOut->tbMeta) { + ctgDebug("stb no longer exist, stbName:%s", stbName.tname); + CTG_ERR_JRET(ctgRelaunchGetTbMetaTask(pTask)); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; + } + + memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); } - - memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); - } -*/ + */ TSWAP(pTask->res, pOut->tbMeta); @@ -1092,20 +1100,19 @@ _return: CTG_RET(code); } - -int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgDBCache *dbCache = NULL; - SCtgTask* pTask = tReq->pTask; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgDBCache* dbCache = NULL; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); - SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; - SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); - SName* pName = ctgGetFetchName(ctx->pNames, pFetch); - int32_t flag = pFetch->flag; - int32_t* vgId = &pFetch->vgId; - bool taskDone = false; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; + SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); + SName* pName = ctgGetFetchName(ctx->pNames, pFetch); + int32_t flag = pFetch->flag; + int32_t* vgId = &pFetch->vgId; + bool taskDone = false; CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); @@ -1225,25 +1232,25 @@ int32_t ctgHandleGetTbMetasRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBu memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); } -/* - else if (CTG_IS_META_CTABLE(pOut->metaType)) { - SName stbName = *pName; - strcpy(stbName.tname, pOut->tbName); - SCtgTbMetaCtx stbCtx = {0}; - stbCtx.flag = flag; - stbCtx.pName = &stbName; + /* + else if (CTG_IS_META_CTABLE(pOut->metaType)) { + SName stbName = *pName; + strcpy(stbName.tname, pOut->tbName); + SCtgTbMetaCtx stbCtx = {0}; + stbCtx.flag = flag; + stbCtx.pName = &stbName; - CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta)); - if (NULL == pOut->tbMeta) { - ctgDebug("stb no longer exist, stbName:%s", stbName.tname); - CTG_ERR_JRET(ctgRelaunchGetTbMetaTask(pTask)); + CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &stbCtx, &pOut->tbMeta)); + if (NULL == pOut->tbMeta) { + ctgDebug("stb no longer exist, stbName:%s", stbName.tname); + CTG_ERR_JRET(ctgRelaunchGetTbMetaTask(pTask)); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; + } + + memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); } - - memcpy(pOut->tbMeta, &pOut->ctbMeta, sizeof(pOut->ctbMeta)); - } -*/ + */ SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx); pRes->code = 0; @@ -1277,19 +1284,18 @@ _return: CTG_RET(code); } - -int32_t ctgHandleGetDbVgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgTask* pTask = tReq->pTask; +int32_t ctgHandleGetDbVgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; SCtgDbVgCtx* ctx = (SCtgDbVgCtx*)pTask->taskCtx; - SCatalog* pCtg = pTask->pJob->pCtg; + SCatalog* pCtg = pTask->pJob->pCtg; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); switch (reqType) { case TDMT_MND_USE_DB: { SUseDbOutput* pOut = (SUseDbOutput*)pTask->msgCtx.out; - SDBVgInfo* pDb = NULL; + SDBVgInfo* pDb = NULL; CTG_ERR_JRET(ctgGenerateVgList(pCtg, pOut->dbVgroup->vgHash, (SArray**)&pTask->res)); @@ -1304,7 +1310,6 @@ int32_t ctgHandleGetDbVgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf * break; } - _return: ctgHandleTaskEnd(pTask, code); @@ -1312,11 +1317,11 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetTbHashRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgTask* pTask = tReq->pTask; +int32_t ctgHandleGetTbHashRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; SCtgTbHashCtx* ctx = (SCtgTbHashCtx*)pTask->taskCtx; - SCatalog* pCtg = pTask->pJob->pCtg; + SCatalog* pCtg = pTask->pJob->pCtg; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1342,7 +1347,6 @@ int32_t ctgHandleGetTbHashRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf break; } - _return: ctgHandleTaskEnd(pTask, code); @@ -1350,14 +1354,14 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetTbHashsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgTask* pTask = tReq->pTask; +int32_t ctgHandleGetTbHashsRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; SCtgTbHashsCtx* ctx = (SCtgTbHashsCtx*)pTask->taskCtx; - SCatalog* pCtg = pTask->pJob->pCtg; - SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); - SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); - bool taskDone = false; + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgFetch* pFetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); + bool taskDone = false; CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); @@ -1388,9 +1392,9 @@ _return: if (code) { STablesReq* pReq = taosArrayGet(ctx->pNames, pFetch->dbIdx); - int32_t num = taosArrayGetSize(pReq->pTables); + int32_t num = taosArrayGetSize(pReq->pTables); for (int32_t i = 0; i < num; ++i) { - SMetaRes *pRes = taosArrayGet(ctx->pResList, pFetch->resIdx + i); + SMetaRes* pRes = taosArrayGet(ctx->pResList, pFetch->resIdx + i); pRes->code = code; pRes->pRes = NULL; } @@ -1408,14 +1412,13 @@ _return: CTG_RET(code); } - -int32_t ctgHandleGetTbIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetTbIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); STableIndex* pOut = (STableIndex*)pTask->msgCtx.out; - SArray* pInfo = NULL; + SArray* pInfo = NULL; CTG_ERR_JRET(ctgCloneTableIndex(pOut->pIndex, &pInfo)); pTask->res = pInfo; @@ -1432,8 +1435,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetTbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetTbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1446,8 +1449,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetDbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetDbCfgRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1460,13 +1463,12 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetDbInfoRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { +int32_t ctgHandleGetDbInfoRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { CTG_RET(TSDB_CODE_APP_ERROR); } - -int32_t ctgHandleGetQnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetQnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1479,8 +1481,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetDnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetDnodeRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1493,8 +1495,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetIndexRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1507,8 +1509,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetUdfRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetUdfRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1521,12 +1523,12 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; - SCtgTask* pTask = tReq->pTask; - SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx; - SCatalog* pCtg = pTask->pJob->pCtg; - bool pass = false; +int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; + SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx; + SCatalog* pCtg = pTask->pJob->pCtg; + bool pass = false; SGetUserAuthRsp* pOut = (SGetUserAuthRsp*)pTask->msgCtx.out; CTG_ERR_JRET(ctgProcessRspMsg(pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1541,9 +1543,11 @@ int32_t ctgHandleGetUserRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf * goto _return; } - if (ctx->user.type == AUTH_TYPE_READ && pOut->readDbs && taosHashGet(pOut->readDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) { + if (ctx->user.type == AUTH_TYPE_READ && pOut->readDbs && + taosHashGet(pOut->readDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) { pass = true; - } else if (ctx->user.type == AUTH_TYPE_WRITE && pOut->writeDbs && taosHashGet(pOut->writeDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) { + } else if (ctx->user.type == AUTH_TYPE_WRITE && pOut->writeDbs && + taosHashGet(pOut->writeDbs, ctx->user.dbFName, strlen(ctx->user.dbFName))) { pass = true; } @@ -1566,8 +1570,8 @@ _return: CTG_RET(code); } -int32_t ctgHandleGetSvrVerRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { - int32_t code = 0; +int32_t ctgHandleGetSvrVerRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); @@ -1581,16 +1585,16 @@ _return: CTG_RET(code); } -int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq *tReq, int32_t flag, SName* pName, int32_t* vgId) { - SCtgTask* pTask = tReq->pTask; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq* tReq, int32_t flag, SName* pName, int32_t* vgId) { + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - int32_t code = 0; + int32_t code = 0; if (CTG_FLAG_IS_SYS_DB(flag)) { ctgDebug("will refresh sys db tbmeta, tbName:%s", tNameGetTableName(pName)); - CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char *)pName->dbname, (char *)pName->tname, NULL, tReq)); + CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char*)pName->dbname, (char*)pName->tname, NULL, tReq)); } if (CTG_FLAG_IS_STB(flag)) { @@ -1600,8 +1604,8 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTaskReq *tReq, int32_t flag, SName* pName, int CTG_RET(ctgGetTbMetaFromMnode(pCtg, pConn, pName, NULL, tReq)); } - SCtgDBCache *dbCache = NULL; - char dbFName[TSDB_DB_FNAME_LEN] = {0}; + SCtgDBCache* dbCache = NULL; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pName, dbFName); CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache)); @@ -1631,11 +1635,11 @@ _return: CTG_RET(code); } -int32_t ctgLaunchGetTbMetaTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbMetaTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1647,7 +1651,7 @@ int32_t ctgLaunchGetTbMetaTask(SCtgTask *pTask) { } SCtgTbMetaCtx* pCtx = (SCtgTbMetaCtx*)pTask->taskCtx; - SCtgTaskReq tReq; + SCtgTaskReq tReq; tReq.pTask = pTask; tReq.msgIdx = -1; CTG_ERR_RET(ctgAsyncRefreshTbMeta(&tReq, pCtx->flag, pCtx->pName, &pCtx->vgId)); @@ -1655,11 +1659,11 @@ int32_t ctgLaunchGetTbMetaTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetTbMetasTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbMetasTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgTbMetasCtx* pCtx = (SCtgTbMetasCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; + SCtgTbMetasCtx* pCtx = (SCtgTbMetasCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; int32_t dbNum = taosArrayGetSize(pCtx->pNames); int32_t fetchIdx = 0; @@ -1683,9 +1687,9 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask *pTask) { taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum); for (int32_t i = 0; i < pCtx->fetchNum; ++i) { - SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); - SName* pName = ctgGetFetchName(pCtx->pNames, pFetch); - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); + SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); + SName* pName = ctgGetFetchName(pCtx->pNames, pFetch); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1699,14 +1703,14 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) { - int32_t code = 0; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetDbVgTask(SCtgTask* pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgDBCache *dbCache = NULL; - SCtgDbVgCtx* pCtx = (SCtgDbVgCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgDBCache* dbCache = NULL; + SCtgDbVgCtx* pCtx = (SCtgDbVgCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1740,14 +1744,14 @@ _return: CTG_RET(code); } -int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) { - int32_t code = 0; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbHashTask(SCtgTask* pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgDBCache *dbCache = NULL; - SCtgTbHashCtx* pCtx = (SCtgTbHashCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgDBCache* dbCache = NULL; + SCtgTbHashCtx* pCtx = (SCtgTbHashCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1785,16 +1789,16 @@ _return: CTG_RET(code); } -int32_t ctgLaunchGetTbHashsTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbHashsTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgTbHashsCtx* pCtx = (SCtgTbHashsCtx*)pTask->taskCtx; - SCtgDBCache *dbCache = NULL; - SCtgJob* pJob = pTask->pJob; - int32_t dbNum = taosArrayGetSize(pCtx->pNames); - int32_t fetchIdx = 0; - int32_t baseResIdx = 0; - int32_t code = 0; + SCtgTbHashsCtx* pCtx = (SCtgTbHashsCtx*)pTask->taskCtx; + SCtgDBCache* dbCache = NULL; + SCtgJob* pJob = pTask->pJob; + int32_t dbNum = taosArrayGetSize(pCtx->pNames); + int32_t fetchIdx = 0; + int32_t baseResIdx = 0; + int32_t code = 0; for (int32_t i = 0; i < dbNum; ++i) { STablesReq* pReq = taosArrayGet(pCtx->pNames, i); @@ -1805,7 +1809,8 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask *pTask) { SCtgTaskReq tReq; tReq.pTask = pTask; tReq.msgIdx = -1; - CTG_ERR_JRET(ctgGetVgInfosFromHashValue(pCtg, &tReq, dbCache->vgCache.vgInfo, pCtx, pReq->dbFName, pReq->pTables, false)); + CTG_ERR_JRET( + ctgGetVgInfosFromHashValue(pCtg, &tReq, dbCache->vgCache.vgInfo, pCtx, pReq->dbFName, pReq->pTables, false)); ctgReleaseVgInfoToCache(pCtg, dbCache); dbCache = NULL; @@ -1831,9 +1836,9 @@ int32_t ctgLaunchGetTbHashsTask(SCtgTask *pTask) { taosArraySetSize(pTask->msgCtxs, pCtx->fetchNum); for (int32_t i = 0; i < pCtx->fetchNum; ++i) { - SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); + SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, i); STablesReq* pReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1858,15 +1863,14 @@ _return: return code; } - -int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) { - int32_t code = 0; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbIndexTask(SCtgTask* pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgTbIndexCtx* pCtx = (SCtgTbIndexCtx*)pTask->taskCtx; - SArray* pRes = NULL; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgTbIndexCtx* pCtx = (SCtgTbIndexCtx*)pTask->taskCtx; + SArray* pRes = NULL; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1883,16 +1887,16 @@ int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetTbCfgTask(SCtgTask *pTask) { - int32_t code = 0; - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgTbCfgCtx* pCtx = (SCtgTbCfgCtx*)pTask->taskCtx; - SArray* pRes = NULL; - char dbFName[TSDB_DB_FNAME_LEN]; + SCtgTbCfgCtx* pCtx = (SCtgTbCfgCtx*)pTask->taskCtx; + SArray* pRes = NULL; + char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pCtx->pName, dbFName); - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1930,12 +1934,11 @@ _return: CTG_RET(code); } - -int32_t ctgLaunchGetQnodeTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetQnodeTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1944,11 +1947,11 @@ int32_t ctgLaunchGetQnodeTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetDnodeTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetDnodeTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1957,13 +1960,12 @@ int32_t ctgLaunchGetDnodeTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } - -int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetDbCfgTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgDbCfgCtx* pCtx = (SCtgDbCfgCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgDbCfgCtx* pCtx = (SCtgDbCfgCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -1973,13 +1975,13 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetDbInfoTask(SCtgTask *pTask) { - int32_t code = 0; - SCatalog* pCtg = pTask->pJob->pCtg; - SCtgDBCache *dbCache = NULL; +int32_t ctgLaunchGetDbInfoTask(SCtgTask* pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgDBCache* dbCache = NULL; SCtgDbInfoCtx* pCtx = (SCtgDbInfoCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -2013,12 +2015,12 @@ _return: CTG_RET(code); } -int32_t ctgLaunchGetIndexTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetIndexTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgIndexCtx* pCtx = (SCtgIndexCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgIndexCtx* pCtx = (SCtgIndexCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -2028,12 +2030,12 @@ int32_t ctgLaunchGetIndexTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetUdfTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetUdfTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgUdfCtx* pCtx = (SCtgUdfCtx*)pTask->taskCtx; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgUdfCtx* pCtx = (SCtgUdfCtx*)pTask->taskCtx; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -2043,14 +2045,14 @@ int32_t ctgLaunchGetUdfTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetUserTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetUserTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgUserCtx* pCtx = (SCtgUserCtx*)pTask->taskCtx; - bool inCache = false; - bool pass = false; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgUserCtx* pCtx = (SCtgUserCtx*)pTask->taskCtx; + bool inCache = false; + bool pass = false; + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -2072,11 +2074,11 @@ int32_t ctgLaunchGetUserTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchGetSvrVerTask(SCtgTask *pTask) { - SCatalog* pCtg = pTask->pJob->pCtg; +int32_t ctgLaunchGetSvrVerTask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; SRequestConnInfo* pConn = &pTask->pJob->conn; - SCtgJob* pJob = pTask->pJob; - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgJob* pJob = pTask->pJob; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); if (NULL == pMsgCtx->pBatchs) { pMsgCtx->pBatchs = pJob->pBatchs; } @@ -2086,7 +2088,7 @@ int32_t ctgLaunchGetSvrVerTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) { +int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask) { ctgResetTbMetaTask(pTask); CTG_ERR_RET(ctgLaunchGetTbMetaTask(pTask)); @@ -2094,7 +2096,7 @@ int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } -int32_t ctgGetTbCfgCb(SCtgTask *pTask) { +int32_t ctgGetTbCfgCb(SCtgTask* pTask) { int32_t code = 0; CTG_ERR_JRET(pTask->subRes.code); @@ -2124,7 +2126,6 @@ int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) { return TSDB_CODE_SUCCESS; } - int32_t ctgCompTbMetaTasks(SCtgTask* pTask, void* param, bool* equal) { SCtgTbMetaCtx* ctx = pTask->taskCtx; @@ -2145,38 +2146,38 @@ int32_t ctgCloneDbVg(SCtgTask* pTask, void** pRes) { CTG_RET(cloneDbVgInfo(pOut->dbVgroup, (SDBVgInfo**)pRes)); } - SCtgAsyncFps gCtgAsyncFps[] = { - {ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL}, - {ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL}, - {ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg}, - {ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL}, - {ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL}, - {ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks, ctgCloneTbMeta}, - {ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL}, - {ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL}, - {ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL}, - {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL}, - {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL}, - {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL}, - {ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL}, - {ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL}, - {ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL}, + {ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL}, + {ctgInitGetDnodeTask, ctgLaunchGetDnodeTask, ctgHandleGetDnodeRsp, ctgDumpDnodeRes, NULL, NULL}, + {ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg}, + {ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL}, + {ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL}, + {ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks, + ctgCloneTbMeta}, + {ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL}, + {ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL}, + {ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL}, + {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL}, + {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL}, + {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL}, + {ctgInitGetSvrVerTask, ctgLaunchGetSvrVerTask, ctgHandleGetSvrVerRsp, ctgDumpSvrVer, NULL, NULL}, + {ctgInitGetTbMetasTask, ctgLaunchGetTbMetasTask, ctgHandleGetTbMetasRsp, ctgDumpTbMetasRes, NULL, NULL}, + {ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL}, }; -int32_t ctgMakeAsyncRes(SCtgJob *pJob) { +int32_t ctgMakeAsyncRes(SCtgJob* pJob) { int32_t code = 0; int32_t taskNum = taosArrayGetSize(pJob->pTasks); for (int32_t i = 0; i < taskNum; ++i) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, i); + SCtgTask* pTask = taosArrayGet(pJob->pTasks, i); CTG_ERR_RET((*gCtgAsyncFps[pTask->type].dumpResFp)(pTask)); } return TSDB_CODE_SUCCESS; } -int32_t ctgSearchExistingTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { +int32_t ctgSearchExistingTask(SCtgJob* pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { bool equal = false; SCtgTask* pTask = NULL; int32_t code = 0; @@ -2186,7 +2187,7 @@ int32_t ctgSearchExistingTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, in int32_t taskNum = taosArrayGetSize(pJob->pTasks); for (int32_t i = 0; i < taskNum; ++i) { pTask = taosArrayGet(pJob->pTasks, i); - if (type != pTask->type) { + if (type != pTask->type) { continue; } @@ -2206,15 +2207,15 @@ _return: CTG_RET(code); } -int32_t ctgSetSubTaskCb(SCtgTask *pSub, SCtgTask *pTask) { +int32_t ctgSetSubTaskCb(SCtgTask* pSub, SCtgTask* pTask) { int32_t code = 0; CTG_LOCK(CTG_WRITE, &pSub->lock); if (CTG_TASK_DONE == pSub->status) { pTask->subRes.code = pSub->code; CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res)); - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); - SCtgMsgCtx *pSubMsgCtx = CTG_GET_TASK_MSGCTX(pSub, -1); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgMsgCtx* pSubMsgCtx = CTG_GET_TASK_MSGCTX(pSub, -1); pMsgCtx->pBatchs = pSubMsgCtx->pBatchs; CTG_ERR_JRET(pTask->subRes.fp(pTask)); @@ -2233,8 +2234,7 @@ _return: CTG_RET(code); } - -int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param) { +int32_t ctgLaunchSubTask(SCtgTask* pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param) { SCtgJob* pJob = pTask->pJob; int32_t subTaskId = -1; bool newTask = false; @@ -2254,8 +2254,8 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask)); if (newTask) { - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); - SCtgMsgCtx *pSubMsgCtx = CTG_GET_TASK_MSGCTX(pSub, -1); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgMsgCtx* pSubMsgCtx = CTG_GET_TASK_MSGCTX(pSub, -1); pSubMsgCtx->pBatchs = pMsgCtx->pBatchs; CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub)); @@ -2265,11 +2265,11 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, return TSDB_CODE_SUCCESS; } -int32_t ctgLaunchJob(SCtgJob *pJob) { +int32_t ctgLaunchJob(SCtgJob* pJob) { int32_t taskNum = taosArrayGetSize(pJob->pTasks); for (int32_t i = 0; i < taskNum; ++i) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, i); + SCtgTask* pTask = taosArrayGet(pJob->pTasks, i); qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId); CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask)); @@ -2289,6 +2289,3 @@ int32_t ctgLaunchJob(SCtgJob *pJob) { return TSDB_CODE_SUCCESS; } - - - diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 1fdf84e120..7b8c66e368 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -68,14 +68,15 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu taskMsg.pData = NULL; taskMsg.len = 0; } - + SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = rsp.msgIdx; + tReq.msgIdx = rsp.msgIdx; SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq.msgIdx); pMsgCtx->pBatchs = pBatchs; - ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s, pBatchs: %p", pJob->queryId, pTask->taskId, rsp.msgIdx, TMSG_INFO(taskMsg.msgType + 1), pBatchs); + ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s, pBatchs: %p", pJob->queryId, pTask->taskId, + rsp.msgIdx, TMSG_INFO(taskMsg.msgType + 1), pBatchs); (*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode)); } @@ -344,13 +345,14 @@ int32_t ctgHandleMsgCallback(void* param, SDataBuf* pMsg, int32_t rspCode) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgMsgCtx *pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1); pMsgCtx->pBatchs = pBatchs; #endif SCtgTaskReq tReq; tReq.pTask = pTask; tReq.msgIdx = -1; + CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, cbParam->reqType, pMsg, rspCode)); #if CTG_BATCH_FETCH @@ -361,6 +363,7 @@ int32_t ctgHandleMsgCallback(void* param, SDataBuf* pMsg, int32_t rspCode) { _return: taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); if (pJob) { taosReleaseRef(gCtgMgmt.jobPool, cbParam->refId); @@ -442,17 +445,17 @@ _return: CTG_RET(code); } -int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTaskReq* tReq, int32_t msgType, void* msg, - uint32_t msgSize) { - int32_t code = 0; - SCtgTask* pTask = tReq->pTask; +int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgTaskReq* tReq, int32_t msgType, + void* msg, uint32_t msgSize) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); - SHashObj* pBatchs = pMsgCtx->pBatchs; - SCtgJob* pJob = pTask->pJob; - SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId)); - SCtgBatch newBatch = {0}; - SBatchMsg req = {0}; - + SHashObj* pBatchs = pMsgCtx->pBatchs; + SCtgJob* pJob = pTask->pJob; + SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId)); + SCtgBatch newBatch = {0}; + SBatchMsg req = {0}; + if (NULL == pBatch) { newBatch.pMsgs = taosArrayInit(pJob->subTaskNum, sizeof(SBatchMsg)); newBatch.pTaskIds = taosArrayInit(pJob->subTaskNum, sizeof(int32_t)); @@ -487,7 +490,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT } else if (TDMT_VND_TABLE_META == msgType) { if (CTG_TASK_GET_TB_META_BATCH == pTask->type) { SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; - SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); + SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); pName = ctgGetFetchName(ctx->pNames, fetch); } else { SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; @@ -521,14 +524,14 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT if (NULL == taosArrayPush(pBatch->pMsgs, &req)) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - msg = NULL; + msg = NULL; if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } if (NULL == taosArrayPush(pBatch->pMsgIdxs, &req.msgIdx)) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - + pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES; if (vgId > 0) { @@ -539,7 +542,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT } else if (TDMT_VND_TABLE_META == msgType) { if (CTG_TASK_GET_TB_META_BATCH == pTask->type) { SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; - SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); + SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); pName = ctgGetFetchName(ctx->pNames, fetch); } else { SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; @@ -550,7 +553,7 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT CTG_ERR_JRET(TSDB_CODE_APP_ERROR); } - tNameGetFullDbName(pName, pBatch->dbFName); + tNameGetFullDbName(pName, pBatch->dbFName); } ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId, @@ -583,7 +586,7 @@ int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) { for (int32_t i = 0; i < num; ++i) { SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i); *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgIdx); - offset += sizeof(pReq->msgIdx); + offset += sizeof(pReq->msgIdx); *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType); offset += sizeof(pReq->msgType); *(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen); @@ -611,7 +614,7 @@ int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob* pJob, SHashObj* pBatchs) { ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId); CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg)); - code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->pMsgIdxs, + code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->pMsgIdxs, pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize); pBatch->pTaskIds = NULL; CTG_ERR_JRET(code); @@ -656,7 +659,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -705,7 +708,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -736,9 +739,9 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out, SCtgTaskReq* tReq) { - char* msg = NULL; - int32_t msgLen = 0; - int32_t reqType = TDMT_MND_USE_DB; + char* msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_MND_USE_DB; SCtgTask* pTask = tReq ? tReq->pTask : NULL; void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; @@ -813,7 +816,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -868,7 +871,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -919,13 +922,13 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n if (NULL == pOut) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - + CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, -1), reqType, pOut, (char*)tbFName)); #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -980,7 +983,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -1035,7 +1038,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -1066,7 +1069,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq) { - SCtgTask *pTask = tReq ? tReq->pTask : NULL; + SCtgTask* pTask = tReq ? tReq->pTask : NULL; SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName}; char* msg = NULL; SEpSet* pVnodeEpSet = NULL; @@ -1091,7 +1094,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* } CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName)); - + #if CTG_BATCH_FETCH CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen)); #else @@ -1131,8 +1134,8 @@ int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo, STableMetaOutput* out, SCtgTaskReq* tReq) { - SCtgTask *pTask = tReq ? tReq->pTask : NULL; - char dbFName[TSDB_DB_FNAME_LEN]; + SCtgTask* pTask = tReq ? tReq->pTask : NULL; + char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); int32_t reqType = TDMT_VND_TABLE_META; char tbFName[TSDB_TABLE_FNAME_LEN]; @@ -1165,7 +1168,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa .requestObjRefId = pConn->requestObjRefId, .mgmtEps = vgroupInfo->epSet}; - CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName)); + CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, tbFName)); #if CTG_BATCH_FETCH CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, tReq, reqType, msg, msgLen)); @@ -1231,7 +1234,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, &tReq, reqType, msg, msgLen)); #else SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx; @@ -1243,7 +1246,8 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S } taosArrayPush(pTaskId, &pTask->taskId); - CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen)); + CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, ctx->pVgInfo->vgId, reqType, msg, + msgLen)); #endif } @@ -1289,7 +1293,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); @@ -1338,7 +1342,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou #if CTG_BATCH_FETCH SCtgTaskReq tReq; tReq.pTask = pTask; - tReq.msgIdx = -1; + tReq.msgIdx = -1; CTG_RET(ctgAddBatch(pCtg, 0, pConn, &tReq, reqType, msg, msgLen)); #else SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 1e985a7476..dc98b05479 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -463,6 +463,7 @@ typedef struct SPartitionDataInfo { typedef struct STimeWindowAggSupp { int8_t calTrigger; int64_t waterMark; + int64_t deleteMark; TSKEY maxTs; TSKEY minTs; SColumnInfoData timeWindowData; // query time window info for scalar function execution. @@ -1064,6 +1065,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); +bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SOperatorInfo* pOperator, STimeWindowAggSupp* pTwSup); void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp); void printDataBlock(SSDataBlock* pBlock, const char* flag); uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId); @@ -1091,7 +1093,7 @@ int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupI int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup, SExecTaskInfo* pTaskInfo); int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult); -int32_t saveOutput(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize); +int32_t saveOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize); #ifdef __cplusplus } diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 55a1a1fdb9..1ade4b89e6 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -93,6 +93,7 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp strcpy(pRes->tableName, pHandle->pDeleter->tableFName); strcpy(pRes->tsColName, pHandle->pDeleter->tsColName); pRes->affectedRows = *(int64_t*)pColRes->pData; + if (pRes->affectedRows) { pRes->skey = *(int64_t*)pColSKey->pData; pRes->ekey = *(int64_t*)pColEKey->pData; @@ -102,6 +103,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey; } + qDebug("delete %ld rows, from %ld to %ld", pRes->affectedRows, pRes->skey, pRes->ekey); + pBuf->useSize += pEntry->dataLen; atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index d75f0580e1..b26603b394 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -989,7 +989,8 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod if (pNode->output) { (*numOfOutputCols) += 1; - } else { + } else if (info != NULL) { + // select distinct tbname from stb where tbname='abc'; info->output = false; } } @@ -1341,7 +1342,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi return TSDB_CODE_SUCCESS; } -void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) { taosMemoryFree(pCond->colList); } +void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) { taosMemoryFreeClear(pCond->colList); } int32_t convertFillType(int32_t mode) { int32_t type = TSDB_FILL_NONE; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index ebb96f348e..373cb451f4 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -49,6 +49,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu SStreamScanInfo* pInfo = pOperator->info; +#if 0 // TODO: if a block was set but not consumed, // prevent setting a different type of block pInfo->validBlockIndex = 0; @@ -57,6 +58,10 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu } else { taosArrayClear(pInfo->pBlockLists); } +#endif + + ASSERT(pInfo->validBlockIndex == 0); + ASSERT(taosArrayGetSize(pInfo->pBlockLists) == 0); if (type == STREAM_INPUT__MERGED_SUBMIT) { // ASSERT(numOfBlocks > 1); @@ -79,7 +84,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu } else if (type == STREAM_INPUT__DATA_BLOCK) { for (int32_t i = 0; i < numOfBlocks; ++i) { SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i]; + taosArrayPush(pInfo->pBlockLists, &pDataBlock); +#if 0 // TODO optimize SSDataBlock* p = createOneDataBlock(pDataBlock, false); p->info = pDataBlock->info; @@ -87,6 +94,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu taosArrayClear(p->pDataBlock); taosArrayAddAll(p->pDataBlock, pDataBlock->pDataBlock); taosArrayPush(pInfo->pBlockLists, &p); +#endif } pInfo->blockType = STREAM_INPUT__DATA_BLOCK; } else { @@ -100,6 +108,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu static FORCE_INLINE void streamInputBlockDataDestory(void* pBlock) { blockDataDestroy((SSDataBlock*)pBlock); } void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) { +#if 0 SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; if (!pTaskInfo || !pTaskInfo->pRoot || pTaskInfo->pRoot->numOfDownstream <= 0) { return; @@ -116,6 +125,7 @@ void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) { } else { ASSERT(0); } +#endif } int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) { @@ -264,11 +274,11 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S } int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bool isAdd) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; STableListInfo* pListInfo = &pTaskInfo->tableqinfoList; if (isAdd) { - qDebug("add %d tables id into query list, %s", (int32_t) taosArrayGetSize(tableIdList), pTaskInfo->id.str); + qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), pTaskInfo->id.str); } if (pListInfo->map == NULL) { @@ -321,6 +331,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } bool exists = false; +#if 0 for (int32_t k = 0; k < taosArrayGetSize(pListInfo->pTableList); ++k) { STableKeyInfo* pKeyInfo = taosArrayGet(pListInfo->pTableList, k); if (pKeyInfo->uid == keyInfo.uid) { @@ -328,6 +339,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo exists = true; } } +#endif if (!exists) { taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &keyInfo); @@ -878,6 +890,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pTaskInfo->tableqinfoList.pTableList, &pInfo->dataReader, NULL); + cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); pTaskInfo->streamInfo.schema = mtInfo.schema; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 0834894350..7fcd41dc3e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -81,11 +81,6 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; } -static int32_t getExprFunctionId(SExprInfo* pExprInfo) { - assert(pExprInfo != NULL && pExprInfo->pExpr != NULL && pExprInfo->pExpr->nodeType == TEXPR_UNARYEXPR_NODE); - return 0; -} - static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static void releaseQueryBuf(size_t numOfTables); @@ -1115,7 +1110,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO } } -static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep); +static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status); void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo) { if (pFilterNode == NULL || pBlock->info.rows == 0) { @@ -1126,18 +1121,17 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM // todo move to the initialization function int32_t code = filterInitFromNode((SNode*)pFilterNode, &filter, 0); - - size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - SFilterColumnParam param1 = {.numOfCols = numOfCols, .pDataBlock = pBlock->pDataBlock}; + SFilterColumnParam param1 = {.numOfCols = taosArrayGetSize(pBlock->pDataBlock), .pDataBlock = pBlock->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m1); - int8_t* rowRes = NULL; + SColumnInfoData* p = NULL; + int32_t status = 0; // todo the keep seems never to be True?? - bool keep = filterExecute(filter, pBlock, &rowRes, NULL, param1.numOfCols); + bool keep = filterExecute(filter, pBlock, &p, NULL, param1.numOfCols, &status); filterFreeInfo(filter); - extractQualifiedTupleByFilterResult(pBlock, rowRes, keep); + extractQualifiedTupleByFilterResult(pBlock, p, keep, status); if (pColMatchInfo != NULL) { for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo); ++i) { @@ -1152,16 +1146,22 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM } } - taosMemoryFree(rowRes); + colDataDestroy(p); + taosMemoryFree(p); } -void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) { +void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status) { if (keep) { return; } - if (rowRes != NULL) { - int32_t totalRows = pBlock->info.rows; + int32_t totalRows = pBlock->info.rows; + + if (status == FILTER_RESULT_ALL_QUALIFIED) { + // here nothing needs to be done + } else if (status == FILTER_RESULT_NONE_QUALIFIED) { + pBlock->info.rows = 0; + } else { SSDataBlock* px = createOneDataBlock(pBlock, true); size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -1177,7 +1177,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR int32_t numOfRows = 0; for (int32_t j = 0; j < totalRows; ++j) { - if (rowRes[j] == 0) { + if (((int8_t*)p->pData)[j] == 0) { continue; } @@ -1189,6 +1189,7 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR numOfRows += 1; } + // todo this value can be assigned directly if (pBlock->info.rows == totalRows) { pBlock->info.rows = numOfRows; } else { @@ -1197,13 +1198,10 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } blockDataDestroy(px); // fix memory leak - } else { - // do nothing - pBlock->info.rows = 0; } } -void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { // for simple group by query without interval, all the tables belong to one group result. SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SAggOperatorInfo* pAggInfo = pOperator->info; @@ -3358,6 +3356,10 @@ static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) { tDeleteSSchemaWrapper(pSchemaInfo->qsw); } +static void cleanupStreamInfo(SStreamTaskInfo* pStreamInfo) { + tDeleteSSchemaWrapper(pStreamInfo->schema); +} + static int32_t sortTableGroup(STableListInfo* pTableListInfo) { taosArrayClear(pTableListInfo->pGroupList); SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t)); @@ -4051,6 +4053,7 @@ void doDestroyTask(SExecTaskInfo* pTaskInfo) { doDestroyTableList(&pTaskInfo->tableqinfoList); destroyOperatorInfo(pTaskInfo->pRoot); cleanupTableSchemaInfo(&pTaskInfo->schemaInfo); + cleanupStreamInfo(&pTaskInfo->streamInfo); if (!pTaskInfo->localFetch.localExec) { nodesDestroyNode((SNode*)pTaskInfo->pSubplan); @@ -4176,9 +4179,8 @@ int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupI }; char* value = NULL; int32_t size = pAggSup->resultRowSize; - /*if (streamStateGet(pTaskInfo->streamInfo.pState, &key, (void**)&value, &size) < 0) {*/ - /*value = taosMemoryCalloc(1, size);*/ - /*}*/ + + tSimpleHashPut(pAggSup->pResultRowHashTable, &key, sizeof(SWinKey), NULL, 0); if (streamStateAddIfNotExist(pTaskInfo->streamInfo.pState, &key, (void**)&value, &size) < 0) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } @@ -4196,7 +4198,7 @@ int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pR return TSDB_CODE_SUCCESS; } -int32_t saveOutput(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize) { +int32_t saveOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize) { streamStatePut(pTaskInfo->streamInfo.pState, pKey, pResult, resSize); return TSDB_CODE_SUCCESS; } @@ -4252,10 +4254,10 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset); if (pCtx[j].fpSet.finalize) { - int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock); - if (TAOS_FAILED(code)) { - qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code)); - T_LONG_JMP(pTaskInfo->env, code); + int32_t code1 = pCtx[j].fpSet.finalize(&pCtx[j], pBlock); + if (TAOS_FAILED(code1)) { + qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code1)); + T_LONG_JMP(pTaskInfo->env, code1); } } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) { // do nothing, todo refactor @@ -4269,8 +4271,9 @@ int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock } } } - releaseOutputBuf(pTaskInfo, &key, pRow); + pBlock->info.rows += pRow->numOfRows; + releaseOutputBuf(pTaskInfo, &key, pRow); } blockDataUpdateTsWindow(pBlock, 0); return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index a6d718bafa..6c5c33ae29 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -637,7 +637,8 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable); tsdbSetTableId(pInfo->dataReader, pTableInfo->uid); - qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables, pInfo->currentTable, pTaskInfo->id.str); + qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables, + pInfo->currentTable, pTaskInfo->id.str); tsdbReaderReset(pInfo->dataReader, &pInfo->cond); pInfo->scanTimes = 0; @@ -919,6 +920,19 @@ _error: } static void doClearBufferedBlocks(SStreamScanInfo* pInfo) { +#if 0 + if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) { + size_t total = taosArrayGetSize(pInfo->pBlockLists); + for (int32_t i = 0; i < total; i++) { + SSDataBlock* p = taosArrayGetP(pInfo->pBlockLists, i); + taosArrayDestroy(p->pDataBlock); + taosMemoryFree(p); + } + } +#endif + taosArrayClear(pInfo->pBlockLists); + pInfo->validBlockIndex = 0; +#if 0 size_t total = taosArrayGetSize(pInfo->pBlockLists); pInfo->validBlockIndex = 0; @@ -927,6 +941,7 @@ static void doClearBufferedBlocks(SStreamScanInfo* pInfo) { blockDataDestroy(p); } taosArrayClear(pInfo->pBlockLists); +#endif } static bool isSessionWindow(SStreamScanInfo* pInfo) { @@ -1302,10 +1317,14 @@ void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + SColumnInfoData* pCalStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + SColumnInfoData* pCalEndCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); colDataAppend(pStartTsCol, pBlock->info.rows, (const char*)pStartTs, false); colDataAppend(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false); colDataAppend(pUidCol, pBlock->info.rows, (const char*)pUid, false); colDataAppend(pGpCol, pBlock->info.rows, (const char*)pGp, false); + colDataAppendNULL(pCalStartCol, pBlock->info.rows); + colDataAppendNULL(pCalEndCol, pBlock->info.rows); pBlock->info.rows++; } @@ -1330,8 +1349,9 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock // must check update info first. bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]); bool closedWin = isClosed && isSignleIntervalWindow(pInfo) && - isDeletedWindow(&win, pBlock->info.groupId, pInfo->windowSup.pIntervalAggSup); + isDeletedStreamWindow(&win, pBlock->info.groupId, pInfo->pTableScanOp, &pInfo->twAggSup); if ((update || closedWin) && out) { + qDebug("stream update check not pass, update %d, closedWin %d", update, closedWin); uint64_t gpId = closedWin && pInfo->partitionSup.needCalc ? calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId) : 0; @@ -1478,6 +1498,40 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { } } +static int32_t filterDelBlockByUid(SSDataBlock* pDst, const SSDataBlock* pSrc, SStreamScanInfo* pInfo) { + STqReader* pReader = pInfo->tqReader; + int32_t rows = pSrc->info.rows; + blockDataEnsureCapacity(pDst, rows); + + SColumnInfoData* pSrcStartCol = taosArrayGet(pSrc->pDataBlock, START_TS_COLUMN_INDEX); + uint64_t* startCol = (uint64_t*)pSrcStartCol->pData; + SColumnInfoData* pSrcEndCol = taosArrayGet(pSrc->pDataBlock, END_TS_COLUMN_INDEX); + uint64_t* endCol = (uint64_t*)pSrcEndCol->pData; + SColumnInfoData* pSrcUidCol = taosArrayGet(pSrc->pDataBlock, UID_COLUMN_INDEX); + uint64_t* uidCol = (uint64_t*)pSrcUidCol->pData; + + SColumnInfoData* pDstStartCol = taosArrayGet(pDst->pDataBlock, START_TS_COLUMN_INDEX); + SColumnInfoData* pDstEndCol = taosArrayGet(pDst->pDataBlock, END_TS_COLUMN_INDEX); + SColumnInfoData* pDstUidCol = taosArrayGet(pDst->pDataBlock, UID_COLUMN_INDEX); + int32_t j = 0; + for (int32_t i = 0; i < rows; i++) { + if (taosHashGet(pReader->tbIdHash, &uidCol[i], sizeof(uint64_t))) { + colDataAppend(pDstStartCol, j, (const char*)&startCol[i], false); + colDataAppend(pDstEndCol, j, (const char*)&endCol[i], false); + colDataAppend(pDstUidCol, j, (const char*)&uidCol[i], false); + + colDataAppendNULL(taosArrayGet(pDst->pDataBlock, GROUPID_COLUMN_INDEX), j); + colDataAppendNULL(taosArrayGet(pDst->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX), j); + colDataAppendNULL(taosArrayGet(pDst->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX), j); + j++; + } + } + pDst->info = pSrc->info; + pDst->info.rows = j; + + return 0; +} + static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -1540,9 +1594,10 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { size_t total = taosArrayGetSize(pInfo->pBlockLists); // TODO: refactor +FETCH_NEXT_BLOCK: if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) { if (pInfo->validBlockIndex >= total) { - /*doClearBufferedBlocks(pInfo);*/ + doClearBufferedBlocks(pInfo); /*pOperator->status = OP_EXEC_DONE;*/ return NULL; } @@ -1566,21 +1621,40 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } break; case STREAM_DELETE_DATA: { printDataBlock(pBlock, "stream scan delete recv"); + SSDataBlock* pDelBlock = NULL; + if (pInfo->tqReader) { + pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA); + filterDelBlockByUid(pDelBlock, pBlock, pInfo); + } else { + pDelBlock = pBlock; + } + printDataBlock(pBlock, "stream scan delete recv filtered"); if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) { - generateDeleteResultBlock(pInfo, pBlock, pInfo->pDeleteDataRes); + generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT; - printDataBlock(pBlock, "stream scan delete result"); - return pInfo->pDeleteDataRes; + printDataBlock(pDelBlock, "stream scan delete result"); + if (pInfo->pDeleteDataRes->info.rows > 0) { + return pInfo->pDeleteDataRes; + } else { + goto FETCH_NEXT_BLOCK; + } } else { pInfo->blockType = STREAM_INPUT__DATA_SUBMIT; pInfo->updateResIndex = 0; - generateScanRange(pInfo, pBlock, pInfo->pUpdateRes); + generateScanRange(pInfo, pDelBlock, pInfo->pUpdateRes); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; - printDataBlock(pBlock, "stream scan delete data"); - return pInfo->pDeleteDataRes; + printDataBlock(pDelBlock, "stream scan delete data"); + if (pInfo->tqReader) { + blockDataDestroy(pDelBlock); + } + if (pInfo->pDeleteDataRes->info.rows > 0) { + return pInfo->pDeleteDataRes; + } else { + goto FETCH_NEXT_BLOCK; + } } } break; default: @@ -1642,9 +1716,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { int32_t totBlockNum = taosArrayGetSize(pInfo->pBlockLists); + NEXT_SUBMIT_BLK: while (1) { if (pInfo->tqReader->pMsg == NULL) { if (pInfo->validBlockIndex >= totBlockNum) { + updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); + doClearBufferedBlocks(pInfo); return NULL; } @@ -1716,7 +1793,12 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } qDebug("scan rows: %d", pBlockInfo->rows); - return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; + if (pBlockInfo->rows > 0) { + return pInfo->pRes; + } else { + goto NEXT_SUBMIT_BLK; + } + /*return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;*/ } else { ASSERT(0); return NULL; @@ -1778,6 +1860,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { qDebug("tmqsnap change get data uid:%ld", mtInfo.uid); qStreamPrepareScan(pTaskInfo, &pTaskInfo->streamInfo.prepareStatus, pInfo->sContext->subType); } + tDeleteSSchemaWrapper(mtInfo.schema); qDebug("tmqsnap stream scan tsdb return null"); return NULL; } else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_META) { @@ -1929,11 +2012,6 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pTagCond = pTagCond; pInfo->pGroupTags = pTableScanNode->pGroupTags; - pInfo->twAggSup = (STimeWindowAggSupp){ - .waterMark = pTableScanNode->watermark, - .calTrigger = pTableScanNode->triggerType, - .maxTs = INT64_MIN, - }; int32_t numOfCols = 0; pInfo->pColMatchInfo = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); @@ -1983,7 +2061,6 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pUpdateInfo = NULL; pInfo->pTableScanOp = pTableScanOp; - pInfo->interval = pTSInfo->pdInfo.interval; pInfo->readHandle = *pHandle; pInfo->tableUid = pScanPhyNode->uid; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index c221aaf4fd..9e51f3638e 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -867,6 +867,10 @@ static int32_t saveWinResultRow(SResultRow* result, uint64_t groupId, SHashObj* return saveWinResult(result->win.skey, result->pageId, result->offset, groupId, pUpdatedMap); } +static int32_t saveWinResultInfo(TSKEY ts, uint64_t groupId, SHashObj* pUpdatedMap) { + return saveWinResult(ts, -1, -1, groupId, pUpdatedMap); +} + static int32_t saveResultRow(SResultRow* result, uint64_t groupId, SArray* pUpdated) { return saveResult(result->win.skey, result->pageId, result->offset, groupId, pUpdated); } @@ -918,12 +922,16 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) { } } -bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup) { - ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0); - return pSup->maxTs != INT64_MIN && ts < pSup->maxTs - pSup->waterMark; +bool isOverdue(TSKEY ekey, STimeWindowAggSupp* pTwSup) { + ASSERT(pTwSup->maxTs == INT64_MIN || pTwSup->maxTs > 0); + return pTwSup->maxTs != INT64_MIN && ekey < pTwSup->maxTs - pTwSup->waterMark; } -bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup) { return isOverdue(pWin->ekey, pSup); } +bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pTwSup) { return isOverdue(pWin->ekey, pTwSup); } + +bool needDeleteWindowBuf(STimeWindow* pWin, STimeWindowAggSupp* pTwSup) { + return pTwSup->maxTs != INT64_MIN && pWin->ekey < pTwSup->maxTs - pTwSup->deleteMark; +} static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, int32_t scanFlag) { @@ -1107,7 +1115,7 @@ static bool compareVal(const char* v, const SStateKeys* pKey) { if (varDataLen(v) != varDataLen(pKey->pData)) { return false; } else { - return strncmp(varDataVal(v), varDataVal(pKey->pData), varDataLen(v)) == 0; + return memcmp(varDataVal(v), varDataVal(pKey->pData), varDataLen(v)) == 0; } } else { return memcmp(pKey->pData, v, pKey->bytes) == 0; @@ -1374,6 +1382,41 @@ static bool doClearWindow(SAggSupporter* pAggSup, SExprSupp* pSup, char* pData, return true; } +static bool doDeleteWindow(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, int32_t numOfOutput) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; + SWinKey key = {.ts = ts, .groupId = groupId}; + tSimpleHashRemove(pInfo->aggSup.pResultRowHashTable, &key, sizeof(SWinKey)); + streamStateDel(pOperator->pTaskInfo->streamInfo.pState, &key); + return true; +} + +static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, int32_t numOfOutput, SSDataBlock* pBlock, + SArray* pUpWins, SHashObj* pUpdatedMap) { + SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* startTsCols = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + TSKEY* endTsCols = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* pGpDatas = (uint64_t*)pGpCol->pData; + for (int32_t i = 0; i < pBlock->info.rows; i++) { + SResultRowInfo dumyInfo; + dumyInfo.cur.pageId = -1; + STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCols[i], pInterval, TSDB_ORDER_ASC); + while (win.ekey <= endTsCols[i]) { + uint64_t winGpId = pGpDatas[i]; + bool res = doDeleteWindow(pOperator, win.skey, winGpId, numOfOutput); + SWinKey winRes = {.ts = win.skey, .groupId = winGpId}; + if (pUpWins && res) { + taosArrayPush(pUpWins, &winRes); + } + if (pUpdatedMap) { + taosHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey)); + } + getNextTimeWindow(pInterval, pInterval->precision, TSDB_ORDER_ASC, &win); + } + } +} + bool doDeleteIntervalWindow(SAggSupporter* pAggSup, TSKEY ts, uint64_t groupId) { size_t bytes = sizeof(TSKEY); SET_RES_WINDOW_KEY(pAggSup->keyBuf, &ts, bytes, groupId); @@ -1383,8 +1426,6 @@ bool doDeleteIntervalWindow(SAggSupporter* pAggSup, TSKEY ts, uint64_t groupId) // window has been closed return false; } - // SFilePage* bufPage = getBufPage(pAggSup->pResultBuf, p1->pageId); - // dBufSetBufPageRecycled(pAggSup->pResultBuf, bufPage); tSimpleHashRemove(pAggSup->pResultRowHashTable, pAggSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); return true; } @@ -1512,6 +1553,49 @@ static int32_t closeIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pSup return TSDB_CODE_SUCCESS; } +static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SInterval* pInterval, + SHashObj* pPullDataMap, SHashObj* closeWins, SOperatorInfo* pOperator) { + qDebug("===stream===close interval window"); + void* pIte = NULL; + size_t keyLen = 0; + int32_t iter = 0; + while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) { + void* key = tSimpleHashGetKey(pIte, &keyLen); + SWinKey* pWinKey = (SWinKey*)key; + void* chIds = taosHashGet(pPullDataMap, pWinKey, sizeof(SWinKey)); + STimeWindow win = { + .skey = pWinKey->ts, + .ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1, + }; + if (isCloseWindow(&win, pTwSup)) { + if (chIds && pPullDataMap) { + SArray* chAy = *(SArray**)chIds; + int32_t size = taosArrayGetSize(chAy); + qDebug("===stream===window %" PRId64 " wait child size:%d", pWinKey->ts, size); + for (int32_t i = 0; i < size; i++) { + qDebug("===stream===window %" PRId64 " wait child id:%d", pWinKey->ts, *(int32_t*)taosArrayGet(chAy, i)); + } + continue; + } else if (pPullDataMap) { + qDebug("===stream===close window %" PRId64, pWinKey->ts); + } + + if (pTwSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + int32_t code = saveWinResultInfo(pWinKey->ts, pWinKey->groupId, closeWins); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + tSimpleHashIterateRemove(pHashMap, pWinKey, sizeof(SWinKey), &pIte, &iter); + + if (needDeleteWindowBuf(&win, pTwSup)) { + streamStateDel(pOperator->pTaskInfo->streamInfo.pState, pWinKey); + } + } + } + return TSDB_CODE_SUCCESS; +} + static void closeChildIntervalWindow(SArray* pChildren, TSKEY maxTs) { int32_t size = taosArrayGetSize(pChildren); for (int32_t i = 0; i < size; i++) { @@ -1611,6 +1695,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { } nodesDestroyNode((SNode*)pInfo->pPhyNode); colDataDestroy(&pInfo->twAggSup.timeWindowData); + cleanupGroupResInfo(&pInfo->groupResInfo); taosMemoryFreeClear(param); } @@ -1669,16 +1754,17 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt } void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup, SInterval* pInterval, - int64_t waterMark) { + STimeWindowAggSupp* pTwSup) { if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - initIntervalDownStream(downstream->pDownstream[0], type, pSup, pInterval, waterMark); + initIntervalDownStream(downstream->pDownstream[0], type, pSup, pInterval, pTwSup); return; } SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->windowSup.parentType = type; pScanInfo->windowSup.pIntervalAggSup = pSup; - pScanInfo->pUpdateInfo = updateInfoInitP(pInterval, waterMark); + pScanInfo->pUpdateInfo = updateInfoInitP(pInterval, pTwSup->waterMark); pScanInfo->interval = *pInterval; + pScanInfo->twAggSup = *pTwSup; } void initStreamFunciton(SqlFunctionCtx* pCtx, int32_t numOfExpr) { @@ -1763,11 +1849,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, NULL, destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); - if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL) { - initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup, &pInfo->interval, - pInfo->twAggSup.waterMark); - } - code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -1994,7 +2075,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo } } - pSliceInfo->fillLastPoint = isLastRow ? true : false; + pSliceInfo->fillLastPoint = isLastRow; } static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock) { @@ -2213,15 +2294,6 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { SSDataBlock* pResBlock = pSliceInfo->pRes; SExprSupp* pSup = &pOperator->exprSupp; - // if (pOperator->status == OP_RES_TO_RETURN) { - // // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); - // if (pResBlock->info.rows == 0 || !hasRemainResults(&pSliceInfo->groupResInfo)) { - // doSetOperatorCompleted(pOperator); - // } - // - // return pResBlock; - // } - int32_t order = TSDB_ORDER_ASC; SInterval* pInterval = &pSliceInfo->interval; SOperatorInfo* downstream = pOperator->pDownstream[0]; @@ -2351,6 +2423,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { break; } } + } else { + // store ts value as start, and calculate interp value when processing next block + doKeepLinearInfo(pSliceInfo, pBlock, i, true); } } else { // non-linear interpolation if (i < pBlock->info.rows - 1) { @@ -2429,6 +2504,9 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { break; } } + } else { // it is the last row of current block + // store ts value as start, and calculate interp value when processing next block + doKeepLinearInfo(pSliceInfo, pBlock, i, true); } } else { // non-linear interpolation pSliceInfo->current = @@ -2534,6 +2612,10 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode pInfo->interval.interval = pInterpPhyNode->interval; pInfo->current = pInfo->win.skey; + STableScanInfo* pScanInfo = (STableScanInfo*)downstream->info; + pScanInfo->cond.twindows = pInfo->win; + pScanInfo->cond.type = TIMEWINDOW_RANGE_EXTERNAL; + pOperator->name = "TimeSliceOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC; pOperator->blocking = false; @@ -2784,6 +2866,19 @@ bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { return p1 == NULL; } +bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SOperatorInfo* pOperator, STimeWindowAggSupp* pTwSup) { + if (pWin->ekey < pTwSup->maxTs - pTwSup->deleteMark) { + SWinKey key = {.ts = pWin->skey, .groupId = groupId}; + void* pVal = NULL; + int32_t size = 0; + if (streamStateGet(pOperator->pTaskInfo->streamInfo.pState, &key, &pVal, &size) < 0) { + return false; + } + streamStateReleaseBuf(pOperator->pTaskInfo->streamInfo.pState, &key, pVal); + } + return false; +} + int32_t getNexWindowPos(SInterval* pInterval, SDataBlockInfo* pBlockInfo, TSKEY* tsCols, int32_t startPos, TSKEY eKey, STimeWindow* pNextWin) { int32_t forwardRows = @@ -2980,6 +3075,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) { taosArrayRemove(chArray, index); if (taosArrayGetSize(chArray) == 0) { // pull data is over + taosArrayDestroy(chArray); taosHashRemove(pMap, &winRes, sizeof(SWinKey)); } } @@ -3016,9 +3112,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info; SOperatorInfo* downstream = pOperator->pDownstream[0]; - SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); - _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); TSKEY maxTs = INT64_MIN; TSKEY minTs = INT64_MAX; @@ -3082,6 +3175,9 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } } + SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -3341,7 +3437,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { - initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, pInfo->twAggSup.waterMark); + initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); } code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4918,8 +5014,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR SExprSupp* pSup = &pOperatorInfo->exprSupp; SInterval* pInterval = &iaInfo->interval; - int32_t startPos = 0; - int64_t* tsCols = extractTsCol(pBlock, iaInfo); + int32_t startPos = 0; + int64_t* tsCols = extractTsCol(pBlock, iaInfo); TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols); @@ -4938,7 +5034,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR win.skey = miaInfo->curTs; win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - int32_t ret = setSingleOutputTupleBuf(pResultRowInfo, &win, &miaInfo->pResultRow, pSup, &iaInfo->aggSup); + int32_t ret = setSingleOutputTupleBuf(pResultRowInfo, &win, &miaInfo->pResultRow, pSup, &iaInfo->aggSup); if (ret != TSDB_CODE_SUCCESS || miaInfo->pResultRow == NULL) { T_LONG_JMP(pTaskInfo->env, ret); } @@ -4963,7 +5059,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR currWin.ekey = taosTimeAdd(currWin.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; startPos = currPos; - ret = setSingleOutputTupleBuf(pResultRowInfo, &win, &miaInfo->pResultRow, pSup, &iaInfo->aggSup); + ret = setSingleOutputTupleBuf(pResultRowInfo, &win, &miaInfo->pResultRow, pSup, &iaInfo->aggSup); if (ret != TSDB_CODE_SUCCESS || miaInfo->pResultRow == NULL) { T_LONG_JMP(pTaskInfo->env, ret); } @@ -5032,7 +5128,7 @@ static void doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { pMiaInfo->prefetchedBlock = pBlock; cleanupAfterGroupResultGen(pMiaInfo, pRes); break; - } else { + } else { // continue } } @@ -5197,7 +5293,7 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet( iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); ASSERT(p1 != NULL); -// finalizeResultRows(iaInfo->aggSup.pResultBuf, p1, pResultBlock, pTaskInfo); + // finalizeResultRows(iaInfo->aggSup.pResultBuf, p1, pResultBlock, pTaskInfo); tSimpleHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); return TSDB_CODE_SUCCESS; } @@ -5222,7 +5318,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t STimeWindow* prevWin = &prevGrpWin->window; if ((ascScan && newWin->skey > prevWin->ekey) || ((!ascScan) && newWin->skey < prevWin->ekey)) { -// finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock); + // finalizeWindowResult(pOperatorInfo, tableGroupId, prevWin, pResultBlock); tdListPopNode(miaInfo->groupIntervals, listNode); } } @@ -5382,7 +5478,7 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { if (listNode != NULL) { SGroupTimeWindow* grpWin = (SGroupTimeWindow*)(listNode->data); -// finalizeWindowResult(pOperator, grpWin->groupId, &grpWin->window, pRes); + // finalizeWindowResult(pOperator, grpWin->groupId, &grpWin->window, pRes); pRes->info.groupId = grpWin->groupId; } } @@ -5562,7 +5658,6 @@ static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock* TSKEY* tsCols = NULL; SResultRow* pResult = NULL; int32_t forwardRows = 0; - int32_t aa = 4; ASSERT(pSDataBlock->pDataBlock != NULL); SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); @@ -5591,7 +5686,7 @@ static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock* forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC); if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) { - saveWinResultRow(pResult, tableGroupId, pUpdatedMap); + saveWinResultInfo(pResult->win.skey, tableGroupId, pUpdatedMap); } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, @@ -5600,7 +5695,7 @@ static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock* .ts = nextWin.skey, .groupId = tableGroupId, }; - saveOutput(pTaskInfo, &key, pResult, pInfo->aggSup.resultRowSize); + saveOutputBuf(pTaskInfo, &key, pResult, pInfo->aggSup.resultRowSize); releaseOutputBuf(pTaskInfo, &key, pResult); int32_t prevEndPos = (forwardRows - 1) * step + startPos; ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); @@ -5645,7 +5740,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pDelRes; } - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); + doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo); + // doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; qDebug("===stream===single interval is done"); @@ -5661,8 +5757,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); - SStreamState* pState = pTaskInfo->streamInfo.pState; - while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -5671,13 +5765,14 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { printDataBlock(pBlock, "single interval recv"); if (pBlock->info.type == STREAM_CLEAR) { - doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, - NULL); + doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, NULL, NULL); qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo)); continue; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { - doDeleteSpecifyIntervalWindow(&pInfo->aggSup, &pInfo->twAggSup, pBlock, pInfo->pDelWins, &pInfo->interval, - pUpdatedMap); + // doDeleteSpecifyIntervalWindow(&pInfo->aggSup, &pInfo->twAggSup, pBlock, pInfo->pDelWins, &pInfo->interval, + // pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock, pInfo->pDelWins, + pUpdatedMap); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap); @@ -5704,45 +5799,15 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { maxTs = TMAX(maxTs, pBlock->info.window.ekey); minTs = TMIN(minTs, pBlock->info.window.skey); - doStreamIntervalAggImpl(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap); + // doStreamIntervalAggImpl(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap); // new disc buf - /*doStreamIntervalAggImpl2(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);*/ + doStreamIntervalAggImpl2(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap); } pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, minTs); - -#if 0 - if (pState) { - printf(">>>>>>>> stream read backend\n"); - SWinKey key = { - .ts = 1, - .groupId = 2, - }; - char* val = NULL; - int32_t sz; - if (streamStateGet(pState, &key, (void**)&val, &sz) < 0) { - ASSERT(0); - } - printf("stream read %s %d\n", val, sz); - streamFreeVal(val); - - SStreamStateCur* pCur = streamStateGetCur(pState, &key); - ASSERT(pCur); - while (streamStateCurNext(pState, pCur) == 0) { - SWinKey key1; - const void* val1; - if (streamStateGetKVByCur(pCur, &key1, &val1, &sz) < 0) { - break; - } - printf("stream iter key groupId:%d ts:%d, value %s %d\n", key1.groupId, key1.ts, val1, sz); - } - streamStateFreeCur(pCur); - } -#endif - pOperator->status = OP_RES_TO_RETURN; - closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdatedMap, - pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); + closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdatedMap, + pOperator); void* pIte = NULL; while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) { @@ -5751,7 +5816,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { taosArraySort(pUpdated, resultrowComparAsc); // new disc buf - finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); + // finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, + // pSup->rowEntryInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); removeDeleteResults(pUpdatedMap, pInfo->pDelWins); @@ -5762,9 +5828,9 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pDelRes; } - doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); + // doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); // new disc buf - // doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo); + doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo); printDataBlock(pInfo->binfo.pRes, "single interval"); return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes; } @@ -5809,6 +5875,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, .minTs = INT64_MAX, + .deleteMark = INT64_MAX, }; ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY); pOperator->pTaskInfo = pTaskInfo; @@ -5856,7 +5923,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL, destroyStreamIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); - initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, pInfo->twAggSup.waterMark); + initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index f3d3393ac3..0677bd7d63 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -207,7 +207,6 @@ static int32_t countTrailingSpaces(const SValueNode* pVal, bool isLtrim) { } return numOfSpaces; - } void static addTimezoneParam(SNodeList* pList) { @@ -322,7 +321,7 @@ static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len } int32_t numOfSpaces = 0; - SNode* pParamNode1 = nodesListGetNode(pFunc->pParameterList, 0); + SNode* pParamNode1 = nodesListGetNode(pFunc->pParameterList, 0); // for select trim functions with constant value from table, // need to set the proper result result schema bytes to avoid // trailing garbage characters @@ -331,7 +330,6 @@ static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len numOfSpaces = countTrailingSpaces(pValue, isLtrim); } - int32_t resBytes = pPara1->resType.bytes - numOfSpaces; pFunc->node.resType = (SDataType){.bytes = resBytes, .type = pPara1->resType.type}; return TSDB_CODE_SUCCESS; @@ -2141,7 +2139,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "avg", .type = FUNCTION_TYPE_AVG, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateInNumOutDou, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getAvgFuncEnv, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 9b502eded7..9177d15fae 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -47,6 +47,7 @@ typedef struct SSumRes { uint64_t usum; double dsum; }; + int16_t type; } SSumRes; typedef struct SAvgRes { @@ -73,6 +74,7 @@ typedef struct SMinmaxResInfo { STuplePos nullTuplePos; bool nullTupleSaved; + int16_t type; } SMinmaxResInfo; typedef struct STopBotResItem { @@ -485,8 +487,7 @@ int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SFirstLastRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; - int32_t bytes = pDestCtx->input.pData[0]->info.bytes; + int32_t bytes = pDBuf->bytes; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SFirstLastRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); @@ -617,6 +618,7 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { int32_t type = pInput->pData[0]->info.type; SSumRes* pSumRes = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + pSumRes->type = type; if (IS_NULL_TYPE(type)) { numOfElem = 0; @@ -740,10 +742,10 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx) { int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SSumRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SSumRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type; if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { pDBuf->isum += pSBuf->isum; @@ -1072,10 +1074,10 @@ int32_t avgInvertFunction(SqlFunctionCtx* pCtx) { int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SAvgRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SAvgRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type; if (IS_SIGNED_NUMERIC_TYPE(type)) { pDBuf->sum.isum += pSBuf->sum.isum; @@ -1181,6 +1183,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SMinmaxResInfo* pBuf = GET_ROWCELL_INTERBUF(pResInfo); + pBuf->type = type; if (IS_NULL_TYPE(type)) { numOfElems = 0; @@ -1729,10 +1732,10 @@ void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { int32_t minMaxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t isMinFunc) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SMinmaxResInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SMinmaxResInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type; if (IS_FLOAT_TYPE(type)) { if (pSBuf->assign && ((((*(double*)&pDBuf->v) < (*(double*)&pSBuf->v)) ^ isMinFunc) || !pDBuf->assign)) { *(double*)&pDBuf->v = *(double*)&pSBuf->v; @@ -2105,10 +2108,10 @@ int32_t stddevPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SStddevRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SStddevRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + int16_t type = pDBuf->type == TSDB_DATA_TYPE_NULL ? pSBuf->type : pDBuf->type; if (IS_SIGNED_NUMERIC_TYPE(type)) { pDBuf->isum += pSBuf->isum; @@ -3069,8 +3072,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); SFirstLastRes* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); - int32_t type = pDestCtx->input.pData[0]->info.type; - int32_t bytes = pDestCtx->input.pData[0]->info.bytes; + int32_t bytes = pDBuf->bytes; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); SFirstLastRes* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); @@ -3746,9 +3748,9 @@ void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type, } int32_t topCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); STopBotRes* pSBuf = getTopBotOutputInfo(pSourceCtx); + int16_t type = pSBuf->type; for (int32_t i = 0; i < pSResInfo->numOfRes; i++) { addResult(pDestCtx, pSBuf->pItems + i, type, true); } @@ -3756,9 +3758,9 @@ int32_t topCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { } int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { - int32_t type = pDestCtx->input.pData[0]->info.type; SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); STopBotRes* pSBuf = getTopBotOutputInfo(pSourceCtx); + int16_t type = pSBuf->type; for (int32_t i = 0; i < pSResInfo->numOfRes; i++) { addResult(pDestCtx, pSBuf->pItems + i, type, false); } @@ -5297,12 +5299,12 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { } static void doModeAdd(SModeInfo* pInfo, char* data) { - int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { int32_t size = sizeof(SModeItem) + pInfo->colBytes; SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); - memcpy(pItem->data, data, pInfo->colBytes); + memcpy(pItem->data, data, hashKeyBytes); pItem->count += 1; taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); @@ -5414,8 +5416,8 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) { int32_t i = pInput->startRowIndex; if (pCtx->start.key != INT64_MIN) { - //ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) || - // (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC)); + // ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) || + // (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC)); ASSERT(last->key == INT64_MIN); for (; i < pInput->numOfRows + pInput->startRowIndex; ++i) { diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 26735fa263..bc10ce71ae 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -26,11 +26,6 @@ typedef struct SFuncMgtService { SHashObj* pFuncNameHashTable; } SFuncMgtService; -typedef struct SUdfInfo { - SDataType outputDt; - int8_t funcType; -} SUdfInfo; - static SFuncMgtService gFunMgtService; static TdThreadOnce functionHashTableInit = PTHREAD_ONCE_INIT; static int32_t initFunctionCode = 0; diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 3f472b53a0..62427e0488 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -961,6 +961,7 @@ void releaseUdfFuncHandle(char* udfName) { strcpy(key.udfName, udfName); SUdfcFuncStub *foundStub = taosArraySearch(gUdfdProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ); if (!foundStub) { + uv_mutex_unlock(&gUdfdProxy.udfStubsMutex); return; } if (foundStub->refCount > 0) { diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index a45e4585e8..636f006d6e 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -41,6 +41,8 @@ typedef struct SUdfdContext { uv_mutex_t udfsMutex; SHashObj * udfsHash; + SArray* residentFuncs; + bool printVersion; } SUdfdContext; @@ -67,6 +69,7 @@ typedef struct SUdf { EUdfState state; uv_mutex_t lock; uv_cond_t condReady; + bool resident; char name[TSDB_FUNC_NAME_LEN]; int8_t funcType; @@ -200,6 +203,14 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { if (udf->initFunc) { udf->initFunc(); } + udf->resident = false; + for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) { + char* funcName = taosArrayGet(global.residentFuncs, i); + if (strcmp(setup->udfName, funcName) == 0) { + udf->resident = true; + break; + } + } udf->state = UDF_STATE_READY; uv_cond_broadcast(&udf->condReady); uv_mutex_unlock(&udf->lock); @@ -345,7 +356,7 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { uv_mutex_lock(&global.udfsMutex); udf->refCount--; - if (udf->refCount == 0) { + if (udf->refCount == 0 && !udf->resident) { unloadUdf = true; taosHashRemove(global.udfsHash, udf->name, strlen(udf->name)); } @@ -576,9 +587,9 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggFinishFunc)); char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; char *mergeSuffix = "_merge"; - strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); - strncat(finishFuncName, mergeSuffix, strlen(mergeSuffix)); - uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggMergeFunc)); + strncpy(mergeFuncName, processFuncName, sizeof(mergeFuncName)); + strncat(mergeFuncName, mergeSuffix, strlen(mergeSuffix)); + uv_dlsym(&udf->lib, mergeFuncName, (void **)(&udf->aggMergeFunc)); } return 0; } @@ -919,8 +930,6 @@ static int32_t udfdRun() { uv_run(global.loop, UV_RUN_DEFAULT); uv_loop_close(global.loop); - uv_mutex_destroy(&global.udfsMutex); - taosHashCleanup(global.udfsHash); return 0; } @@ -941,6 +950,47 @@ void udfdConnectMnodeThreadFunc(void *args) { } } +int32_t udfdInitResidentFuncs() { + if (strlen(tsUdfdResFuncs) == 0) { + return TSDB_CODE_SUCCESS; + } + + global.residentFuncs = taosArrayInit(2, TSDB_FUNC_NAME_LEN); + char* pSave = tsUdfdResFuncs; + char* token; + while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { + char func[TSDB_FUNC_NAME_LEN] = {0}; + strncpy(func, token, strlen(token)); + taosArrayPush(global.residentFuncs, func); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t udfdDeinitResidentFuncs() { + for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) { + char* funcName = taosArrayGet(global.residentFuncs, i); + SUdf** udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName)); + if (udfInHash) { + taosHashRemove(global.udfsHash, funcName, strlen(funcName)); + SUdf* udf = *udfInHash; + if (udf->destroyFunc) { + (udf->destroyFunc)(); + } + uv_dlclose(&udf->lib); + taosMemoryFree(udf); + } + } + taosArrayDestroy(global.residentFuncs); + return TSDB_CODE_SUCCESS; +} + +int32_t udfdCleanup() { + uv_mutex_destroy(&global.udfsMutex); + taosHashCleanup(global.udfsHash); + return 0; +} + int main(int argc, char *argv[]) { if (!taosCheckSystemIsLittleEnd()) { printf("failed to start since on non-little-end machines\n"); @@ -978,6 +1028,8 @@ int main(int argc, char *argv[]) { return -5; } + udfdInitResidentFuncs(); + uv_thread_t mnodeConnectThread; uv_thread_create(&mnodeConnectThread, udfdConnectMnodeThreadFunc, NULL); @@ -986,5 +1038,7 @@ int main(int argc, char *argv[]) { removeListeningPipe(); udfdCloseClientRpc(); + udfdDeinitResidentFuncs(); + udfdCleanup(); return 0; } diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index d2571a395e..f353efcf3c 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -324,6 +324,21 @@ static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { return TSDB_CODE_SUCCESS; } +static int32_t whenThenNodeCopy(const SWhenThenNode* pSrc, SWhenThenNode* pDst) { + COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); + CLONE_NODE_FIELD(pWhen); + CLONE_NODE_FIELD(pThen); + return TSDB_CODE_SUCCESS; +} + +static int32_t caseWhenNodeCopy(const SCaseWhenNode* pSrc, SCaseWhenNode* pDst) { + COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); + CLONE_NODE_FIELD(pCase); + CLONE_NODE_FIELD(pElse); + CLONE_NODE_LIST_FIELD(pWhenThenList); + return TSDB_CODE_SUCCESS; +} + static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { CLONE_NODE_LIST_FIELD(pTargets); CLONE_NODE_FIELD(pConditions); @@ -712,6 +727,12 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_LEFT_VALUE: code = TSDB_CODE_SUCCESS; break; + case QUERY_NODE_WHEN_THEN: + code = whenThenNodeCopy((const SWhenThenNode*)pNode, (SWhenThenNode*)pDst); + break; + case QUERY_NODE_CASE_WHEN: + code = caseWhenNodeCopy((const SCaseWhenNode*)pNode, (SCaseWhenNode*)pDst); + break; case QUERY_NODE_SELECT_STMT: code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index afd05eff1d..3242f20830 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -81,6 +81,10 @@ const char* nodesNodeName(ENodeType type) { return "IndexOptions"; case QUERY_NODE_LEFT_VALUE: return "LeftValue"; + case QUERY_NODE_WHEN_THEN: + return "WhenThen"; + case QUERY_NODE_CASE_WHEN: + return "CaseWhen"; case QUERY_NODE_SET_OPERATOR: return "SetOperator"; case QUERY_NODE_SELECT_STMT: @@ -559,6 +563,8 @@ static const char* jkScanLogicPlanStableId = "StableId"; static const char* jkScanLogicPlanScanType = "ScanType"; static const char* jkScanLogicPlanScanCount = "ScanCount"; static const char* jkScanLogicPlanReverseScanCount = "ReverseScanCount"; +static const char* jkScanLogicPlanDynamicScanFuncs = "DynamicScanFuncs"; +static const char* jkScanLogicPlanDataRequired = "DataRequired"; static const char* jkScanLogicPlanTagCond = "TagCond"; static const char* jkScanLogicPlanGroupTags = "GroupTags"; @@ -590,6 +596,12 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanReverseScanCount, pNode->scanSeq[1]); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkScanLogicPlanDynamicScanFuncs, nodeToJson, pNode->pDynamicScanFuncs); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanDataRequired, pNode->dataRequired); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond); } @@ -629,6 +641,12 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetUTinyIntValue(pJson, jkScanLogicPlanReverseScanCount, &pNode->scanSeq[1]); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkScanLogicPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkScanLogicPlanDataRequired, &pNode->dataRequired); + } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond); } @@ -3903,6 +3921,75 @@ static int32_t jsonToDatabaseOptions(const SJson* pJson, void* pObj) { return code; } +static const char* jkWhenThenWhen = "When"; +static const char* jkWhenThenThen = "Then"; + +static int32_t whenThenNodeToJson(const void* pObj, SJson* pJson) { + const SWhenThenNode* pNode = (const SWhenThenNode*)pObj; + + int32_t code = exprNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkWhenThenWhen, nodeToJson, pNode->pWhen); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkWhenThenThen, nodeToJson, pNode->pThen); + } + + return code; +} + +static int32_t jsonToWhenThenNode(const SJson* pJson, void* pObj) { + SWhenThenNode* pNode = (SWhenThenNode*)pObj; + + int32_t code = jsonToExprNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkWhenThenWhen, &pNode->pWhen); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkWhenThenThen, &pNode->pThen); + } + + return code; +} + +static const char* jkCaseWhenCase = "Case"; +static const char* jkCaseWhenWhenThenList = "WhenThenList"; +static const char* jkCaseWhenElse = "Else"; + +static int32_t caseWhenNodeToJson(const void* pObj, SJson* pJson) { + const SCaseWhenNode* pNode = (const SCaseWhenNode*)pObj; + + int32_t code = exprNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkCaseWhenCase, nodeToJson, pNode->pCase); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodeListToJson(pJson, jkCaseWhenWhenThenList, pNode->pWhenThenList); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkCaseWhenElse, nodeToJson, pNode->pElse); + } + + return code; +} + +static int32_t jsonToCaseWhenNode(const SJson* pJson, void* pObj) { + SCaseWhenNode* pNode = (SCaseWhenNode*)pObj; + + int32_t code = jsonToExprNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkCaseWhenCase, &pNode->pCase); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkCaseWhenWhenThenList, &pNode->pWhenThenList); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkCaseWhenElse, &pNode->pElse); + } + + return code; +} + static const char* jkDataBlockDescDataBlockId = "DataBlockId"; static const char* jkDataBlockDescSlots = "Slots"; static const char* jkDataBlockTotalRowSize = "TotalRowSize"; @@ -4385,6 +4472,10 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return databaseOptionsToJson(pObj, pJson); case QUERY_NODE_LEFT_VALUE: return TSDB_CODE_SUCCESS; // SLeftValueNode has no fields to serialize. + case QUERY_NODE_WHEN_THEN: + return whenThenNodeToJson(pObj, pJson); + case QUERY_NODE_CASE_WHEN: + return caseWhenNodeToJson(pObj, pJson); case QUERY_NODE_SET_OPERATOR: return setOperatorToJson(pObj, pJson); case QUERY_NODE_SELECT_STMT: @@ -4548,6 +4639,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToDatabaseOptions(pJson, pObj); case QUERY_NODE_LEFT_VALUE: return TSDB_CODE_SUCCESS; // SLeftValueNode has no fields to deserialize. + case QUERY_NODE_WHEN_THEN: + return jsonToWhenThenNode(pJson, pObj); + case QUERY_NODE_CASE_WHEN: + return jsonToCaseWhenNode(pJson, pObj); case QUERY_NODE_SET_OPERATOR: return jsonToSetOperator(pJson, pObj); case QUERY_NODE_SELECT_STMT: diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 9cb7e8b66d..4e23999ec2 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -140,6 +140,19 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) { return true; } +static bool whenThenNodeEqual(const SWhenThenNode* a, const SWhenThenNode* b) { + COMPARE_NODE_FIELD(pWhen); + COMPARE_NODE_FIELD(pThen); + return true; +} + +static bool caseWhenNodeEqual(const SCaseWhenNode* a, const SCaseWhenNode* b) { + COMPARE_NODE_FIELD(pCase); + COMPARE_NODE_FIELD(pElse); + COMPARE_NODE_LIST_FIELD(pWhenThenList); + return true; +} + bool nodesEqualNode(const SNode* a, const SNode* b) { if (a == b) { return true; @@ -164,13 +177,17 @@ bool nodesEqualNode(const SNode* a, const SNode* b) { return logicConditionNodeEqual((const SLogicConditionNode*)a, (const SLogicConditionNode*)b); case QUERY_NODE_FUNCTION: return functionNodeEqual((const SFunctionNode*)a, (const SFunctionNode*)b); + case QUERY_NODE_WHEN_THEN: + return whenThenNodeEqual((const SWhenThenNode*)a, (const SWhenThenNode*)b); + case QUERY_NODE_CASE_WHEN: + return caseWhenNodeEqual((const SCaseWhenNode*)a, (const SCaseWhenNode*)b); case QUERY_NODE_REAL_TABLE: case QUERY_NODE_TEMP_TABLE: case QUERY_NODE_JOIN_TABLE: case QUERY_NODE_GROUPING_SET: case QUERY_NODE_ORDER_BY_EXPR: case QUERY_NODE_LIMIT: - return false; // todo + return false; default: break; } diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 202ee6717a..2249cfe888 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -17,17 +17,34 @@ #include "plannodes.h" #include "tdatablock.h" +#ifndef htonll + +#define htonll(x) \ + (((int64_t)x & 0x00000000000000ff) << 7 * 8) | (((int64_t)x & 0x000000000000ff00) << 5 * 8) | \ + (((int64_t)x & 0x0000000000ff0000) << 3 * 8) | (((int64_t)x & 0x00000000ff000000) << 1 * 8) | \ + (((int64_t)x & 0x000000ff00000000) >> 1 * 8) | (((int64_t)x & 0x0000ff0000000000) >> 3 * 8) | \ + (((int64_t)x & 0x00ff000000000000) >> 5 * 8) | (((int64_t)x & 0xff00000000000000) >> 7 * 8) + +#define ntohll(x) htonll(x) + +#endif + #define NODES_MSG_DEFAULT_LEN 1024 +#define TLV_TYPE_ARRAY_ELEM 0 #define tlvForEach(pDecoder, pTlv, code) \ while (TSDB_CODE_SUCCESS == code && TSDB_CODE_SUCCESS == (code = tlvGetNextTlv(pDecoder, &pTlv)) && NULL != pTlv) +#pragma pack(push, 1) + typedef struct STlv { int16_t type; int32_t len; char value[0]; } STlv; +#pragma pack(pop) + typedef struct STlvEncoder { int32_t allocSize; int32_t offset; @@ -81,54 +98,124 @@ static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pV pEncoder->allocSize = pEncoder->allocSize * 2; } STlv* pTlv = (STlv*)(pEncoder->pBuf + pEncoder->offset); - pTlv->type = type; - pTlv->len = len; + pTlv->type = htons(type); + pTlv->len = htonl(len); memcpy(pTlv->value, pValue, len); pEncoder->offset += tlvLen; ++(pEncoder->tlvCount); return TSDB_CODE_SUCCESS; } +static int32_t tlvEncodeValueImpl(STlvEncoder* pEncoder, const void* pValue, int32_t len) { + if (pEncoder->offset + len > pEncoder->allocSize) { + void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize * 2); + if (NULL == pNewBuf) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pEncoder->pBuf = pNewBuf; + pEncoder->allocSize = pEncoder->allocSize * 2; + } + memcpy(pEncoder->pBuf + pEncoder->offset, pValue, len); + pEncoder->offset += len; + return TSDB_CODE_SUCCESS; +} + static int32_t tlvEncodeI8(STlvEncoder* pEncoder, int16_t type, int8_t value) { return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueI8(STlvEncoder* pEncoder, int8_t value) { + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeI16(STlvEncoder* pEncoder, int16_t type, int16_t value) { + value = htons(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueI16(STlvEncoder* pEncoder, int16_t value) { + value = htons(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeI32(STlvEncoder* pEncoder, int16_t type, int32_t value) { + value = htonl(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueI32(STlvEncoder* pEncoder, int32_t value) { + value = htonl(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeI64(STlvEncoder* pEncoder, int16_t type, int64_t value) { + value = htonll(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueI64(STlvEncoder* pEncoder, int64_t value) { + value = htonll(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeU8(STlvEncoder* pEncoder, int16_t type, uint8_t value) { return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueU8(STlvEncoder* pEncoder, uint8_t value) { + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeU16(STlvEncoder* pEncoder, int16_t type, uint16_t value) { + value = htons(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueU16(STlvEncoder* pEncoder, uint16_t value) { + value = htons(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeU64(STlvEncoder* pEncoder, int16_t type, uint64_t value) { + value = htonll(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueU64(STlvEncoder* pEncoder, uint64_t value) { + value = htonll(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeDouble(STlvEncoder* pEncoder, int16_t type, double value) { - return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); + int64_t temp = *(int64_t*)&value; + temp = htonll(temp); + return tlvEncodeImpl(pEncoder, type, &temp, sizeof(temp)); +} + +static int32_t tlvEncodeValueDouble(STlvEncoder* pEncoder, double value) { + int64_t temp = *(int64_t*)&value; + temp = htonll(temp); + return tlvEncodeValueImpl(pEncoder, &temp, sizeof(temp)); } static int32_t tlvEncodeEnum(STlvEncoder* pEncoder, int16_t type, int32_t value) { + value = htonl(value); return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } -static int32_t tlvEncodeBool(STlvEncoder* pEncoder, int16_t type, bool value) { +static int32_t tlvEncodeValueEnum(STlvEncoder* pEncoder, int32_t value) { + value = htonl(value); + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + +static int32_t tlvEncodeBool(STlvEncoder* pEncoder, int16_t type, int8_t value) { return tlvEncodeImpl(pEncoder, type, &value, sizeof(value)); } +static int32_t tlvEncodeValueBool(STlvEncoder* pEncoder, int8_t value) { + return tlvEncodeValueImpl(pEncoder, &value, sizeof(value)); +} + static int32_t tlvEncodeCStr(STlvEncoder* pEncoder, int16_t type, const char* pValue) { if (NULL == pValue) { return TSDB_CODE_SUCCESS; @@ -136,6 +223,15 @@ static int32_t tlvEncodeCStr(STlvEncoder* pEncoder, int16_t type, const char* pV return tlvEncodeImpl(pEncoder, type, pValue, strlen(pValue)); } +static int32_t tlvEncodeValueCStr(STlvEncoder* pEncoder, const char* pValue) { + int16_t len = strlen(pValue); + int32_t code = tlvEncodeValueI16(pEncoder, len); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueImpl(pEncoder, pValue, len); + } + return code; +} + static int32_t tlvEncodeBinary(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) { return tlvEncodeImpl(pEncoder, type, pValue, len); } @@ -150,9 +246,10 @@ static int32_t tlvEncodeObj(STlvEncoder* pEncoder, int16_t type, FToMsg func, co int32_t code = func(pObj, pEncoder); if (TSDB_CODE_SUCCESS == code) { STlv* pTlv = (STlv*)(pEncoder->pBuf + start); - pTlv->type = type; - pTlv->len = pEncoder->offset - start - sizeof(STlv); + pTlv->type = htons(type); + pTlv->len = htonl(pEncoder->offset - start - sizeof(STlv)); } + ++(pEncoder->tlvCount); return code; } @@ -163,17 +260,26 @@ static int32_t tlvEncodeObjArray(STlvEncoder* pEncoder, int16_t type, FToMsg fun int32_t start = pEncoder->offset; pEncoder->offset += sizeof(STlv); for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) { - code = tlvEncodeObj(pEncoder, 0, func, (const char*)pArray + i * itemSize); + code = tlvEncodeObj(pEncoder, TLV_TYPE_ARRAY_ELEM, func, (const char*)pArray + i * itemSize); } if (TSDB_CODE_SUCCESS == code) { STlv* pTlv = (STlv*)(pEncoder->pBuf + start); - pTlv->type = type; - pTlv->len = pEncoder->offset - start - sizeof(STlv); + pTlv->type = htons(type); + pTlv->len = htonl(pEncoder->offset - start - sizeof(STlv)); } } return code; } +static int32_t tlvEncodeValueArray(STlvEncoder* pEncoder, FToMsg func, const void* pArray, int32_t itemSize, + int32_t num) { + int32_t code = tlvEncodeValueI32(pEncoder, num); + for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) { + code = func((const char*)pArray + i * itemSize, pEncoder); + } + return code; +} + static int32_t tlvGetNextTlv(STlvDecoder* pDecoder, STlv** pTlv) { if (pDecoder->offset == pDecoder->bufSize) { *pTlv = NULL; @@ -181,6 +287,8 @@ static int32_t tlvGetNextTlv(STlvDecoder* pDecoder, STlv** pTlv) { } *pTlv = (STlv*)(pDecoder->pBuf + pDecoder->offset); + (*pTlv)->type = ntohs((*pTlv)->type); + (*pTlv)->len = ntohl((*pTlv)->len); if ((*pTlv)->len + pDecoder->offset > pDecoder->bufSize) { return TSDB_CODE_FAILED; } @@ -198,27 +306,126 @@ static int32_t tlvDecodeImpl(STlv* pTlv, void* pValue, int32_t len) { return TSDB_CODE_SUCCESS; } +static int32_t tlvDecodeValueImpl(STlvDecoder* pDecoder, void* pValue, int32_t len) { + if (pDecoder->offset + len > pDecoder->bufSize) { + return TSDB_CODE_FAILED; + } + memcpy(pValue, pDecoder->pBuf + pDecoder->offset, len); + pDecoder->offset += len; + return TSDB_CODE_SUCCESS; +} + static int32_t tlvDecodeI8(STlv* pTlv, int8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } -static int32_t tlvDecodeI16(STlv* pTlv, int16_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeValueI8(STlvDecoder* pDecoder, int8_t* pValue) { + return tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); +} -static int32_t tlvDecodeI32(STlv* pTlv, int32_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeI16(STlv* pTlv, int16_t* pValue) { + int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohs(*pValue); + } + return code; +} -static int32_t tlvDecodeI64(STlv* pTlv, int64_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeValueI16(STlvDecoder* pDecoder, int16_t* pValue) { + int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohs(*pValue); + } + return code; +} + +static int32_t tlvDecodeI32(STlv* pTlv, int32_t* pValue) { + int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohl(*pValue); + } + return code; +} + +static int32_t tlvDecodeValueI32(STlvDecoder* pDecoder, int32_t* pValue) { + int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohl(*pValue); + } + return code; +} + +static int32_t tlvDecodeI64(STlv* pTlv, int64_t* pValue) { + int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohll(*pValue); + } + return code; +} + +static int32_t tlvDecodeValueI64(STlvDecoder* pDecoder, int64_t* pValue) { + int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohll(*pValue); + } + return code; +} static int32_t tlvDecodeU8(STlv* pTlv, uint8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } -static int32_t tlvDecodeU16(STlv* pTlv, uint16_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeValueU8(STlvDecoder* pDecoder, uint8_t* pValue) { + return tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); +} -static int32_t tlvDecodeU64(STlv* pTlv, uint64_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeU16(STlv* pTlv, uint16_t* pValue) { + int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohs(*pValue); + } + return code; +} -static int32_t tlvDecodeDouble(STlv* pTlv, double* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeValueU16(STlvDecoder* pDecoder, uint16_t* pValue) { + int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohs(*pValue); + } + return code; +} -static int32_t tlvDecodeBool(STlv* pTlv, bool* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); } +static int32_t tlvDecodeU64(STlv* pTlv, uint64_t* pValue) { + int32_t code = tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohll(*pValue); + } + return code; +} -static int32_t tlvDecodeEnum(STlv* pTlv, void* pValue, int16_t len) { - int32_t value = 0; - memcpy(&value, pTlv->value, pTlv->len); +static int32_t tlvDecodeValueU64(STlvDecoder* pDecoder, uint64_t* pValue) { + int32_t code = tlvDecodeValueImpl(pDecoder, pValue, sizeof(*pValue)); + if (TSDB_CODE_SUCCESS == code) { + *pValue = ntohll(*pValue); + } + return code; +} + +static int32_t tlvDecodeDouble(STlv* pTlv, double* pValue) { + int64_t temp = 0; + int32_t code = tlvDecodeI64(pTlv, &temp); + if (TSDB_CODE_SUCCESS == code) { + *pValue = *(double*)&temp; + } + return code; +} + +static int32_t tlvDecodeValueDouble(STlvDecoder* pDecoder, double* pValue) { + int64_t temp = 0; + int32_t code = tlvDecodeValueI64(pDecoder, &temp); + if (TSDB_CODE_SUCCESS == code) { + *pValue = *(double*)&temp; + } + return code; +} + +static int32_t convertIntegerType(int32_t value, void* pValue, int16_t len) { switch (len) { case 1: *(int8_t*)pValue = value; @@ -235,11 +442,56 @@ static int32_t tlvDecodeEnum(STlv* pTlv, void* pValue, int16_t len) { return TSDB_CODE_SUCCESS; } +static int32_t tlvDecodeBool(STlv* pTlv, bool* pValue) { + int8_t value = 0; + int32_t code = tlvDecodeI8(pTlv, &value); + if (TSDB_CODE_SUCCESS == code) { + code = convertIntegerType(value, pValue, sizeof(bool)); + } + return code; +} + +static int32_t tlvDecodeValueBool(STlvDecoder* pDecoder, bool* pValue) { + int8_t value = 0; + int32_t code = tlvDecodeValueI8(pDecoder, &value); + if (TSDB_CODE_SUCCESS == code) { + code = convertIntegerType(value, pValue, sizeof(bool)); + } + return code; +} + +static int32_t tlvDecodeEnum(STlv* pTlv, void* pValue, int16_t len) { + int32_t value = 0; + int32_t code = tlvDecodeI32(pTlv, &value); + if (TSDB_CODE_SUCCESS == code) { + code = convertIntegerType(value, pValue, len); + } + return code; +} + +static int32_t tlvDecodeValueEnum(STlvDecoder* pDecoder, void* pValue, int16_t len) { + int32_t value = 0; + int32_t code = tlvDecodeValueI32(pDecoder, &value); + if (TSDB_CODE_SUCCESS == code) { + code = convertIntegerType(value, pValue, len); + } + return code; +} + static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue) { memcpy(pValue, pTlv->value, pTlv->len); return TSDB_CODE_SUCCESS; } +static int32_t tlvDecodeValueCStr(STlvDecoder* pDecoder, char* pValue) { + int16_t len = 0; + int32_t code = tlvDecodeValueI16(pDecoder, &len); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueImpl(pDecoder, pValue, len); + } + return code; +} + static int32_t tlvDecodeCStrP(STlv* pTlv, char** pValue) { *pValue = strndup(pTlv->value, pTlv->len); return NULL == *pValue ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS; @@ -281,6 +533,15 @@ static int32_t tlvDecodeObjArray(STlvDecoder* pDecoder, FToObject func, void* pA return code; } +static int32_t tlvDecodeValueArray(STlvDecoder* pDecoder, FToObject func, void* pArray, int32_t itemSize, + int32_t* pNum) { + int32_t code = tlvDecodeValueI32(pDecoder, pNum); + for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < *pNum; ++i) { + code = func(pDecoder, (char*)pArray + i * itemSize); + } + return code; +} + static int32_t tlvDecodeObjArrayFromTlv(STlv* pTlv, FToObject func, void* pArray, int32_t itemSize) { STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value}; return tlvDecodeObjArray(&decoder, func, pArray, itemSize); @@ -305,6 +566,23 @@ static int32_t tlvDecodeDynObj(STlvDecoder* pDecoder, FMakeObject makeFunc, FToO enum { DATA_TYPE_CODE_TYPE = 1, DATA_TYPE_CODE_PRECISION, DATA_TYPE_CODE_SCALE, DATA_TYPE_CODE_BYTES }; +static int32_t dataTypeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SDataType* pNode = (const SDataType*)pObj; + + int32_t code = tlvEncodeValueI8(pEncoder, pNode->type); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueU8(pEncoder, pNode->precision); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueU8(pEncoder, pNode->scale); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->bytes); + } + + return code; +} + static int32_t dataTypeToMsg(const void* pObj, STlvEncoder* pEncoder) { const SDataType* pNode = (const SDataType*)pObj; @@ -322,6 +600,23 @@ static int32_t dataTypeToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToDataTypeInline(STlvDecoder* pDecoder, void* pObj) { + SDataType* pNode = (SDataType*)pObj; + + int32_t code = tlvDecodeValueI8(pDecoder, &pNode->type); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU8(pDecoder, &pNode->precision); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU8(pDecoder, &pNode->scale); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->bytes); + } + + return code; +} + static int32_t msgToDataType(STlvDecoder* pDecoder, void* pObj) { SDataType* pNode = (SDataType*)pObj; @@ -374,53 +669,83 @@ static int32_t msgToExprNode(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { - COLUMN_CODE_EXPR_BASE = 1, - COLUMN_CODE_TABLE_ID, - COLUMN_CODE_TABLE_TYPE, - COLUMN_CODE_COLUMN_ID, - COLUMN_CODE_COLUMN_TYPE, - COLUMN_CODE_DB_NAME, - COLUMN_CODE_TABLE_NAME, - COLUMN_CODE_TABLE_ALIAS, - COLUMN_CODE_COL_NAME, - COLUMN_CODE_DATABLOCK_ID, - COLUMN_CODE_SLOT_ID -}; +enum { COLUMN_CODE_INLINE_ATTRS = 1 }; -static int32_t columnNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { +static int32_t columnNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { const SColumnNode* pNode = (const SColumnNode*)pObj; - int32_t code = tlvEncodeObj(pEncoder, COLUMN_CODE_EXPR_BASE, exprNodeToMsg, pNode); + int32_t code = dataTypeInlineToMsg(&pNode->node.resType, pEncoder); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU64(pEncoder, COLUMN_CODE_TABLE_ID, pNode->tableId); + code = tlvEncodeValueU64(pEncoder, pNode->tableId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, COLUMN_CODE_TABLE_TYPE, pNode->tableType); + code = tlvEncodeValueI8(pEncoder, pNode->tableType); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI16(pEncoder, COLUMN_CODE_COLUMN_ID, pNode->colId); + code = tlvEncodeValueI16(pEncoder, pNode->colId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeEnum(pEncoder, COLUMN_CODE_COLUMN_TYPE, pNode->colType); + code = tlvEncodeValueEnum(pEncoder, pNode->colType); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, COLUMN_CODE_DB_NAME, pNode->dbName); + code = tlvEncodeValueCStr(pEncoder, pNode->dbName); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, COLUMN_CODE_TABLE_NAME, pNode->tableName); + code = tlvEncodeValueCStr(pEncoder, pNode->tableName); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, COLUMN_CODE_TABLE_ALIAS, pNode->tableAlias); + code = tlvEncodeValueCStr(pEncoder, pNode->tableAlias); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, COLUMN_CODE_COL_NAME, pNode->colName); + code = tlvEncodeValueCStr(pEncoder, pNode->colName); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI16(pEncoder, COLUMN_CODE_DATABLOCK_ID, pNode->dataBlockId); + code = tlvEncodeValueI16(pEncoder, pNode->dataBlockId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI16(pEncoder, COLUMN_CODE_SLOT_ID, pNode->slotId); + code = tlvEncodeValueI16(pEncoder, pNode->slotId); + } + + return code; +} + +static int32_t columnNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + return tlvEncodeObj(pEncoder, COLUMN_CODE_INLINE_ATTRS, columnNodeInlineToMsg, pObj); +} + +static int32_t msgToColumnNodeInline(STlvDecoder* pDecoder, void* pObj) { + SColumnNode* pNode = (SColumnNode*)pObj; + + int32_t code = msgToDataTypeInline(pDecoder, &pNode->node.resType); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU64(pDecoder, &pNode->tableId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI8(pDecoder, &pNode->tableType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI16(pDecoder, &pNode->colId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueEnum(pDecoder, &pNode->colType, sizeof(pNode->colType)); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->tableName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->tableAlias); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->colName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI16(pDecoder, &pNode->dataBlockId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI16(pDecoder, &pNode->slotId); } return code; @@ -433,38 +758,8 @@ static int32_t msgToColumnNode(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case COLUMN_CODE_EXPR_BASE: - code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node); - break; - case COLUMN_CODE_TABLE_ID: - code = tlvDecodeU64(pTlv, &pNode->tableId); - break; - case COLUMN_CODE_TABLE_TYPE: - code = tlvDecodeI8(pTlv, &pNode->tableType); - break; - case COLUMN_CODE_COLUMN_ID: - code = tlvDecodeI16(pTlv, &pNode->colId); - break; - case COLUMN_CODE_COLUMN_TYPE: - code = tlvDecodeEnum(pTlv, &pNode->colType, sizeof(pNode->colType)); - break; - case COLUMN_CODE_DB_NAME: - code = tlvDecodeCStr(pTlv, pNode->dbName); - break; - case COLUMN_CODE_TABLE_NAME: - code = tlvDecodeCStr(pTlv, pNode->tableName); - break; - case COLUMN_CODE_TABLE_ALIAS: - code = tlvDecodeCStr(pTlv, pNode->tableAlias); - break; - case COLUMN_CODE_COL_NAME: - code = tlvDecodeCStr(pTlv, pNode->colName); - break; - case COLUMN_CODE_DATABLOCK_ID: - code = tlvDecodeI16(pTlv, &pNode->dataBlockId); - break; - case COLUMN_CODE_SLOT_ID: - code = tlvDecodeI16(pTlv, &pNode->slotId); + case COLUMN_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToColumnNodeInline, pNode); break; default: break; @@ -983,7 +1278,7 @@ enum { NODE_LIST_CODE_DATA_TYPE = 1, NODE_LIST_CODE_NODE_LIST }; static int32_t nodeListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { const SNodeListNode* pNode = (const SNodeListNode*)pObj; - int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_DATA_TYPE, dataTypeToMsg, &pNode->dataType); + int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_DATA_TYPE, dataTypeInlineToMsg, &pNode->dataType); if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_NODE_LIST, nodeListToMsg, pNode->pNodeList); } @@ -999,7 +1294,7 @@ static int32_t msgToNodeListNode(STlvDecoder* pDecoder, void* pObj) { tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { case NODE_LIST_CODE_DATA_TYPE: - code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->dataType); + code = tlvDecodeObjFromTlv(pTlv, msgToDataTypeInline, &pNode->dataType); break; case NODE_LIST_CODE_NODE_LIST: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList); @@ -1012,15 +1307,23 @@ static int32_t msgToNodeListNode(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { TARGET_CODE_DATA_BLOCK_ID = 1, TARGET_CODE_SLOT_ID, TARGET_CODE_EXPR }; +enum { TARGET_CODE_INLINE_ATTRS = 1, TARGET_CODE_EXPR }; + +static int32_t targetNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const STargetNode* pNode = (const STargetNode*)pObj; + + int32_t code = tlvEncodeValueI16(pEncoder, pNode->dataBlockId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI16(pEncoder, pNode->slotId); + } + + return code; +} static int32_t targetNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { const STargetNode* pNode = (const STargetNode*)pObj; - int32_t code = tlvEncodeI16(pEncoder, TARGET_CODE_DATA_BLOCK_ID, pNode->dataBlockId); - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI16(pEncoder, TARGET_CODE_SLOT_ID, pNode->slotId); - } + int32_t code = tlvEncodeObj(pEncoder, TARGET_CODE_INLINE_ATTRS, targetNodeInlineToMsg, pNode); if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, TARGET_CODE_EXPR, nodeToMsg, pNode->pExpr); } @@ -1028,6 +1331,17 @@ static int32_t targetNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToTargetNodeInline(STlvDecoder* pDecoder, void* pObj) { + STargetNode* pNode = (STargetNode*)pObj; + + int32_t code = tlvDecodeValueI16(pDecoder, &pNode->dataBlockId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI16(pDecoder, &pNode->slotId); + } + + return code; +} + static int32_t msgToTargetNode(STlvDecoder* pDecoder, void* pObj) { STargetNode* pNode = (STargetNode*)pObj; @@ -1035,11 +1349,8 @@ static int32_t msgToTargetNode(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case TARGET_CODE_DATA_BLOCK_ID: - code = tlvDecodeI16(pTlv, &pNode->dataBlockId); - break; - case TARGET_CODE_SLOT_ID: - code = tlvDecodeI16(pTlv, &pNode->slotId); + case TARGET_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToTargetNodeInline, pNode); break; case TARGET_CODE_EXPR: code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExpr); @@ -1052,29 +1363,48 @@ static int32_t msgToTargetNode(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { - DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID = 1, - DATA_BLOCK_DESC_CODE_SLOTS, - DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE, - DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE, - DATA_BLOCK_DESC_CODE_PRECISION -}; +enum { DATA_BLOCK_DESC_CODE_INLINE_ATTRS = 1, DATA_BLOCK_DESC_CODE_SLOTS }; + +static int32_t dataBlockDescNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SDataBlockDescNode* pNode = (const SDataBlockDescNode*)pObj; + + int32_t code = tlvEncodeValueI16(pEncoder, pNode->dataBlockId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->totalRowSize); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->outputRowSize); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueU8(pEncoder, pNode->precision); + } + + return code; +} static int32_t dataBlockDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { const SDataBlockDescNode* pNode = (const SDataBlockDescNode*)pObj; - int32_t code = tlvEncodeI16(pEncoder, DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID, pNode->dataBlockId); + int32_t code = tlvEncodeObj(pEncoder, DATA_BLOCK_DESC_CODE_INLINE_ATTRS, dataBlockDescNodeInlineToMsg, pNode); if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, DATA_BLOCK_DESC_CODE_SLOTS, nodeListToMsg, pNode->pSlots); } + + return code; +} + +static int32_t msgToDataBlockDescNodeInline(STlvDecoder* pDecoder, void* pObj) { + SDataBlockDescNode* pNode = (SDataBlockDescNode*)pObj; + + int32_t code = tlvDecodeValueI16(pDecoder, &pNode->dataBlockId); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE, pNode->totalRowSize); + code = tlvDecodeValueI32(pDecoder, &pNode->totalRowSize); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE, pNode->outputRowSize); + code = tlvDecodeValueI32(pDecoder, &pNode->outputRowSize); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU8(pEncoder, DATA_BLOCK_DESC_CODE_PRECISION, pNode->precision); + code = tlvDecodeValueU8(pDecoder, &pNode->precision); } return code; @@ -1087,21 +1417,12 @@ static int32_t msgToDataBlockDescNode(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID: - code = tlvDecodeI16(pTlv, &pNode->dataBlockId); + case DATA_BLOCK_DESC_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToDataBlockDescNodeInline, pNode); break; case DATA_BLOCK_DESC_CODE_SLOTS: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSlots); break; - case DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE: - code = tlvDecodeI32(pTlv, &pNode->totalRowSize); - break; - case DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE: - code = tlvDecodeI32(pTlv, &pNode->outputRowSize); - break; - case DATA_BLOCK_DESC_CODE_PRECISION: - code = tlvDecodeU8(pTlv, &pNode->precision); - break; default: break; } @@ -1110,29 +1431,47 @@ static int32_t msgToDataBlockDescNode(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { - SLOT_DESC_CODE_SLOT_ID = 1, - SLOT_DESC_CODE_DATA_TYPE, - SLOT_DESC_CODE_RESERVE, - SLOT_DESC_CODE_OUTPUT, - SLOT_DESC_CODE_TAG -}; +enum { SLOT_DESC_CODE_INLINE_ATTRS = 1 }; -static int32_t slotDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { +static int32_t slotDescNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { const SSlotDescNode* pNode = (const SSlotDescNode*)pObj; - int32_t code = tlvEncodeI16(pEncoder, SLOT_DESC_CODE_SLOT_ID, pNode->slotId); + int32_t code = tlvEncodeValueI16(pEncoder, pNode->slotId); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeObj(pEncoder, SLOT_DESC_CODE_DATA_TYPE, dataTypeToMsg, &pNode->dataType); + code = dataTypeInlineToMsg(&pNode->dataType, pEncoder); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_RESERVE, pNode->reserve); + code = tlvEncodeValueBool(pEncoder, pNode->reserve); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_OUTPUT, pNode->output); + code = tlvEncodeValueBool(pEncoder, pNode->output); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_TAG, pNode->tag); + code = tlvEncodeValueBool(pEncoder, pNode->tag); + } + + return code; +} + +static int32_t slotDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + return tlvEncodeObj(pEncoder, SLOT_DESC_CODE_INLINE_ATTRS, slotDescNodeInlineToMsg, pObj); +} + +static int32_t msgToSlotDescNodeInline(STlvDecoder* pDecoder, void* pObj) { + SSlotDescNode* pNode = (SSlotDescNode*)pObj; + + int32_t code = tlvDecodeValueI16(pDecoder, &pNode->slotId); + if (TSDB_CODE_SUCCESS == code) { + code = msgToDataTypeInline(pDecoder, &pNode->dataType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueBool(pDecoder, &pNode->reserve); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueBool(pDecoder, &pNode->output); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueBool(pDecoder, &pNode->tag); } return code; @@ -1145,20 +1484,8 @@ static int32_t msgToSlotDescNode(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case SLOT_DESC_CODE_SLOT_ID: - code = tlvDecodeI16(pTlv, &pNode->slotId); - break; - case SLOT_DESC_CODE_DATA_TYPE: - code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->dataType); - break; - case SLOT_DESC_CODE_RESERVE: - code = tlvDecodeBool(pTlv, &pNode->reserve); - break; - case SLOT_DESC_CODE_OUTPUT: - code = tlvDecodeBool(pTlv, &pNode->output); - break; - case SLOT_DESC_CODE_TAG: - code = tlvDecodeBool(pTlv, &pNode->tag); + case SLOT_DESC_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToSlotDescNodeInline, pNode); break; default: break; @@ -1170,6 +1497,17 @@ static int32_t msgToSlotDescNode(STlvDecoder* pDecoder, void* pObj) { enum { EP_CODE_FQDN = 1, EP_CODE_port }; +static int32_t epInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SEp* pNode = (const SEp*)pObj; + + int32_t code = tlvEncodeValueCStr(pEncoder, pNode->fqdn); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueU16(pEncoder, pNode->port); + } + + return code; +} + static int32_t epToMsg(const void* pObj, STlvEncoder* pEncoder) { const SEp* pNode = (const SEp*)pObj; @@ -1181,6 +1519,17 @@ static int32_t epToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToEpInline(STlvDecoder* pDecoder, void* pObj) { + SEp* pNode = (SEp*)pObj; + + int32_t code = tlvDecodeValueCStr(pDecoder, pNode->fqdn); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU16(pDecoder, &pNode->port); + } + + return code; +} + static int32_t msgToEp(STlvDecoder* pDecoder, void* pObj) { SEp* pNode = (SEp*)pObj; @@ -1204,6 +1553,17 @@ static int32_t msgToEp(STlvDecoder* pDecoder, void* pObj) { enum { EP_SET_CODE_IN_USE = 1, EP_SET_CODE_NUM_OF_EPS, EP_SET_CODE_EPS }; +static int32_t epSetInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SEpSet* pNode = (const SEpSet*)pObj; + + int32_t code = tlvEncodeValueI8(pEncoder, pNode->inUse); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueArray(pEncoder, epInlineToMsg, pNode->eps, sizeof(SEp), pNode->numOfEps); + } + + return code; +} + static int32_t epSetToMsg(const void* pObj, STlvEncoder* pEncoder) { const SEpSet* pNode = (const SEpSet*)pObj; @@ -1218,6 +1578,19 @@ static int32_t epSetToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToEpSetInline(STlvDecoder* pDecoder, void* pObj) { + SEpSet* pNode = (SEpSet*)pObj; + + int32_t code = tlvDecodeValueI8(pDecoder, &pNode->inUse); + if (TSDB_CODE_SUCCESS == code) { + int32_t numOfEps = 0; + code = tlvDecodeValueArray(pDecoder, msgToEpInline, pNode->eps, sizeof(SEp), &numOfEps); + pNode->numOfEps = numOfEps; + } + + return code; +} + static int32_t msgToEpSet(STlvDecoder* pDecoder, void* pObj) { SEpSet* pNode = (SEpSet*)pObj; @@ -1244,6 +1617,17 @@ static int32_t msgToEpSet(STlvDecoder* pDecoder, void* pObj) { enum { QUERY_NODE_ADDR_CODE_NODE_ID = 1, QUERY_NODE_ADDR_CODE_EP_SET }; +static int32_t queryNodeAddrInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SQueryNodeAddr* pNode = (const SQueryNodeAddr*)pObj; + + int32_t code = tlvEncodeValueI32(pEncoder, pNode->nodeId); + if (TSDB_CODE_SUCCESS == code) { + code = epSetInlineToMsg(&pNode->epSet, pEncoder); + } + + return code; +} + static int32_t queryNodeAddrToMsg(const void* pObj, STlvEncoder* pEncoder) { const SQueryNodeAddr* pNode = (const SQueryNodeAddr*)pObj; @@ -1255,6 +1639,17 @@ static int32_t queryNodeAddrToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToQueryNodeAddrInline(STlvDecoder* pDecoder, void* pObj) { + SQueryNodeAddr* pNode = (SQueryNodeAddr*)pObj; + + int32_t code = tlvDecodeValueI32(pDecoder, &pNode->nodeId); + if (TSDB_CODE_SUCCESS == code) { + code = msgToEpSetInline(pDecoder, &pNode->epSet); + } + + return code; +} + static int32_t msgToQueryNodeAddr(STlvDecoder* pDecoder, void* pObj) { SQueryNodeAddr* pNode = (SQueryNodeAddr*)pObj; @@ -1274,29 +1669,47 @@ static int32_t msgToQueryNodeAddr(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { - DOWNSTREAM_SOURCE_CODE_ADDR = 1, - DOWNSTREAM_SOURCE_CODE_TASK_ID, - DOWNSTREAM_SOURCE_CODE_SCHED_ID, - DOWNSTREAM_SOURCE_CODE_EXEC_ID, - DOWNSTREAM_SOURCE_CODE_FETCH_MSG_TYPE -}; +enum { DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS = 1 }; -static int32_t downstreamSourceNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { +static int32_t downstreamSourceNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { const SDownstreamSourceNode* pNode = (const SDownstreamSourceNode*)pObj; - int32_t code = tlvEncodeObj(pEncoder, DOWNSTREAM_SOURCE_CODE_ADDR, queryNodeAddrToMsg, &pNode->addr); + int32_t code = queryNodeAddrInlineToMsg(&pNode->addr, pEncoder); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU64(pEncoder, DOWNSTREAM_SOURCE_CODE_TASK_ID, pNode->taskId); + code = tlvEncodeValueU64(pEncoder, pNode->taskId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU64(pEncoder, DOWNSTREAM_SOURCE_CODE_SCHED_ID, pNode->schedId); + code = tlvEncodeValueU64(pEncoder, pNode->schedId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, DOWNSTREAM_SOURCE_CODE_EXEC_ID, pNode->execId); + code = tlvEncodeValueI32(pEncoder, pNode->execId); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, DOWNSTREAM_SOURCE_CODE_FETCH_MSG_TYPE, pNode->fetchMsgType); + code = tlvEncodeValueI32(pEncoder, pNode->fetchMsgType); + } + + return code; +} + +static int32_t downstreamSourceNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + return tlvEncodeObj(pEncoder, DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS, downstreamSourceNodeInlineToMsg, pObj); +} + +static int32_t msgToDownstreamSourceNodeInlineToMsg(STlvDecoder* pDecoder, void* pObj) { + SDownstreamSourceNode* pNode = (SDownstreamSourceNode*)pObj; + + int32_t code = msgToQueryNodeAddrInline(pDecoder, &pNode->addr); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU64(pDecoder, &pNode->taskId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueU64(pDecoder, &pNode->schedId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->execId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->fetchMsgType); } return code; @@ -1309,20 +1722,94 @@ static int32_t msgToDownstreamSourceNode(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case DOWNSTREAM_SOURCE_CODE_ADDR: - code = tlvDecodeObjFromTlv(pTlv, msgToQueryNodeAddr, &pNode->addr); + case DOWNSTREAM_SOURCE_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToDownstreamSourceNodeInlineToMsg, pNode); break; - case DOWNSTREAM_SOURCE_CODE_TASK_ID: - code = tlvDecodeU64(pTlv, &pNode->taskId); + default: break; - case DOWNSTREAM_SOURCE_CODE_SCHED_ID: - code = tlvDecodeU64(pTlv, &pNode->schedId); + } + } + + return code; +} + +enum { WHEN_THEN_CODE_EXPR_BASE = 1, WHEN_THEN_CODE_WHEN, WHEN_THEN_CODE_THEN }; + +static int32_t whenThenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SWhenThenNode* pNode = (const SWhenThenNode*)pObj; + + int32_t code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_EXPR_BASE, exprNodeToMsg, pNode); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_WHEN, nodeToMsg, pNode->pWhen); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, WHEN_THEN_CODE_THEN, nodeToMsg, pNode->pThen); + } + + return code; +} + +static int32_t msgToWhenThenNode(STlvDecoder* pDecoder, void* pObj) { + SWhenThenNode* pNode = (SWhenThenNode*)pObj; + + int32_t code = TSDB_CODE_SUCCESS; + STlv* pTlv = NULL; + tlvForEach(pDecoder, pTlv, code) { + switch (pTlv->type) { + case WHEN_THEN_CODE_EXPR_BASE: + code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node); break; - case DOWNSTREAM_SOURCE_CODE_EXEC_ID: - code = tlvDecodeI32(pTlv, &pNode->execId); + case WHEN_THEN_CODE_WHEN: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWhen); break; - case DOWNSTREAM_SOURCE_CODE_FETCH_MSG_TYPE: - code = tlvDecodeI32(pTlv, &pNode->fetchMsgType); + case WHEN_THEN_CODE_THEN: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pThen); + break; + default: + break; + } + } + + return code; +} + +enum { CASE_WHEN_CODE_EXPR_BASE = 1, CASE_WHEN_CODE_CASE, CASE_WHEN_CODE_ELSE, CASE_WHEN_CODE_WHEN_THEN_LIST }; + +static int32_t caseWhenNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SCaseWhenNode* pNode = (const SCaseWhenNode*)pObj; + + int32_t code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_EXPR_BASE, exprNodeToMsg, pNode); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_CASE, nodeToMsg, pNode->pCase); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_ELSE, nodeToMsg, pNode->pElse); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeObj(pEncoder, CASE_WHEN_CODE_WHEN_THEN_LIST, nodeListToMsg, pNode->pWhenThenList); + } + + return code; +} + +static int32_t msgToCaseWhenNode(STlvDecoder* pDecoder, void* pObj) { + SCaseWhenNode* pNode = (SCaseWhenNode*)pObj; + + int32_t code = TSDB_CODE_SUCCESS; + STlv* pTlv = NULL; + tlvForEach(pDecoder, pTlv, code) { + switch (pTlv->type) { + case CASE_WHEN_CODE_EXPR_BASE: + code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node); + break; + case CASE_WHEN_CODE_CASE: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pCase); + break; + case CASE_WHEN_CODE_ELSE: + code = msgToNodeFromTlv(pTlv, (void**)&pNode->pElse); + break; + case CASE_WHEN_CODE_WHEN_THEN_LIST: + code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pWhenThenList); break; default: break; @@ -1504,43 +1991,70 @@ static int32_t msgToPhysiLastRowScanNode(STlvDecoder* pDecoder, void* pObj) { enum { PHY_TABLE_SCAN_CODE_SCAN = 1, - PHY_TABLE_SCAN_CODE_SCAN_COUNT, - PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT, - PHY_TABLE_SCAN_CODE_SCAN_RANGE, - PHY_TABLE_SCAN_CODE_RATIO, - PHY_TABLE_SCAN_CODE_DATA_REQUIRED, + PHY_TABLE_SCAN_CODE_INLINE_ATTRS, PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS, - PHY_TABLE_SCAN_CODE_GROUP_TAGS, - PHY_TABLE_SCAN_CODE_GROUP_SORT, - PHY_TABLE_SCAN_CODE_INTERVAL, - PHY_TABLE_SCAN_CODE_OFFSET, - PHY_TABLE_SCAN_CODE_SLIDING, - PHY_TABLE_SCAN_CODE_INTERVAL_UNIT, - PHY_TABLE_SCAN_CODE_SLIDING_UNIT, - PHY_TABLE_SCAN_CODE_TRIGGER_TYPE, - PHY_TABLE_SCAN_CODE_WATERMARK, - PHY_TABLE_SCAN_CODE_IG_EXPIRED, - PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID, + PHY_TABLE_SCAN_CODE_GROUP_TAGS }; +static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; + + int32_t code = tlvEncodeValueU8(pEncoder, pNode->scanSeq[0]); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueU8(pEncoder, pNode->scanSeq[1]); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->scanRange.skey); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->scanRange.ekey); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueDouble(pEncoder, pNode->ratio); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->dataRequired); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueBool(pEncoder, pNode->groupSort); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->interval); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->offset); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->sliding); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->slidingUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->triggerType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->watermark); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->igExpired); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueBool(pEncoder, pNode->assignBlockUid); + } + + return code; +} + static int32_t physiTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; int32_t code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU8(pEncoder, PHY_TABLE_SCAN_CODE_SCAN_COUNT, pNode->scanSeq[0]); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeU8(pEncoder, PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT, pNode->scanSeq[1]); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SCAN_RANGE, timeWindowToMsg, &pNode->scanRange); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeDouble(pEncoder, PHY_TABLE_SCAN_CODE_RATIO, pNode->ratio); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, PHY_TABLE_SCAN_CODE_DATA_REQUIRED, pNode->dataRequired); + code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_INLINE_ATTRS, physiTableScanNodeInlineToMsg, pNode); } if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS, nodeListToMsg, pNode->pDynamicScanFuncs); @@ -1548,35 +2062,58 @@ static int32_t physiTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags); } + + return code; +} + +static int32_t msgToPhysiTableScanNodeInline(STlvDecoder* pDecoder, void* pObj) { + STableScanPhysiNode* pNode = (STableScanPhysiNode*)pObj; + + int32_t code = tlvDecodeValueU8(pDecoder, pNode->scanSeq); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeBool(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_SORT, pNode->groupSort); + code = tlvDecodeValueU8(pDecoder, pNode->scanSeq + 1); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_INTERVAL, pNode->interval); + code = tlvDecodeValueI64(pDecoder, &pNode->scanRange.skey); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_OFFSET, pNode->offset); + code = tlvDecodeValueI64(pDecoder, &pNode->scanRange.ekey); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_SLIDING, pNode->sliding); + code = tlvDecodeValueDouble(pDecoder, &pNode->ratio); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_INTERVAL_UNIT, pNode->intervalUnit); + code = tlvDecodeValueI32(pDecoder, &pNode->dataRequired); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_SLIDING_UNIT, pNode->slidingUnit); + code = tlvDecodeValueBool(pDecoder, &pNode->groupSort); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_TRIGGER_TYPE, pNode->triggerType); + code = tlvDecodeValueI64(pDecoder, &pNode->interval); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_WATERMARK, pNode->watermark); + code = tlvDecodeValueI64(pDecoder, &pNode->offset); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_IG_EXPIRED, pNode->igExpired); + code = tlvDecodeValueI64(pDecoder, &pNode->sliding); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeBool(pEncoder, PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID, pNode->assignBlockUid); + code = tlvDecodeValueI8(pDecoder, &pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI8(pDecoder, &pNode->slidingUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI8(pDecoder, &pNode->triggerType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI64(pDecoder, &pNode->watermark); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI8(pDecoder, &pNode->igExpired); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueBool(pDecoder, &pNode->assignBlockUid); } return code; @@ -1592,20 +2129,8 @@ static int32_t msgToPhysiTableScanNode(STlvDecoder* pDecoder, void* pObj) { case PHY_TABLE_SCAN_CODE_SCAN: code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan); break; - case PHY_TABLE_SCAN_CODE_SCAN_COUNT: - code = tlvDecodeU8(pTlv, pNode->scanSeq); - break; - case PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT: - code = tlvDecodeU8(pTlv, pNode->scanSeq + 1); - break; - case PHY_TABLE_SCAN_CODE_SCAN_RANGE: - code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->scanRange); - break; - case PHY_TABLE_SCAN_CODE_RATIO: - code = tlvDecodeDouble(pTlv, &pNode->ratio); - break; - case PHY_TABLE_SCAN_CODE_DATA_REQUIRED: - code = tlvDecodeI32(pTlv, &pNode->dataRequired); + case PHY_TABLE_SCAN_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToPhysiTableScanNodeInline, pNode); break; case PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pDynamicScanFuncs); @@ -1613,36 +2138,6 @@ static int32_t msgToPhysiTableScanNode(STlvDecoder* pDecoder, void* pObj) { case PHY_TABLE_SCAN_CODE_GROUP_TAGS: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags); break; - case PHY_TABLE_SCAN_CODE_GROUP_SORT: - code = tlvDecodeBool(pTlv, &pNode->groupSort); - break; - case PHY_TABLE_SCAN_CODE_INTERVAL: - code = tlvDecodeI64(pTlv, &pNode->interval); - break; - case PHY_TABLE_SCAN_CODE_OFFSET: - code = tlvDecodeI64(pTlv, &pNode->offset); - break; - case PHY_TABLE_SCAN_CODE_SLIDING: - code = tlvDecodeI64(pTlv, &pNode->sliding); - break; - case PHY_TABLE_SCAN_CODE_INTERVAL_UNIT: - code = tlvDecodeI8(pTlv, &pNode->intervalUnit); - break; - case PHY_TABLE_SCAN_CODE_SLIDING_UNIT: - code = tlvDecodeI8(pTlv, &pNode->slidingUnit); - break; - case PHY_TABLE_SCAN_CODE_TRIGGER_TYPE: - code = tlvDecodeI8(pTlv, &pNode->triggerType); - break; - case PHY_TABLE_SCAN_CODE_WATERMARK: - code = tlvDecodeI64(pTlv, &pNode->watermark); - break; - case PHY_TABLE_SCAN_CODE_IG_EXPIRED: - code = tlvDecodeI8(pTlv, &pNode->igExpired); - break; - case PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID: - code = tlvDecodeBool(pTlv, &pNode->assignBlockUid); - break; default: break; } @@ -2145,33 +2640,54 @@ static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { - PHY_INTERVAL_CODE_WINDOW = 1, - PHY_INTERVAL_CODE_INTERVAL, - PHY_INTERVAL_CODE_OFFSET, - PHY_INTERVAL_CODE_SLIDING, - PHY_INTERVAL_CODE_INTERVAL_UNIT, - PHY_INTERVAL_CODE_SLIDING_UNIT -}; +enum { PHY_INTERVAL_CODE_WINDOW = 1, PHY_INTERVAL_CODE_INLINE_ATTRS }; + +static int32_t physiIntervalNodeInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj; + + int32_t code = tlvEncodeValueI64(pEncoder, pNode->interval); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->offset); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI64(pEncoder, pNode->sliding); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->slidingUnit); + } + + return code; +} static int32_t physiIntervalNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj; int32_t code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window); if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_INTERVAL, pNode->interval); + code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_INLINE_ATTRS, physiIntervalNodeInlineToMsg, pNode); + } + + return code; +} + +static int32_t msgToPhysiIntervalNodeInline(STlvDecoder* pDecoder, void* pObj) { + SIntervalPhysiNode* pNode = (SIntervalPhysiNode*)pObj; + + int32_t code = tlvDecodeValueI64(pDecoder, &pNode->interval); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI64(pDecoder, &pNode->offset); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_OFFSET, pNode->offset); + code = tlvDecodeValueI64(pDecoder, &pNode->sliding); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_SLIDING, pNode->sliding); + code = tlvDecodeValueI8(pDecoder, &pNode->intervalUnit); } if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_INTERVAL_CODE_INTERVAL_UNIT, pNode->intervalUnit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI8(pEncoder, PHY_INTERVAL_CODE_SLIDING_UNIT, pNode->slidingUnit); + code = tlvDecodeValueI8(pDecoder, &pNode->slidingUnit); } return code; @@ -2187,20 +2703,8 @@ static int32_t msgToPhysiIntervalNode(STlvDecoder* pDecoder, void* pObj) { case PHY_INTERVAL_CODE_WINDOW: code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window); break; - case PHY_INTERVAL_CODE_INTERVAL: - code = tlvDecodeI64(pTlv, &pNode->interval); - break; - case PHY_INTERVAL_CODE_OFFSET: - code = tlvDecodeI64(pTlv, &pNode->offset); - break; - case PHY_INTERVAL_CODE_SLIDING: - code = tlvDecodeI64(pTlv, &pNode->sliding); - break; - case PHY_INTERVAL_CODE_INTERVAL_UNIT: - code = tlvDecodeI8(pTlv, &pNode->intervalUnit); - break; - case PHY_INTERVAL_CODE_SLIDING_UNIT: - code = tlvDecodeI8(pTlv, &pNode->slidingUnit); + case PHY_INTERVAL_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToPhysiIntervalNodeInline, pNode); break; default: break; @@ -2746,6 +3250,20 @@ static int32_t msgToPhysiDeleteNode(STlvDecoder* pDecoder, void* pObj) { enum { SUBPLAN_ID_CODE_QUERY_ID = 1, SUBPLAN_ID_CODE_GROUP_ID, SUBPLAN_ID_CODE_SUBPLAN_ID }; +static int32_t subplanIdInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SSubplanId* pNode = (const SSubplanId*)pObj; + + int32_t code = tlvEncodeValueU64(pEncoder, pNode->queryId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->groupId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->subplanId); + } + + return code; +} + static int32_t subplanIdToMsg(const void* pObj, STlvEncoder* pEncoder) { const SSubplanId* pNode = (const SSubplanId*)pObj; @@ -2760,6 +3278,20 @@ static int32_t subplanIdToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToSubplanIdInline(STlvDecoder* pDecoder, void* pObj) { + SSubplanId* pNode = (SSubplanId*)pObj; + + int32_t code = tlvDecodeValueU64(pDecoder, &pNode->queryId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->groupId); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->subplanId); + } + + return code; +} + static int32_t msgToSubplanId(STlvDecoder* pDecoder, void* pObj) { SSubplanId* pNode = (SSubplanId*)pObj; @@ -2785,41 +3317,43 @@ static int32_t msgToSubplanId(STlvDecoder* pDecoder, void* pObj) { } enum { - SUBPLAN_CODE_SUBPLAN_ID = 1, - SUBPLAN_CODE_SUBPLAN_TYPE, - SUBPLAN_CODE_MSG_TYPE, - SUBPLAN_CODE_LEVEL, - SUBPLAN_CODE_DBFNAME, - SUBPLAN_CODE_USER, - SUBPLAN_CODE_EXECNODE, + SUBPLAN_CODE_INLINE_ATTRS = 1, SUBPLAN_CODE_ROOT_NODE, SUBPLAN_CODE_DATA_SINK, SUBPLAN_CODE_TAG_COND, SUBPLAN_CODE_TAG_INDEX_COND }; +static int32_t subplanInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SSubplan* pNode = (const SSubplan*)pObj; + + int32_t code = subplanIdInlineToMsg(&pNode->id, pEncoder); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueEnum(pEncoder, pNode->subplanType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->msgType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->level); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueCStr(pEncoder, pNode->dbFName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueCStr(pEncoder, pNode->user); + } + if (TSDB_CODE_SUCCESS == code) { + code = queryNodeAddrInlineToMsg(&pNode->execNode, pEncoder); + } + + return code; +} + static int32_t subplanToMsg(const void* pObj, STlvEncoder* pEncoder) { const SSubplan* pNode = (const SSubplan*)pObj; - int32_t code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_SUBPLAN_ID, subplanIdToMsg, &pNode->id); - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeEnum(pEncoder, SUBPLAN_CODE_SUBPLAN_TYPE, pNode->subplanType); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, SUBPLAN_CODE_MSG_TYPE, pNode->msgType); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, SUBPLAN_CODE_LEVEL, pNode->level); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, SUBPLAN_CODE_DBFNAME, pNode->dbFName); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeCStr(pEncoder, SUBPLAN_CODE_USER, pNode->user); - } - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_EXECNODE, queryNodeAddrToMsg, &pNode->execNode); - } + int32_t code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_INLINE_ATTRS, subplanInlineToMsg, pNode); if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_ROOT_NODE, nodeToMsg, pNode->pNode); } @@ -2836,6 +3370,32 @@ static int32_t subplanToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToSubplanInline(STlvDecoder* pDecoder, void* pObj) { + SSubplan* pNode = (SSubplan*)pObj; + + int32_t code = msgToSubplanIdInline(pDecoder, &pNode->id); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueEnum(pDecoder, &pNode->subplanType, sizeof(pNode->subplanType)); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->msgType); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->level); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->dbFName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueCStr(pDecoder, pNode->user); + } + if (TSDB_CODE_SUCCESS == code) { + code = msgToQueryNodeAddrInline(pDecoder, &pNode->execNode); + } + + return code; +} + static int32_t msgToSubplan(STlvDecoder* pDecoder, void* pObj) { SSubplan* pNode = (SSubplan*)pObj; @@ -2843,26 +3403,8 @@ static int32_t msgToSubplan(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case SUBPLAN_CODE_SUBPLAN_ID: - code = tlvDecodeObjFromTlv(pTlv, msgToSubplanId, &pNode->id); - break; - case SUBPLAN_CODE_SUBPLAN_TYPE: - code = tlvDecodeEnum(pTlv, &pNode->subplanType, sizeof(pNode->subplanType)); - break; - case SUBPLAN_CODE_MSG_TYPE: - code = tlvDecodeI32(pTlv, &pNode->msgType); - break; - case SUBPLAN_CODE_LEVEL: - code = tlvDecodeI32(pTlv, &pNode->level); - break; - case SUBPLAN_CODE_DBFNAME: - code = tlvDecodeCStr(pTlv, pNode->dbFName); - break; - case SUBPLAN_CODE_USER: - code = tlvDecodeCStr(pTlv, pNode->user); - break; - case SUBPLAN_CODE_EXECNODE: - code = tlvDecodeObjFromTlv(pTlv, msgToQueryNodeAddr, &pNode->execNode); + case SUBPLAN_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToSubplanInline, pNode); break; case SUBPLAN_CODE_ROOT_NODE: code = msgToNodeFromTlv(pTlv, (void**)&pNode->pNode); @@ -2884,15 +3426,23 @@ static int32_t msgToSubplan(STlvDecoder* pDecoder, void* pObj) { return code; } -enum { QUERY_PLAN_CODE_QUERY_ID = 1, QUERY_PLAN_CODE_NUM_OF_SUBPLANS, QUERY_PLAN_CODE_SUBPLANS }; +enum { QUERY_PLAN_CODE_INLINE_ATTRS = 1, QUERY_PLAN_CODE_SUBPLANS }; + +static int32_t queryPlanInlineToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SQueryPlan* pNode = (const SQueryPlan*)pObj; + + int32_t code = tlvEncodeValueU64(pEncoder, pNode->queryId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI32(pEncoder, pNode->numOfSubplans); + } + + return code; +} static int32_t queryPlanToMsg(const void* pObj, STlvEncoder* pEncoder) { const SQueryPlan* pNode = (const SQueryPlan*)pObj; - int32_t code = tlvEncodeU64(pEncoder, QUERY_PLAN_CODE_QUERY_ID, pNode->queryId); - if (TSDB_CODE_SUCCESS == code) { - code = tlvEncodeI32(pEncoder, QUERY_PLAN_CODE_NUM_OF_SUBPLANS, pNode->numOfSubplans); - } + int32_t code = tlvEncodeObj(pEncoder, QUERY_PLAN_CODE_INLINE_ATTRS, queryPlanInlineToMsg, pNode); if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeObj(pEncoder, QUERY_PLAN_CODE_SUBPLANS, nodeListToMsg, pNode->pSubplans); } @@ -2900,6 +3450,17 @@ static int32_t queryPlanToMsg(const void* pObj, STlvEncoder* pEncoder) { return code; } +static int32_t msgToQueryPlanInline(STlvDecoder* pDecoder, void* pObj) { + SQueryPlan* pNode = (SQueryPlan*)pObj; + + int32_t code = tlvDecodeValueU64(pDecoder, &pNode->queryId); + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI32(pDecoder, &pNode->numOfSubplans); + } + + return code; +} + static int32_t msgToQueryPlan(STlvDecoder* pDecoder, void* pObj) { SQueryPlan* pNode = (SQueryPlan*)pObj; @@ -2907,11 +3468,8 @@ static int32_t msgToQueryPlan(STlvDecoder* pDecoder, void* pObj) { STlv* pTlv = NULL; tlvForEach(pDecoder, pTlv, code) { switch (pTlv->type) { - case QUERY_PLAN_CODE_QUERY_ID: - code = tlvDecodeU64(pTlv, &pNode->queryId); - break; - case QUERY_PLAN_CODE_NUM_OF_SUBPLANS: - code = tlvDecodeI32(pTlv, &pNode->numOfSubplans); + case QUERY_PLAN_CODE_INLINE_ATTRS: + code = tlvDecodeObjFromTlv(pTlv, msgToQueryPlanInline, pNode); break; case QUERY_PLAN_CODE_SUBPLANS: code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSubplans); @@ -2925,6 +3483,7 @@ static int32_t msgToQueryPlan(STlvDecoder* pDecoder, void* pObj) { } static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + // nodesWarn("specificNodeToMsg node = %s, before tlv count = %d", nodesNodeName(nodeType(pObj)), pEncoder->tlvCount); int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pObj)) { case QUERY_NODE_COLUMN: @@ -2961,9 +3520,16 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { code = slotDescNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_DOWNSTREAM_SOURCE: - return downstreamSourceNodeToMsg(pObj, pEncoder); + code = downstreamSourceNodeToMsg(pObj, pEncoder); + break; case QUERY_NODE_LEFT_VALUE: break; + case QUERY_NODE_WHEN_THEN: + code = whenThenNodeToMsg(pObj, pEncoder); + break; + case QUERY_NODE_CASE_WHEN: + code = caseWhenNodeToMsg(pObj, pEncoder); + break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: code = physiScanNodeToMsg(pObj, pEncoder); @@ -3044,12 +3610,12 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { code = queryPlanToMsg(pObj, pEncoder); break; default: - nodesWarn("specificNodeToMsg unknown node = %s", nodesNodeName(nodeType(pObj))); break; } if (TSDB_CODE_SUCCESS != code) { nodesError("specificNodeToMsg error node = %s", nodesNodeName(nodeType(pObj))); } + // nodesWarn("specificNodeToMsg node = %s, after tlv count = %d", nodesNodeName(nodeType(pObj)), pEncoder->tlvCount); return code; } @@ -3090,9 +3656,15 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { code = msgToSlotDescNode(pDecoder, pObj); break; case QUERY_NODE_DOWNSTREAM_SOURCE: - return msgToDownstreamSourceNode(pDecoder, pObj); + code = msgToDownstreamSourceNode(pDecoder, pObj); case QUERY_NODE_LEFT_VALUE: break; + case QUERY_NODE_WHEN_THEN: + code = msgToWhenThenNode(pDecoder, pObj); + break; + case QUERY_NODE_CASE_WHEN: + code = msgToCaseWhenNode(pDecoder, pObj); + break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: code = msgToPhysiScanNode(pDecoder, pObj); @@ -3173,7 +3745,6 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { code = msgToQueryPlan(pDecoder, pObj); break; default: - nodesWarn("msgToSpecificNode unknown node = %s", nodesNodeName(nodeType(pObj))); break; } if (TSDB_CODE_SUCCESS != code) { diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 728e173ff8..8ea80344fc 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -146,6 +146,25 @@ static EDealRes dispatchExpr(SNode* pNode, ETraversalOrder order, FNodeWalker wa case QUERY_NODE_TARGET: res = walkExpr(((STargetNode*)pNode)->pExpr, order, walker, pContext); break; + case QUERY_NODE_WHEN_THEN: { + SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode; + res = walkExpr(pWhenThen->pWhen, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pWhenThen->pThen, order, walker, pContext); + } + break; + } + case QUERY_NODE_CASE_WHEN: { + SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode; + res = walkExpr(pCaseWhen->pCase, order, walker, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExpr(pCaseWhen->pElse, order, walker, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = walkExprs(pCaseWhen->pWhenThenList, order, walker, pContext); + } + break; + } default: break; } @@ -291,6 +310,25 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit case QUERY_NODE_TARGET: res = rewriteExpr(&(((STargetNode*)pNode)->pExpr), order, rewriter, pContext); break; + case QUERY_NODE_WHEN_THEN: { + SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode; + res = rewriteExpr(&pWhenThen->pWhen, order, rewriter, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = rewriteExpr(&pWhenThen->pThen, order, rewriter, pContext); + } + break; + } + case QUERY_NODE_CASE_WHEN: { + SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)pNode; + res = rewriteExpr(&pCaseWhen->pCase, order, rewriter, pContext); + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = rewriteExpr(&pCaseWhen->pElse, order, rewriter, pContext); + } + if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { + res = rewriteExprs(pCaseWhen->pWhenThenList, order, rewriter, pContext); + } + break; + } default: break; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 805ddb9e42..7a04d319ec 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -21,9 +21,209 @@ #include "taoserror.h" #include "tdatablock.h" #include "thash.h" +#include "tref.h" -static SNode* makeNode(ENodeType type, size_t size) { - SNode* p = taosMemoryCalloc(1, size); +typedef struct SNodeMemChunk { + int32_t availableSize; + int32_t usedSize; + char* pBuf; + struct SNodeMemChunk* pNext; +} SNodeMemChunk; + +typedef struct SNodeAllocator { + int64_t self; + int64_t queryId; + int32_t chunkSize; + int32_t chunkNum; + SNodeMemChunk* pCurrChunk; + SNodeMemChunk* pChunks; + TdThreadMutex mutex; +} SNodeAllocator; + +static threadlocal SNodeAllocator* g_pNodeAllocator; +static int32_t g_allocatorReqRefPool = -1; + +static SNodeMemChunk* callocNodeChunk(SNodeAllocator* pAllocator) { + SNodeMemChunk* pNewChunk = taosMemoryCalloc(1, sizeof(SNodeMemChunk) + pAllocator->chunkSize); + if (NULL == pNewChunk) { + return NULL; + } + pNewChunk->pBuf = (char*)(pNewChunk + 1); + pNewChunk->availableSize = pAllocator->chunkSize; + pNewChunk->usedSize = 0; + pNewChunk->pNext = NULL; + if (NULL != pAllocator->pCurrChunk) { + pAllocator->pCurrChunk->pNext = pNewChunk; + } + pAllocator->pCurrChunk = pNewChunk; + if (NULL == pAllocator->pChunks) { + pAllocator->pChunks = pNewChunk; + } + ++(pAllocator->chunkNum); + return pNewChunk; +} + +static void* nodesCallocImpl(int32_t size) { + if (NULL == g_pNodeAllocator) { + return taosMemoryCalloc(1, size); + } + + if (g_pNodeAllocator->pCurrChunk->usedSize + size > g_pNodeAllocator->pCurrChunk->availableSize) { + if (NULL == callocNodeChunk(g_pNodeAllocator)) { + return NULL; + } + } + void* p = g_pNodeAllocator->pCurrChunk->pBuf + g_pNodeAllocator->pCurrChunk->usedSize; + g_pNodeAllocator->pCurrChunk->usedSize += size; + return p; +} + +static void* nodesCalloc(int32_t num, int32_t size) { + void* p = nodesCallocImpl(num * size + 1); + if (NULL == p) { + return NULL; + } + *(char*)p = (NULL != g_pNodeAllocator) ? 1 : 0; + return (char*)p + 1; +} + +static void nodesFree(void* p) { + char* ptr = (char*)p - 1; + if (0 == *ptr) { + taosMemoryFree(ptr); + } + return; +} + +static int32_t createNodeAllocator(int32_t chunkSize, SNodeAllocator** pAllocator) { + *pAllocator = taosMemoryCalloc(1, sizeof(SNodeAllocator)); + if (NULL == *pAllocator) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (*pAllocator)->chunkSize = chunkSize; + if (NULL == callocNodeChunk(*pAllocator)) { + taosMemoryFreeClear(*pAllocator); + return TSDB_CODE_OUT_OF_MEMORY; + } + taosThreadMutexInit(&(*pAllocator)->mutex, NULL); + return TSDB_CODE_SUCCESS; +} + +static void destroyNodeAllocator(void* p) { + if (NULL == p) { + return; + } + + SNodeAllocator* pAllocator = p; + + nodesDebug("query id %" PRIx64 " allocator id %" PRIx64 " alloc chunkNum: %d, chunkTotakSize: %d", + pAllocator->queryId, pAllocator->self, pAllocator->chunkNum, pAllocator->chunkNum * pAllocator->chunkSize); + + SNodeMemChunk* pChunk = pAllocator->pChunks; + while (NULL != pChunk) { + SNodeMemChunk* pTemp = pChunk->pNext; + taosMemoryFree(pChunk); + pChunk = pTemp; + } + taosThreadMutexDestroy(&pAllocator->mutex); + taosMemoryFree(pAllocator); +} + +int32_t nodesInitAllocatorSet() { + if (g_allocatorReqRefPool >= 0) { + nodesWarn("nodes already initialized"); + return TSDB_CODE_SUCCESS; + } + + g_allocatorReqRefPool = taosOpenRef(1024, destroyNodeAllocator); + if (g_allocatorReqRefPool < 0) { + nodesError("init nodes failed"); + return TSDB_CODE_OUT_OF_MEMORY; + } + + return TSDB_CODE_SUCCESS; +} + +void nodesDestroyAllocatorSet() { + if (g_allocatorReqRefPool >= 0) { + SNodeAllocator* pAllocator = taosIterateRef(g_allocatorReqRefPool, 0); + int64_t refId = 0; + while (NULL != pAllocator) { + refId = pAllocator->self; + taosRemoveRef(g_allocatorReqRefPool, refId); + pAllocator = taosIterateRef(g_allocatorReqRefPool, refId); + } + taosCloseRef(g_allocatorReqRefPool); + } +} + +int32_t nodesCreateAllocator(int64_t queryId, int32_t chunkSize, int64_t* pAllocatorId) { + SNodeAllocator* pAllocator = NULL; + int32_t code = createNodeAllocator(chunkSize, &pAllocator); + if (TSDB_CODE_SUCCESS == code) { + pAllocator->self = taosAddRef(g_allocatorReqRefPool, pAllocator); + if (pAllocator->self <= 0) { + return terrno; + } + pAllocator->queryId = queryId; + *pAllocatorId = pAllocator->self; + } + return code; +} + +int32_t nodesAcquireAllocator(int64_t allocatorId) { + if (allocatorId <= 0) { + return TSDB_CODE_SUCCESS; + } + + SNodeAllocator* pAllocator = taosAcquireRef(g_allocatorReqRefPool, allocatorId); + if (NULL == pAllocator) { + return terrno; + } + taosThreadMutexLock(&pAllocator->mutex); + g_pNodeAllocator = pAllocator; + return TSDB_CODE_SUCCESS; +} + +int32_t nodesReleaseAllocator(int64_t allocatorId) { + if (allocatorId <= 0) { + return TSDB_CODE_SUCCESS; + } + + if (NULL == g_pNodeAllocator) { + nodesError("allocator id %" PRIx64 + " release failed: The nodesReleaseAllocator function needs to be called after the nodesAcquireAllocator " + "function is called!", + allocatorId); + return TSDB_CODE_FAILED; + } + SNodeAllocator* pAllocator = g_pNodeAllocator; + g_pNodeAllocator = NULL; + taosThreadMutexUnlock(&pAllocator->mutex); + return taosReleaseRef(g_allocatorReqRefPool, allocatorId); +} + +int64_t nodesMakeAllocatorWeakRef(int64_t allocatorId) { + if (allocatorId <= 0) { + return 0; + } + + SNodeAllocator* pAllocator = taosAcquireRef(g_allocatorReqRefPool, allocatorId); + return pAllocator->self; +} + +int64_t nodesReleaseAllocatorWeakRef(int64_t allocatorId) { return taosReleaseRef(g_allocatorReqRefPool, allocatorId); } + +void nodesDestroyAllocator(int64_t allocatorId) { + if (allocatorId <= 0) { + return; + } + + taosRemoveRef(g_allocatorReqRefPool, allocatorId); +} + +static SNode* makeNode(ENodeType type, int32_t size) { + SNode* p = nodesCalloc(1, size); if (NULL == p) { return NULL; } @@ -91,6 +291,10 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SLeftValueNode)); case QUERY_NODE_COLUMN_REF: return makeNode(type, sizeof(SColumnDefNode)); + case QUERY_NODE_WHEN_THEN: + return makeNode(type, sizeof(SWhenThenNode)); + case QUERY_NODE_CASE_WHEN: + return makeNode(type, sizeof(SCaseWhenNode)); case QUERY_NODE_SET_OPERATOR: return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: @@ -538,7 +742,21 @@ void nodesDestroyNode(SNode* pNode) { break; } case QUERY_NODE_LEFT_VALUE: // no pointer field + case QUERY_NODE_COLUMN_REF: // no pointer field break; + case QUERY_NODE_WHEN_THEN: { + SWhenThenNode* pStmt = (SWhenThenNode*)pNode; + nodesDestroyNode(pStmt->pWhen); + nodesDestroyNode(pStmt->pThen); + break; + } + case QUERY_NODE_CASE_WHEN: { + SCaseWhenNode* pStmt = (SCaseWhenNode*)pNode; + nodesDestroyNode(pStmt->pCase); + nodesDestroyNode(pStmt->pElse); + nodesDestroyList(pStmt->pWhenThenList); + break; + } case QUERY_NODE_SET_OPERATOR: { SSetOperator* pStmt = (SSetOperator*)pNode; nodesDestroyList(pStmt->pProjectionList); @@ -824,6 +1042,7 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pLogicNode->pWStartTs); nodesDestroyNode(pLogicNode->pValues); nodesDestroyList(pLogicNode->pFillExprs); + nodesDestroyList(pLogicNode->pNotFillExprs); break; } case QUERY_NODE_LOGIC_PLAN_SORT: { @@ -1021,12 +1240,12 @@ void nodesDestroyNode(SNode* pNode) { default: break; } - taosMemoryFreeClear(pNode); + nodesFree(pNode); return; } SNodeList* nodesMakeList() { - SNodeList* p = taosMemoryCalloc(1, sizeof(SNodeList)); + SNodeList* p = nodesCalloc(1, sizeof(SNodeList)); if (NULL == p) { return NULL; } @@ -1037,7 +1256,7 @@ int32_t nodesListAppend(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } - SListCell* p = taosMemoryCalloc(1, sizeof(SListCell)); + SListCell* p = nodesCalloc(1, sizeof(SListCell)); if (NULL == p) { terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY; @@ -1104,7 +1323,7 @@ int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) { } pTarget->pTail = pSrc->pTail; pTarget->length += pSrc->length; - taosMemoryFreeClear(pSrc); + nodesFree(pSrc); return TSDB_CODE_SUCCESS; } @@ -1124,7 +1343,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { return TSDB_CODE_FAILED; } - SListCell* p = taosMemoryCalloc(1, sizeof(SListCell)); + SListCell* p = nodesCalloc(1, sizeof(SListCell)); if (NULL == p) { terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY; @@ -1152,7 +1371,7 @@ SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) { } SListCell* pNext = pCell->pNext; nodesDestroyNode(pCell->pNode); - taosMemoryFreeClear(pCell); + nodesFree(pCell); --(pList->length); return pNext; } @@ -1172,7 +1391,7 @@ void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc) { pPos->pPrev = pSrc->pTail; pTarget->length += pSrc->length; - taosMemoryFreeClear(pSrc); + nodesFree(pSrc); } SNode* nodesListGetNode(SNodeList* pList, int32_t index) { @@ -1204,7 +1423,7 @@ void nodesDestroyList(SNodeList* pList) { while (NULL != pNext) { pNext = nodesListErase(pList, pNext); } - taosMemoryFreeClear(pList); + nodesFree(pList); } void nodesClearList(SNodeList* pList) { @@ -1216,9 +1435,9 @@ void nodesClearList(SNodeList* pList) { while (NULL != pNext) { SListCell* tmp = pNext; pNext = pNext->pNext; - taosMemoryFreeClear(tmp); + nodesFree(tmp); } - taosMemoryFreeClear(pList); + nodesFree(pList); } void* nodesGetValueFromNode(SValueNode* pNode) { diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 898e4bf732..dea741cc9b 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -119,6 +119,8 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues); SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode); SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd); +SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen); +SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse); SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere); SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index bef2ed98ec..3e05583d92 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -452,7 +452,7 @@ sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; } /************************************************ create/drop topic ***************************************************/ -cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_or_subquery(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); } cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); } cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) WITH META AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, true); } @@ -471,7 +471,7 @@ cmd ::= DESCRIBE full_table_name(A). cmd ::= RESET QUERY CACHE. { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } /************************************************ explain *************************************************************/ -cmd ::= EXPLAIN analyze_opt(A) explain_options(B) query_expression(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); } +cmd ::= EXPLAIN analyze_opt(A) explain_options(B) query_or_subquery(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); } %type analyze_opt { bool } %destructor analyze_opt { } @@ -502,7 +502,7 @@ bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). /************************************************ create/drop stream **************************************************/ cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) - stream_options(B) INTO full_table_name(C) AS query_expression(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, D); } + stream_options(B) INTO full_table_name(C) AS query_or_subquery(D). { pCxt->pRootNode = createCreateStreamStmt(pCxt, E, &A, C, B, D); } cmd ::= DROP STREAM exists_opt(A) stream_name(B). { pCxt->pRootNode = createDropStreamStmt(pCxt, A, &B); } stream_options(A) ::= . { A = createStreamOptions(pCxt); } @@ -535,12 +535,12 @@ dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C). cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B). { pCxt->pRootNode = createDeleteStmt(pCxt, A, B); } /************************************************ select **************************************************************/ -cmd ::= query_expression(A). { pCxt->pRootNode = A; } +cmd ::= query_or_subquery(A). { pCxt->pRootNode = A; } /************************************************ insert **************************************************************/ cmd ::= INSERT INTO full_table_name(A) - NK_LP col_name_list(B) NK_RP query_expression(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); } -cmd ::= INSERT INTO full_table_name(A) query_expression(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); } + NK_LP col_name_list(B) NK_RP query_or_subquery(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); } +cmd ::= INSERT INTO full_table_name(A) query_or_subquery(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); } /************************************************ literal *************************************************************/ literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); } @@ -625,42 +625,44 @@ stream_name(A) ::= NK_ID(B). cgroup_name(A) ::= NK_ID(B). { A = B; } /************************************************ expression **********************************************************/ +expr_or_subquery(A) ::= expression(B). { A = B; } +expr_or_subquery(A) ::= subquery(B). { A = B; } + expression(A) ::= literal(B). { A = B; } expression(A) ::= pseudo_column(B). { A = B; } expression(A) ::= column_reference(B). { A = B; } expression(A) ::= function_expression(B). { A = B; } -//expression(A) ::= case_expression(B). { A = B; } -expression(A) ::= subquery(B). { A = B; } +expression(A) ::= case_when_expression(B). { A = B; } expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); } -expression(A) ::= NK_PLUS(B) expression(C). { +expression(A) ::= NK_PLUS(B) expr_or_subquery(C). { SToken t = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &B, &t, releaseRawExprNode(pCxt, C)); } -expression(A) ::= NK_MINUS(B) expression(C). { +expression(A) ::= NK_MINUS(B) expr_or_subquery(C). { SToken t = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &B, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, C), NULL)); } -expression(A) ::= expression(B) NK_PLUS expression(C). { +expression(A) ::= expr_or_subquery(B) NK_PLUS expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } -expression(A) ::= expression(B) NK_MINUS expression(C). { +expression(A) ::= expr_or_subquery(B) NK_MINUS expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } -expression(A) ::= expression(B) NK_STAR expression(C). { +expression(A) ::= expr_or_subquery(B) NK_STAR expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } -expression(A) ::= expression(B) NK_SLASH expression(C). { +expression(A) ::= expr_or_subquery(B) NK_SLASH expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } -expression(A) ::= expression(B) NK_REM expression(C). { +expression(A) ::= expr_or_subquery(B) NK_REM expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); @@ -669,12 +671,12 @@ expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). SToken s = getTokenFromRawExprNode(pCxt, B); A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, B), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C))); } -expression(A) ::= expression(B) NK_BITAND expression(C). { +expression(A) ::= expr_or_subquery(B) NK_BITAND expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); } -expression(A) ::= expression(B) NK_BITOR expression(C). { +expression(A) ::= expr_or_subquery(B) NK_BITOR expr_or_subquery(C). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, C); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); @@ -682,8 +684,8 @@ expression(A) ::= expression(B) NK_BITOR expression(C). %type expression_list { SNodeList* } %destructor expression_list { nodesDestroyList($$); } -expression_list(A) ::= expression(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); } -expression_list(A) ::= expression_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); } +expression_list(A) ::= expr_or_subquery(B). { A = createNodeList(pCxt, releaseRawExprNode(pCxt, B)); } +expression_list(A) ::= expression_list(B) NK_COMMA expr_or_subquery(C). { A = addNodeToList(pCxt, B, releaseRawExprNode(pCxt, C)); } column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); } column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); } @@ -700,7 +702,8 @@ pseudo_column(A) ::= WDURATION(B). function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } -function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); } +function_expression(A) ::= + CAST(B) NK_LP expr_or_subquery(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); } function_expression(A) ::= literal_func(B). { A = B; } literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); } @@ -735,35 +738,52 @@ star_func_para_list(A) ::= other_para_list(B). other_para_list(A) ::= star_func_para(B). { A = createNodeList(pCxt, B); } other_para_list(A) ::= other_para_list(B) NK_COMMA star_func_para(C). { A = addNodeToList(pCxt, B, C); } -star_func_para(A) ::= expression(B). { A = releaseRawExprNode(pCxt, B); } +star_func_para(A) ::= expr_or_subquery(B). { A = releaseRawExprNode(pCxt, B); } star_func_para(A) ::= table_name(B) NK_DOT NK_STAR(C). { A = createColumnNode(pCxt, &B, &C); } +case_when_expression(A) ::= + CASE(E) when_then_list(C) case_when_else_opt(D) END(F). { A = createRawExprNodeExt(pCxt, &E, &F, createCaseWhenNode(pCxt, NULL, C, D)); } +case_when_expression(A) ::= + CASE(E) common_expression(B) when_then_list(C) case_when_else_opt(D) END(F). { A = createRawExprNodeExt(pCxt, &E, &F, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, B), C, D)); } + +%type when_then_list { SNodeList* } +%destructor when_then_list { nodesDestroyList($$); } +when_then_list(A) ::= when_then_expr(B). { A = createNodeList(pCxt, B); } +when_then_list(A) ::= when_then_list(B) when_then_expr(C). { A = addNodeToList(pCxt, B, C); } + +when_then_expr(A) ::= WHEN common_expression(B) THEN common_expression(C). { A = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); } + +case_when_else_opt(A) ::= . { A = NULL; } +case_when_else_opt(A) ::= ELSE common_expression(B). { A = releaseRawExprNode(pCxt, B); } + /************************************************ predicate ***********************************************************/ -predicate(A) ::= expression(B) compare_op(C) expression(D). { +predicate(A) ::= expr_or_subquery(B) compare_op(C) expr_or_subquery(D). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, D); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D))); } //predicate(A) ::= expression(B) compare_op sub_type expression(B). -predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D). { +predicate(A) ::= + expr_or_subquery(B) BETWEEN expr_or_subquery(C) AND expr_or_subquery(D). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, D); A = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D))); } -predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). { +predicate(A) ::= + expr_or_subquery(B) NOT BETWEEN expr_or_subquery(C) AND expr_or_subquery(D). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, D); A = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D))); } -predicate(A) ::= expression(B) IS NULL(C). { +predicate(A) ::= expr_or_subquery(B) IS NULL(C). { SToken s = getTokenFromRawExprNode(pCxt, B); A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, B), NULL)); } -predicate(A) ::= expression(B) IS NOT NULL(C). { +predicate(A) ::= expr_or_subquery(B) IS NOT NULL(C). { SToken s = getTokenFromRawExprNode(pCxt, B); A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, B), NULL)); } -predicate(A) ::= expression(B) in_op(C) in_predicate_value(D). { +predicate(A) ::= expr_or_subquery(B) in_op(C) in_predicate_value(D). { SToken s = getTokenFromRawExprNode(pCxt, B); SToken e = getTokenFromRawExprNode(pCxt, D); A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, C, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, D))); @@ -813,7 +833,7 @@ boolean_primary(A) ::= predicate(B). boolean_primary(A) ::= NK_LP(C) boolean_value_expression(B) NK_RP(D). { A = createRawExprNodeExt(pCxt, &C, &D, releaseRawExprNode(pCxt, B)); } /************************************************ common_expression ********************************************/ -common_expression(A) ::= expression(B). { A = B; } +common_expression(A) ::= expr_or_subquery(B). { A = B; } common_expression(A) ::= boolean_value_expression(B). { A = B; } /************************************************ from_clause_opt *********************************************************/ @@ -894,7 +914,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B). twindow_clause_opt(A) ::= . { A = NULL; } twindow_clause_opt(A) ::= SESSION NK_LP column_reference(B) NK_COMMA duration_literal(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); } -twindow_clause_opt(A) ::= STATE_WINDOW NK_LP expression(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); } +twindow_clause_opt(A) ::= STATE_WINDOW NK_LP expr_or_subquery(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); } twindow_clause_opt(A) ::= INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); } twindow_clause_opt(A) ::= @@ -923,41 +943,40 @@ group_by_clause_opt(A) ::= GROUP BY group_by_list(B). %type group_by_list { SNodeList* } %destructor group_by_list { nodesDestroyList($$); } -group_by_list(A) ::= expression(B). { A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); } -group_by_list(A) ::= group_by_list(B) NK_COMMA expression(C). { A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); } +group_by_list(A) ::= expr_or_subquery(B). { A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); } +group_by_list(A) ::= group_by_list(B) NK_COMMA expr_or_subquery(C). { A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); } having_clause_opt(A) ::= . { A = NULL; } having_clause_opt(A) ::= HAVING search_condition(B). { A = B; } range_opt(A) ::= . { A = NULL; } -range_opt(A) ::= RANGE NK_LP expression(B) NK_COMMA expression(C) NK_RP. { A = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); } +range_opt(A) ::= + RANGE NK_LP expr_or_subquery(B) NK_COMMA expr_or_subquery(C) NK_RP. { A = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)); } every_opt(A) ::= . { A = NULL; } every_opt(A) ::= EVERY NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } /************************************************ query_expression ****************************************************/ -query_expression(A) ::= - query_expression_body(B) - order_by_clause_opt(C) slimit_clause_opt(D) limit_clause_opt(E). { +query_expression(A) ::= query_simple(B) + order_by_clause_opt(C) slimit_clause_opt(D) limit_clause_opt(E). { A = addOrderByClause(pCxt, B, C); A = addSlimitClause(pCxt, A, D); A = addLimitClause(pCxt, A, E); } -query_expression_body(A) ::= query_primary(B). { A = B; } -query_expression_body(A) ::= - query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); } -query_expression_body(A) ::= - query_expression_body(B) UNION query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION, B, D); } +query_simple(A) ::= query_specification(B). { A = B; } +query_simple(A) ::= union_query_expression(B). { A = B; } -query_primary(A) ::= query_specification(B). { A = B; } -query_primary(A) ::= - NK_LP query_expression_body(B) - order_by_clause_opt(C) slimit_clause_opt(D) limit_clause_opt(E) NK_RP. { - A = addOrderByClause(pCxt, B, C); - A = addSlimitClause(pCxt, A, D); - A = addLimitClause(pCxt, A, E); - } +union_query_expression(A) ::= + query_simple_or_subquery(B) UNION ALL query_simple_or_subquery(C). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, C); } +union_query_expression(A) ::= + query_simple_or_subquery(B) UNION query_simple_or_subquery(C). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION, B, C); } + +query_simple_or_subquery(A) ::= query_simple(B). { A = B; } +query_simple_or_subquery(A) ::= subquery(B). { A = releaseRawExprNode(pCxt, B); } + +query_or_subquery(A) ::= query_expression(B). { A = B; } +query_or_subquery(A) ::= subquery(B). { A = releaseRawExprNode(pCxt, B); } %type order_by_clause_opt { SNodeList* } %destructor order_by_clause_opt { nodesDestroyList($$); } @@ -976,6 +995,7 @@ limit_clause_opt(A) ::= LIMIT NK_INTEGER(C) NK_COMMA NK_INTEGER(B). /************************************************ subquery ************************************************************/ subquery(A) ::= NK_LP(B) query_expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, C); } +subquery(A) ::= NK_LP(B) subquery(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); } /************************************************ search_condition ****************************************************/ search_condition(A) ::= common_expression(B). { A = releaseRawExprNode(pCxt, B); } @@ -988,7 +1008,7 @@ sort_specification_list(A) ::= sort_specification_list(B) NK_COMMA sort_specification(C). { A = addNodeToList(pCxt, B, C); } sort_specification(A) ::= - expression(B) ordering_specification_opt(C) null_ordering_opt(D). { A = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, B), C, D); } + expr_or_subquery(B) ordering_specification_opt(C) null_ordering_opt(D). { A = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, B), C, D); } %type ordering_specification_opt EOrder %destructor ordering_specification_opt { } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 6f11c653a4..65afc84c9d 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -247,7 +247,8 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { pExpr->userAlias[len] = '\0'; } } - taosMemoryFreeClear(pNode); + pRawExpr->pNode = NULL; + nodesDestroyNode(pNode); return pRealizedExpr; } @@ -646,6 +647,25 @@ SNode* createInterpTimeRange(SAstCreateContext* pCxt, SNode* pStart, SNode* pEnd return createBetweenAnd(pCxt, createPrimaryKeyCol(pCxt, NULL), pStart, pEnd); } +SNode* createWhenThenNode(SAstCreateContext* pCxt, SNode* pWhen, SNode* pThen) { + CHECK_PARSER_STATUS(pCxt); + SWhenThenNode* pWhenThen = (SWhenThenNode*)nodesMakeNode(QUERY_NODE_WHEN_THEN); + CHECK_OUT_OF_MEM(pWhenThen); + pWhenThen->pWhen = pWhen; + pWhenThen->pThen = pThen; + return (SNode*)pWhenThen; +} + +SNode* createCaseWhenNode(SAstCreateContext* pCxt, SNode* pCase, SNodeList* pWhenThenList, SNode* pElse) { + CHECK_PARSER_STATUS(pCxt); + SCaseWhenNode* pCaseWhen = (SCaseWhenNode*)nodesMakeNode(QUERY_NODE_CASE_WHEN); + CHECK_OUT_OF_MEM(pCaseWhen); + pCaseWhen->pCase = pCase; + pCaseWhen->pWhenThenList = pWhenThenList; + pCaseWhen->pElse = pElse; + return (SNode*)pCaseWhen; +} + SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, SToken* pAlias) { CHECK_PARSER_STATUS(pCxt); trimEscape(pAlias); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 1af61b0ca8..4fb55ed373 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1059,7 +1059,7 @@ end: for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { STagVal* p = (STagVal*)taosArrayGet(pTagVals, i); if (IS_VAR_DATA_TYPE(p->type)) { - taosMemoryFree(p->pData); + taosMemoryFreeClear(p->pData); } } taosArrayDestroy(pTagVals); @@ -1537,6 +1537,9 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { autoCreateTbl = true; } else if (!existedUsing) { CHECK_CODE(getTableMeta(pCxt, tbNum, &name, dbFName)); + if (TSDB_SUPER_TABLE == pCxt->pTableMeta->tableType) { + return buildInvalidOperationMsg(&pCxt->msg, "insert data into super table is not supported"); + } } STableDataBlocks* dataBuf = NULL; @@ -2040,7 +2043,7 @@ end: for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); if (p->type == TSDB_DATA_TYPE_NCHAR) { - taosMemoryFree(p->pData); + taosMemoryFreeClear(p->pData); } } taosArrayDestroy(pTagArray); @@ -2534,7 +2537,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols if (p) kv = *p; } - if (kv){ + if (kv) { int32_t colLen = kv->length; if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { // uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); @@ -2547,7 +2550,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols } else { MemRowAppend(&pBuf, &(kv->value), colLen, ¶m); } - }else{ + } else { pBuilder->hasNone = true; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 68eb3e6fb1..c51553f7a1 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -54,6 +54,7 @@ static SKeyword keywordTable[] = { {"CACHE", TK_CACHE}, {"CACHEMODEL", TK_CACHEMODEL}, {"CACHESIZE", TK_CACHESIZE}, + {"CASE", TK_CASE}, {"CAST", TK_CAST}, {"CLIENT_VERSION", TK_CLIENT_VERSION}, {"CLUSTER", TK_CLUSTER}, @@ -82,7 +83,9 @@ static SKeyword keywordTable[] = { {"DOUBLE", TK_DOUBLE}, {"DROP", TK_DROP}, {"DURATION", TK_DURATION}, + {"ELSE", TK_ELSE}, {"ENABLE", TK_ENABLE}, + {"END", TK_END}, {"EXISTS", TK_EXISTS}, {"EXPIRED", TK_EXPIRED}, {"EXPLAIN", TK_EXPLAIN}, @@ -205,6 +208,7 @@ static SKeyword keywordTable[] = { {"TAG", TK_TAG}, {"TAGS", TK_TAGS}, {"TBNAME", TK_TBNAME}, + {"THEN", TK_THEN}, {"TIMESTAMP", TK_TIMESTAMP}, {"TIMEZONE", TK_TIMEZONE}, {"TINYINT", TK_TINYINT}, @@ -240,6 +244,7 @@ static SKeyword keywordTable[] = { {"WAL_ROLL_PERIOD", TK_WAL_ROLL_PERIOD}, {"WAL_SEGMENT_SIZE", TK_WAL_SEGMENT_SIZE}, {"WATERMARK", TK_WATERMARK}, + {"WHEN", TK_WHEN}, {"WHERE", TK_WHERE}, {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, {"WITH", TK_WITH}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ea9eefbb29..82167e8911 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -264,6 +264,8 @@ static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; static bool afterHaving(ESqlClause clause) { return clause > SQL_CLAUSE_HAVING; } +static bool beforeWindow(ESqlClause clause) { return clause < SQL_CLAUSE_WINDOW; } + static bool hasSameTableAlias(SArray* pTables) { if (taosArrayGetSize(pTables) < 2) { return false; @@ -1476,6 +1478,10 @@ static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SFunctio if (!isSelectStmt(pCxt->pCurrStmt) || NULL == ((SSelectStmt*)pCxt->pCurrStmt)->pWindow) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC); } + if (beforeWindow(pCxt->currClause)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC, "There mustn't be %s", + pFunc->functionName); + } return TSDB_CODE_SUCCESS; } @@ -1807,6 +1813,59 @@ static EDealRes translateLogicCond(STranslateContext* pCxt, SLogicConditionNode* return DEAL_RES_CONTINUE; } +static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pFunc->functionName, "cast"); + pFunc->node.resType = dt; + if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) { + nodesDestroyNode((SNode*)pFunc); + return TSDB_CODE_OUT_OF_MEMORY; + } + if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) { + nodesClearList(pFunc->pParameterList); + pFunc->pParameterList = NULL; + nodesDestroyNode((SNode*)pFunc); + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName); + } + *pCast = (SNode*)pFunc; + return TSDB_CODE_SUCCESS; +} + +static EDealRes translateWhenThen(STranslateContext* pCxt, SWhenThenNode* pWhenThen) { + pWhenThen->node.resType = ((SExprNode*)pWhenThen->pThen)->resType; + return DEAL_RES_CONTINUE; +} + +static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) { + bool first = true; + SNode* pNode = NULL; + FOREACH(pNode, pCaseWhen->pWhenThenList) { + if (first) { + pCaseWhen->node.resType = ((SExprNode*)pNode)->resType; + } else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) { + SWhenThenNode* pWhenThen = (SWhenThenNode*)pNode; + SNode* pCastFunc = NULL; + if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pWhenThen->pThen, pCaseWhen->node.resType, &pCastFunc)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch"); + } + pWhenThen->pThen = pCastFunc; + pWhenThen->node.resType = pCaseWhen->node.resType; + } + } + if (NULL != pCaseWhen->pElse && !dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pCaseWhen->pElse)->resType)) { + SNode* pCastFunc = NULL; + if (TSDB_CODE_SUCCESS != createCastFunc(pCxt, pCaseWhen->pElse, pCaseWhen->node.resType, &pCastFunc)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "CASE WHEN data type mismatch"); + } + pCaseWhen->pElse = pCastFunc; + ((SExprNode*)pCaseWhen->pElse)->resType = pCaseWhen->node.resType; + } + return DEAL_RES_CONTINUE; +} + static EDealRes doTranslateExpr(SNode** pNode, void* pContext) { STranslateContext* pCxt = (STranslateContext*)pContext; switch (nodeType(*pNode)) { @@ -1822,6 +1881,10 @@ static EDealRes doTranslateExpr(SNode** pNode, void* pContext) { return translateLogicCond(pCxt, (SLogicConditionNode*)*pNode); case QUERY_NODE_TEMP_TABLE: return translateExprSubquery(pCxt, ((STempTableNode*)*pNode)->pSubquery); + case QUERY_NODE_WHEN_THEN: + return translateWhenThen(pCxt, (SWhenThenNode*)*pNode); + case QUERY_NODE_CASE_WHEN: + return translateCaseWhen(pCxt, (SCaseWhenNode*)*pNode); default: break; } @@ -2213,6 +2276,17 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele return code; } +static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTable) { + if ((QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pLeft) && + !isTimeLineQuery(((STempTableNode*)pJoinTable->pLeft)->pSubquery)) || + (QUERY_NODE_TEMP_TABLE == nodeType(pJoinTable->pRight) && + !isTimeLineQuery(((STempTableNode*)pJoinTable->pRight)->pSubquery))) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, + "Join requires valid time series input"); + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -2259,6 +2333,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { if (TSDB_CODE_SUCCESS == code) { code = translateTable(pCxt, pJoinTable->pRight); } + if (TSDB_CODE_SUCCESS == code) { + code = checkJoinTable(pCxt, pJoinTable); + } if (TSDB_CODE_SUCCESS == code) { pJoinTable->table.precision = calcJoinTablePrecision(pJoinTable); pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable); @@ -3208,27 +3285,6 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { return (SNode*)pCol; } -static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { - SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); - if (NULL == pFunc) { - return TSDB_CODE_OUT_OF_MEMORY; - } - strcpy(pFunc->functionName, "cast"); - pFunc->node.resType = dt; - if (TSDB_CODE_SUCCESS != nodesListMakeAppend(&pFunc->pParameterList, pExpr)) { - nodesDestroyNode((SNode*)pFunc); - return TSDB_CODE_OUT_OF_MEMORY; - } - if (TSDB_CODE_SUCCESS != getFuncInfo(pCxt, pFunc)) { - nodesClearList(pFunc->pParameterList); - pFunc->pParameterList = NULL; - nodesDestroyNode((SNode*)pFunc); - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pExpr)->aliasName); - } - *pCast = (SNode*)pFunc; - return TSDB_CODE_SUCCESS; -} - static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pSetOperator) { SNodeList* pLeftProjections = getProjectList(pSetOperator->pLeft); SNodeList* pRightProjections = getProjectList(pSetOperator->pRight); @@ -6664,12 +6720,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS break; } } while (0); - for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { - STagVal* p = (STagVal*)taosArrayGet(pTagVals, i); - if (IS_VAR_DATA_TYPE(p->type)) { - taosMemoryFree(p->pData); - } - } + taosArrayDestroy(pTagVals); if (code != TSDB_CODE_SUCCESS) { return code; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index daab80667c..3075be1a00 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -410,6 +410,12 @@ end: if (retCode == TSDB_CODE_SUCCESS) { tTagNew(pTagVals, 1, true, ppTag); } + for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pTagVals, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } cJSON_Delete(root); return retCode; } diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 7ee6a5b223..2fe6ebfb79 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -177,15 +177,18 @@ int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery) { int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq* pCatalogReq) { SParseMetaCache metaCache = {0}; - int32_t code = TSDB_CODE_SUCCESS; - if (qIsInsertValuesSql(pCxt->pSql, pCxt->sqlLen)) { - code = parseInsertSyntax(pCxt, pQuery, &metaCache); - } else { - code = parseSqlSyntax(pCxt, pQuery, &metaCache); + int32_t code = nodesAcquireAllocator(pCxt->allocatorId); + if (TSDB_CODE_SUCCESS == code) { + if (qIsInsertValuesSql(pCxt->pSql, pCxt->sqlLen)) { + code = parseInsertSyntax(pCxt, pQuery, &metaCache); + } else { + code = parseSqlSyntax(pCxt, pQuery, &metaCache); + } } if (TSDB_CODE_SUCCESS == code) { code = buildCatalogReq(pCxt, &metaCache, pCatalogReq); } + nodesReleaseAllocator(pCxt->allocatorId); destoryParseMetaCache(&metaCache, true); terrno = code; return code; @@ -194,7 +197,10 @@ int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCatalogReq, const struct SMetaData* pMetaData, SQuery* pQuery) { SParseMetaCache metaCache = {0}; - int32_t code = putMetaDataToCache(pCatalogReq, pMetaData, &metaCache, NULL == pQuery->pRoot); + int32_t code = nodesAcquireAllocator(pCxt->allocatorId); + if (TSDB_CODE_SUCCESS == code) { + code = putMetaDataToCache(pCatalogReq, pMetaData, &metaCache, NULL == pQuery->pRoot); + } if (TSDB_CODE_SUCCESS == code) { if (NULL == pQuery->pRoot) { code = parseInsertSql(pCxt, &pQuery, &metaCache); @@ -202,6 +208,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata code = analyseSemantic(pCxt, pQuery, &metaCache); } } + nodesReleaseAllocator(pCxt->allocatorId); destoryParseMetaCache(&metaCache, false); terrno = code; return code; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index a2a52aa0e0..f4ced2799a 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 430 +#define YYNOCODE 441 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - int64_t yy49; - SDataType yy84; - EFillMode yy134; - SToken yy149; - EOrder yy158; - int32_t yy160; - SNode* yy312; - EOperatorType yy320; - int8_t yy363; - SAlterOption yy405; - ENullOrder yy417; - bool yy497; - SNodeList* yy824; - EJoinType yy832; + EFillMode yy18; + EOperatorType yy128; + bool yy173; + SNodeList* yy334; + int8_t yy341; + int64_t yy459; + ENullOrder yy487; + SAlterOption yy515; + EJoinType yy540; + SNode* yy560; + SDataType yy574; + EOrder yy596; + SToken yy659; + int32_t yy676; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 675 -#define YYNRULE 496 -#define YYNTOKEN 309 -#define YY_MAX_SHIFT 674 -#define YY_MIN_SHIFTREDUCE 985 -#define YY_MAX_SHIFTREDUCE 1480 -#define YY_ERROR_ACTION 1481 -#define YY_ACCEPT_ACTION 1482 -#define YY_NO_ACTION 1483 -#define YY_MIN_REDUCE 1484 -#define YY_MAX_REDUCE 1979 +#define YYNSTATE 679 +#define YYNRULE 509 +#define YYNTOKEN 313 +#define YY_MAX_SHIFT 678 +#define YY_MIN_SHIFTREDUCE 1000 +#define YY_MAX_SHIFTREDUCE 1508 +#define YY_ERROR_ACTION 1509 +#define YY_ACCEPT_ACTION 1510 +#define YY_NO_ACTION 1511 +#define YY_MIN_REDUCE 1512 +#define YY_MAX_REDUCE 2020 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,690 +216,720 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2512) +#define YY_ACTTAB_COUNT (2662) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 436, 1813, 437, 1519, 444, 345, 437, 1519, 1674, 1676, - /* 10 */ 33, 32, 39, 37, 40, 38, 36, 35, 34, 1620, - /* 20 */ 340, 530, 1281, 1801, 40, 38, 36, 35, 34, 1831, - /* 30 */ 1797, 1681, 117, 1357, 1797, 1279, 1770, 582, 312, 474, - /* 40 */ 30, 260, 1783, 1525, 581, 385, 148, 1679, 1496, 1629, - /* 50 */ 1035, 1813, 1034, 1801, 1793, 1799, 1352, 558, 1793, 1799, - /* 60 */ 329, 14, 1675, 1676, 1797, 472, 575, 1845, 1287, 1546, - /* 70 */ 575, 94, 1814, 584, 1816, 1817, 580, 1485, 575, 1831, - /* 80 */ 1036, 1891, 303, 362, 1802, 306, 1887, 582, 1793, 1799, - /* 90 */ 335, 666, 1783, 1, 581, 1797, 1451, 1957, 107, 1957, - /* 100 */ 575, 106, 105, 104, 103, 102, 101, 100, 99, 98, - /* 110 */ 166, 1681, 165, 1307, 1954, 671, 1954, 1845, 328, 1793, - /* 120 */ 1799, 149, 1814, 584, 1816, 1817, 580, 1679, 575, 1359, - /* 130 */ 1360, 575, 648, 647, 646, 645, 350, 1607, 644, 643, - /* 140 */ 128, 638, 637, 636, 635, 634, 633, 632, 631, 139, - /* 150 */ 627, 626, 625, 349, 348, 622, 621, 620, 619, 618, - /* 160 */ 36, 35, 34, 33, 32, 559, 1971, 40, 38, 36, - /* 170 */ 35, 34, 556, 556, 1306, 1282, 556, 1280, 1136, 606, - /* 180 */ 605, 604, 1140, 603, 1142, 1143, 602, 1145, 599, 63, - /* 190 */ 1151, 596, 1153, 1154, 593, 590, 453, 453, 1285, 1286, - /* 200 */ 553, 1334, 1335, 1337, 1338, 1339, 1340, 1341, 1342, 577, - /* 210 */ 573, 1350, 1351, 1353, 1354, 1355, 1356, 1358, 1361, 39, - /* 220 */ 37, 1420, 1178, 1179, 1307, 1831, 500, 340, 127, 1281, - /* 230 */ 33, 32, 167, 546, 40, 38, 36, 35, 34, 498, - /* 240 */ 1357, 496, 1279, 486, 485, 43, 42, 63, 558, 107, - /* 250 */ 123, 379, 106, 105, 104, 103, 102, 101, 100, 99, - /* 260 */ 98, 481, 484, 1352, 491, 22, 125, 480, 14, 545, - /* 270 */ 378, 84, 377, 1018, 1813, 1287, 39, 37, 530, 501, - /* 280 */ 1417, 250, 1899, 552, 340, 551, 1281, 478, 1957, 117, - /* 290 */ 1813, 1957, 1622, 209, 7, 327, 479, 1357, 1507, 1279, - /* 300 */ 2, 166, 1831, 146, 164, 1954, 1629, 494, 1954, 477, - /* 310 */ 582, 488, 1631, 1022, 1023, 1783, 208, 581, 1831, 150, - /* 320 */ 1352, 1957, 671, 1588, 435, 14, 579, 439, 167, 1441, - /* 330 */ 558, 1783, 1287, 581, 1956, 422, 1359, 1360, 1954, 1783, - /* 340 */ 1845, 135, 173, 517, 94, 1814, 584, 1816, 1817, 580, - /* 350 */ 326, 575, 58, 1729, 1891, 57, 1845, 2, 306, 1887, - /* 360 */ 293, 1814, 584, 1816, 1817, 580, 578, 575, 572, 1863, - /* 370 */ 1957, 1484, 539, 1439, 1440, 1442, 1443, 222, 71, 671, - /* 380 */ 146, 70, 1282, 164, 1280, 167, 167, 1954, 1506, 1632, - /* 390 */ 177, 176, 54, 1359, 1360, 116, 115, 114, 113, 112, - /* 400 */ 111, 110, 109, 108, 63, 1285, 1286, 1098, 1334, 1335, - /* 410 */ 1337, 1338, 1339, 1340, 1341, 1342, 577, 573, 1350, 1351, - /* 420 */ 1353, 1354, 1355, 1356, 1358, 1361, 33, 32, 1681, 1783, - /* 430 */ 40, 38, 36, 35, 34, 344, 26, 1261, 1262, 1282, - /* 440 */ 1100, 1280, 33, 32, 1679, 28, 40, 38, 36, 35, - /* 450 */ 34, 33, 32, 217, 562, 40, 38, 36, 35, 34, - /* 460 */ 1813, 317, 1285, 1286, 542, 1334, 1335, 1337, 1338, 1339, - /* 470 */ 1340, 1341, 1342, 577, 573, 1350, 1351, 1353, 1354, 1355, - /* 480 */ 1356, 1358, 1361, 39, 37, 302, 1413, 1304, 1831, 530, - /* 490 */ 63, 340, 78, 1281, 415, 210, 557, 427, 223, 224, - /* 500 */ 55, 1783, 1957, 581, 1357, 1308, 1279, 441, 516, 1416, - /* 510 */ 353, 1957, 1431, 1304, 400, 165, 428, 1629, 402, 1954, - /* 520 */ 318, 49, 316, 315, 1955, 476, 1845, 1352, 1954, 478, - /* 530 */ 95, 1814, 584, 1816, 1817, 580, 1722, 575, 1306, 1287, - /* 540 */ 1891, 548, 543, 167, 331, 1887, 159, 172, 1957, 1281, - /* 550 */ 1957, 477, 76, 305, 674, 64, 520, 305, 163, 393, - /* 560 */ 520, 164, 1279, 164, 8, 1954, 1917, 1954, 267, 553, - /* 570 */ 547, 389, 158, 33, 32, 343, 346, 40, 38, 36, - /* 580 */ 35, 34, 156, 146, 146, 1668, 671, 664, 660, 656, - /* 590 */ 652, 265, 1631, 1631, 1482, 1287, 1035, 127, 1034, 426, - /* 600 */ 1359, 1360, 421, 420, 419, 418, 417, 414, 413, 412, - /* 610 */ 411, 410, 406, 405, 404, 403, 397, 396, 395, 394, - /* 620 */ 1505, 391, 390, 314, 617, 1424, 1036, 92, 1367, 167, - /* 630 */ 230, 1306, 33, 32, 1306, 125, 40, 38, 36, 35, - /* 640 */ 34, 1305, 671, 1381, 63, 615, 1282, 252, 1280, 555, - /* 650 */ 160, 1899, 1900, 355, 1904, 352, 11, 10, 483, 482, - /* 660 */ 167, 1783, 563, 527, 137, 136, 612, 611, 610, 1285, - /* 670 */ 1286, 1732, 1334, 1335, 1337, 1338, 1339, 1340, 1341, 1342, - /* 680 */ 577, 573, 1350, 1351, 1353, 1354, 1355, 1356, 1358, 1361, - /* 690 */ 39, 37, 1362, 1957, 1287, 1957, 219, 502, 340, 374, - /* 700 */ 1281, 74, 1282, 167, 1280, 27, 164, 74, 164, 91, - /* 710 */ 1954, 1357, 1954, 1279, 1255, 1386, 212, 1504, 376, 372, - /* 720 */ 122, 1605, 124, 1625, 1813, 1285, 1286, 1722, 1503, 1624, - /* 730 */ 1621, 1502, 1477, 530, 1352, 33, 32, 1957, 175, 40, - /* 740 */ 38, 36, 35, 34, 169, 530, 1287, 39, 37, 1393, - /* 750 */ 164, 530, 1831, 1549, 1954, 340, 383, 1281, 1783, 1501, - /* 760 */ 582, 1629, 384, 443, 553, 1783, 439, 581, 1357, 1783, - /* 770 */ 1279, 9, 1783, 1629, 530, 642, 640, 517, 530, 1629, - /* 780 */ 558, 617, 61, 167, 1306, 392, 145, 1730, 1500, 407, - /* 790 */ 1845, 1352, 127, 671, 285, 1814, 584, 1816, 1817, 580, - /* 800 */ 1783, 575, 1629, 1287, 337, 336, 1629, 1359, 1360, 609, - /* 810 */ 1499, 530, 530, 1336, 1295, 530, 1336, 486, 485, 1476, - /* 820 */ 1957, 1319, 408, 451, 123, 1357, 452, 1288, 9, 1783, - /* 830 */ 125, 530, 1498, 166, 1495, 481, 484, 1954, 629, 1629, - /* 840 */ 1629, 480, 1626, 1629, 1309, 161, 1899, 1900, 1352, 1904, - /* 850 */ 671, 1783, 1728, 1282, 300, 1280, 630, 1618, 1601, 1629, - /* 860 */ 1287, 90, 33, 32, 1359, 1360, 40, 38, 36, 35, - /* 870 */ 34, 87, 1727, 1783, 300, 1783, 1285, 1286, 1494, 1334, - /* 880 */ 1335, 1337, 1338, 1339, 1340, 1341, 1342, 577, 573, 1350, - /* 890 */ 1351, 1353, 1354, 1355, 1356, 1358, 1361, 530, 530, 553, - /* 900 */ 530, 201, 530, 530, 199, 1906, 509, 570, 347, 503, - /* 910 */ 1282, 510, 1280, 514, 227, 307, 1614, 1493, 613, 1783, - /* 920 */ 1492, 1672, 1491, 1022, 1023, 1629, 1629, 127, 1629, 1903, - /* 930 */ 1629, 1629, 1490, 1285, 1286, 1489, 1334, 1335, 1337, 1338, - /* 940 */ 1339, 1340, 1341, 1342, 577, 573, 1350, 1351, 1353, 1354, - /* 950 */ 1355, 1356, 1358, 1361, 39, 37, 1379, 530, 1783, 530, - /* 960 */ 1616, 1783, 340, 1783, 1281, 125, 1336, 1296, 526, 1291, - /* 970 */ 528, 1911, 1413, 1783, 196, 1357, 1783, 1279, 1488, 1487, - /* 980 */ 162, 1899, 1900, 1606, 1904, 1629, 232, 1629, 152, 1813, - /* 990 */ 1299, 1301, 1906, 470, 466, 462, 458, 195, 1352, 1681, - /* 1000 */ 44, 4, 573, 1350, 1351, 1353, 1354, 1355, 1356, 1604, - /* 1010 */ 1287, 1380, 530, 530, 386, 1680, 1902, 1831, 614, 1783, - /* 1020 */ 1783, 1672, 324, 529, 261, 582, 1906, 387, 560, 147, - /* 1030 */ 1783, 565, 581, 75, 278, 2, 193, 571, 33, 32, - /* 1040 */ 1629, 1629, 40, 38, 36, 35, 34, 41, 276, 60, - /* 1050 */ 1901, 272, 59, 203, 1659, 1845, 202, 671, 216, 294, - /* 1060 */ 1814, 584, 1816, 1817, 580, 221, 575, 131, 180, 432, - /* 1070 */ 430, 1359, 1360, 29, 338, 1374, 1375, 1376, 1377, 1378, - /* 1080 */ 1382, 1383, 1384, 1385, 205, 1290, 207, 204, 615, 206, - /* 1090 */ 1536, 307, 53, 513, 11, 10, 1289, 77, 1232, 192, - /* 1100 */ 186, 1531, 191, 1529, 63, 1589, 449, 137, 136, 612, - /* 1110 */ 611, 610, 487, 134, 615, 135, 225, 1282, 523, 1280, - /* 1120 */ 51, 236, 184, 489, 1319, 492, 1479, 1480, 1804, 1612, - /* 1130 */ 51, 41, 1379, 137, 136, 612, 611, 610, 41, 588, - /* 1140 */ 1285, 1286, 93, 1334, 1335, 1337, 1338, 1339, 1340, 1341, - /* 1150 */ 1342, 577, 573, 1350, 1351, 1353, 1354, 1355, 1356, 1358, - /* 1160 */ 1361, 134, 135, 119, 229, 134, 1129, 1062, 213, 623, - /* 1170 */ 624, 1438, 239, 576, 1371, 1806, 608, 1497, 68, 67, - /* 1180 */ 382, 1387, 1343, 171, 255, 540, 471, 1380, 244, 271, - /* 1190 */ 1157, 1082, 1080, 1832, 1813, 351, 1520, 1669, 1921, 301, - /* 1200 */ 1063, 554, 370, 254, 368, 364, 360, 357, 354, 249, - /* 1210 */ 3, 257, 1161, 1168, 1166, 259, 138, 356, 5, 361, - /* 1220 */ 1248, 313, 1831, 174, 1304, 268, 388, 1293, 409, 1724, - /* 1230 */ 557, 416, 424, 423, 425, 1783, 429, 581, 1292, 431, - /* 1240 */ 433, 566, 1310, 167, 1312, 434, 442, 1813, 183, 29, - /* 1250 */ 338, 1374, 1375, 1376, 1377, 1378, 1382, 1383, 1384, 1385, - /* 1260 */ 1845, 445, 446, 185, 95, 1814, 584, 1816, 1817, 580, - /* 1270 */ 1311, 575, 447, 1313, 1891, 1831, 188, 450, 331, 1887, - /* 1280 */ 159, 448, 473, 582, 190, 72, 73, 1813, 1783, 454, - /* 1290 */ 581, 194, 269, 475, 1619, 198, 304, 1615, 118, 200, - /* 1300 */ 1918, 1763, 211, 140, 141, 1617, 1613, 504, 214, 505, - /* 1310 */ 142, 1813, 143, 1845, 511, 1831, 515, 95, 1814, 584, - /* 1320 */ 1816, 1817, 580, 582, 575, 218, 508, 1891, 1783, 524, - /* 1330 */ 581, 331, 1887, 1970, 518, 81, 538, 132, 1762, 1831, - /* 1340 */ 323, 83, 1925, 1734, 521, 1309, 270, 582, 325, 1630, - /* 1350 */ 541, 1813, 1783, 1845, 581, 6, 133, 279, 1814, 584, - /* 1360 */ 1816, 1817, 580, 1932, 575, 534, 525, 536, 537, 234, - /* 1370 */ 238, 330, 550, 544, 535, 533, 532, 1845, 1413, 1831, - /* 1380 */ 126, 95, 1814, 584, 1816, 1817, 580, 582, 575, 1922, - /* 1390 */ 245, 1891, 1783, 1931, 581, 331, 1887, 1970, 567, 1308, - /* 1400 */ 564, 248, 48, 332, 1813, 85, 1948, 1907, 586, 1673, - /* 1410 */ 1602, 273, 667, 52, 668, 1913, 243, 1845, 670, 299, - /* 1420 */ 264, 95, 1814, 584, 1816, 1817, 580, 277, 575, 246, - /* 1430 */ 153, 1891, 1831, 1872, 247, 331, 1887, 1970, 275, 286, - /* 1440 */ 582, 296, 295, 1777, 253, 1783, 1910, 581, 1776, 1775, - /* 1450 */ 1953, 65, 1774, 561, 1813, 568, 256, 1973, 258, 66, - /* 1460 */ 558, 1771, 358, 359, 1273, 1274, 170, 363, 1769, 365, - /* 1470 */ 1845, 1813, 366, 367, 285, 1814, 584, 1816, 1817, 580, - /* 1480 */ 1768, 575, 1831, 369, 1767, 371, 1766, 373, 1765, 375, - /* 1490 */ 582, 1251, 1250, 1745, 1744, 1783, 381, 581, 380, 1831, - /* 1500 */ 1957, 1743, 1742, 1220, 1717, 1716, 1715, 582, 129, 1714, - /* 1510 */ 1713, 1712, 1783, 164, 581, 69, 1711, 1954, 1710, 1709, - /* 1520 */ 1845, 1813, 398, 1706, 96, 1814, 584, 1816, 1817, 580, - /* 1530 */ 1708, 575, 1707, 399, 1891, 401, 1705, 1845, 1890, 1887, - /* 1540 */ 1704, 96, 1814, 584, 1816, 1817, 580, 1703, 575, 1831, - /* 1550 */ 1702, 1891, 1701, 1700, 1699, 569, 1887, 582, 1698, 1697, - /* 1560 */ 1696, 1695, 1783, 1694, 581, 1693, 1692, 130, 1691, 1813, - /* 1570 */ 1690, 1689, 1688, 1687, 1686, 1685, 1684, 1222, 1683, 1813, - /* 1580 */ 178, 1550, 179, 1548, 1516, 181, 182, 1845, 1682, 1551, - /* 1590 */ 120, 96, 1814, 584, 1816, 1817, 580, 1831, 575, 157, - /* 1600 */ 1025, 1891, 531, 438, 1024, 582, 1888, 1831, 440, 1515, - /* 1610 */ 1783, 1758, 581, 1752, 1741, 582, 121, 189, 187, 1740, - /* 1620 */ 1783, 1726, 581, 1608, 1547, 1545, 1055, 1543, 455, 456, - /* 1630 */ 1813, 459, 460, 457, 461, 1845, 1541, 463, 464, 294, - /* 1640 */ 1814, 584, 1816, 1817, 580, 1845, 575, 465, 1539, 289, - /* 1650 */ 1814, 584, 1816, 1817, 580, 467, 575, 468, 1831, 1171, - /* 1660 */ 1609, 469, 1528, 1527, 1512, 1610, 582, 1172, 1097, 50, - /* 1670 */ 1096, 1783, 639, 581, 641, 1093, 1092, 1091, 1537, 319, - /* 1680 */ 1532, 1530, 493, 320, 1511, 495, 1510, 549, 490, 321, - /* 1690 */ 1813, 497, 1509, 499, 97, 1757, 1845, 197, 1751, 56, - /* 1700 */ 149, 1814, 584, 1816, 1817, 580, 144, 575, 1813, 506, - /* 1710 */ 1257, 507, 1739, 1737, 1738, 1736, 1735, 1265, 1831, 15, - /* 1720 */ 519, 1733, 220, 226, 1725, 231, 579, 79, 215, 80, - /* 1730 */ 45, 1783, 41, 581, 47, 82, 1831, 23, 233, 16, - /* 1740 */ 1453, 339, 241, 235, 582, 1972, 87, 522, 1435, 1783, - /* 1750 */ 242, 581, 1437, 1804, 25, 1465, 1845, 228, 1813, 237, - /* 1760 */ 293, 1814, 584, 1816, 1817, 580, 322, 575, 251, 1864, - /* 1770 */ 512, 1430, 46, 1803, 1845, 17, 151, 154, 294, 1814, - /* 1780 */ 584, 1816, 1817, 580, 1813, 575, 1831, 240, 18, 24, - /* 1790 */ 86, 341, 1464, 333, 582, 1410, 1409, 1470, 1469, 1783, - /* 1800 */ 1459, 581, 1468, 334, 10, 1297, 155, 19, 1813, 1327, - /* 1810 */ 1372, 1848, 1831, 587, 585, 168, 583, 1347, 574, 31, - /* 1820 */ 582, 342, 1345, 12, 1845, 1783, 1344, 581, 294, 1814, - /* 1830 */ 584, 1816, 1817, 580, 1813, 575, 1831, 13, 1158, 20, - /* 1840 */ 21, 589, 591, 1155, 582, 592, 594, 1152, 595, 1783, - /* 1850 */ 1845, 581, 597, 600, 280, 1814, 584, 1816, 1817, 580, - /* 1860 */ 1146, 575, 1831, 598, 1135, 1144, 601, 1150, 1149, 88, - /* 1870 */ 582, 1148, 1167, 1147, 1845, 1783, 262, 581, 281, 1814, - /* 1880 */ 584, 1816, 1817, 580, 607, 575, 89, 62, 1163, 1053, - /* 1890 */ 616, 1088, 1813, 1087, 1086, 1085, 1084, 1083, 1081, 1079, - /* 1900 */ 1845, 628, 1078, 1077, 288, 1814, 584, 1816, 1817, 580, - /* 1910 */ 1813, 575, 553, 1104, 263, 1075, 1074, 1073, 1072, 1071, - /* 1920 */ 1831, 1070, 1069, 1068, 1099, 1101, 1065, 1064, 582, 1061, - /* 1930 */ 1059, 1060, 1544, 1783, 1058, 581, 649, 650, 1831, 651, - /* 1940 */ 127, 1542, 653, 655, 1540, 654, 582, 657, 659, 658, - /* 1950 */ 1538, 1783, 661, 581, 663, 1526, 1508, 662, 1845, 665, - /* 1960 */ 558, 1015, 290, 1814, 584, 1816, 1817, 580, 266, 575, - /* 1970 */ 669, 1813, 1483, 1283, 274, 672, 1845, 673, 125, 1483, - /* 1980 */ 282, 1814, 584, 1816, 1817, 580, 1483, 575, 1483, 1483, - /* 1990 */ 1483, 1483, 1483, 250, 1899, 552, 1483, 551, 1483, 1831, - /* 2000 */ 1957, 1483, 1483, 1483, 1483, 1483, 1483, 582, 1483, 1483, - /* 2010 */ 1483, 1483, 1783, 164, 581, 1483, 1483, 1954, 1483, 1483, - /* 2020 */ 1483, 1813, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2030 */ 1483, 1813, 1483, 1483, 1483, 1483, 1483, 1845, 1483, 1483, - /* 2040 */ 1483, 291, 1814, 584, 1816, 1817, 580, 1483, 575, 1831, - /* 2050 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 582, 1483, 1831, - /* 2060 */ 1483, 1483, 1783, 1483, 581, 1483, 1483, 582, 1483, 1483, - /* 2070 */ 1483, 1813, 1783, 1483, 581, 1483, 1483, 1483, 1483, 1483, - /* 2080 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1845, 1483, 1483, - /* 2090 */ 1483, 283, 1814, 584, 1816, 1817, 580, 1845, 575, 1831, - /* 2100 */ 1483, 292, 1814, 584, 1816, 1817, 580, 582, 575, 1483, - /* 2110 */ 1483, 1483, 1783, 1483, 581, 1483, 1483, 1483, 1483, 1483, - /* 2120 */ 1483, 1813, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2130 */ 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1845, 1483, 1483, - /* 2140 */ 1483, 284, 1814, 584, 1816, 1817, 580, 1813, 575, 1831, - /* 2150 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 582, 1483, 1483, - /* 2160 */ 1483, 1831, 1783, 1483, 581, 1483, 1483, 1483, 1483, 582, - /* 2170 */ 1483, 1483, 1483, 1483, 1783, 1831, 581, 1483, 1483, 1483, - /* 2180 */ 1483, 1483, 1483, 582, 1483, 1483, 1483, 1845, 1783, 1483, - /* 2190 */ 581, 297, 1814, 584, 1816, 1817, 580, 1483, 575, 1845, - /* 2200 */ 1483, 1483, 1483, 298, 1814, 584, 1816, 1817, 580, 1483, - /* 2210 */ 575, 1483, 1483, 1845, 1483, 1483, 1483, 1825, 1814, 584, - /* 2220 */ 1816, 1817, 580, 1813, 575, 1483, 1483, 1483, 1483, 1483, - /* 2230 */ 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2240 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2250 */ 1483, 1831, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 582, - /* 2260 */ 1483, 1831, 1483, 1483, 1783, 1483, 581, 1483, 1483, 582, - /* 2270 */ 1483, 1483, 1483, 1483, 1783, 1483, 581, 1483, 1483, 1483, - /* 2280 */ 1483, 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1483, 1845, - /* 2290 */ 1483, 1483, 1483, 1824, 1814, 584, 1816, 1817, 580, 1845, - /* 2300 */ 575, 1483, 1483, 1823, 1814, 584, 1816, 1817, 580, 1483, - /* 2310 */ 575, 1483, 1831, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2320 */ 582, 1483, 1483, 1483, 1483, 1783, 1483, 581, 1483, 1483, - /* 2330 */ 1483, 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1483, 1483, - /* 2340 */ 1483, 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1483, 1483, - /* 2350 */ 1845, 1483, 1483, 1483, 310, 1814, 584, 1816, 1817, 580, - /* 2360 */ 1483, 575, 1831, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2370 */ 582, 1483, 1831, 1483, 1483, 1783, 1483, 581, 1483, 1483, - /* 2380 */ 582, 1483, 1483, 1483, 1813, 1783, 1483, 581, 1483, 1483, - /* 2390 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2400 */ 1845, 1483, 1483, 1483, 309, 1814, 584, 1816, 1817, 580, - /* 2410 */ 1845, 575, 1831, 1483, 311, 1814, 584, 1816, 1817, 580, - /* 2420 */ 582, 575, 1483, 1483, 1483, 1783, 1483, 581, 1483, 1483, - /* 2430 */ 1483, 1483, 1483, 1483, 1813, 1483, 1483, 1483, 1483, 1483, - /* 2440 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2450 */ 1845, 1483, 1483, 1483, 308, 1814, 584, 1816, 1817, 580, - /* 2460 */ 1483, 575, 1831, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2470 */ 582, 1483, 1483, 1483, 1483, 1783, 1483, 581, 1483, 1483, - /* 2480 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2490 */ 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, 1483, - /* 2500 */ 1845, 1483, 1483, 1483, 287, 1814, 584, 1816, 1817, 580, - /* 2510 */ 1483, 575, + /* 0 */ 530, 556, 1760, 530, 435, 1829, 436, 1547, 32, 258, + /* 10 */ 1843, 117, 42, 40, 117, 1996, 1825, 1033, 473, 1646, + /* 20 */ 339, 478, 1296, 41, 39, 38, 37, 36, 1657, 1323, + /* 30 */ 1991, 1657, 1323, 1374, 1577, 1294, 571, 571, 1861, 1648, + /* 40 */ 1821, 1827, 327, 555, 166, 1510, 572, 325, 1992, 557, + /* 50 */ 1825, 1811, 1642, 584, 578, 150, 1369, 1037, 1038, 571, + /* 60 */ 443, 16, 436, 1547, 1659, 1861, 60, 1843, 1302, 42, + /* 70 */ 40, 1444, 440, 550, 1821, 1827, 1875, 339, 1319, 1296, + /* 80 */ 95, 1841, 1842, 1844, 588, 1846, 1847, 583, 578, 578, + /* 90 */ 1374, 530, 1294, 1, 163, 1861, 1928, 384, 485, 484, + /* 100 */ 332, 1924, 50, 572, 354, 124, 1498, 56, 1811, 44, + /* 110 */ 584, 549, 152, 1369, 1524, 675, 480, 483, 16, 1657, + /* 120 */ 513, 1955, 479, 344, 1829, 1302, 1702, 1704, 452, 1376, + /* 130 */ 1377, 212, 44, 1875, 301, 1825, 1996, 95, 1841, 1842, + /* 140 */ 1844, 588, 1846, 1847, 583, 1830, 578, 1703, 1704, 1991, + /* 150 */ 1, 163, 45, 1928, 1843, 56, 1825, 332, 1924, 1821, + /* 160 */ 1827, 333, 1997, 166, 532, 1991, 1900, 1992, 557, 1709, + /* 170 */ 168, 257, 675, 578, 257, 1297, 326, 1295, 1954, 1995, + /* 180 */ 1821, 1827, 1861, 1992, 1994, 1707, 1376, 1377, 77, 303, + /* 190 */ 585, 1322, 520, 568, 578, 1811, 154, 584, 1300, 1301, + /* 200 */ 1616, 1351, 1352, 1354, 1355, 1356, 1357, 1358, 1359, 580, + /* 210 */ 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, 1378, 3, + /* 220 */ 1875, 130, 162, 621, 95, 1841, 1842, 1844, 588, 1846, + /* 230 */ 1847, 583, 1297, 578, 1295, 1696, 127, 169, 137, 1899, + /* 240 */ 1928, 1465, 35, 34, 332, 1924, 41, 39, 38, 37, + /* 250 */ 36, 169, 1050, 169, 1049, 1300, 1301, 128, 1351, 1352, + /* 260 */ 1354, 1355, 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, + /* 270 */ 1370, 1371, 1372, 1373, 1375, 1378, 3, 42, 40, 165, + /* 280 */ 1936, 1937, 1051, 1941, 11, 339, 1321, 1296, 1322, 543, + /* 290 */ 1463, 1464, 1466, 1467, 434, 1843, 169, 438, 1374, 169, + /* 300 */ 1294, 56, 1151, 610, 609, 608, 1155, 607, 1157, 1158, + /* 310 */ 606, 1160, 603, 568, 1166, 600, 1168, 1169, 597, 594, + /* 320 */ 421, 1369, 11, 1861, 9, 219, 16, 1635, 1475, 225, + /* 330 */ 226, 585, 530, 1302, 42, 40, 1811, 613, 584, 546, + /* 340 */ 1709, 130, 339, 171, 1296, 35, 34, 343, 1535, 41, + /* 350 */ 39, 38, 37, 36, 1324, 1374, 1707, 1294, 1, 56, + /* 360 */ 1657, 1875, 56, 1113, 79, 95, 1841, 1842, 1844, 588, + /* 370 */ 1846, 1847, 583, 373, 578, 179, 178, 119, 1369, 1903, + /* 380 */ 675, 1928, 377, 16, 376, 332, 1924, 452, 303, 1811, + /* 390 */ 1302, 520, 375, 371, 1376, 1377, 1115, 1193, 1194, 255, + /* 400 */ 1936, 567, 1513, 566, 35, 34, 1991, 530, 41, 39, + /* 410 */ 38, 37, 36, 442, 617, 1, 438, 1700, 382, 555, + /* 420 */ 166, 552, 547, 107, 1992, 557, 106, 105, 104, 103, + /* 430 */ 102, 101, 100, 99, 98, 1657, 517, 675, 1633, 24, + /* 440 */ 1297, 1448, 1295, 324, 85, 169, 1757, 1321, 1534, 1302, + /* 450 */ 107, 1376, 1377, 106, 105, 104, 103, 102, 101, 100, + /* 460 */ 99, 98, 1321, 1300, 1301, 1650, 1351, 1352, 1354, 1355, + /* 470 */ 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, 1370, 1371, + /* 480 */ 1372, 1373, 1375, 1378, 3, 1512, 11, 35, 34, 1811, + /* 490 */ 530, 41, 39, 38, 37, 36, 234, 1297, 621, 1295, + /* 500 */ 1995, 383, 126, 169, 1505, 1899, 169, 315, 633, 116, + /* 510 */ 115, 114, 113, 112, 111, 110, 109, 108, 1657, 1943, + /* 520 */ 1300, 1301, 551, 1351, 1352, 1354, 1355, 1356, 1357, 1358, + /* 530 */ 1359, 580, 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, + /* 540 */ 1378, 3, 42, 40, 1709, 224, 1296, 342, 1940, 1644, + /* 550 */ 339, 310, 1296, 482, 481, 150, 563, 75, 75, 1294, + /* 560 */ 1707, 568, 198, 1374, 1659, 1294, 316, 530, 314, 313, + /* 570 */ 123, 475, 1050, 1455, 1049, 477, 156, 1533, 391, 1652, + /* 580 */ 1653, 469, 465, 461, 457, 197, 1369, 471, 556, 130, + /* 590 */ 92, 1843, 1302, 619, 1320, 1657, 1504, 476, 1302, 42, + /* 600 */ 40, 1379, 1051, 125, 1943, 1276, 1277, 339, 1640, 1296, + /* 610 */ 568, 1649, 141, 140, 616, 615, 614, 1991, 1811, 1861, + /* 620 */ 1374, 76, 1294, 8, 195, 128, 530, 585, 215, 1353, + /* 630 */ 555, 166, 1811, 1939, 584, 1992, 557, 406, 130, 675, + /* 640 */ 175, 530, 1532, 1369, 1384, 675, 570, 164, 1936, 1937, + /* 650 */ 1321, 1941, 407, 579, 1657, 1302, 1709, 1875, 499, 1376, + /* 660 */ 1377, 95, 1841, 1842, 1844, 588, 1846, 1847, 583, 1657, + /* 670 */ 578, 497, 1708, 495, 128, 2011, 72, 1928, 530, 71, + /* 680 */ 8, 332, 1924, 1811, 1843, 485, 484, 194, 188, 450, + /* 690 */ 193, 1962, 124, 534, 448, 1900, 167, 1936, 1937, 1297, + /* 700 */ 1941, 1295, 675, 480, 483, 1297, 1657, 1295, 1750, 479, + /* 710 */ 186, 1531, 1861, 38, 37, 36, 1376, 1377, 1634, 174, + /* 720 */ 585, 150, 1300, 1301, 1530, 1811, 508, 584, 1300, 1301, + /* 730 */ 1660, 1351, 1352, 1354, 1355, 1356, 1357, 1358, 1359, 580, + /* 740 */ 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, 1378, 3, + /* 750 */ 1875, 559, 1811, 1943, 95, 1841, 1842, 1844, 588, 1846, + /* 760 */ 1847, 583, 1297, 578, 1295, 1811, 28, 169, 1901, 1529, + /* 770 */ 1928, 564, 35, 34, 332, 1924, 41, 39, 38, 37, + /* 780 */ 36, 1528, 1938, 1843, 1527, 1300, 1301, 7, 1351, 1352, + /* 790 */ 1354, 1355, 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, + /* 800 */ 1370, 1371, 1372, 1373, 1375, 1378, 3, 42, 40, 1526, + /* 810 */ 1811, 1861, 345, 646, 644, 339, 322, 1296, 618, 585, + /* 820 */ 150, 1700, 1811, 619, 1811, 1811, 584, 30, 1374, 1659, + /* 830 */ 1294, 378, 1353, 35, 34, 1037, 1038, 41, 39, 38, + /* 840 */ 37, 36, 141, 140, 616, 615, 614, 513, 1321, 1875, + /* 850 */ 1811, 1369, 1523, 292, 1841, 1842, 1844, 588, 1846, 1847, + /* 860 */ 583, 218, 578, 1302, 42, 40, 1750, 612, 1756, 517, + /* 870 */ 298, 530, 339, 1755, 1296, 298, 1991, 177, 678, 1758, + /* 880 */ 1522, 634, 451, 1629, 1525, 1374, 1405, 1294, 8, 1997, + /* 890 */ 166, 252, 265, 1811, 1992, 557, 1617, 35, 34, 1657, + /* 900 */ 78, 41, 39, 38, 37, 36, 160, 530, 1369, 477, + /* 910 */ 675, 668, 664, 660, 656, 263, 516, 1521, 1654, 1077, + /* 920 */ 1302, 1811, 35, 34, 1376, 1377, 41, 39, 38, 37, + /* 930 */ 36, 476, 513, 35, 34, 1657, 91, 41, 39, 38, + /* 940 */ 37, 36, 13, 12, 270, 1, 88, 1687, 530, 530, + /* 950 */ 306, 93, 1078, 29, 232, 530, 1305, 530, 1811, 502, + /* 960 */ 509, 1991, 530, 1410, 46, 4, 514, 675, 229, 1441, + /* 970 */ 1297, 139, 1295, 526, 1997, 166, 1657, 1657, 1520, 1992, + /* 980 */ 557, 1376, 1377, 1657, 1437, 1657, 544, 527, 1948, 1437, + /* 990 */ 1657, 1403, 1519, 1300, 1301, 1564, 1351, 1352, 1354, 1355, + /* 1000 */ 1356, 1357, 1358, 1359, 580, 576, 1367, 1368, 1370, 1371, + /* 1010 */ 1372, 1373, 1375, 1378, 3, 530, 300, 486, 1319, 1811, + /* 1020 */ 221, 385, 49, 48, 512, 414, 528, 1297, 426, 1295, + /* 1030 */ 1353, 1518, 1798, 1811, 386, 1417, 352, 1517, 1270, 1516, + /* 1040 */ 214, 203, 1515, 1657, 201, 399, 1404, 427, 1862, 401, + /* 1050 */ 1300, 1301, 513, 1351, 1352, 1354, 1355, 1356, 1357, 1358, + /* 1060 */ 1359, 580, 576, 1367, 1368, 1370, 1371, 1372, 1373, 1375, + /* 1070 */ 1378, 3, 1811, 530, 205, 1559, 149, 204, 1811, 361, + /* 1080 */ 1811, 1991, 530, 1811, 529, 207, 151, 560, 206, 1557, + /* 1090 */ 392, 276, 1632, 259, 1997, 166, 575, 488, 1308, 1992, + /* 1100 */ 557, 1657, 388, 1574, 209, 274, 64, 208, 43, 63, + /* 1110 */ 1657, 491, 223, 31, 336, 1398, 1399, 1400, 1401, 1402, + /* 1120 */ 1406, 1407, 1408, 1409, 470, 182, 431, 429, 13, 12, + /* 1130 */ 425, 1507, 1508, 420, 419, 418, 417, 416, 413, 412, + /* 1140 */ 411, 410, 409, 405, 404, 403, 402, 396, 395, 394, + /* 1150 */ 393, 246, 390, 389, 312, 134, 1996, 350, 138, 1247, + /* 1160 */ 139, 56, 1548, 227, 58, 1996, 652, 651, 650, 649, + /* 1170 */ 349, 238, 648, 647, 131, 642, 641, 640, 639, 638, + /* 1180 */ 637, 636, 635, 143, 631, 630, 629, 348, 347, 626, + /* 1190 */ 625, 624, 623, 622, 1991, 1304, 530, 619, 58, 94, + /* 1200 */ 1697, 1958, 1843, 1440, 43, 1832, 523, 346, 1995, 231, + /* 1210 */ 627, 1144, 1992, 1993, 254, 1462, 141, 140, 616, 615, + /* 1220 */ 614, 1553, 241, 569, 1657, 251, 628, 2, 5, 43, + /* 1230 */ 1861, 592, 1097, 1395, 355, 69, 68, 381, 585, 138, + /* 1240 */ 173, 360, 490, 1811, 311, 584, 139, 1498, 1095, 1411, + /* 1250 */ 120, 351, 1834, 138, 1263, 1360, 299, 500, 176, 369, + /* 1260 */ 387, 367, 363, 359, 356, 353, 266, 513, 1875, 670, + /* 1270 */ 1319, 211, 96, 586, 338, 1844, 588, 1846, 1847, 583, + /* 1280 */ 269, 578, 1172, 501, 1843, 493, 408, 1752, 1928, 487, + /* 1290 */ 1176, 415, 305, 1924, 210, 423, 1991, 1183, 422, 513, + /* 1300 */ 561, 1181, 424, 1991, 142, 169, 428, 430, 432, 1997, + /* 1310 */ 166, 1325, 1861, 1327, 1992, 557, 555, 166, 433, 441, + /* 1320 */ 585, 1992, 557, 444, 185, 1811, 445, 584, 1991, 1326, + /* 1330 */ 62, 187, 446, 61, 1328, 449, 190, 1307, 192, 447, + /* 1340 */ 73, 1997, 166, 74, 1843, 453, 1992, 557, 196, 472, + /* 1350 */ 1875, 1791, 267, 474, 95, 1841, 1842, 1844, 588, 1846, + /* 1360 */ 1847, 583, 1647, 578, 118, 302, 1843, 200, 2011, 1643, + /* 1370 */ 1928, 202, 1861, 144, 332, 1924, 507, 145, 1645, 213, + /* 1380 */ 585, 1641, 146, 147, 1985, 1811, 503, 584, 504, 216, + /* 1390 */ 510, 515, 542, 321, 1861, 524, 220, 135, 518, 1790, + /* 1400 */ 1762, 525, 585, 521, 82, 323, 84, 1811, 1658, 584, + /* 1410 */ 1875, 268, 136, 1324, 95, 1841, 1842, 1844, 588, 1846, + /* 1420 */ 1847, 583, 1843, 578, 545, 236, 240, 1969, 2011, 538, + /* 1430 */ 1928, 540, 1875, 541, 332, 1924, 285, 586, 338, 1844, + /* 1440 */ 588, 1846, 1847, 583, 1947, 578, 1959, 335, 334, 1968, + /* 1450 */ 1861, 328, 548, 6, 554, 536, 537, 1310, 585, 250, + /* 1460 */ 329, 539, 565, 1811, 2014, 584, 562, 1991, 1374, 1437, + /* 1470 */ 1303, 129, 1323, 55, 247, 1950, 245, 157, 248, 86, + /* 1480 */ 555, 166, 249, 1843, 1944, 1992, 557, 1909, 1875, 1990, + /* 1490 */ 590, 1369, 95, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 1500 */ 1701, 578, 1630, 1302, 271, 1843, 533, 262, 1928, 671, + /* 1510 */ 253, 1861, 332, 1924, 672, 47, 674, 297, 273, 585, + /* 1520 */ 283, 294, 293, 275, 1811, 1805, 584, 66, 1803, 1802, + /* 1530 */ 67, 1799, 357, 1861, 1804, 358, 1288, 1289, 172, 362, + /* 1540 */ 1797, 585, 364, 365, 366, 1796, 1811, 368, 584, 1875, + /* 1550 */ 574, 1795, 370, 96, 1841, 1842, 1844, 588, 1846, 1847, + /* 1560 */ 583, 1794, 578, 372, 1793, 374, 1266, 1265, 1773, 1928, + /* 1570 */ 1772, 1875, 379, 1927, 1924, 96, 1841, 1842, 1844, 588, + /* 1580 */ 1846, 1847, 583, 380, 578, 1771, 1770, 1745, 1235, 1843, + /* 1590 */ 1744, 1928, 1743, 1742, 132, 573, 1924, 1741, 1740, 70, + /* 1600 */ 1739, 1738, 1737, 1736, 1735, 397, 398, 1734, 400, 1733, + /* 1610 */ 1311, 1732, 1306, 1731, 1730, 1729, 1728, 1861, 1727, 1726, + /* 1620 */ 1725, 1724, 1723, 1722, 1721, 582, 1720, 1719, 1718, 1717, + /* 1630 */ 1811, 133, 584, 1314, 1316, 1716, 1715, 1714, 1713, 1237, + /* 1640 */ 1712, 1711, 1710, 1579, 1843, 576, 1367, 1368, 1370, 1371, + /* 1650 */ 1372, 1373, 1578, 1576, 1544, 1875, 437, 1543, 1040, 291, + /* 1660 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 581, 578, 531, + /* 1670 */ 1893, 121, 1861, 183, 184, 1039, 161, 1786, 122, 1780, + /* 1680 */ 585, 180, 1769, 1768, 191, 1811, 181, 584, 189, 1754, + /* 1690 */ 1636, 439, 1575, 1573, 454, 455, 1571, 1843, 458, 1569, + /* 1700 */ 462, 456, 459, 460, 1567, 463, 464, 466, 468, 1070, + /* 1710 */ 1875, 1556, 1555, 467, 153, 1841, 1842, 1844, 588, 1846, + /* 1720 */ 1847, 583, 1540, 578, 1638, 1861, 1187, 1186, 1637, 1112, + /* 1730 */ 1111, 643, 1108, 585, 1565, 1107, 1106, 1560, 1811, 317, + /* 1740 */ 584, 645, 318, 1558, 492, 319, 1539, 1538, 494, 1843, + /* 1750 */ 489, 199, 57, 496, 1537, 498, 97, 1785, 1779, 148, + /* 1760 */ 1272, 1843, 505, 1875, 217, 558, 2012, 96, 1841, 1842, + /* 1770 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1861, 1767, 1765, + /* 1780 */ 1996, 1766, 1764, 1928, 1763, 582, 1280, 1761, 1925, 1861, + /* 1790 */ 1811, 1753, 584, 519, 535, 81, 17, 585, 233, 1386, + /* 1800 */ 10, 222, 1811, 1861, 584, 18, 43, 19, 1385, 228, + /* 1810 */ 244, 585, 80, 88, 230, 1875, 1811, 54, 584, 291, + /* 1820 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1875, 578, 1843, + /* 1830 */ 1894, 292, 1841, 1842, 1844, 588, 1846, 1847, 583, 511, + /* 1840 */ 578, 1875, 51, 1843, 522, 287, 1841, 1842, 1844, 588, + /* 1850 */ 1846, 1847, 583, 83, 578, 1477, 243, 1861, 25, 235, + /* 1860 */ 1832, 27, 237, 1459, 506, 585, 239, 59, 320, 1461, + /* 1870 */ 1811, 1861, 584, 155, 21, 1492, 337, 1454, 242, 585, + /* 1880 */ 1497, 26, 87, 1491, 1811, 330, 584, 1496, 553, 1498, + /* 1890 */ 1495, 331, 1434, 1843, 1433, 1875, 53, 256, 12, 153, + /* 1900 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1831, 578, 1875, + /* 1910 */ 1312, 20, 1843, 292, 1841, 1842, 1844, 588, 1846, 1847, + /* 1920 */ 583, 1861, 578, 158, 1396, 1878, 340, 15, 1364, 585, + /* 1930 */ 577, 159, 1362, 1361, 1811, 33, 584, 14, 22, 170, + /* 1940 */ 1861, 1336, 1344, 52, 587, 589, 591, 23, 585, 341, + /* 1950 */ 593, 2013, 1173, 1811, 1170, 584, 595, 1167, 596, 1875, + /* 1960 */ 598, 599, 1843, 292, 1841, 1842, 1844, 588, 1846, 1847, + /* 1970 */ 583, 601, 578, 1161, 602, 604, 1843, 1159, 1875, 605, + /* 1980 */ 1150, 1182, 277, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 1990 */ 1861, 578, 1165, 1164, 611, 1163, 89, 1162, 585, 90, + /* 2000 */ 65, 1178, 260, 1811, 1861, 584, 1068, 1103, 620, 1102, + /* 2010 */ 1101, 1100, 585, 1099, 632, 1098, 1096, 1811, 1094, 584, + /* 2020 */ 1093, 1092, 1119, 1090, 1089, 261, 1088, 1087, 1875, 1086, + /* 2030 */ 1085, 1843, 278, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 2040 */ 1084, 578, 1875, 1083, 1114, 1116, 279, 1841, 1842, 1844, + /* 2050 */ 588, 1846, 1847, 583, 1080, 578, 1079, 1843, 1076, 1861, + /* 2060 */ 1075, 1074, 1073, 1572, 653, 655, 1570, 585, 657, 654, + /* 2070 */ 659, 658, 1811, 1568, 584, 661, 663, 662, 1566, 665, + /* 2080 */ 667, 666, 1554, 1843, 669, 1861, 1030, 1536, 677, 264, + /* 2090 */ 673, 1511, 1298, 585, 272, 676, 1511, 1875, 1811, 1511, + /* 2100 */ 584, 286, 1841, 1842, 1844, 588, 1846, 1847, 583, 1843, + /* 2110 */ 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, + /* 2120 */ 1511, 1511, 1511, 1875, 1811, 1511, 584, 288, 1841, 1842, + /* 2130 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1861, 1511, 1511, + /* 2140 */ 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, 1875, + /* 2150 */ 1811, 1511, 584, 280, 1841, 1842, 1844, 588, 1846, 1847, + /* 2160 */ 583, 1511, 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2170 */ 1511, 585, 1511, 1511, 1511, 1875, 1811, 1511, 584, 289, + /* 2180 */ 1841, 1842, 1844, 588, 1846, 1847, 583, 1843, 578, 1511, + /* 2190 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2200 */ 1511, 1875, 1511, 1843, 1511, 281, 1841, 1842, 1844, 588, + /* 2210 */ 1846, 1847, 583, 1511, 578, 1861, 1511, 1511, 1511, 1511, + /* 2220 */ 1511, 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, 1511, + /* 2230 */ 584, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, + /* 2240 */ 1511, 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, + /* 2250 */ 1511, 1511, 1511, 1875, 1511, 1511, 1511, 290, 1841, 1842, + /* 2260 */ 1844, 588, 1846, 1847, 583, 1843, 578, 1511, 1511, 1875, + /* 2270 */ 1511, 1511, 1511, 282, 1841, 1842, 1844, 588, 1846, 1847, + /* 2280 */ 583, 1843, 578, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2290 */ 1511, 1511, 1511, 1861, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2300 */ 1511, 585, 1511, 1511, 1511, 1511, 1811, 1511, 584, 1861, + /* 2310 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, + /* 2320 */ 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, 1511, + /* 2330 */ 1511, 1875, 1511, 1511, 1843, 295, 1841, 1842, 1844, 588, + /* 2340 */ 1846, 1847, 583, 1511, 578, 1511, 1511, 1875, 1843, 1511, + /* 2350 */ 1511, 296, 1841, 1842, 1844, 588, 1846, 1847, 583, 1511, + /* 2360 */ 578, 1511, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2370 */ 585, 1511, 1511, 1511, 1511, 1811, 1861, 584, 1511, 1511, + /* 2380 */ 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, + /* 2390 */ 1511, 584, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2400 */ 1875, 1511, 1843, 1511, 1855, 1841, 1842, 1844, 588, 1846, + /* 2410 */ 1847, 583, 1511, 578, 1875, 1511, 1511, 1511, 1854, 1841, + /* 2420 */ 1842, 1844, 588, 1846, 1847, 583, 1843, 578, 1511, 1511, + /* 2430 */ 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, + /* 2440 */ 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, + /* 2450 */ 1511, 1511, 1843, 1511, 1861, 1511, 1511, 1511, 1511, 1511, + /* 2460 */ 1511, 1511, 585, 1511, 1511, 1511, 1511, 1811, 1875, 584, + /* 2470 */ 1511, 1511, 1853, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 2480 */ 1861, 578, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, + /* 2490 */ 1511, 1511, 1875, 1811, 1511, 584, 307, 1841, 1842, 1844, + /* 2500 */ 588, 1846, 1847, 583, 1843, 578, 1511, 1511, 1511, 1511, + /* 2510 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1875, 1511, + /* 2520 */ 1843, 1511, 308, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 2530 */ 1511, 578, 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2540 */ 585, 1511, 1511, 1511, 1511, 1811, 1511, 584, 1861, 1511, + /* 2550 */ 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, 1511, 1511, + /* 2560 */ 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2570 */ 1875, 1511, 1511, 1511, 304, 1841, 1842, 1844, 588, 1846, + /* 2580 */ 1847, 583, 1843, 578, 1511, 1511, 1875, 1511, 1511, 1511, + /* 2590 */ 309, 1841, 1842, 1844, 588, 1846, 1847, 583, 1511, 578, + /* 2600 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2610 */ 1861, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 585, 1511, + /* 2620 */ 1511, 1511, 1511, 1811, 1511, 584, 1511, 1511, 1511, 1511, + /* 2630 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, + /* 2640 */ 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1511, 1875, 1511, + /* 2650 */ 1511, 1511, 284, 1841, 1842, 1844, 588, 1846, 1847, 583, + /* 2660 */ 1511, 578, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 316, 312, 318, 319, 316, 351, 318, 319, 354, 355, - /* 10 */ 8, 9, 12, 13, 12, 13, 14, 15, 16, 342, - /* 20 */ 20, 320, 22, 342, 12, 13, 14, 15, 16, 340, - /* 30 */ 353, 340, 331, 33, 353, 35, 0, 348, 347, 338, - /* 40 */ 393, 394, 353, 0, 355, 320, 311, 356, 313, 348, - /* 50 */ 20, 312, 22, 342, 377, 378, 56, 368, 377, 378, - /* 60 */ 379, 61, 354, 355, 353, 35, 389, 378, 68, 0, - /* 70 */ 389, 382, 383, 384, 385, 386, 387, 0, 389, 340, - /* 80 */ 50, 392, 357, 47, 342, 396, 397, 348, 377, 378, - /* 90 */ 379, 48, 353, 93, 355, 353, 94, 408, 21, 408, - /* 100 */ 389, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 110 */ 421, 340, 421, 20, 425, 115, 425, 378, 347, 377, - /* 120 */ 378, 382, 383, 384, 385, 386, 387, 356, 389, 129, - /* 130 */ 130, 389, 63, 64, 65, 66, 67, 0, 69, 70, - /* 140 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - /* 150 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - /* 160 */ 14, 15, 16, 8, 9, 426, 427, 12, 13, 14, - /* 170 */ 15, 16, 20, 20, 20, 175, 20, 177, 106, 107, - /* 180 */ 108, 109, 110, 111, 112, 113, 114, 115, 116, 93, - /* 190 */ 118, 119, 120, 121, 122, 123, 60, 60, 198, 199, - /* 200 */ 320, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 12, - /* 220 */ 13, 14, 129, 130, 20, 340, 21, 20, 348, 22, - /* 230 */ 8, 9, 232, 348, 12, 13, 14, 15, 16, 34, - /* 240 */ 33, 36, 35, 64, 65, 93, 93, 93, 368, 21, - /* 250 */ 71, 368, 24, 25, 26, 27, 28, 29, 30, 31, - /* 260 */ 32, 82, 83, 56, 4, 43, 386, 88, 61, 384, - /* 270 */ 174, 322, 176, 4, 312, 68, 12, 13, 320, 19, - /* 280 */ 4, 401, 402, 403, 20, 405, 22, 105, 408, 331, - /* 290 */ 312, 408, 343, 33, 39, 332, 338, 33, 312, 35, - /* 300 */ 93, 421, 340, 340, 421, 425, 348, 47, 425, 127, - /* 310 */ 348, 51, 349, 44, 45, 353, 56, 355, 340, 325, - /* 320 */ 56, 408, 115, 329, 317, 61, 348, 320, 232, 198, - /* 330 */ 368, 353, 68, 355, 421, 78, 129, 130, 425, 353, - /* 340 */ 378, 43, 56, 355, 382, 383, 384, 385, 386, 387, - /* 350 */ 362, 389, 92, 365, 392, 95, 378, 93, 396, 397, - /* 360 */ 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, - /* 370 */ 408, 0, 241, 242, 243, 244, 245, 124, 92, 115, - /* 380 */ 340, 95, 175, 421, 177, 232, 232, 425, 312, 349, - /* 390 */ 133, 134, 94, 129, 130, 24, 25, 26, 27, 28, - /* 400 */ 29, 30, 31, 32, 93, 198, 199, 35, 201, 202, - /* 410 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 420 */ 213, 214, 215, 216, 217, 218, 8, 9, 340, 353, - /* 430 */ 12, 13, 14, 15, 16, 347, 2, 184, 185, 175, - /* 440 */ 68, 177, 8, 9, 356, 2, 12, 13, 14, 15, - /* 450 */ 16, 8, 9, 56, 43, 12, 13, 14, 15, 16, - /* 460 */ 312, 37, 198, 199, 160, 201, 202, 203, 204, 205, - /* 470 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - /* 480 */ 216, 217, 218, 12, 13, 18, 231, 20, 340, 320, - /* 490 */ 93, 20, 95, 22, 27, 125, 348, 30, 124, 125, - /* 500 */ 331, 353, 408, 355, 33, 20, 35, 14, 368, 233, - /* 510 */ 368, 408, 94, 20, 47, 421, 49, 348, 51, 425, - /* 520 */ 96, 93, 98, 99, 421, 101, 378, 56, 425, 105, - /* 530 */ 382, 383, 384, 385, 386, 387, 348, 389, 20, 68, - /* 540 */ 392, 237, 238, 232, 396, 397, 398, 359, 408, 22, - /* 550 */ 408, 127, 182, 183, 19, 4, 186, 183, 410, 92, - /* 560 */ 186, 421, 35, 421, 93, 425, 418, 425, 33, 320, - /* 570 */ 20, 104, 339, 8, 9, 332, 332, 12, 13, 14, - /* 580 */ 15, 16, 47, 340, 340, 352, 115, 52, 53, 54, - /* 590 */ 55, 56, 349, 349, 309, 68, 20, 348, 22, 132, - /* 600 */ 129, 130, 135, 136, 137, 138, 139, 140, 141, 142, - /* 610 */ 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, - /* 620 */ 312, 154, 155, 156, 60, 14, 50, 92, 14, 232, - /* 630 */ 95, 20, 8, 9, 20, 386, 12, 13, 14, 15, - /* 640 */ 16, 20, 115, 157, 93, 105, 175, 162, 177, 400, - /* 650 */ 401, 402, 403, 368, 405, 368, 1, 2, 326, 327, - /* 660 */ 232, 353, 251, 128, 124, 125, 126, 127, 128, 198, - /* 670 */ 199, 0, 201, 202, 203, 204, 205, 206, 207, 208, - /* 680 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, - /* 690 */ 12, 13, 14, 408, 68, 408, 161, 368, 20, 170, - /* 700 */ 22, 324, 175, 232, 177, 219, 421, 324, 421, 322, - /* 710 */ 425, 33, 425, 35, 179, 229, 181, 312, 189, 190, - /* 720 */ 337, 0, 335, 346, 312, 198, 199, 348, 312, 346, - /* 730 */ 343, 312, 167, 320, 56, 8, 9, 408, 359, 12, - /* 740 */ 13, 14, 15, 16, 331, 320, 68, 12, 13, 94, - /* 750 */ 421, 320, 340, 0, 425, 20, 331, 22, 353, 312, - /* 760 */ 348, 348, 331, 317, 320, 353, 320, 355, 33, 353, - /* 770 */ 35, 93, 353, 348, 320, 326, 327, 355, 320, 348, - /* 780 */ 368, 60, 3, 232, 20, 331, 162, 365, 312, 331, - /* 790 */ 378, 56, 348, 115, 382, 383, 384, 385, 386, 387, - /* 800 */ 353, 389, 348, 68, 12, 13, 348, 129, 130, 104, - /* 810 */ 312, 320, 320, 202, 22, 320, 202, 64, 65, 254, - /* 820 */ 408, 94, 331, 331, 71, 33, 331, 35, 93, 353, - /* 830 */ 386, 320, 312, 421, 312, 82, 83, 425, 68, 348, - /* 840 */ 348, 88, 331, 348, 20, 401, 402, 403, 56, 405, - /* 850 */ 115, 353, 364, 175, 366, 177, 328, 341, 330, 348, - /* 860 */ 68, 93, 8, 9, 129, 130, 12, 13, 14, 15, - /* 870 */ 16, 103, 364, 353, 366, 353, 198, 199, 312, 201, - /* 880 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, - /* 890 */ 212, 213, 214, 215, 216, 217, 218, 320, 320, 320, - /* 900 */ 320, 97, 320, 320, 100, 380, 372, 115, 331, 331, - /* 910 */ 175, 331, 177, 331, 331, 61, 341, 312, 350, 353, - /* 920 */ 312, 353, 312, 44, 45, 348, 348, 348, 348, 404, - /* 930 */ 348, 348, 312, 198, 199, 312, 201, 202, 203, 204, - /* 940 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - /* 950 */ 215, 216, 217, 218, 12, 13, 102, 320, 353, 320, - /* 960 */ 341, 353, 20, 353, 22, 386, 202, 175, 331, 177, - /* 970 */ 331, 230, 231, 353, 33, 33, 353, 35, 312, 312, - /* 980 */ 401, 402, 403, 0, 405, 348, 162, 348, 47, 312, - /* 990 */ 198, 199, 380, 52, 53, 54, 55, 56, 56, 340, - /* 1000 */ 42, 43, 210, 211, 212, 213, 214, 215, 216, 0, - /* 1010 */ 68, 157, 320, 320, 22, 356, 404, 340, 350, 353, - /* 1020 */ 353, 353, 345, 331, 331, 348, 380, 35, 249, 18, - /* 1030 */ 353, 43, 355, 92, 23, 93, 95, 61, 8, 9, - /* 1040 */ 348, 348, 12, 13, 14, 15, 16, 43, 37, 38, - /* 1050 */ 404, 333, 41, 97, 336, 378, 100, 115, 56, 382, - /* 1060 */ 383, 384, 385, 386, 387, 43, 389, 43, 57, 58, - /* 1070 */ 59, 129, 130, 219, 220, 221, 222, 223, 224, 225, - /* 1080 */ 226, 227, 228, 229, 97, 35, 97, 100, 105, 100, - /* 1090 */ 0, 61, 162, 163, 1, 2, 35, 95, 94, 158, - /* 1100 */ 159, 0, 161, 0, 93, 329, 165, 124, 125, 126, - /* 1110 */ 127, 128, 22, 43, 105, 43, 94, 175, 94, 177, - /* 1120 */ 43, 43, 181, 22, 94, 22, 129, 130, 46, 341, - /* 1130 */ 43, 43, 102, 124, 125, 126, 127, 128, 43, 43, - /* 1140 */ 198, 199, 131, 201, 202, 203, 204, 205, 206, 207, - /* 1150 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, - /* 1160 */ 218, 43, 43, 43, 94, 43, 94, 35, 341, 13, - /* 1170 */ 13, 94, 94, 341, 198, 93, 341, 313, 167, 168, - /* 1180 */ 169, 94, 94, 172, 428, 419, 321, 157, 415, 94, - /* 1190 */ 94, 35, 35, 340, 312, 321, 319, 352, 381, 188, - /* 1200 */ 68, 406, 191, 422, 193, 194, 195, 196, 197, 399, - /* 1210 */ 409, 422, 94, 94, 94, 422, 94, 376, 234, 47, - /* 1220 */ 173, 375, 340, 42, 20, 370, 360, 177, 320, 320, - /* 1230 */ 348, 360, 157, 358, 358, 353, 320, 355, 177, 320, - /* 1240 */ 320, 253, 20, 232, 20, 314, 314, 312, 324, 219, - /* 1250 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - /* 1260 */ 378, 374, 355, 324, 382, 383, 384, 385, 386, 387, - /* 1270 */ 20, 389, 367, 20, 392, 340, 324, 367, 396, 397, - /* 1280 */ 398, 369, 314, 348, 324, 324, 324, 312, 353, 320, - /* 1290 */ 355, 324, 374, 340, 340, 340, 314, 340, 320, 340, - /* 1300 */ 418, 353, 322, 340, 340, 340, 340, 180, 322, 373, - /* 1310 */ 340, 312, 340, 378, 320, 340, 320, 382, 383, 384, - /* 1320 */ 385, 386, 387, 348, 389, 322, 355, 392, 353, 159, - /* 1330 */ 355, 396, 397, 398, 353, 322, 239, 363, 353, 340, - /* 1340 */ 367, 322, 407, 353, 353, 20, 336, 348, 353, 348, - /* 1350 */ 240, 312, 353, 378, 355, 246, 363, 382, 383, 384, - /* 1360 */ 385, 386, 387, 414, 389, 353, 361, 353, 353, 363, - /* 1370 */ 363, 353, 166, 353, 248, 247, 235, 378, 231, 340, - /* 1380 */ 348, 382, 383, 384, 385, 386, 387, 348, 389, 381, - /* 1390 */ 413, 392, 353, 414, 355, 396, 397, 398, 252, 20, - /* 1400 */ 250, 376, 93, 255, 312, 93, 407, 380, 344, 353, - /* 1410 */ 330, 320, 36, 371, 315, 417, 416, 378, 314, 366, - /* 1420 */ 322, 382, 383, 384, 385, 386, 387, 310, 389, 412, - /* 1430 */ 414, 392, 340, 395, 411, 396, 397, 398, 323, 334, - /* 1440 */ 348, 334, 334, 0, 423, 353, 407, 355, 0, 0, - /* 1450 */ 424, 182, 0, 424, 312, 424, 423, 429, 423, 42, - /* 1460 */ 368, 0, 35, 192, 35, 35, 35, 192, 0, 35, - /* 1470 */ 378, 312, 35, 192, 382, 383, 384, 385, 386, 387, - /* 1480 */ 0, 389, 340, 192, 0, 35, 0, 22, 0, 35, - /* 1490 */ 348, 177, 175, 0, 0, 353, 170, 355, 171, 340, - /* 1500 */ 408, 0, 0, 46, 0, 0, 0, 348, 42, 0, - /* 1510 */ 0, 0, 353, 421, 355, 153, 0, 425, 0, 0, - /* 1520 */ 378, 312, 148, 0, 382, 383, 384, 385, 386, 387, - /* 1530 */ 0, 389, 0, 35, 392, 148, 0, 378, 396, 397, - /* 1540 */ 0, 382, 383, 384, 385, 386, 387, 0, 389, 340, - /* 1550 */ 0, 392, 0, 0, 0, 396, 397, 348, 0, 0, - /* 1560 */ 0, 0, 353, 0, 355, 0, 0, 42, 0, 312, - /* 1570 */ 0, 0, 0, 0, 0, 0, 0, 22, 0, 312, - /* 1580 */ 56, 0, 56, 0, 0, 42, 40, 378, 0, 0, - /* 1590 */ 39, 382, 383, 384, 385, 386, 387, 340, 389, 43, - /* 1600 */ 14, 392, 345, 46, 14, 348, 397, 340, 46, 0, - /* 1610 */ 353, 0, 355, 0, 0, 348, 39, 166, 39, 0, - /* 1620 */ 353, 0, 355, 0, 0, 0, 62, 0, 35, 47, - /* 1630 */ 312, 35, 47, 39, 39, 378, 0, 35, 47, 382, - /* 1640 */ 383, 384, 385, 386, 387, 378, 389, 39, 0, 382, - /* 1650 */ 383, 384, 385, 386, 387, 35, 389, 47, 340, 22, - /* 1660 */ 0, 39, 0, 0, 0, 0, 348, 35, 35, 102, - /* 1670 */ 35, 353, 43, 355, 43, 35, 35, 22, 0, 22, - /* 1680 */ 0, 0, 35, 22, 0, 35, 0, 420, 49, 22, - /* 1690 */ 312, 35, 0, 22, 20, 0, 378, 100, 0, 162, - /* 1700 */ 382, 383, 384, 385, 386, 387, 178, 389, 312, 22, - /* 1710 */ 35, 162, 0, 0, 0, 0, 0, 35, 340, 93, - /* 1720 */ 187, 0, 94, 93, 0, 46, 348, 93, 159, 39, - /* 1730 */ 230, 353, 43, 355, 43, 93, 340, 93, 93, 236, - /* 1740 */ 94, 345, 43, 94, 348, 427, 103, 160, 94, 353, - /* 1750 */ 46, 355, 94, 46, 43, 35, 378, 158, 312, 93, - /* 1760 */ 382, 383, 384, 385, 386, 387, 162, 389, 46, 391, - /* 1770 */ 164, 94, 43, 46, 378, 236, 93, 46, 382, 383, - /* 1780 */ 384, 385, 386, 387, 312, 389, 340, 93, 43, 93, - /* 1790 */ 93, 345, 35, 35, 348, 94, 94, 94, 35, 353, - /* 1800 */ 94, 355, 35, 35, 2, 22, 46, 43, 312, 22, - /* 1810 */ 198, 93, 340, 35, 104, 46, 200, 94, 93, 93, - /* 1820 */ 348, 35, 94, 93, 378, 353, 94, 355, 382, 383, - /* 1830 */ 384, 385, 386, 387, 312, 389, 340, 236, 94, 93, - /* 1840 */ 93, 93, 35, 94, 348, 93, 35, 94, 93, 353, - /* 1850 */ 378, 355, 35, 35, 382, 383, 384, 385, 386, 387, - /* 1860 */ 94, 389, 340, 93, 22, 94, 93, 117, 117, 93, - /* 1870 */ 348, 117, 35, 117, 378, 353, 43, 355, 382, 383, - /* 1880 */ 384, 385, 386, 387, 105, 389, 93, 93, 22, 62, - /* 1890 */ 61, 35, 312, 35, 35, 35, 35, 35, 35, 35, - /* 1900 */ 378, 91, 35, 35, 382, 383, 384, 385, 386, 387, - /* 1910 */ 312, 389, 320, 68, 43, 35, 35, 22, 35, 22, - /* 1920 */ 340, 35, 35, 35, 35, 68, 35, 35, 348, 35, - /* 1930 */ 22, 35, 0, 353, 35, 355, 35, 47, 340, 39, - /* 1940 */ 348, 0, 35, 39, 0, 47, 348, 35, 39, 47, - /* 1950 */ 0, 353, 35, 355, 39, 0, 0, 47, 378, 35, - /* 1960 */ 368, 35, 382, 383, 384, 385, 386, 387, 22, 389, - /* 1970 */ 21, 312, 430, 22, 22, 21, 378, 20, 386, 430, - /* 1980 */ 382, 383, 384, 385, 386, 387, 430, 389, 430, 430, - /* 1990 */ 430, 430, 430, 401, 402, 403, 430, 405, 430, 340, - /* 2000 */ 408, 430, 430, 430, 430, 430, 430, 348, 430, 430, - /* 2010 */ 430, 430, 353, 421, 355, 430, 430, 425, 430, 430, - /* 2020 */ 430, 312, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2030 */ 430, 312, 430, 430, 430, 430, 430, 378, 430, 430, - /* 2040 */ 430, 382, 383, 384, 385, 386, 387, 430, 389, 340, - /* 2050 */ 430, 430, 430, 430, 430, 430, 430, 348, 430, 340, - /* 2060 */ 430, 430, 353, 430, 355, 430, 430, 348, 430, 430, - /* 2070 */ 430, 312, 353, 430, 355, 430, 430, 430, 430, 430, - /* 2080 */ 430, 430, 430, 430, 430, 430, 430, 378, 430, 430, - /* 2090 */ 430, 382, 383, 384, 385, 386, 387, 378, 389, 340, - /* 2100 */ 430, 382, 383, 384, 385, 386, 387, 348, 389, 430, - /* 2110 */ 430, 430, 353, 430, 355, 430, 430, 430, 430, 430, - /* 2120 */ 430, 312, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2130 */ 430, 430, 430, 312, 430, 430, 430, 378, 430, 430, - /* 2140 */ 430, 382, 383, 384, 385, 386, 387, 312, 389, 340, - /* 2150 */ 430, 430, 430, 430, 430, 430, 430, 348, 430, 430, - /* 2160 */ 430, 340, 353, 430, 355, 430, 430, 430, 430, 348, - /* 2170 */ 430, 430, 430, 430, 353, 340, 355, 430, 430, 430, - /* 2180 */ 430, 430, 430, 348, 430, 430, 430, 378, 353, 430, - /* 2190 */ 355, 382, 383, 384, 385, 386, 387, 430, 389, 378, - /* 2200 */ 430, 430, 430, 382, 383, 384, 385, 386, 387, 430, - /* 2210 */ 389, 430, 430, 378, 430, 430, 430, 382, 383, 384, - /* 2220 */ 385, 386, 387, 312, 389, 430, 430, 430, 430, 430, - /* 2230 */ 430, 430, 430, 312, 430, 430, 430, 430, 430, 430, - /* 2240 */ 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2250 */ 430, 340, 430, 430, 430, 430, 430, 430, 430, 348, - /* 2260 */ 430, 340, 430, 430, 353, 430, 355, 430, 430, 348, - /* 2270 */ 430, 430, 430, 430, 353, 430, 355, 430, 430, 430, - /* 2280 */ 430, 430, 430, 430, 312, 430, 430, 430, 430, 378, - /* 2290 */ 430, 430, 430, 382, 383, 384, 385, 386, 387, 378, - /* 2300 */ 389, 430, 430, 382, 383, 384, 385, 386, 387, 430, - /* 2310 */ 389, 430, 340, 430, 430, 430, 430, 430, 430, 430, - /* 2320 */ 348, 430, 430, 430, 430, 353, 430, 355, 430, 430, - /* 2330 */ 430, 430, 430, 430, 312, 430, 430, 430, 430, 430, - /* 2340 */ 430, 430, 430, 430, 312, 430, 430, 430, 430, 430, - /* 2350 */ 378, 430, 430, 430, 382, 383, 384, 385, 386, 387, - /* 2360 */ 430, 389, 340, 430, 430, 430, 430, 430, 430, 430, - /* 2370 */ 348, 430, 340, 430, 430, 353, 430, 355, 430, 430, - /* 2380 */ 348, 430, 430, 430, 312, 353, 430, 355, 430, 430, - /* 2390 */ 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2400 */ 378, 430, 430, 430, 382, 383, 384, 385, 386, 387, - /* 2410 */ 378, 389, 340, 430, 382, 383, 384, 385, 386, 387, - /* 2420 */ 348, 389, 430, 430, 430, 353, 430, 355, 430, 430, - /* 2430 */ 430, 430, 430, 430, 312, 430, 430, 430, 430, 430, - /* 2440 */ 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2450 */ 378, 430, 430, 430, 382, 383, 384, 385, 386, 387, - /* 2460 */ 430, 389, 340, 430, 430, 430, 430, 430, 430, 430, - /* 2470 */ 348, 430, 430, 430, 430, 353, 430, 355, 430, 430, - /* 2480 */ 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2490 */ 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, - /* 2500 */ 378, 430, 430, 430, 382, 383, 384, 385, 386, 387, - /* 2510 */ 430, 389, + /* 0 */ 324, 388, 0, 324, 320, 346, 322, 323, 403, 404, + /* 10 */ 316, 335, 12, 13, 335, 3, 357, 4, 342, 345, + /* 20 */ 20, 342, 22, 12, 13, 14, 15, 16, 352, 20, + /* 30 */ 417, 352, 20, 33, 0, 35, 20, 20, 344, 346, + /* 40 */ 381, 382, 383, 430, 431, 313, 352, 336, 435, 436, + /* 50 */ 357, 357, 345, 359, 395, 344, 56, 44, 45, 20, + /* 60 */ 320, 61, 322, 323, 353, 344, 4, 316, 68, 12, + /* 70 */ 13, 14, 14, 352, 381, 382, 382, 20, 20, 22, + /* 80 */ 386, 387, 388, 389, 390, 391, 392, 393, 395, 395, + /* 90 */ 33, 324, 35, 93, 400, 344, 402, 324, 64, 65, + /* 100 */ 406, 407, 335, 352, 372, 71, 94, 93, 357, 93, + /* 110 */ 359, 390, 315, 56, 317, 115, 82, 83, 61, 352, + /* 120 */ 388, 427, 88, 355, 346, 68, 358, 359, 60, 129, + /* 130 */ 130, 125, 93, 382, 361, 357, 388, 386, 387, 388, + /* 140 */ 389, 390, 391, 392, 393, 346, 395, 358, 359, 417, + /* 150 */ 93, 400, 93, 402, 316, 93, 357, 406, 407, 381, + /* 160 */ 382, 383, 430, 431, 399, 417, 401, 435, 436, 344, + /* 170 */ 419, 162, 115, 395, 162, 175, 351, 177, 427, 431, + /* 180 */ 381, 382, 344, 435, 436, 360, 129, 130, 182, 183, + /* 190 */ 352, 20, 186, 324, 395, 357, 329, 359, 198, 199, + /* 200 */ 333, 201, 202, 203, 204, 205, 206, 207, 208, 209, + /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 220 */ 382, 352, 343, 60, 386, 387, 388, 389, 390, 391, + /* 230 */ 392, 393, 175, 395, 177, 356, 398, 237, 400, 401, + /* 240 */ 402, 198, 8, 9, 406, 407, 12, 13, 14, 15, + /* 250 */ 16, 237, 20, 237, 22, 198, 199, 388, 201, 202, + /* 260 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + /* 270 */ 213, 214, 215, 216, 217, 218, 219, 12, 13, 410, + /* 280 */ 411, 412, 50, 414, 221, 20, 20, 22, 20, 246, + /* 290 */ 247, 248, 249, 250, 321, 316, 237, 324, 33, 237, + /* 300 */ 35, 93, 106, 107, 108, 109, 110, 111, 112, 113, + /* 310 */ 114, 115, 116, 324, 118, 119, 120, 121, 122, 123, + /* 320 */ 78, 56, 221, 344, 223, 56, 61, 0, 94, 124, + /* 330 */ 125, 352, 324, 68, 12, 13, 357, 104, 359, 160, + /* 340 */ 344, 352, 20, 335, 22, 8, 9, 351, 316, 12, + /* 350 */ 13, 14, 15, 16, 20, 33, 360, 35, 93, 93, + /* 360 */ 352, 382, 93, 35, 95, 386, 387, 388, 389, 390, + /* 370 */ 391, 392, 393, 170, 395, 133, 134, 388, 56, 400, + /* 380 */ 115, 402, 174, 61, 176, 406, 407, 60, 183, 357, + /* 390 */ 68, 186, 189, 190, 129, 130, 68, 129, 130, 410, + /* 400 */ 411, 412, 0, 414, 8, 9, 417, 324, 12, 13, + /* 410 */ 14, 15, 16, 321, 354, 93, 324, 357, 335, 430, + /* 420 */ 431, 242, 243, 21, 435, 436, 24, 25, 26, 27, + /* 430 */ 28, 29, 30, 31, 32, 352, 359, 115, 0, 43, + /* 440 */ 175, 14, 177, 366, 326, 237, 369, 20, 316, 68, + /* 450 */ 21, 129, 130, 24, 25, 26, 27, 28, 29, 30, + /* 460 */ 31, 32, 20, 198, 199, 347, 201, 202, 203, 204, + /* 470 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + /* 480 */ 215, 216, 217, 218, 219, 0, 221, 8, 9, 357, + /* 490 */ 324, 12, 13, 14, 15, 16, 162, 175, 60, 177, + /* 500 */ 3, 335, 398, 237, 167, 401, 237, 37, 68, 24, + /* 510 */ 25, 26, 27, 28, 29, 30, 31, 32, 352, 384, + /* 520 */ 198, 199, 20, 201, 202, 203, 204, 205, 206, 207, + /* 530 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + /* 540 */ 218, 219, 12, 13, 344, 124, 22, 336, 413, 345, + /* 550 */ 20, 351, 22, 330, 331, 344, 43, 328, 328, 35, + /* 560 */ 360, 324, 33, 33, 353, 35, 96, 324, 98, 99, + /* 570 */ 341, 101, 20, 94, 22, 105, 47, 316, 335, 350, + /* 580 */ 350, 52, 53, 54, 55, 56, 56, 35, 388, 352, + /* 590 */ 326, 316, 68, 105, 20, 352, 259, 127, 68, 12, + /* 600 */ 13, 14, 50, 339, 384, 184, 185, 20, 345, 22, + /* 610 */ 324, 347, 124, 125, 126, 127, 128, 417, 357, 344, + /* 620 */ 33, 92, 35, 93, 95, 388, 324, 352, 345, 202, + /* 630 */ 430, 431, 357, 413, 359, 435, 436, 335, 352, 115, + /* 640 */ 56, 324, 316, 56, 14, 115, 409, 410, 411, 412, + /* 650 */ 20, 414, 335, 345, 352, 68, 344, 382, 21, 129, + /* 660 */ 130, 386, 387, 388, 389, 390, 391, 392, 393, 352, + /* 670 */ 395, 34, 360, 36, 388, 400, 92, 402, 324, 95, + /* 680 */ 93, 406, 407, 357, 316, 64, 65, 158, 159, 335, + /* 690 */ 161, 416, 71, 399, 165, 401, 410, 411, 412, 175, + /* 700 */ 414, 177, 115, 82, 83, 175, 352, 177, 352, 88, + /* 710 */ 181, 316, 344, 14, 15, 16, 129, 130, 0, 363, + /* 720 */ 352, 344, 198, 199, 316, 357, 376, 359, 198, 199, + /* 730 */ 353, 201, 202, 203, 204, 205, 206, 207, 208, 209, + /* 740 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 750 */ 382, 254, 357, 384, 386, 387, 388, 389, 390, 391, + /* 760 */ 392, 393, 175, 395, 177, 357, 2, 237, 400, 316, + /* 770 */ 402, 258, 8, 9, 406, 407, 12, 13, 14, 15, + /* 780 */ 16, 316, 413, 316, 316, 198, 199, 39, 201, 202, + /* 790 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + /* 800 */ 213, 214, 215, 216, 217, 218, 219, 12, 13, 316, + /* 810 */ 357, 344, 336, 330, 331, 20, 349, 22, 354, 352, + /* 820 */ 344, 357, 357, 105, 357, 357, 359, 2, 33, 353, + /* 830 */ 35, 372, 202, 8, 9, 44, 45, 12, 13, 14, + /* 840 */ 15, 16, 124, 125, 126, 127, 128, 388, 20, 382, + /* 850 */ 357, 56, 316, 386, 387, 388, 389, 390, 391, 392, + /* 860 */ 393, 56, 395, 68, 12, 13, 352, 345, 368, 359, + /* 870 */ 370, 324, 20, 368, 22, 370, 417, 363, 19, 369, + /* 880 */ 316, 332, 335, 334, 317, 33, 157, 35, 93, 430, + /* 890 */ 431, 439, 33, 357, 435, 436, 333, 8, 9, 352, + /* 900 */ 95, 12, 13, 14, 15, 16, 47, 324, 56, 105, + /* 910 */ 115, 52, 53, 54, 55, 56, 372, 316, 335, 35, + /* 920 */ 68, 357, 8, 9, 129, 130, 12, 13, 14, 15, + /* 930 */ 16, 127, 388, 8, 9, 352, 93, 12, 13, 14, + /* 940 */ 15, 16, 1, 2, 337, 93, 103, 340, 324, 324, + /* 950 */ 61, 92, 68, 224, 95, 324, 35, 324, 357, 335, + /* 960 */ 335, 417, 324, 234, 42, 43, 335, 115, 335, 4, + /* 970 */ 175, 43, 177, 335, 430, 431, 352, 352, 316, 435, + /* 980 */ 436, 129, 130, 352, 236, 352, 428, 128, 235, 236, + /* 990 */ 352, 102, 316, 198, 199, 0, 201, 202, 203, 204, + /* 1000 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + /* 1010 */ 215, 216, 217, 218, 219, 324, 18, 22, 20, 357, + /* 1020 */ 161, 22, 94, 162, 163, 27, 335, 175, 30, 177, + /* 1030 */ 202, 316, 0, 357, 35, 94, 372, 316, 179, 316, + /* 1040 */ 181, 97, 316, 352, 100, 47, 157, 49, 344, 51, + /* 1050 */ 198, 199, 388, 201, 202, 203, 204, 205, 206, 207, + /* 1060 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + /* 1070 */ 218, 219, 357, 324, 97, 0, 162, 100, 357, 47, + /* 1080 */ 357, 417, 324, 357, 335, 97, 18, 43, 100, 0, + /* 1090 */ 92, 23, 0, 335, 430, 431, 61, 22, 177, 435, + /* 1100 */ 436, 352, 104, 0, 97, 37, 38, 100, 43, 41, + /* 1110 */ 352, 22, 43, 224, 225, 226, 227, 228, 229, 230, + /* 1120 */ 231, 232, 233, 234, 325, 57, 58, 59, 1, 2, + /* 1130 */ 132, 129, 130, 135, 136, 137, 138, 139, 140, 141, + /* 1140 */ 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, + /* 1150 */ 152, 424, 154, 155, 156, 43, 3, 325, 43, 94, + /* 1160 */ 43, 93, 323, 94, 43, 388, 63, 64, 65, 66, + /* 1170 */ 67, 43, 69, 70, 71, 72, 73, 74, 75, 76, + /* 1180 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + /* 1190 */ 87, 88, 89, 90, 417, 35, 324, 105, 43, 131, + /* 1200 */ 356, 385, 316, 238, 43, 46, 94, 335, 431, 94, + /* 1210 */ 13, 94, 435, 436, 432, 94, 124, 125, 126, 127, + /* 1220 */ 128, 0, 94, 415, 352, 408, 13, 418, 239, 43, + /* 1230 */ 344, 43, 35, 198, 380, 167, 168, 169, 352, 43, + /* 1240 */ 172, 47, 4, 357, 379, 359, 43, 94, 35, 94, + /* 1250 */ 43, 372, 93, 43, 173, 94, 188, 19, 42, 191, + /* 1260 */ 364, 193, 194, 195, 196, 197, 374, 388, 382, 48, + /* 1270 */ 20, 33, 386, 387, 388, 389, 390, 391, 392, 393, + /* 1280 */ 94, 395, 94, 372, 316, 47, 324, 324, 402, 51, + /* 1290 */ 94, 364, 406, 407, 56, 157, 417, 94, 362, 388, + /* 1300 */ 256, 94, 362, 417, 94, 237, 324, 324, 324, 430, + /* 1310 */ 431, 20, 344, 20, 435, 436, 430, 431, 318, 318, + /* 1320 */ 352, 435, 436, 378, 328, 357, 359, 359, 417, 20, + /* 1330 */ 92, 328, 371, 95, 20, 371, 328, 177, 328, 373, + /* 1340 */ 328, 430, 431, 328, 316, 324, 435, 436, 328, 318, + /* 1350 */ 382, 357, 378, 344, 386, 387, 388, 389, 390, 391, + /* 1360 */ 392, 393, 344, 395, 324, 318, 316, 344, 400, 344, + /* 1370 */ 402, 344, 344, 344, 406, 407, 359, 344, 344, 326, + /* 1380 */ 352, 344, 344, 344, 416, 357, 180, 359, 377, 326, + /* 1390 */ 324, 324, 244, 371, 344, 159, 326, 367, 357, 357, + /* 1400 */ 357, 365, 352, 357, 326, 357, 326, 357, 352, 359, + /* 1410 */ 382, 340, 367, 20, 386, 387, 388, 389, 390, 391, + /* 1420 */ 392, 393, 316, 395, 245, 367, 367, 423, 400, 357, + /* 1430 */ 402, 357, 382, 357, 406, 407, 386, 387, 388, 389, + /* 1440 */ 390, 391, 392, 393, 416, 395, 385, 12, 13, 423, + /* 1450 */ 344, 357, 357, 251, 166, 240, 252, 22, 352, 380, + /* 1460 */ 260, 253, 257, 357, 440, 359, 255, 417, 33, 236, + /* 1470 */ 35, 352, 20, 93, 422, 426, 425, 423, 421, 93, + /* 1480 */ 430, 431, 420, 316, 384, 435, 436, 405, 382, 434, + /* 1490 */ 348, 56, 386, 387, 388, 389, 390, 391, 392, 393, + /* 1500 */ 357, 395, 334, 68, 324, 316, 400, 326, 402, 36, + /* 1510 */ 433, 344, 406, 407, 319, 375, 318, 370, 327, 352, + /* 1520 */ 338, 338, 338, 314, 357, 0, 359, 182, 0, 0, + /* 1530 */ 42, 0, 35, 344, 0, 192, 35, 35, 35, 192, + /* 1540 */ 0, 352, 35, 35, 192, 0, 357, 192, 359, 382, + /* 1550 */ 115, 0, 35, 386, 387, 388, 389, 390, 391, 392, + /* 1560 */ 393, 0, 395, 22, 0, 35, 177, 175, 0, 402, + /* 1570 */ 0, 382, 171, 406, 407, 386, 387, 388, 389, 390, + /* 1580 */ 391, 392, 393, 170, 395, 0, 0, 0, 46, 316, + /* 1590 */ 0, 402, 0, 0, 42, 406, 407, 0, 0, 153, + /* 1600 */ 0, 0, 0, 0, 0, 148, 35, 0, 148, 0, + /* 1610 */ 175, 0, 177, 0, 0, 0, 0, 344, 0, 0, + /* 1620 */ 0, 0, 0, 0, 0, 352, 0, 0, 0, 0, + /* 1630 */ 357, 42, 359, 198, 199, 0, 0, 0, 0, 22, + /* 1640 */ 0, 0, 0, 0, 316, 210, 211, 212, 213, 214, + /* 1650 */ 215, 216, 0, 0, 0, 382, 46, 0, 14, 386, + /* 1660 */ 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, + /* 1670 */ 397, 39, 344, 42, 40, 14, 43, 0, 39, 0, + /* 1680 */ 352, 56, 0, 0, 166, 357, 56, 359, 39, 0, + /* 1690 */ 0, 46, 0, 0, 35, 47, 0, 316, 35, 0, + /* 1700 */ 35, 39, 47, 39, 0, 47, 39, 35, 39, 62, + /* 1710 */ 382, 0, 0, 47, 386, 387, 388, 389, 390, 391, + /* 1720 */ 392, 393, 0, 395, 0, 344, 35, 22, 0, 35, + /* 1730 */ 35, 43, 35, 352, 0, 35, 22, 0, 357, 22, + /* 1740 */ 359, 43, 22, 0, 35, 22, 0, 0, 35, 316, + /* 1750 */ 49, 100, 102, 35, 0, 22, 20, 0, 0, 178, + /* 1760 */ 35, 316, 22, 382, 159, 437, 438, 386, 387, 388, + /* 1770 */ 389, 390, 391, 392, 393, 316, 395, 344, 0, 0, + /* 1780 */ 3, 0, 0, 402, 0, 352, 35, 0, 407, 344, + /* 1790 */ 357, 0, 359, 187, 349, 39, 93, 352, 46, 220, + /* 1800 */ 222, 94, 357, 344, 359, 43, 43, 241, 220, 93, + /* 1810 */ 46, 352, 93, 103, 158, 382, 357, 43, 359, 386, + /* 1820 */ 387, 388, 389, 390, 391, 392, 393, 382, 395, 316, + /* 1830 */ 397, 386, 387, 388, 389, 390, 391, 392, 393, 164, + /* 1840 */ 395, 382, 162, 316, 160, 386, 387, 388, 389, 390, + /* 1850 */ 391, 392, 393, 93, 395, 94, 43, 344, 93, 93, + /* 1860 */ 46, 43, 94, 94, 162, 352, 93, 3, 162, 94, + /* 1870 */ 357, 344, 359, 93, 43, 35, 349, 94, 93, 352, + /* 1880 */ 94, 93, 93, 35, 357, 35, 359, 35, 429, 94, + /* 1890 */ 35, 35, 94, 316, 94, 382, 43, 46, 2, 386, + /* 1900 */ 387, 388, 389, 390, 391, 392, 393, 46, 395, 382, + /* 1910 */ 22, 241, 316, 386, 387, 388, 389, 390, 391, 392, + /* 1920 */ 393, 344, 395, 46, 198, 93, 349, 241, 94, 352, + /* 1930 */ 93, 46, 94, 94, 357, 93, 359, 93, 93, 46, + /* 1940 */ 344, 94, 22, 235, 200, 104, 35, 93, 352, 35, + /* 1950 */ 93, 438, 94, 357, 94, 359, 35, 94, 93, 382, + /* 1960 */ 35, 93, 316, 386, 387, 388, 389, 390, 391, 392, + /* 1970 */ 393, 35, 395, 94, 93, 35, 316, 94, 382, 93, + /* 1980 */ 22, 35, 386, 387, 388, 389, 390, 391, 392, 393, + /* 1990 */ 344, 395, 117, 117, 105, 117, 93, 117, 352, 93, + /* 2000 */ 93, 22, 43, 357, 344, 359, 62, 35, 61, 35, + /* 2010 */ 35, 35, 352, 35, 91, 35, 35, 357, 35, 359, + /* 2020 */ 35, 35, 68, 35, 35, 43, 22, 35, 382, 22, + /* 2030 */ 35, 316, 386, 387, 388, 389, 390, 391, 392, 393, + /* 2040 */ 35, 395, 382, 35, 35, 68, 386, 387, 388, 389, + /* 2050 */ 390, 391, 392, 393, 35, 395, 35, 316, 35, 344, + /* 2060 */ 35, 22, 35, 0, 35, 39, 0, 352, 35, 47, + /* 2070 */ 39, 47, 357, 0, 359, 35, 39, 47, 0, 35, + /* 2080 */ 39, 47, 0, 316, 35, 344, 35, 0, 20, 22, + /* 2090 */ 21, 441, 22, 352, 22, 21, 441, 382, 357, 441, + /* 2100 */ 359, 386, 387, 388, 389, 390, 391, 392, 393, 316, + /* 2110 */ 395, 344, 441, 441, 441, 441, 441, 441, 441, 352, + /* 2120 */ 441, 441, 441, 382, 357, 441, 359, 386, 387, 388, + /* 2130 */ 389, 390, 391, 392, 393, 316, 395, 344, 441, 441, + /* 2140 */ 441, 441, 441, 441, 441, 352, 441, 441, 441, 382, + /* 2150 */ 357, 441, 359, 386, 387, 388, 389, 390, 391, 392, + /* 2160 */ 393, 441, 395, 344, 441, 441, 441, 441, 441, 441, + /* 2170 */ 441, 352, 441, 441, 441, 382, 357, 441, 359, 386, + /* 2180 */ 387, 388, 389, 390, 391, 392, 393, 316, 395, 441, + /* 2190 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, + /* 2200 */ 441, 382, 441, 316, 441, 386, 387, 388, 389, 390, + /* 2210 */ 391, 392, 393, 441, 395, 344, 441, 441, 441, 441, + /* 2220 */ 441, 441, 441, 352, 441, 441, 441, 441, 357, 441, + /* 2230 */ 359, 344, 441, 441, 441, 441, 441, 441, 441, 352, + /* 2240 */ 441, 441, 441, 441, 357, 441, 359, 441, 441, 441, + /* 2250 */ 441, 441, 441, 382, 441, 441, 441, 386, 387, 388, + /* 2260 */ 389, 390, 391, 392, 393, 316, 395, 441, 441, 382, + /* 2270 */ 441, 441, 441, 386, 387, 388, 389, 390, 391, 392, + /* 2280 */ 393, 316, 395, 441, 441, 441, 441, 441, 441, 441, + /* 2290 */ 441, 441, 441, 344, 441, 441, 441, 441, 441, 441, + /* 2300 */ 441, 352, 441, 441, 441, 441, 357, 441, 359, 344, + /* 2310 */ 441, 441, 441, 441, 441, 441, 441, 352, 441, 441, + /* 2320 */ 441, 441, 357, 441, 359, 441, 441, 441, 441, 441, + /* 2330 */ 441, 382, 441, 441, 316, 386, 387, 388, 389, 390, + /* 2340 */ 391, 392, 393, 441, 395, 441, 441, 382, 316, 441, + /* 2350 */ 441, 386, 387, 388, 389, 390, 391, 392, 393, 441, + /* 2360 */ 395, 441, 344, 441, 441, 441, 441, 441, 441, 441, + /* 2370 */ 352, 441, 441, 441, 441, 357, 344, 359, 441, 441, + /* 2380 */ 441, 441, 441, 441, 352, 441, 441, 441, 441, 357, + /* 2390 */ 441, 359, 441, 441, 441, 441, 441, 441, 441, 441, + /* 2400 */ 382, 441, 316, 441, 386, 387, 388, 389, 390, 391, + /* 2410 */ 392, 393, 441, 395, 382, 441, 441, 441, 386, 387, + /* 2420 */ 388, 389, 390, 391, 392, 393, 316, 395, 441, 441, + /* 2430 */ 344, 441, 441, 441, 441, 441, 441, 441, 352, 441, + /* 2440 */ 441, 441, 441, 357, 441, 359, 441, 441, 441, 441, + /* 2450 */ 441, 441, 316, 441, 344, 441, 441, 441, 441, 441, + /* 2460 */ 441, 441, 352, 441, 441, 441, 441, 357, 382, 359, + /* 2470 */ 441, 441, 386, 387, 388, 389, 390, 391, 392, 393, + /* 2480 */ 344, 395, 441, 441, 441, 441, 441, 441, 352, 441, + /* 2490 */ 441, 441, 382, 357, 441, 359, 386, 387, 388, 389, + /* 2500 */ 390, 391, 392, 393, 316, 395, 441, 441, 441, 441, + /* 2510 */ 441, 441, 441, 441, 441, 441, 441, 441, 382, 441, + /* 2520 */ 316, 441, 386, 387, 388, 389, 390, 391, 392, 393, + /* 2530 */ 441, 395, 344, 441, 441, 441, 441, 441, 441, 441, + /* 2540 */ 352, 441, 441, 441, 441, 357, 441, 359, 344, 441, + /* 2550 */ 441, 441, 441, 441, 441, 441, 352, 441, 441, 441, + /* 2560 */ 441, 357, 441, 359, 441, 441, 441, 441, 441, 441, + /* 2570 */ 382, 441, 441, 441, 386, 387, 388, 389, 390, 391, + /* 2580 */ 392, 393, 316, 395, 441, 441, 382, 441, 441, 441, + /* 2590 */ 386, 387, 388, 389, 390, 391, 392, 393, 441, 395, + /* 2600 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, + /* 2610 */ 344, 441, 441, 441, 441, 441, 441, 441, 352, 441, + /* 2620 */ 441, 441, 441, 357, 441, 359, 441, 441, 441, 441, + /* 2630 */ 441, 441, 441, 441, 441, 441, 441, 441, 441, 441, + /* 2640 */ 441, 441, 441, 441, 441, 441, 441, 441, 382, 441, + /* 2650 */ 441, 441, 386, 387, 388, 389, 390, 391, 392, 393, + /* 2660 */ 441, 395, }; -#define YY_SHIFT_COUNT (674) +#define YY_SHIFT_COUNT (678) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1957) +#define YY_SHIFT_MAX (2087) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1011, 0, 0, 207, 207, 264, 264, 264, 471, 471, - /* 10 */ 264, 264, 678, 735, 942, 735, 735, 735, 735, 735, - /* 20 */ 735, 735, 735, 735, 735, 735, 735, 735, 735, 735, - /* 30 */ 735, 735, 735, 735, 735, 735, 735, 735, 735, 735, - /* 40 */ 735, 735, 153, 153, 152, 152, 152, 792, 792, 154, - /* 50 */ 792, 792, 96, 397, 311, 428, 311, 156, 156, 269, - /* 60 */ 269, 551, 93, 311, 311, 156, 156, 156, 156, 156, - /* 70 */ 156, 156, 156, 156, 156, 136, 156, 156, 156, 204, - /* 80 */ 156, 156, 518, 156, 156, 518, 550, 156, 518, 518, - /* 90 */ 518, 156, 564, 467, 1030, 854, 854, 228, 527, 527, - /* 100 */ 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, - /* 110 */ 527, 527, 527, 527, 527, 527, 527, 424, 179, 93, - /* 120 */ 493, 493, 137, 372, 721, 485, 485, 485, 372, 621, - /* 130 */ 621, 204, 671, 671, 518, 518, 626, 626, 705, 770, - /* 140 */ 72, 72, 72, 72, 72, 72, 72, 535, 77, 565, - /* 150 */ 753, 131, 30, 304, 611, 614, 576, 879, 182, 824, - /* 160 */ 741, 255, 741, 958, 779, 779, 779, 276, 764, 984, - /* 170 */ 1172, 1047, 1181, 1204, 1204, 1181, 1075, 1075, 1204, 1204, - /* 180 */ 1204, 1222, 1222, 1224, 136, 204, 136, 1250, 1253, 136, - /* 190 */ 1250, 136, 136, 136, 1204, 136, 1222, 518, 518, 518, - /* 200 */ 518, 518, 518, 518, 518, 518, 518, 518, 1204, 1222, - /* 210 */ 626, 1224, 564, 1127, 204, 564, 1204, 1204, 1250, 564, - /* 220 */ 1097, 626, 626, 626, 626, 1097, 626, 1170, 564, 705, - /* 230 */ 564, 621, 1325, 626, 1110, 1097, 626, 626, 1110, 1097, - /* 240 */ 626, 626, 518, 1109, 1206, 1110, 1126, 1128, 1141, 984, - /* 250 */ 1147, 621, 1379, 1146, 1150, 1148, 1146, 1150, 1146, 1150, - /* 260 */ 1309, 1312, 626, 770, 1204, 564, 1376, 1222, 2512, 2512, - /* 270 */ 2512, 2512, 2512, 2512, 2512, 69, 941, 371, 260, 2, - /* 280 */ 222, 418, 434, 443, 624, 727, 983, 155, 155, 155, - /* 290 */ 155, 155, 155, 155, 155, 1009, 540, 12, 12, 370, - /* 300 */ 374, 529, 286, 257, 205, 253, 655, 486, 146, 146, - /* 310 */ 146, 146, 298, 36, 992, 804, 956, 987, 989, 1090, - /* 320 */ 1101, 1103, 1002, 930, 1004, 1022, 1024, 1070, 1072, 1077, - /* 330 */ 1078, 1093, 997, 411, 988, 1087, 1050, 1061, 976, 1088, - /* 340 */ 1082, 1095, 1096, 1118, 1119, 1120, 1122, 768, 1156, 1157, - /* 350 */ 1132, 43, 1443, 1448, 1269, 1449, 1452, 1417, 1461, 1427, - /* 360 */ 1271, 1429, 1430, 1431, 1275, 1468, 1434, 1437, 1281, 1480, - /* 370 */ 1291, 1484, 1450, 1486, 1465, 1488, 1454, 1314, 1317, 1493, - /* 380 */ 1494, 1327, 1326, 1501, 1502, 1457, 1504, 1505, 1506, 1466, - /* 390 */ 1509, 1510, 1511, 1362, 1516, 1518, 1519, 1530, 1532, 1374, - /* 400 */ 1498, 1523, 1387, 1536, 1540, 1547, 1550, 1552, 1553, 1554, - /* 410 */ 1558, 1559, 1560, 1561, 1563, 1565, 1566, 1525, 1568, 1570, - /* 420 */ 1571, 1572, 1573, 1574, 1555, 1575, 1576, 1578, 1588, 1589, - /* 430 */ 1524, 1581, 1526, 1583, 1584, 1543, 1551, 1556, 1586, 1557, - /* 440 */ 1590, 1562, 1609, 1546, 1577, 1611, 1613, 1614, 1579, 1451, - /* 450 */ 1619, 1621, 1623, 1564, 1624, 1625, 1593, 1582, 1594, 1627, - /* 460 */ 1596, 1585, 1595, 1636, 1602, 1591, 1608, 1648, 1620, 1610, - /* 470 */ 1622, 1662, 1663, 1664, 1665, 1567, 1597, 1632, 1637, 1660, - /* 480 */ 1633, 1635, 1629, 1631, 1640, 1641, 1655, 1678, 1657, 1680, - /* 490 */ 1661, 1639, 1681, 1667, 1647, 1684, 1650, 1686, 1656, 1692, - /* 500 */ 1671, 1674, 1695, 1537, 1675, 1698, 1528, 1687, 1549, 1569, - /* 510 */ 1712, 1713, 1604, 1606, 1714, 1715, 1716, 1626, 1628, 1682, - /* 520 */ 1533, 1721, 1630, 1587, 1634, 1724, 1690, 1599, 1642, 1643, - /* 530 */ 1679, 1689, 1503, 1644, 1646, 1645, 1649, 1654, 1666, 1691, - /* 540 */ 1658, 1683, 1694, 1696, 1677, 1699, 1704, 1707, 1697, 1711, - /* 550 */ 1539, 1701, 1702, 1722, 1500, 1729, 1727, 1731, 1703, 1745, - /* 560 */ 1601, 1706, 1720, 1757, 1758, 1763, 1767, 1768, 1706, 1802, - /* 570 */ 1783, 1612, 1764, 1718, 1723, 1725, 1728, 1726, 1732, 1760, - /* 580 */ 1730, 1746, 1769, 1787, 1616, 1747, 1710, 1744, 1778, 1786, - /* 590 */ 1748, 1749, 1807, 1752, 1753, 1811, 1755, 1766, 1817, 1770, - /* 600 */ 1771, 1818, 1773, 1750, 1751, 1754, 1756, 1842, 1779, 1776, - /* 610 */ 1793, 1837, 1794, 1833, 1833, 1866, 1827, 1829, 1856, 1858, - /* 620 */ 1859, 1860, 1861, 1862, 1863, 1864, 1867, 1868, 1845, 1810, - /* 630 */ 1871, 1880, 1881, 1895, 1883, 1897, 1886, 1887, 1888, 1857, - /* 640 */ 1629, 1889, 1631, 1891, 1892, 1894, 1896, 1908, 1899, 1932, - /* 650 */ 1901, 1890, 1900, 1941, 1907, 1898, 1904, 1944, 1912, 1902, - /* 660 */ 1909, 1950, 1917, 1910, 1915, 1955, 1924, 1926, 1956, 1946, - /* 670 */ 1949, 1951, 1952, 1954, 1957, + /* 0 */ 1068, 0, 57, 265, 57, 322, 322, 322, 530, 322, + /* 10 */ 322, 322, 322, 322, 587, 795, 852, 795, 795, 795, + /* 20 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, + /* 30 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, + /* 40 */ 795, 795, 795, 795, 16, 266, 39, 208, 269, 14, + /* 50 */ 59, 14, 39, 39, 1435, 1435, 14, 1435, 1435, 62, + /* 60 */ 14, 17, 17, 13, 13, 268, 17, 17, 17, 17, + /* 70 */ 17, 17, 17, 17, 17, 17, 68, 17, 17, 17, + /* 80 */ 171, 17, 17, 442, 17, 17, 442, 502, 17, 442, + /* 90 */ 442, 442, 17, 163, 998, 889, 889, 429, 524, 524, + /* 100 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, + /* 110 */ 524, 524, 524, 524, 524, 524, 524, 470, 621, 12, + /* 120 */ 268, 58, 58, 327, 328, 438, 101, 101, 9, 9, + /* 130 */ 9, 328, 574, 574, 171, 2, 2, 63, 442, 442, + /* 140 */ 381, 381, 233, 440, 196, 196, 196, 196, 196, 196, + /* 150 */ 196, 859, 402, 337, 34, 43, 552, 179, 427, 630, + /* 160 */ 232, 791, 804, 334, 753, 748, 497, 753, 922, 965, + /* 170 */ 828, 989, 1194, 1081, 1216, 1250, 1250, 1216, 1138, 1138, + /* 180 */ 1250, 1250, 1250, 1291, 1291, 1293, 68, 171, 68, 1309, + /* 190 */ 1314, 68, 1309, 68, 68, 68, 1250, 68, 1291, 442, + /* 200 */ 442, 442, 442, 442, 442, 442, 442, 442, 442, 442, + /* 210 */ 1250, 1291, 381, 1293, 163, 1206, 171, 163, 1250, 1250, + /* 220 */ 1309, 163, 1148, 381, 381, 381, 381, 1148, 381, 1236, + /* 230 */ 163, 233, 163, 574, 1393, 381, 1179, 1148, 381, 381, + /* 240 */ 1179, 1148, 381, 381, 442, 1202, 1288, 1179, 1208, 1204, + /* 250 */ 1215, 989, 1200, 1205, 1211, 1233, 574, 1452, 1380, 1386, + /* 260 */ 381, 440, 1250, 163, 1473, 1291, 2662, 2662, 2662, 2662, + /* 270 */ 2662, 2662, 2662, 1103, 529, 485, 1238, 234, 396, 479, + /* 280 */ 764, 825, 914, 718, 925, 925, 925, 925, 925, 925, + /* 290 */ 925, 925, 925, 1092, 488, 11, 11, 6, 205, 203, + /* 300 */ 584, 242, 637, 421, 699, 941, 729, 699, 699, 699, + /* 310 */ 928, 1032, 999, 944, 977, 988, 1007, 995, 1075, 1089, + /* 320 */ 805, 861, 1065, 1069, 1112, 1115, 1117, 1121, 1128, 1002, + /* 330 */ 1044, 513, 1127, 1155, 921, 1160, 1035, 1161, 1153, 1159, + /* 340 */ 1186, 1188, 1196, 1203, 1207, 1210, 843, 1197, 1213, 884, + /* 350 */ 1221, 1525, 1534, 1345, 1528, 1529, 1488, 1531, 1497, 1343, + /* 360 */ 1501, 1502, 1503, 1347, 1540, 1507, 1508, 1352, 1545, 1355, + /* 370 */ 1551, 1517, 1561, 1541, 1564, 1530, 1389, 1392, 1568, 1570, + /* 380 */ 1401, 1413, 1585, 1586, 1542, 1587, 1590, 1592, 1552, 1593, + /* 390 */ 1597, 1598, 1446, 1600, 1601, 1602, 1603, 1604, 1457, 1571, + /* 400 */ 1607, 1460, 1609, 1611, 1613, 1614, 1615, 1616, 1618, 1619, + /* 410 */ 1620, 1621, 1622, 1623, 1624, 1626, 1589, 1627, 1628, 1629, + /* 420 */ 1635, 1636, 1637, 1617, 1638, 1640, 1641, 1642, 1643, 1625, + /* 430 */ 1652, 1630, 1653, 1654, 1631, 1632, 1633, 1644, 1610, 1661, + /* 440 */ 1645, 1657, 1634, 1639, 1677, 1679, 1682, 1649, 1518, 1683, + /* 450 */ 1689, 1690, 1647, 1692, 1693, 1659, 1648, 1662, 1696, 1663, + /* 460 */ 1655, 1664, 1699, 1665, 1658, 1667, 1704, 1672, 1666, 1669, + /* 470 */ 1711, 1712, 1722, 1724, 1650, 1651, 1691, 1705, 1728, 1694, + /* 480 */ 1695, 1688, 1698, 1697, 1700, 1714, 1734, 1717, 1737, 1720, + /* 490 */ 1701, 1743, 1723, 1709, 1746, 1713, 1747, 1718, 1754, 1733, + /* 500 */ 1736, 1757, 1680, 1725, 1758, 1581, 1740, 1702, 1605, 1778, + /* 510 */ 1779, 1706, 1675, 1777, 1781, 1782, 1784, 1703, 1707, 1751, + /* 520 */ 1606, 1787, 1716, 1684, 1719, 1791, 1756, 1656, 1760, 1710, + /* 530 */ 1752, 1762, 1579, 1578, 1588, 1763, 1566, 1765, 1761, 1766, + /* 540 */ 1768, 1769, 1773, 1774, 1775, 1780, 1785, 1788, 1783, 1813, + /* 550 */ 1764, 1814, 1789, 1818, 1670, 1786, 1795, 1864, 1831, 1686, + /* 560 */ 1840, 1848, 1850, 1852, 1855, 1856, 1798, 1800, 1851, 1708, + /* 570 */ 1853, 1861, 1877, 1896, 1888, 1726, 1832, 1834, 1837, 1838, + /* 580 */ 1842, 1839, 1885, 1844, 1845, 1893, 1847, 1920, 1744, 1854, + /* 590 */ 1841, 1858, 1911, 1914, 1857, 1860, 1921, 1865, 1863, 1925, + /* 600 */ 1868, 1879, 1936, 1881, 1883, 1940, 1886, 1875, 1876, 1878, + /* 610 */ 1880, 1958, 1889, 1903, 1906, 1946, 1907, 1959, 1959, 1979, + /* 620 */ 1944, 1947, 1972, 1974, 1975, 1976, 1978, 1980, 1981, 1983, + /* 630 */ 1985, 1986, 1954, 1923, 1982, 1988, 1989, 2004, 1992, 2007, + /* 640 */ 1995, 2005, 2008, 1977, 1688, 2009, 1698, 2019, 2021, 2023, + /* 650 */ 2025, 2039, 2027, 2063, 2029, 2022, 2026, 2066, 2033, 2024, + /* 660 */ 2031, 2073, 2040, 2030, 2037, 2078, 2044, 2034, 2041, 2082, + /* 670 */ 2049, 2051, 2087, 2067, 2069, 2070, 2072, 2074, 2068, }; -#define YY_REDUCE_COUNT (274) -#define YY_REDUCE_MIN (-353) -#define YY_REDUCE_MAX (2122) +#define YY_REDUCE_COUNT (272) +#define YY_REDUCE_MIN (-395) +#define YY_REDUCE_MAX (2266) static const short yy_reduce_ofst[] = { - /* 0 */ 285, -311, -38, 148, 882, 935, 999, 1039, 412, 1092, - /* 10 */ 1142, 1159, -22, -261, 1209, 677, 1257, 1267, 1318, 1378, - /* 20 */ 1396, 1446, 975, 1472, 1496, 1522, 1580, 1598, 1659, 1709, - /* 30 */ 1719, 1759, 1809, 1821, 1835, 1911, 1921, 1972, 2022, 2032, - /* 40 */ 2072, 2122, -120, 1592, 249, 444, 579, -319, -289, -309, - /* 50 */ -323, -258, -117, 140, 142, 287, 329, -299, -42, -316, - /* 60 */ -312, -87, -346, 94, 103, 169, 413, 425, 431, 454, - /* 70 */ 458, 491, 492, 495, 511, 383, 578, 580, 582, -12, - /* 80 */ 583, 637, -37, 639, 692, -229, -115, 693, 243, 88, - /* 90 */ 244, 577, 387, -275, -353, -353, -353, -265, -14, 76, - /* 100 */ 308, 405, 416, 419, 447, 476, 498, 520, 522, 566, - /* 110 */ 605, 608, 610, 620, 623, 666, 667, 233, -6, -292, - /* 120 */ 7, 446, 377, 332, -51, 525, 612, 646, 449, 188, - /* 130 */ 379, 422, 488, 508, 40, 659, 568, 668, 718, 528, - /* 140 */ 516, 575, 619, 788, 827, 832, 835, 534, 864, 756, - /* 150 */ 776, 766, 865, 773, 853, 853, 874, 877, 845, 817, - /* 160 */ 795, 795, 795, 810, 781, 789, 793, 801, 853, 841, - /* 170 */ 846, 855, 866, 908, 909, 871, 875, 876, 916, 919, - /* 180 */ 920, 931, 932, 887, 924, 907, 939, 905, 912, 952, - /* 190 */ 910, 960, 961, 962, 969, 967, 968, 953, 954, 955, - /* 200 */ 957, 959, 963, 964, 965, 966, 970, 972, 978, 982, - /* 210 */ 948, 918, 980, 936, 971, 986, 994, 996, 973, 1003, - /* 220 */ 974, 981, 985, 990, 991, 993, 995, 1005, 1013, 1010, - /* 230 */ 1019, 1001, 1008, 1012, 949, 1006, 1014, 1015, 979, 1007, - /* 240 */ 1018, 1020, 853, 998, 1000, 1016, 977, 1017, 1023, 1025, - /* 250 */ 795, 1032, 1027, 1026, 1021, 1028, 1029, 1033, 1031, 1035, - /* 260 */ 1038, 1064, 1056, 1080, 1091, 1098, 1099, 1104, 1042, 1053, - /* 270 */ 1105, 1107, 1108, 1115, 1117, + /* 0 */ -268, 886, -249, -162, -306, 275, 968, 1028, 1050, -21, + /* 10 */ 368, 1106, 1167, 1189, 1273, 1328, 1381, 467, 1433, 1445, + /* 20 */ 1459, 1513, 1527, 1577, 1596, 1646, 1660, 1715, 1741, 1767, + /* 30 */ 1793, 1819, 1871, 1887, 1949, 1965, 2018, 2032, 2086, 2110, + /* 40 */ 2136, 2188, 2204, 2266, -11, 200, 237, 459, 544, 664, + /* 50 */ 879, 911, -131, 286, -341, -222, -387, -307, -201, -252, + /* 60 */ 777, -324, -321, -316, -260, -232, -233, 8, 83, 166, + /* 70 */ 243, 302, 317, 354, 547, 583, 229, 624, 625, 631, + /* 80 */ 77, 633, 638, -289, 691, 749, -175, -279, 758, 211, + /* 90 */ -4, 476, 872, 264, -227, -395, -395, -203, 32, 132, + /* 100 */ 261, 326, 395, 408, 453, 465, 468, 493, 536, 564, + /* 110 */ 601, 662, 676, 715, 721, 723, 726, -121, -133, 135, + /* 120 */ -211, -27, 92, 230, 223, 118, -235, 294, 135, 220, + /* 130 */ 369, 483, 356, 514, 510, 500, 505, 104, 377, 312, + /* 140 */ 60, 464, 607, 549, -326, -293, 204, 263, 283, 308, + /* 150 */ 522, 350, 567, 452, 563, 558, 799, 727, 704, 704, + /* 160 */ 832, 839, 844, 816, 808, 808, 782, 808, 817, 809, + /* 170 */ 704, 854, 865, 892, 896, 962, 963, 927, 936, 940, + /* 180 */ 982, 983, 984, 1000, 1001, 945, 996, 967, 1003, 961, + /* 190 */ 966, 1008, 964, 1010, 1012, 1015, 1021, 1020, 1031, 1009, + /* 200 */ 1018, 1023, 1025, 1027, 1029, 1033, 1034, 1037, 1038, 1039, + /* 210 */ 1040, 1047, 994, 974, 1053, 1011, 1017, 1063, 1066, 1067, + /* 220 */ 1022, 1070, 1030, 1041, 1042, 1043, 1046, 1045, 1048, 1036, + /* 230 */ 1078, 1071, 1080, 1056, 1061, 1072, 1004, 1058, 1074, 1076, + /* 240 */ 1026, 1059, 1094, 1095, 704, 1049, 1051, 1054, 1052, 1057, + /* 250 */ 1062, 1079, 1024, 1055, 1077, 808, 1119, 1100, 1082, 1142, + /* 260 */ 1143, 1168, 1180, 1181, 1195, 1198, 1140, 1147, 1182, 1183, + /* 270 */ 1184, 1191, 1209, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 10 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 30 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 40 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 50 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 60 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 70 */ 1481, 1481, 1481, 1481, 1481, 1555, 1481, 1481, 1481, 1481, - /* 80 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 90 */ 1481, 1481, 1553, 1718, 1481, 1893, 1481, 1481, 1481, 1481, - /* 100 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 110 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 120 */ 1481, 1481, 1555, 1481, 1553, 1905, 1905, 1905, 1481, 1481, - /* 130 */ 1481, 1481, 1759, 1759, 1481, 1481, 1481, 1481, 1658, 1481, - /* 140 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1753, 1481, 1974, - /* 150 */ 1481, 1481, 1481, 1928, 1481, 1481, 1481, 1481, 1611, 1920, - /* 160 */ 1897, 1911, 1898, 1895, 1959, 1959, 1959, 1914, 1481, 1924, - /* 170 */ 1481, 1746, 1723, 1481, 1481, 1723, 1720, 1720, 1481, 1481, - /* 180 */ 1481, 1481, 1481, 1481, 1555, 1481, 1555, 1481, 1481, 1555, - /* 190 */ 1481, 1555, 1555, 1555, 1481, 1555, 1481, 1481, 1481, 1481, - /* 200 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 210 */ 1481, 1481, 1553, 1755, 1481, 1553, 1481, 1481, 1481, 1553, - /* 220 */ 1933, 1481, 1481, 1481, 1481, 1933, 1481, 1481, 1553, 1481, - /* 230 */ 1553, 1481, 1481, 1481, 1935, 1933, 1481, 1481, 1935, 1933, - /* 240 */ 1481, 1481, 1481, 1947, 1943, 1935, 1951, 1949, 1926, 1924, - /* 250 */ 1911, 1481, 1481, 1965, 1961, 1977, 1965, 1961, 1965, 1961, - /* 260 */ 1481, 1627, 1481, 1481, 1481, 1553, 1513, 1481, 1748, 1759, - /* 270 */ 1661, 1661, 1661, 1556, 1486, 1481, 1481, 1481, 1481, 1481, - /* 280 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1830, 1946, 1945, - /* 290 */ 1869, 1868, 1867, 1865, 1829, 1481, 1623, 1828, 1827, 1481, - /* 300 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1821, 1822, - /* 310 */ 1820, 1819, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 320 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 330 */ 1481, 1894, 1481, 1962, 1966, 1481, 1481, 1481, 1481, 1481, - /* 340 */ 1805, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 350 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 360 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 370 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 380 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 390 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 400 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 410 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 420 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 430 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1518, 1481, 1481, - /* 440 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 450 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 460 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 470 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 480 */ 1481, 1481, 1594, 1593, 1481, 1481, 1481, 1481, 1481, 1481, - /* 490 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 500 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 510 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 520 */ 1481, 1763, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 530 */ 1481, 1927, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 540 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1805, 1481, 1944, - /* 550 */ 1481, 1904, 1900, 1481, 1481, 1896, 1804, 1481, 1481, 1960, - /* 560 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1889, - /* 570 */ 1481, 1481, 1862, 1847, 1481, 1481, 1481, 1481, 1481, 1481, - /* 580 */ 1481, 1481, 1481, 1481, 1815, 1481, 1481, 1481, 1481, 1481, - /* 590 */ 1655, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 600 */ 1481, 1481, 1481, 1640, 1638, 1637, 1636, 1481, 1633, 1481, - /* 610 */ 1481, 1481, 1481, 1664, 1663, 1481, 1481, 1481, 1481, 1481, - /* 620 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 630 */ 1575, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 640 */ 1566, 1481, 1565, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 650 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 660 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 670 */ 1481, 1481, 1481, 1481, 1481, + /* 0 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 10 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 20 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 30 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 40 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 50 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 60 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 70 */ 1509, 1509, 1509, 1509, 1509, 1509, 1583, 1509, 1509, 1509, + /* 80 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 90 */ 1509, 1509, 1509, 1581, 1746, 1930, 1509, 1509, 1509, 1509, + /* 100 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 110 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1942, + /* 120 */ 1509, 1509, 1509, 1583, 1509, 1581, 1902, 1902, 1942, 1942, + /* 130 */ 1942, 1509, 1509, 1509, 1509, 1787, 1787, 1509, 1509, 1509, + /* 140 */ 1509, 1509, 1686, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 150 */ 1509, 1781, 1509, 2015, 1509, 1509, 1509, 1965, 1509, 1509, + /* 160 */ 1509, 1509, 1639, 1957, 1934, 1948, 1999, 1935, 1932, 1951, + /* 170 */ 1509, 1961, 1509, 1774, 1751, 1509, 1509, 1751, 1748, 1748, + /* 180 */ 1509, 1509, 1509, 1509, 1509, 1509, 1583, 1509, 1583, 1509, + /* 190 */ 1509, 1583, 1509, 1583, 1583, 1583, 1509, 1583, 1509, 1509, + /* 200 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 210 */ 1509, 1509, 1509, 1509, 1581, 1783, 1509, 1581, 1509, 1509, + /* 220 */ 1509, 1581, 1970, 1509, 1509, 1509, 1509, 1970, 1509, 1509, + /* 230 */ 1581, 1509, 1581, 1509, 1509, 1509, 1972, 1970, 1509, 1509, + /* 240 */ 1972, 1970, 1509, 1509, 1509, 1984, 1980, 1972, 1988, 1986, + /* 250 */ 1963, 1961, 2018, 2005, 2001, 1948, 1509, 1509, 1509, 1655, + /* 260 */ 1509, 1509, 1509, 1581, 1541, 1509, 1776, 1787, 1689, 1689, + /* 270 */ 1689, 1584, 1514, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 280 */ 1509, 1509, 1509, 1509, 1860, 1509, 1983, 1982, 1906, 1905, + /* 290 */ 1904, 1895, 1859, 1509, 1651, 1858, 1857, 1509, 1509, 1509, + /* 300 */ 1509, 1509, 1509, 1509, 1851, 1509, 1509, 1852, 1850, 1849, + /* 310 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 320 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 330 */ 2002, 2006, 1931, 1509, 1509, 1509, 1509, 1509, 1842, 1833, + /* 340 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 350 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 360 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 370 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 380 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 390 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 400 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 410 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 420 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 430 */ 1509, 1509, 1509, 1509, 1509, 1509, 1546, 1509, 1509, 1509, + /* 440 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 450 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 460 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 470 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 480 */ 1509, 1622, 1621, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 490 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 500 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 510 */ 1509, 1509, 1509, 1998, 1509, 1509, 1509, 1509, 1509, 1509, + /* 520 */ 1509, 1791, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 530 */ 1509, 1892, 1509, 1509, 1509, 1964, 1509, 1509, 1509, 1509, + /* 540 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 550 */ 1509, 1833, 1509, 1981, 1509, 1509, 1996, 1509, 2000, 1509, + /* 560 */ 1509, 1509, 1509, 1509, 1509, 1509, 1941, 1937, 1509, 1509, + /* 570 */ 1933, 1832, 1509, 1926, 1509, 1509, 1877, 1509, 1509, 1509, + /* 580 */ 1509, 1509, 1509, 1509, 1509, 1509, 1841, 1509, 1845, 1509, + /* 590 */ 1509, 1509, 1509, 1509, 1683, 1509, 1509, 1509, 1509, 1509, + /* 600 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1668, 1666, 1665, + /* 610 */ 1664, 1509, 1661, 1509, 1509, 1509, 1509, 1692, 1691, 1509, + /* 620 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 630 */ 1509, 1509, 1509, 1509, 1603, 1509, 1509, 1509, 1509, 1509, + /* 640 */ 1509, 1509, 1509, 1509, 1594, 1509, 1593, 1509, 1509, 1509, + /* 650 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 660 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, + /* 670 */ 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1509, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1138,6 +1168,11 @@ static const YYCODETYPE yyFallback[] = { 0, /* CURRENT_USER => nothing */ 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ + 0, /* CASE => nothing */ + 261, /* END => ABORT */ + 0, /* WHEN => nothing */ + 0, /* THEN => nothing */ + 0, /* ELSE => nothing */ 0, /* BETWEEN => nothing */ 0, /* IS => nothing */ 0, /* NK_LT => nothing */ @@ -1176,58 +1211,57 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 256, /* AFTER => ABORT */ - 256, /* ATTACH => ABORT */ - 256, /* BEFORE => ABORT */ - 256, /* BEGIN => ABORT */ - 256, /* BITAND => ABORT */ - 256, /* BITNOT => ABORT */ - 256, /* BITOR => ABORT */ - 256, /* BLOCKS => ABORT */ - 256, /* CHANGE => ABORT */ - 256, /* COMMA => ABORT */ - 256, /* COMPACT => ABORT */ - 256, /* CONCAT => ABORT */ - 256, /* CONFLICT => ABORT */ - 256, /* COPY => ABORT */ - 256, /* DEFERRED => ABORT */ - 256, /* DELIMITERS => ABORT */ - 256, /* DETACH => ABORT */ - 256, /* DIVIDE => ABORT */ - 256, /* DOT => ABORT */ - 256, /* EACH => ABORT */ - 256, /* END => ABORT */ - 256, /* FAIL => ABORT */ - 256, /* FILE => ABORT */ - 256, /* FOR => ABORT */ - 256, /* GLOB => ABORT */ - 256, /* ID => ABORT */ - 256, /* IMMEDIATE => ABORT */ - 256, /* IMPORT => ABORT */ - 256, /* INITIALLY => ABORT */ - 256, /* INSTEAD => ABORT */ - 256, /* ISNULL => ABORT */ - 256, /* KEY => ABORT */ - 256, /* NK_BITNOT => ABORT */ - 256, /* NK_SEMI => ABORT */ - 256, /* NOTNULL => ABORT */ - 256, /* OF => ABORT */ - 256, /* PLUS => ABORT */ - 256, /* PRIVILEGE => ABORT */ - 256, /* RAISE => ABORT */ - 256, /* REPLACE => ABORT */ - 256, /* RESTRICT => ABORT */ - 256, /* ROW => ABORT */ - 256, /* SEMI => ABORT */ - 256, /* STAR => ABORT */ - 256, /* STATEMENT => ABORT */ - 256, /* STRING => ABORT */ - 256, /* TIMES => ABORT */ - 256, /* UPDATE => ABORT */ - 256, /* VALUES => ABORT */ - 256, /* VARIABLE => ABORT */ - 256, /* VIEW => ABORT */ - 256, /* WAL => ABORT */ + 261, /* AFTER => ABORT */ + 261, /* ATTACH => ABORT */ + 261, /* BEFORE => ABORT */ + 261, /* BEGIN => ABORT */ + 261, /* BITAND => ABORT */ + 261, /* BITNOT => ABORT */ + 261, /* BITOR => ABORT */ + 261, /* BLOCKS => ABORT */ + 261, /* CHANGE => ABORT */ + 261, /* COMMA => ABORT */ + 261, /* COMPACT => ABORT */ + 261, /* CONCAT => ABORT */ + 261, /* CONFLICT => ABORT */ + 261, /* COPY => ABORT */ + 261, /* DEFERRED => ABORT */ + 261, /* DELIMITERS => ABORT */ + 261, /* DETACH => ABORT */ + 261, /* DIVIDE => ABORT */ + 261, /* DOT => ABORT */ + 261, /* EACH => ABORT */ + 261, /* FAIL => ABORT */ + 261, /* FILE => ABORT */ + 261, /* FOR => ABORT */ + 261, /* GLOB => ABORT */ + 261, /* ID => ABORT */ + 261, /* IMMEDIATE => ABORT */ + 261, /* IMPORT => ABORT */ + 261, /* INITIALLY => ABORT */ + 261, /* INSTEAD => ABORT */ + 261, /* ISNULL => ABORT */ + 261, /* KEY => ABORT */ + 261, /* NK_BITNOT => ABORT */ + 261, /* NK_SEMI => ABORT */ + 261, /* NOTNULL => ABORT */ + 261, /* OF => ABORT */ + 261, /* PLUS => ABORT */ + 261, /* PRIVILEGE => ABORT */ + 261, /* RAISE => ABORT */ + 261, /* REPLACE => ABORT */ + 261, /* RESTRICT => ABORT */ + 261, /* ROW => ABORT */ + 261, /* SEMI => ABORT */ + 261, /* STAR => ABORT */ + 261, /* STATEMENT => ABORT */ + 261, /* STRING => ABORT */ + 261, /* TIMES => ABORT */ + 261, /* UPDATE => ABORT */ + 261, /* VALUES => ABORT */ + 261, /* VARIABLE => ABORT */ + 261, /* VIEW => ABORT */ + 261, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1534,217 +1568,228 @@ static const char *const yyTokenName[] = { /* 216 */ "CURRENT_USER", /* 217 */ "COUNT", /* 218 */ "LAST_ROW", - /* 219 */ "BETWEEN", - /* 220 */ "IS", - /* 221 */ "NK_LT", - /* 222 */ "NK_GT", - /* 223 */ "NK_LE", - /* 224 */ "NK_GE", - /* 225 */ "NK_NE", - /* 226 */ "MATCH", - /* 227 */ "NMATCH", - /* 228 */ "CONTAINS", - /* 229 */ "IN", - /* 230 */ "JOIN", - /* 231 */ "INNER", - /* 232 */ "SELECT", - /* 233 */ "DISTINCT", - /* 234 */ "WHERE", - /* 235 */ "PARTITION", - /* 236 */ "BY", - /* 237 */ "SESSION", - /* 238 */ "STATE_WINDOW", - /* 239 */ "SLIDING", - /* 240 */ "FILL", - /* 241 */ "VALUE", - /* 242 */ "NONE", - /* 243 */ "PREV", - /* 244 */ "LINEAR", - /* 245 */ "NEXT", - /* 246 */ "HAVING", - /* 247 */ "RANGE", - /* 248 */ "EVERY", - /* 249 */ "ORDER", - /* 250 */ "SLIMIT", - /* 251 */ "SOFFSET", - /* 252 */ "LIMIT", - /* 253 */ "OFFSET", - /* 254 */ "ASC", - /* 255 */ "NULLS", - /* 256 */ "ABORT", - /* 257 */ "AFTER", - /* 258 */ "ATTACH", - /* 259 */ "BEFORE", - /* 260 */ "BEGIN", - /* 261 */ "BITAND", - /* 262 */ "BITNOT", - /* 263 */ "BITOR", - /* 264 */ "BLOCKS", - /* 265 */ "CHANGE", - /* 266 */ "COMMA", - /* 267 */ "COMPACT", - /* 268 */ "CONCAT", - /* 269 */ "CONFLICT", - /* 270 */ "COPY", - /* 271 */ "DEFERRED", - /* 272 */ "DELIMITERS", - /* 273 */ "DETACH", - /* 274 */ "DIVIDE", - /* 275 */ "DOT", - /* 276 */ "EACH", - /* 277 */ "END", - /* 278 */ "FAIL", - /* 279 */ "FILE", - /* 280 */ "FOR", - /* 281 */ "GLOB", - /* 282 */ "ID", - /* 283 */ "IMMEDIATE", - /* 284 */ "IMPORT", - /* 285 */ "INITIALLY", - /* 286 */ "INSTEAD", - /* 287 */ "ISNULL", - /* 288 */ "KEY", - /* 289 */ "NK_BITNOT", - /* 290 */ "NK_SEMI", - /* 291 */ "NOTNULL", - /* 292 */ "OF", - /* 293 */ "PLUS", - /* 294 */ "PRIVILEGE", - /* 295 */ "RAISE", - /* 296 */ "REPLACE", - /* 297 */ "RESTRICT", - /* 298 */ "ROW", - /* 299 */ "SEMI", - /* 300 */ "STAR", - /* 301 */ "STATEMENT", - /* 302 */ "STRING", - /* 303 */ "TIMES", - /* 304 */ "UPDATE", - /* 305 */ "VALUES", - /* 306 */ "VARIABLE", - /* 307 */ "VIEW", - /* 308 */ "WAL", - /* 309 */ "cmd", - /* 310 */ "account_options", - /* 311 */ "alter_account_options", - /* 312 */ "literal", - /* 313 */ "alter_account_option", - /* 314 */ "user_name", - /* 315 */ "sysinfo_opt", - /* 316 */ "privileges", - /* 317 */ "priv_level", - /* 318 */ "priv_type_list", - /* 319 */ "priv_type", - /* 320 */ "db_name", - /* 321 */ "dnode_endpoint", - /* 322 */ "not_exists_opt", - /* 323 */ "db_options", - /* 324 */ "exists_opt", - /* 325 */ "alter_db_options", - /* 326 */ "integer_list", - /* 327 */ "variable_list", - /* 328 */ "retention_list", - /* 329 */ "alter_db_option", - /* 330 */ "retention", - /* 331 */ "full_table_name", - /* 332 */ "column_def_list", - /* 333 */ "tags_def_opt", - /* 334 */ "table_options", - /* 335 */ "multi_create_clause", - /* 336 */ "tags_def", - /* 337 */ "multi_drop_clause", - /* 338 */ "alter_table_clause", - /* 339 */ "alter_table_options", - /* 340 */ "column_name", - /* 341 */ "type_name", - /* 342 */ "signed_literal", - /* 343 */ "create_subtable_clause", - /* 344 */ "specific_cols_opt", - /* 345 */ "expression_list", - /* 346 */ "drop_table_clause", - /* 347 */ "col_name_list", - /* 348 */ "table_name", - /* 349 */ "column_def", - /* 350 */ "duration_list", - /* 351 */ "rollup_func_list", - /* 352 */ "alter_table_option", - /* 353 */ "duration_literal", - /* 354 */ "rollup_func_name", - /* 355 */ "function_name", - /* 356 */ "col_name", - /* 357 */ "db_name_cond_opt", - /* 358 */ "like_pattern_opt", - /* 359 */ "table_name_cond", - /* 360 */ "from_db_opt", - /* 361 */ "index_options", - /* 362 */ "func_list", - /* 363 */ "sliding_opt", - /* 364 */ "sma_stream_opt", - /* 365 */ "func", - /* 366 */ "stream_options", - /* 367 */ "topic_name", - /* 368 */ "query_expression", - /* 369 */ "cgroup_name", - /* 370 */ "analyze_opt", - /* 371 */ "explain_options", - /* 372 */ "agg_func_opt", - /* 373 */ "bufsize_opt", - /* 374 */ "stream_name", - /* 375 */ "dnode_list", - /* 376 */ "where_clause_opt", - /* 377 */ "signed", - /* 378 */ "literal_func", - /* 379 */ "literal_list", - /* 380 */ "table_alias", - /* 381 */ "column_alias", - /* 382 */ "expression", - /* 383 */ "pseudo_column", - /* 384 */ "column_reference", - /* 385 */ "function_expression", - /* 386 */ "subquery", - /* 387 */ "star_func", - /* 388 */ "star_func_para_list", - /* 389 */ "noarg_func", - /* 390 */ "other_para_list", - /* 391 */ "star_func_para", - /* 392 */ "predicate", - /* 393 */ "compare_op", - /* 394 */ "in_op", - /* 395 */ "in_predicate_value", - /* 396 */ "boolean_value_expression", - /* 397 */ "boolean_primary", - /* 398 */ "common_expression", - /* 399 */ "from_clause_opt", - /* 400 */ "table_reference_list", - /* 401 */ "table_reference", - /* 402 */ "table_primary", - /* 403 */ "joined_table", - /* 404 */ "alias_opt", - /* 405 */ "parenthesized_joined_table", - /* 406 */ "join_type", - /* 407 */ "search_condition", - /* 408 */ "query_specification", - /* 409 */ "set_quantifier_opt", - /* 410 */ "select_list", - /* 411 */ "partition_by_clause_opt", - /* 412 */ "range_opt", - /* 413 */ "every_opt", - /* 414 */ "fill_opt", - /* 415 */ "twindow_clause_opt", - /* 416 */ "group_by_clause_opt", - /* 417 */ "having_clause_opt", - /* 418 */ "select_item", - /* 419 */ "fill_mode", - /* 420 */ "group_by_list", - /* 421 */ "query_expression_body", - /* 422 */ "order_by_clause_opt", - /* 423 */ "slimit_clause_opt", - /* 424 */ "limit_clause_opt", - /* 425 */ "query_primary", - /* 426 */ "sort_specification_list", - /* 427 */ "sort_specification", - /* 428 */ "ordering_specification_opt", - /* 429 */ "null_ordering_opt", + /* 219 */ "CASE", + /* 220 */ "END", + /* 221 */ "WHEN", + /* 222 */ "THEN", + /* 223 */ "ELSE", + /* 224 */ "BETWEEN", + /* 225 */ "IS", + /* 226 */ "NK_LT", + /* 227 */ "NK_GT", + /* 228 */ "NK_LE", + /* 229 */ "NK_GE", + /* 230 */ "NK_NE", + /* 231 */ "MATCH", + /* 232 */ "NMATCH", + /* 233 */ "CONTAINS", + /* 234 */ "IN", + /* 235 */ "JOIN", + /* 236 */ "INNER", + /* 237 */ "SELECT", + /* 238 */ "DISTINCT", + /* 239 */ "WHERE", + /* 240 */ "PARTITION", + /* 241 */ "BY", + /* 242 */ "SESSION", + /* 243 */ "STATE_WINDOW", + /* 244 */ "SLIDING", + /* 245 */ "FILL", + /* 246 */ "VALUE", + /* 247 */ "NONE", + /* 248 */ "PREV", + /* 249 */ "LINEAR", + /* 250 */ "NEXT", + /* 251 */ "HAVING", + /* 252 */ "RANGE", + /* 253 */ "EVERY", + /* 254 */ "ORDER", + /* 255 */ "SLIMIT", + /* 256 */ "SOFFSET", + /* 257 */ "LIMIT", + /* 258 */ "OFFSET", + /* 259 */ "ASC", + /* 260 */ "NULLS", + /* 261 */ "ABORT", + /* 262 */ "AFTER", + /* 263 */ "ATTACH", + /* 264 */ "BEFORE", + /* 265 */ "BEGIN", + /* 266 */ "BITAND", + /* 267 */ "BITNOT", + /* 268 */ "BITOR", + /* 269 */ "BLOCKS", + /* 270 */ "CHANGE", + /* 271 */ "COMMA", + /* 272 */ "COMPACT", + /* 273 */ "CONCAT", + /* 274 */ "CONFLICT", + /* 275 */ "COPY", + /* 276 */ "DEFERRED", + /* 277 */ "DELIMITERS", + /* 278 */ "DETACH", + /* 279 */ "DIVIDE", + /* 280 */ "DOT", + /* 281 */ "EACH", + /* 282 */ "FAIL", + /* 283 */ "FILE", + /* 284 */ "FOR", + /* 285 */ "GLOB", + /* 286 */ "ID", + /* 287 */ "IMMEDIATE", + /* 288 */ "IMPORT", + /* 289 */ "INITIALLY", + /* 290 */ "INSTEAD", + /* 291 */ "ISNULL", + /* 292 */ "KEY", + /* 293 */ "NK_BITNOT", + /* 294 */ "NK_SEMI", + /* 295 */ "NOTNULL", + /* 296 */ "OF", + /* 297 */ "PLUS", + /* 298 */ "PRIVILEGE", + /* 299 */ "RAISE", + /* 300 */ "REPLACE", + /* 301 */ "RESTRICT", + /* 302 */ "ROW", + /* 303 */ "SEMI", + /* 304 */ "STAR", + /* 305 */ "STATEMENT", + /* 306 */ "STRING", + /* 307 */ "TIMES", + /* 308 */ "UPDATE", + /* 309 */ "VALUES", + /* 310 */ "VARIABLE", + /* 311 */ "VIEW", + /* 312 */ "WAL", + /* 313 */ "cmd", + /* 314 */ "account_options", + /* 315 */ "alter_account_options", + /* 316 */ "literal", + /* 317 */ "alter_account_option", + /* 318 */ "user_name", + /* 319 */ "sysinfo_opt", + /* 320 */ "privileges", + /* 321 */ "priv_level", + /* 322 */ "priv_type_list", + /* 323 */ "priv_type", + /* 324 */ "db_name", + /* 325 */ "dnode_endpoint", + /* 326 */ "not_exists_opt", + /* 327 */ "db_options", + /* 328 */ "exists_opt", + /* 329 */ "alter_db_options", + /* 330 */ "integer_list", + /* 331 */ "variable_list", + /* 332 */ "retention_list", + /* 333 */ "alter_db_option", + /* 334 */ "retention", + /* 335 */ "full_table_name", + /* 336 */ "column_def_list", + /* 337 */ "tags_def_opt", + /* 338 */ "table_options", + /* 339 */ "multi_create_clause", + /* 340 */ "tags_def", + /* 341 */ "multi_drop_clause", + /* 342 */ "alter_table_clause", + /* 343 */ "alter_table_options", + /* 344 */ "column_name", + /* 345 */ "type_name", + /* 346 */ "signed_literal", + /* 347 */ "create_subtable_clause", + /* 348 */ "specific_cols_opt", + /* 349 */ "expression_list", + /* 350 */ "drop_table_clause", + /* 351 */ "col_name_list", + /* 352 */ "table_name", + /* 353 */ "column_def", + /* 354 */ "duration_list", + /* 355 */ "rollup_func_list", + /* 356 */ "alter_table_option", + /* 357 */ "duration_literal", + /* 358 */ "rollup_func_name", + /* 359 */ "function_name", + /* 360 */ "col_name", + /* 361 */ "db_name_cond_opt", + /* 362 */ "like_pattern_opt", + /* 363 */ "table_name_cond", + /* 364 */ "from_db_opt", + /* 365 */ "index_options", + /* 366 */ "func_list", + /* 367 */ "sliding_opt", + /* 368 */ "sma_stream_opt", + /* 369 */ "func", + /* 370 */ "stream_options", + /* 371 */ "topic_name", + /* 372 */ "query_or_subquery", + /* 373 */ "cgroup_name", + /* 374 */ "analyze_opt", + /* 375 */ "explain_options", + /* 376 */ "agg_func_opt", + /* 377 */ "bufsize_opt", + /* 378 */ "stream_name", + /* 379 */ "dnode_list", + /* 380 */ "where_clause_opt", + /* 381 */ "signed", + /* 382 */ "literal_func", + /* 383 */ "literal_list", + /* 384 */ "table_alias", + /* 385 */ "column_alias", + /* 386 */ "expr_or_subquery", + /* 387 */ "expression", + /* 388 */ "subquery", + /* 389 */ "pseudo_column", + /* 390 */ "column_reference", + /* 391 */ "function_expression", + /* 392 */ "case_when_expression", + /* 393 */ "star_func", + /* 394 */ "star_func_para_list", + /* 395 */ "noarg_func", + /* 396 */ "other_para_list", + /* 397 */ "star_func_para", + /* 398 */ "when_then_list", + /* 399 */ "case_when_else_opt", + /* 400 */ "common_expression", + /* 401 */ "when_then_expr", + /* 402 */ "predicate", + /* 403 */ "compare_op", + /* 404 */ "in_op", + /* 405 */ "in_predicate_value", + /* 406 */ "boolean_value_expression", + /* 407 */ "boolean_primary", + /* 408 */ "from_clause_opt", + /* 409 */ "table_reference_list", + /* 410 */ "table_reference", + /* 411 */ "table_primary", + /* 412 */ "joined_table", + /* 413 */ "alias_opt", + /* 414 */ "parenthesized_joined_table", + /* 415 */ "join_type", + /* 416 */ "search_condition", + /* 417 */ "query_specification", + /* 418 */ "set_quantifier_opt", + /* 419 */ "select_list", + /* 420 */ "partition_by_clause_opt", + /* 421 */ "range_opt", + /* 422 */ "every_opt", + /* 423 */ "fill_opt", + /* 424 */ "twindow_clause_opt", + /* 425 */ "group_by_clause_opt", + /* 426 */ "having_clause_opt", + /* 427 */ "select_item", + /* 428 */ "fill_mode", + /* 429 */ "group_by_list", + /* 430 */ "query_expression", + /* 431 */ "query_simple", + /* 432 */ "order_by_clause_opt", + /* 433 */ "slimit_clause_opt", + /* 434 */ "limit_clause_opt", + /* 435 */ "union_query_expression", + /* 436 */ "query_simple_or_subquery", + /* 437 */ "sort_specification_list", + /* 438 */ "sort_specification", + /* 439 */ "ordering_specification_opt", + /* 440 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2003,7 +2048,7 @@ static const char *const yyRuleName[] = { /* 248 */ "sma_stream_opt ::=", /* 249 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", /* 250 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", /* 252 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", /* 253 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", /* 254 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", @@ -2013,7 +2058,7 @@ static const char *const yyRuleName[] = { /* 258 */ "cmd ::= DESC full_table_name", /* 259 */ "cmd ::= DESCRIBE full_table_name", /* 260 */ "cmd ::= RESET QUERY CACHE", - /* 261 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 261 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", /* 262 */ "analyze_opt ::=", /* 263 */ "analyze_opt ::= ANALYZE", /* 264 */ "explain_options ::=", @@ -2025,7 +2070,7 @@ static const char *const yyRuleName[] = { /* 270 */ "agg_func_opt ::= AGGREGATE", /* 271 */ "bufsize_opt ::=", /* 272 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 273 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression", + /* 273 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery", /* 274 */ "cmd ::= DROP STREAM exists_opt stream_name", /* 275 */ "stream_options ::=", /* 276 */ "stream_options ::= stream_options TRIGGER AT_ONCE", @@ -2043,9 +2088,9 @@ static const char *const yyRuleName[] = { /* 288 */ "dnode_list ::= DNODE NK_INTEGER", /* 289 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", /* 290 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 291 */ "cmd ::= query_expression", - /* 292 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression", - /* 293 */ "cmd ::= INSERT INTO full_table_name query_expression", + /* 291 */ "cmd ::= query_or_subquery", + /* 292 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 293 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", /* 294 */ "literal ::= NK_INTEGER", /* 295 */ "literal ::= NK_FLOAT", /* 296 */ "literal ::= NK_STRING", @@ -2081,173 +2126,186 @@ static const char *const yyRuleName[] = { /* 326 */ "topic_name ::= NK_ID", /* 327 */ "stream_name ::= NK_ID", /* 328 */ "cgroup_name ::= NK_ID", - /* 329 */ "expression ::= literal", - /* 330 */ "expression ::= pseudo_column", - /* 331 */ "expression ::= column_reference", - /* 332 */ "expression ::= function_expression", - /* 333 */ "expression ::= subquery", - /* 334 */ "expression ::= NK_LP expression NK_RP", - /* 335 */ "expression ::= NK_PLUS expression", - /* 336 */ "expression ::= NK_MINUS expression", - /* 337 */ "expression ::= expression NK_PLUS expression", - /* 338 */ "expression ::= expression NK_MINUS expression", - /* 339 */ "expression ::= expression NK_STAR expression", - /* 340 */ "expression ::= expression NK_SLASH expression", - /* 341 */ "expression ::= expression NK_REM expression", - /* 342 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 343 */ "expression ::= expression NK_BITAND expression", - /* 344 */ "expression ::= expression NK_BITOR expression", - /* 345 */ "expression_list ::= expression", - /* 346 */ "expression_list ::= expression_list NK_COMMA expression", - /* 347 */ "column_reference ::= column_name", - /* 348 */ "column_reference ::= table_name NK_DOT column_name", - /* 349 */ "pseudo_column ::= ROWTS", - /* 350 */ "pseudo_column ::= TBNAME", - /* 351 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 352 */ "pseudo_column ::= QSTART", - /* 353 */ "pseudo_column ::= QEND", - /* 354 */ "pseudo_column ::= QDURATION", - /* 355 */ "pseudo_column ::= WSTART", - /* 356 */ "pseudo_column ::= WEND", - /* 357 */ "pseudo_column ::= WDURATION", - /* 358 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 359 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 360 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 361 */ "function_expression ::= literal_func", - /* 362 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 363 */ "literal_func ::= NOW", - /* 364 */ "noarg_func ::= NOW", - /* 365 */ "noarg_func ::= TODAY", - /* 366 */ "noarg_func ::= TIMEZONE", - /* 367 */ "noarg_func ::= DATABASE", - /* 368 */ "noarg_func ::= CLIENT_VERSION", - /* 369 */ "noarg_func ::= SERVER_VERSION", - /* 370 */ "noarg_func ::= SERVER_STATUS", - /* 371 */ "noarg_func ::= CURRENT_USER", - /* 372 */ "noarg_func ::= USER", - /* 373 */ "star_func ::= COUNT", - /* 374 */ "star_func ::= FIRST", - /* 375 */ "star_func ::= LAST", - /* 376 */ "star_func ::= LAST_ROW", - /* 377 */ "star_func_para_list ::= NK_STAR", - /* 378 */ "star_func_para_list ::= other_para_list", - /* 379 */ "other_para_list ::= star_func_para", - /* 380 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 381 */ "star_func_para ::= expression", - /* 382 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 383 */ "predicate ::= expression compare_op expression", - /* 384 */ "predicate ::= expression BETWEEN expression AND expression", - /* 385 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 386 */ "predicate ::= expression IS NULL", - /* 387 */ "predicate ::= expression IS NOT NULL", - /* 388 */ "predicate ::= expression in_op in_predicate_value", - /* 389 */ "compare_op ::= NK_LT", - /* 390 */ "compare_op ::= NK_GT", - /* 391 */ "compare_op ::= NK_LE", - /* 392 */ "compare_op ::= NK_GE", - /* 393 */ "compare_op ::= NK_NE", - /* 394 */ "compare_op ::= NK_EQ", - /* 395 */ "compare_op ::= LIKE", - /* 396 */ "compare_op ::= NOT LIKE", - /* 397 */ "compare_op ::= MATCH", - /* 398 */ "compare_op ::= NMATCH", - /* 399 */ "compare_op ::= CONTAINS", - /* 400 */ "in_op ::= IN", - /* 401 */ "in_op ::= NOT IN", - /* 402 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 403 */ "boolean_value_expression ::= boolean_primary", - /* 404 */ "boolean_value_expression ::= NOT boolean_primary", - /* 405 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 406 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 407 */ "boolean_primary ::= predicate", - /* 408 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 409 */ "common_expression ::= expression", - /* 410 */ "common_expression ::= boolean_value_expression", - /* 411 */ "from_clause_opt ::=", - /* 412 */ "from_clause_opt ::= FROM table_reference_list", - /* 413 */ "table_reference_list ::= table_reference", - /* 414 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 415 */ "table_reference ::= table_primary", - /* 416 */ "table_reference ::= joined_table", - /* 417 */ "table_primary ::= table_name alias_opt", - /* 418 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 419 */ "table_primary ::= subquery alias_opt", - /* 420 */ "table_primary ::= parenthesized_joined_table", - /* 421 */ "alias_opt ::=", - /* 422 */ "alias_opt ::= table_alias", - /* 423 */ "alias_opt ::= AS table_alias", - /* 424 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 425 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 426 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 427 */ "join_type ::=", - /* 428 */ "join_type ::= INNER", - /* 429 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 430 */ "set_quantifier_opt ::=", - /* 431 */ "set_quantifier_opt ::= DISTINCT", - /* 432 */ "set_quantifier_opt ::= ALL", - /* 433 */ "select_list ::= select_item", - /* 434 */ "select_list ::= select_list NK_COMMA select_item", - /* 435 */ "select_item ::= NK_STAR", - /* 436 */ "select_item ::= common_expression", - /* 437 */ "select_item ::= common_expression column_alias", - /* 438 */ "select_item ::= common_expression AS column_alias", - /* 439 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 440 */ "where_clause_opt ::=", - /* 441 */ "where_clause_opt ::= WHERE search_condition", - /* 442 */ "partition_by_clause_opt ::=", - /* 443 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 444 */ "twindow_clause_opt ::=", - /* 445 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 446 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 447 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 448 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 449 */ "sliding_opt ::=", - /* 450 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 451 */ "fill_opt ::=", - /* 452 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 453 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 454 */ "fill_mode ::= NONE", - /* 455 */ "fill_mode ::= PREV", - /* 456 */ "fill_mode ::= NULL", - /* 457 */ "fill_mode ::= LINEAR", - /* 458 */ "fill_mode ::= NEXT", - /* 459 */ "group_by_clause_opt ::=", - /* 460 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 461 */ "group_by_list ::= expression", - /* 462 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 463 */ "having_clause_opt ::=", - /* 464 */ "having_clause_opt ::= HAVING search_condition", - /* 465 */ "range_opt ::=", - /* 466 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 467 */ "every_opt ::=", - /* 468 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 469 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 470 */ "query_expression_body ::= query_primary", - /* 471 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 472 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 473 */ "query_primary ::= query_specification", - /* 474 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 475 */ "order_by_clause_opt ::=", - /* 476 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 477 */ "slimit_clause_opt ::=", - /* 478 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 479 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 480 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 481 */ "limit_clause_opt ::=", - /* 482 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 483 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 484 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 485 */ "subquery ::= NK_LP query_expression NK_RP", - /* 486 */ "search_condition ::= common_expression", - /* 487 */ "sort_specification_list ::= sort_specification", - /* 488 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 489 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 490 */ "ordering_specification_opt ::=", - /* 491 */ "ordering_specification_opt ::= ASC", - /* 492 */ "ordering_specification_opt ::= DESC", - /* 493 */ "null_ordering_opt ::=", - /* 494 */ "null_ordering_opt ::= NULLS FIRST", - /* 495 */ "null_ordering_opt ::= NULLS LAST", + /* 329 */ "expr_or_subquery ::= expression", + /* 330 */ "expr_or_subquery ::= subquery", + /* 331 */ "expression ::= literal", + /* 332 */ "expression ::= pseudo_column", + /* 333 */ "expression ::= column_reference", + /* 334 */ "expression ::= function_expression", + /* 335 */ "expression ::= case_when_expression", + /* 336 */ "expression ::= NK_LP expression NK_RP", + /* 337 */ "expression ::= NK_PLUS expr_or_subquery", + /* 338 */ "expression ::= NK_MINUS expr_or_subquery", + /* 339 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 340 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 341 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 342 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 343 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 344 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 345 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 346 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 347 */ "expression_list ::= expr_or_subquery", + /* 348 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 349 */ "column_reference ::= column_name", + /* 350 */ "column_reference ::= table_name NK_DOT column_name", + /* 351 */ "pseudo_column ::= ROWTS", + /* 352 */ "pseudo_column ::= TBNAME", + /* 353 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 354 */ "pseudo_column ::= QSTART", + /* 355 */ "pseudo_column ::= QEND", + /* 356 */ "pseudo_column ::= QDURATION", + /* 357 */ "pseudo_column ::= WSTART", + /* 358 */ "pseudo_column ::= WEND", + /* 359 */ "pseudo_column ::= WDURATION", + /* 360 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 361 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 362 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 363 */ "function_expression ::= literal_func", + /* 364 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 365 */ "literal_func ::= NOW", + /* 366 */ "noarg_func ::= NOW", + /* 367 */ "noarg_func ::= TODAY", + /* 368 */ "noarg_func ::= TIMEZONE", + /* 369 */ "noarg_func ::= DATABASE", + /* 370 */ "noarg_func ::= CLIENT_VERSION", + /* 371 */ "noarg_func ::= SERVER_VERSION", + /* 372 */ "noarg_func ::= SERVER_STATUS", + /* 373 */ "noarg_func ::= CURRENT_USER", + /* 374 */ "noarg_func ::= USER", + /* 375 */ "star_func ::= COUNT", + /* 376 */ "star_func ::= FIRST", + /* 377 */ "star_func ::= LAST", + /* 378 */ "star_func ::= LAST_ROW", + /* 379 */ "star_func_para_list ::= NK_STAR", + /* 380 */ "star_func_para_list ::= other_para_list", + /* 381 */ "other_para_list ::= star_func_para", + /* 382 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 383 */ "star_func_para ::= expr_or_subquery", + /* 384 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 385 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 386 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 387 */ "when_then_list ::= when_then_expr", + /* 388 */ "when_then_list ::= when_then_list when_then_expr", + /* 389 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 390 */ "case_when_else_opt ::=", + /* 391 */ "case_when_else_opt ::= ELSE common_expression", + /* 392 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 393 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 394 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 395 */ "predicate ::= expr_or_subquery IS NULL", + /* 396 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 397 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 398 */ "compare_op ::= NK_LT", + /* 399 */ "compare_op ::= NK_GT", + /* 400 */ "compare_op ::= NK_LE", + /* 401 */ "compare_op ::= NK_GE", + /* 402 */ "compare_op ::= NK_NE", + /* 403 */ "compare_op ::= NK_EQ", + /* 404 */ "compare_op ::= LIKE", + /* 405 */ "compare_op ::= NOT LIKE", + /* 406 */ "compare_op ::= MATCH", + /* 407 */ "compare_op ::= NMATCH", + /* 408 */ "compare_op ::= CONTAINS", + /* 409 */ "in_op ::= IN", + /* 410 */ "in_op ::= NOT IN", + /* 411 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 412 */ "boolean_value_expression ::= boolean_primary", + /* 413 */ "boolean_value_expression ::= NOT boolean_primary", + /* 414 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 415 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 416 */ "boolean_primary ::= predicate", + /* 417 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 418 */ "common_expression ::= expr_or_subquery", + /* 419 */ "common_expression ::= boolean_value_expression", + /* 420 */ "from_clause_opt ::=", + /* 421 */ "from_clause_opt ::= FROM table_reference_list", + /* 422 */ "table_reference_list ::= table_reference", + /* 423 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 424 */ "table_reference ::= table_primary", + /* 425 */ "table_reference ::= joined_table", + /* 426 */ "table_primary ::= table_name alias_opt", + /* 427 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 428 */ "table_primary ::= subquery alias_opt", + /* 429 */ "table_primary ::= parenthesized_joined_table", + /* 430 */ "alias_opt ::=", + /* 431 */ "alias_opt ::= table_alias", + /* 432 */ "alias_opt ::= AS table_alias", + /* 433 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 434 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 435 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 436 */ "join_type ::=", + /* 437 */ "join_type ::= INNER", + /* 438 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 439 */ "set_quantifier_opt ::=", + /* 440 */ "set_quantifier_opt ::= DISTINCT", + /* 441 */ "set_quantifier_opt ::= ALL", + /* 442 */ "select_list ::= select_item", + /* 443 */ "select_list ::= select_list NK_COMMA select_item", + /* 444 */ "select_item ::= NK_STAR", + /* 445 */ "select_item ::= common_expression", + /* 446 */ "select_item ::= common_expression column_alias", + /* 447 */ "select_item ::= common_expression AS column_alias", + /* 448 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 449 */ "where_clause_opt ::=", + /* 450 */ "where_clause_opt ::= WHERE search_condition", + /* 451 */ "partition_by_clause_opt ::=", + /* 452 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 453 */ "twindow_clause_opt ::=", + /* 454 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 455 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 456 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 457 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 458 */ "sliding_opt ::=", + /* 459 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 460 */ "fill_opt ::=", + /* 461 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 462 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 463 */ "fill_mode ::= NONE", + /* 464 */ "fill_mode ::= PREV", + /* 465 */ "fill_mode ::= NULL", + /* 466 */ "fill_mode ::= LINEAR", + /* 467 */ "fill_mode ::= NEXT", + /* 468 */ "group_by_clause_opt ::=", + /* 469 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 470 */ "group_by_list ::= expr_or_subquery", + /* 471 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 472 */ "having_clause_opt ::=", + /* 473 */ "having_clause_opt ::= HAVING search_condition", + /* 474 */ "range_opt ::=", + /* 475 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 476 */ "every_opt ::=", + /* 477 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 478 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 479 */ "query_simple ::= query_specification", + /* 480 */ "query_simple ::= union_query_expression", + /* 481 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 482 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 483 */ "query_simple_or_subquery ::= query_simple", + /* 484 */ "query_simple_or_subquery ::= subquery", + /* 485 */ "query_or_subquery ::= query_expression", + /* 486 */ "query_or_subquery ::= subquery", + /* 487 */ "order_by_clause_opt ::=", + /* 488 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 489 */ "slimit_clause_opt ::=", + /* 490 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 491 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 492 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 493 */ "limit_clause_opt ::=", + /* 494 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 495 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 496 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 497 */ "subquery ::= NK_LP query_expression NK_RP", + /* 498 */ "subquery ::= NK_LP subquery NK_RP", + /* 499 */ "search_condition ::= common_expression", + /* 500 */ "sort_specification_list ::= sort_specification", + /* 501 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 502 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 503 */ "ordering_specification_opt ::=", + /* 504 */ "ordering_specification_opt ::= ASC", + /* 505 */ "ordering_specification_opt ::= DESC", + /* 506 */ "null_ordering_opt ::=", + /* 507 */ "null_ordering_opt ::= NULLS FIRST", + /* 508 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2374,179 +2432,186 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 309: /* cmd */ - case 312: /* literal */ - case 323: /* db_options */ - case 325: /* alter_db_options */ - case 330: /* retention */ - case 331: /* full_table_name */ - case 334: /* table_options */ - case 338: /* alter_table_clause */ - case 339: /* alter_table_options */ - case 342: /* signed_literal */ - case 343: /* create_subtable_clause */ - case 346: /* drop_table_clause */ - case 349: /* column_def */ - case 353: /* duration_literal */ - case 354: /* rollup_func_name */ - case 356: /* col_name */ - case 357: /* db_name_cond_opt */ - case 358: /* like_pattern_opt */ - case 359: /* table_name_cond */ - case 360: /* from_db_opt */ - case 361: /* index_options */ - case 363: /* sliding_opt */ - case 364: /* sma_stream_opt */ - case 365: /* func */ - case 366: /* stream_options */ - case 368: /* query_expression */ - case 371: /* explain_options */ - case 376: /* where_clause_opt */ - case 377: /* signed */ - case 378: /* literal_func */ - case 382: /* expression */ - case 383: /* pseudo_column */ - case 384: /* column_reference */ - case 385: /* function_expression */ - case 386: /* subquery */ - case 391: /* star_func_para */ - case 392: /* predicate */ - case 395: /* in_predicate_value */ - case 396: /* boolean_value_expression */ - case 397: /* boolean_primary */ - case 398: /* common_expression */ - case 399: /* from_clause_opt */ - case 400: /* table_reference_list */ - case 401: /* table_reference */ - case 402: /* table_primary */ - case 403: /* joined_table */ - case 405: /* parenthesized_joined_table */ - case 407: /* search_condition */ - case 408: /* query_specification */ - case 412: /* range_opt */ - case 413: /* every_opt */ - case 414: /* fill_opt */ - case 415: /* twindow_clause_opt */ - case 417: /* having_clause_opt */ - case 418: /* select_item */ - case 421: /* query_expression_body */ - case 423: /* slimit_clause_opt */ - case 424: /* limit_clause_opt */ - case 425: /* query_primary */ - case 427: /* sort_specification */ + case 313: /* cmd */ + case 316: /* literal */ + case 327: /* db_options */ + case 329: /* alter_db_options */ + case 334: /* retention */ + case 335: /* full_table_name */ + case 338: /* table_options */ + case 342: /* alter_table_clause */ + case 343: /* alter_table_options */ + case 346: /* signed_literal */ + case 347: /* create_subtable_clause */ + case 350: /* drop_table_clause */ + case 353: /* column_def */ + case 357: /* duration_literal */ + case 358: /* rollup_func_name */ + case 360: /* col_name */ + case 361: /* db_name_cond_opt */ + case 362: /* like_pattern_opt */ + case 363: /* table_name_cond */ + case 364: /* from_db_opt */ + case 365: /* index_options */ + case 367: /* sliding_opt */ + case 368: /* sma_stream_opt */ + case 369: /* func */ + case 370: /* stream_options */ + case 372: /* query_or_subquery */ + case 375: /* explain_options */ + case 380: /* where_clause_opt */ + case 381: /* signed */ + case 382: /* literal_func */ + case 386: /* expr_or_subquery */ + case 387: /* expression */ + case 388: /* subquery */ + case 389: /* pseudo_column */ + case 390: /* column_reference */ + case 391: /* function_expression */ + case 392: /* case_when_expression */ + case 397: /* star_func_para */ + case 399: /* case_when_else_opt */ + case 400: /* common_expression */ + case 401: /* when_then_expr */ + case 402: /* predicate */ + case 405: /* in_predicate_value */ + case 406: /* boolean_value_expression */ + case 407: /* boolean_primary */ + case 408: /* from_clause_opt */ + case 409: /* table_reference_list */ + case 410: /* table_reference */ + case 411: /* table_primary */ + case 412: /* joined_table */ + case 414: /* parenthesized_joined_table */ + case 416: /* search_condition */ + case 417: /* query_specification */ + case 421: /* range_opt */ + case 422: /* every_opt */ + case 423: /* fill_opt */ + case 424: /* twindow_clause_opt */ + case 426: /* having_clause_opt */ + case 427: /* select_item */ + case 430: /* query_expression */ + case 431: /* query_simple */ + case 433: /* slimit_clause_opt */ + case 434: /* limit_clause_opt */ + case 435: /* union_query_expression */ + case 436: /* query_simple_or_subquery */ + case 438: /* sort_specification */ { - nodesDestroyNode((yypminor->yy312)); + nodesDestroyNode((yypminor->yy560)); } break; - case 310: /* account_options */ - case 311: /* alter_account_options */ - case 313: /* alter_account_option */ - case 373: /* bufsize_opt */ + case 314: /* account_options */ + case 315: /* alter_account_options */ + case 317: /* alter_account_option */ + case 377: /* bufsize_opt */ { } break; - case 314: /* user_name */ - case 317: /* priv_level */ - case 320: /* db_name */ - case 321: /* dnode_endpoint */ - case 340: /* column_name */ - case 348: /* table_name */ - case 355: /* function_name */ - case 367: /* topic_name */ - case 369: /* cgroup_name */ - case 374: /* stream_name */ - case 380: /* table_alias */ - case 381: /* column_alias */ - case 387: /* star_func */ - case 389: /* noarg_func */ - case 404: /* alias_opt */ + case 318: /* user_name */ + case 321: /* priv_level */ + case 324: /* db_name */ + case 325: /* dnode_endpoint */ + case 344: /* column_name */ + case 352: /* table_name */ + case 359: /* function_name */ + case 371: /* topic_name */ + case 373: /* cgroup_name */ + case 378: /* stream_name */ + case 384: /* table_alias */ + case 385: /* column_alias */ + case 393: /* star_func */ + case 395: /* noarg_func */ + case 413: /* alias_opt */ { } break; - case 315: /* sysinfo_opt */ + case 319: /* sysinfo_opt */ { } break; - case 316: /* privileges */ - case 318: /* priv_type_list */ - case 319: /* priv_type */ + case 320: /* privileges */ + case 322: /* priv_type_list */ + case 323: /* priv_type */ { } break; - case 322: /* not_exists_opt */ - case 324: /* exists_opt */ - case 370: /* analyze_opt */ - case 372: /* agg_func_opt */ - case 409: /* set_quantifier_opt */ + case 326: /* not_exists_opt */ + case 328: /* exists_opt */ + case 374: /* analyze_opt */ + case 376: /* agg_func_opt */ + case 418: /* set_quantifier_opt */ { } break; - case 326: /* integer_list */ - case 327: /* variable_list */ - case 328: /* retention_list */ - case 332: /* column_def_list */ - case 333: /* tags_def_opt */ - case 335: /* multi_create_clause */ - case 336: /* tags_def */ - case 337: /* multi_drop_clause */ - case 344: /* specific_cols_opt */ - case 345: /* expression_list */ - case 347: /* col_name_list */ - case 350: /* duration_list */ - case 351: /* rollup_func_list */ - case 362: /* func_list */ - case 375: /* dnode_list */ - case 379: /* literal_list */ - case 388: /* star_func_para_list */ - case 390: /* other_para_list */ - case 410: /* select_list */ - case 411: /* partition_by_clause_opt */ - case 416: /* group_by_clause_opt */ - case 420: /* group_by_list */ - case 422: /* order_by_clause_opt */ - case 426: /* sort_specification_list */ + case 330: /* integer_list */ + case 331: /* variable_list */ + case 332: /* retention_list */ + case 336: /* column_def_list */ + case 337: /* tags_def_opt */ + case 339: /* multi_create_clause */ + case 340: /* tags_def */ + case 341: /* multi_drop_clause */ + case 348: /* specific_cols_opt */ + case 349: /* expression_list */ + case 351: /* col_name_list */ + case 354: /* duration_list */ + case 355: /* rollup_func_list */ + case 366: /* func_list */ + case 379: /* dnode_list */ + case 383: /* literal_list */ + case 394: /* star_func_para_list */ + case 396: /* other_para_list */ + case 398: /* when_then_list */ + case 419: /* select_list */ + case 420: /* partition_by_clause_opt */ + case 425: /* group_by_clause_opt */ + case 429: /* group_by_list */ + case 432: /* order_by_clause_opt */ + case 437: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy824)); + nodesDestroyList((yypminor->yy334)); } break; - case 329: /* alter_db_option */ - case 352: /* alter_table_option */ + case 333: /* alter_db_option */ + case 356: /* alter_table_option */ { } break; - case 341: /* type_name */ + case 345: /* type_name */ { } break; - case 393: /* compare_op */ - case 394: /* in_op */ + case 403: /* compare_op */ + case 404: /* in_op */ { } break; - case 406: /* join_type */ + case 415: /* join_type */ { } break; - case 419: /* fill_mode */ + case 428: /* fill_mode */ { } break; - case 428: /* ordering_specification_opt */ + case 439: /* ordering_specification_opt */ { } break; - case 429: /* null_ordering_opt */ + case 440: /* null_ordering_opt */ { } @@ -2845,502 +2910,515 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 309, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 309, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 310, 0 }, /* (2) account_options ::= */ - { 310, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 310, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 310, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 310, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 310, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 310, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 310, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 310, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 310, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 311, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 311, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 313, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 313, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 313, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 313, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 313, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 313, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 313, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 313, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 313, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 313, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 309, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 309, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 309, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 309, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 309, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 315, 0 }, /* (29) sysinfo_opt ::= */ - { 315, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 309, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 309, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 316, -1 }, /* (33) privileges ::= ALL */ - { 316, -1 }, /* (34) privileges ::= priv_type_list */ - { 318, -1 }, /* (35) priv_type_list ::= priv_type */ - { 318, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 319, -1 }, /* (37) priv_type ::= READ */ - { 319, -1 }, /* (38) priv_type ::= WRITE */ - { 317, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 317, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 309, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 309, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 309, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 309, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 309, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 309, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 309, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 309, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 321, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 321, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 321, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 309, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 309, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 309, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 309, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 309, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 309, -2 }, /* (64) cmd ::= USE db_name */ - { 309, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 309, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ - { 309, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ - { 322, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ - { 322, 0 }, /* (69) not_exists_opt ::= */ - { 324, -2 }, /* (70) exists_opt ::= IF EXISTS */ - { 324, 0 }, /* (71) exists_opt ::= */ - { 323, 0 }, /* (72) db_options ::= */ - { 323, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ - { 323, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ - { 323, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 323, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ - { 323, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ - { 323, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ - { 323, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ - { 323, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ - { 323, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ - { 323, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ - { 323, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ - { 323, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 323, -3 }, /* (85) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 323, -3 }, /* (86) db_options ::= db_options PRECISION NK_STRING */ - { 323, -3 }, /* (87) db_options ::= db_options REPLICA NK_INTEGER */ - { 323, -3 }, /* (88) db_options ::= db_options STRICT NK_STRING */ - { 323, -3 }, /* (89) db_options ::= db_options VGROUPS NK_INTEGER */ - { 323, -3 }, /* (90) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 323, -3 }, /* (91) db_options ::= db_options RETENTIONS retention_list */ - { 323, -3 }, /* (92) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 323, -3 }, /* (93) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 323, -3 }, /* (94) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 323, -3 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 323, -4 }, /* (96) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 323, -3 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 323, -4 }, /* (98) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 323, -3 }, /* (99) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 323, -3 }, /* (100) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 323, -3 }, /* (101) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 323, -3 }, /* (102) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 323, -3 }, /* (103) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 325, -1 }, /* (104) alter_db_options ::= alter_db_option */ - { 325, -2 }, /* (105) alter_db_options ::= alter_db_options alter_db_option */ - { 329, -2 }, /* (106) alter_db_option ::= CACHEMODEL NK_STRING */ - { 329, -2 }, /* (107) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 329, -2 }, /* (108) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 329, -2 }, /* (109) alter_db_option ::= KEEP integer_list */ - { 329, -2 }, /* (110) alter_db_option ::= KEEP variable_list */ - { 329, -2 }, /* (111) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 329, -2 }, /* (112) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 326, -1 }, /* (113) integer_list ::= NK_INTEGER */ - { 326, -3 }, /* (114) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 327, -1 }, /* (115) variable_list ::= NK_VARIABLE */ - { 327, -3 }, /* (116) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 328, -1 }, /* (117) retention_list ::= retention */ - { 328, -3 }, /* (118) retention_list ::= retention_list NK_COMMA retention */ - { 330, -3 }, /* (119) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 309, -9 }, /* (120) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 309, -3 }, /* (121) cmd ::= CREATE TABLE multi_create_clause */ - { 309, -9 }, /* (122) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 309, -3 }, /* (123) cmd ::= DROP TABLE multi_drop_clause */ - { 309, -4 }, /* (124) cmd ::= DROP STABLE exists_opt full_table_name */ - { 309, -3 }, /* (125) cmd ::= ALTER TABLE alter_table_clause */ - { 309, -3 }, /* (126) cmd ::= ALTER STABLE alter_table_clause */ - { 338, -2 }, /* (127) alter_table_clause ::= full_table_name alter_table_options */ - { 338, -5 }, /* (128) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 338, -4 }, /* (129) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 338, -5 }, /* (130) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 338, -5 }, /* (131) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 338, -5 }, /* (132) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 338, -4 }, /* (133) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 338, -5 }, /* (134) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 338, -5 }, /* (135) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 338, -6 }, /* (136) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 335, -1 }, /* (137) multi_create_clause ::= create_subtable_clause */ - { 335, -2 }, /* (138) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 343, -10 }, /* (139) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - { 337, -1 }, /* (140) multi_drop_clause ::= drop_table_clause */ - { 337, -2 }, /* (141) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 346, -2 }, /* (142) drop_table_clause ::= exists_opt full_table_name */ - { 344, 0 }, /* (143) specific_cols_opt ::= */ - { 344, -3 }, /* (144) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 331, -1 }, /* (145) full_table_name ::= table_name */ - { 331, -3 }, /* (146) full_table_name ::= db_name NK_DOT table_name */ - { 332, -1 }, /* (147) column_def_list ::= column_def */ - { 332, -3 }, /* (148) column_def_list ::= column_def_list NK_COMMA column_def */ - { 349, -2 }, /* (149) column_def ::= column_name type_name */ - { 349, -4 }, /* (150) column_def ::= column_name type_name COMMENT NK_STRING */ - { 341, -1 }, /* (151) type_name ::= BOOL */ - { 341, -1 }, /* (152) type_name ::= TINYINT */ - { 341, -1 }, /* (153) type_name ::= SMALLINT */ - { 341, -1 }, /* (154) type_name ::= INT */ - { 341, -1 }, /* (155) type_name ::= INTEGER */ - { 341, -1 }, /* (156) type_name ::= BIGINT */ - { 341, -1 }, /* (157) type_name ::= FLOAT */ - { 341, -1 }, /* (158) type_name ::= DOUBLE */ - { 341, -4 }, /* (159) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 341, -1 }, /* (160) type_name ::= TIMESTAMP */ - { 341, -4 }, /* (161) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 341, -2 }, /* (162) type_name ::= TINYINT UNSIGNED */ - { 341, -2 }, /* (163) type_name ::= SMALLINT UNSIGNED */ - { 341, -2 }, /* (164) type_name ::= INT UNSIGNED */ - { 341, -2 }, /* (165) type_name ::= BIGINT UNSIGNED */ - { 341, -1 }, /* (166) type_name ::= JSON */ - { 341, -4 }, /* (167) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 341, -1 }, /* (168) type_name ::= MEDIUMBLOB */ - { 341, -1 }, /* (169) type_name ::= BLOB */ - { 341, -4 }, /* (170) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 341, -1 }, /* (171) type_name ::= DECIMAL */ - { 341, -4 }, /* (172) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 341, -6 }, /* (173) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 333, 0 }, /* (174) tags_def_opt ::= */ - { 333, -1 }, /* (175) tags_def_opt ::= tags_def */ - { 336, -4 }, /* (176) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 334, 0 }, /* (177) table_options ::= */ - { 334, -3 }, /* (178) table_options ::= table_options COMMENT NK_STRING */ - { 334, -3 }, /* (179) table_options ::= table_options MAX_DELAY duration_list */ - { 334, -3 }, /* (180) table_options ::= table_options WATERMARK duration_list */ - { 334, -5 }, /* (181) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 334, -3 }, /* (182) table_options ::= table_options TTL NK_INTEGER */ - { 334, -5 }, /* (183) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 339, -1 }, /* (184) alter_table_options ::= alter_table_option */ - { 339, -2 }, /* (185) alter_table_options ::= alter_table_options alter_table_option */ - { 352, -2 }, /* (186) alter_table_option ::= COMMENT NK_STRING */ - { 352, -2 }, /* (187) alter_table_option ::= TTL NK_INTEGER */ - { 350, -1 }, /* (188) duration_list ::= duration_literal */ - { 350, -3 }, /* (189) duration_list ::= duration_list NK_COMMA duration_literal */ - { 351, -1 }, /* (190) rollup_func_list ::= rollup_func_name */ - { 351, -3 }, /* (191) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 354, -1 }, /* (192) rollup_func_name ::= function_name */ - { 354, -1 }, /* (193) rollup_func_name ::= FIRST */ - { 354, -1 }, /* (194) rollup_func_name ::= LAST */ - { 347, -1 }, /* (195) col_name_list ::= col_name */ - { 347, -3 }, /* (196) col_name_list ::= col_name_list NK_COMMA col_name */ - { 356, -1 }, /* (197) col_name ::= column_name */ - { 309, -2 }, /* (198) cmd ::= SHOW DNODES */ - { 309, -2 }, /* (199) cmd ::= SHOW USERS */ - { 309, -2 }, /* (200) cmd ::= SHOW DATABASES */ - { 309, -4 }, /* (201) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 309, -4 }, /* (202) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 309, -3 }, /* (203) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 309, -2 }, /* (204) cmd ::= SHOW MNODES */ - { 309, -2 }, /* (205) cmd ::= SHOW MODULES */ - { 309, -2 }, /* (206) cmd ::= SHOW QNODES */ - { 309, -2 }, /* (207) cmd ::= SHOW FUNCTIONS */ - { 309, -5 }, /* (208) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 309, -2 }, /* (209) cmd ::= SHOW STREAMS */ - { 309, -2 }, /* (210) cmd ::= SHOW ACCOUNTS */ - { 309, -2 }, /* (211) cmd ::= SHOW APPS */ - { 309, -2 }, /* (212) cmd ::= SHOW CONNECTIONS */ - { 309, -2 }, /* (213) cmd ::= SHOW LICENCES */ - { 309, -2 }, /* (214) cmd ::= SHOW GRANTS */ - { 309, -4 }, /* (215) cmd ::= SHOW CREATE DATABASE db_name */ - { 309, -4 }, /* (216) cmd ::= SHOW CREATE TABLE full_table_name */ - { 309, -4 }, /* (217) cmd ::= SHOW CREATE STABLE full_table_name */ - { 309, -2 }, /* (218) cmd ::= SHOW QUERIES */ - { 309, -2 }, /* (219) cmd ::= SHOW SCORES */ - { 309, -2 }, /* (220) cmd ::= SHOW TOPICS */ - { 309, -2 }, /* (221) cmd ::= SHOW VARIABLES */ - { 309, -3 }, /* (222) cmd ::= SHOW LOCAL VARIABLES */ - { 309, -4 }, /* (223) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 309, -2 }, /* (224) cmd ::= SHOW BNODES */ - { 309, -2 }, /* (225) cmd ::= SHOW SNODES */ - { 309, -2 }, /* (226) cmd ::= SHOW CLUSTER */ - { 309, -2 }, /* (227) cmd ::= SHOW TRANSACTIONS */ - { 309, -4 }, /* (228) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 309, -2 }, /* (229) cmd ::= SHOW CONSUMERS */ - { 309, -2 }, /* (230) cmd ::= SHOW SUBSCRIPTIONS */ - { 309, -5 }, /* (231) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 309, -3 }, /* (232) cmd ::= SHOW VNODES NK_INTEGER */ - { 309, -3 }, /* (233) cmd ::= SHOW VNODES NK_STRING */ - { 357, 0 }, /* (234) db_name_cond_opt ::= */ - { 357, -2 }, /* (235) db_name_cond_opt ::= db_name NK_DOT */ - { 358, 0 }, /* (236) like_pattern_opt ::= */ - { 358, -2 }, /* (237) like_pattern_opt ::= LIKE NK_STRING */ - { 359, -1 }, /* (238) table_name_cond ::= table_name */ - { 360, 0 }, /* (239) from_db_opt ::= */ - { 360, -2 }, /* (240) from_db_opt ::= FROM db_name */ - { 309, -8 }, /* (241) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 309, -4 }, /* (242) cmd ::= DROP INDEX exists_opt full_table_name */ - { 361, -10 }, /* (243) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 361, -12 }, /* (244) 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 */ - { 362, -1 }, /* (245) func_list ::= func */ - { 362, -3 }, /* (246) func_list ::= func_list NK_COMMA func */ - { 365, -4 }, /* (247) func ::= function_name NK_LP expression_list NK_RP */ - { 364, 0 }, /* (248) sma_stream_opt ::= */ - { 364, -3 }, /* (249) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 364, -3 }, /* (250) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 309, -6 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 309, -7 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 309, -9 }, /* (253) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 309, -7 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 309, -9 }, /* (255) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 309, -4 }, /* (256) cmd ::= DROP TOPIC exists_opt topic_name */ - { 309, -7 }, /* (257) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 309, -2 }, /* (258) cmd ::= DESC full_table_name */ - { 309, -2 }, /* (259) cmd ::= DESCRIBE full_table_name */ - { 309, -3 }, /* (260) cmd ::= RESET QUERY CACHE */ - { 309, -4 }, /* (261) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 370, 0 }, /* (262) analyze_opt ::= */ - { 370, -1 }, /* (263) analyze_opt ::= ANALYZE */ - { 371, 0 }, /* (264) explain_options ::= */ - { 371, -3 }, /* (265) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 371, -3 }, /* (266) explain_options ::= explain_options RATIO NK_FLOAT */ - { 309, -10 }, /* (267) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 309, -4 }, /* (268) cmd ::= DROP FUNCTION exists_opt function_name */ - { 372, 0 }, /* (269) agg_func_opt ::= */ - { 372, -1 }, /* (270) agg_func_opt ::= AGGREGATE */ - { 373, 0 }, /* (271) bufsize_opt ::= */ - { 373, -2 }, /* (272) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 309, -9 }, /* (273) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ - { 309, -4 }, /* (274) cmd ::= DROP STREAM exists_opt stream_name */ - { 366, 0 }, /* (275) stream_options ::= */ - { 366, -3 }, /* (276) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 366, -3 }, /* (277) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 366, -4 }, /* (278) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 366, -3 }, /* (279) stream_options ::= stream_options WATERMARK duration_literal */ - { 366, -4 }, /* (280) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 309, -3 }, /* (281) cmd ::= KILL CONNECTION NK_INTEGER */ - { 309, -3 }, /* (282) cmd ::= KILL QUERY NK_STRING */ - { 309, -3 }, /* (283) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 309, -2 }, /* (284) cmd ::= BALANCE VGROUP */ - { 309, -4 }, /* (285) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 309, -4 }, /* (286) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 309, -3 }, /* (287) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 375, -2 }, /* (288) dnode_list ::= DNODE NK_INTEGER */ - { 375, -3 }, /* (289) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 309, -4 }, /* (290) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 309, -1 }, /* (291) cmd ::= query_expression */ - { 309, -7 }, /* (292) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ - { 309, -4 }, /* (293) cmd ::= INSERT INTO full_table_name query_expression */ - { 312, -1 }, /* (294) literal ::= NK_INTEGER */ - { 312, -1 }, /* (295) literal ::= NK_FLOAT */ - { 312, -1 }, /* (296) literal ::= NK_STRING */ - { 312, -1 }, /* (297) literal ::= NK_BOOL */ - { 312, -2 }, /* (298) literal ::= TIMESTAMP NK_STRING */ - { 312, -1 }, /* (299) literal ::= duration_literal */ - { 312, -1 }, /* (300) literal ::= NULL */ - { 312, -1 }, /* (301) literal ::= NK_QUESTION */ - { 353, -1 }, /* (302) duration_literal ::= NK_VARIABLE */ - { 377, -1 }, /* (303) signed ::= NK_INTEGER */ - { 377, -2 }, /* (304) signed ::= NK_PLUS NK_INTEGER */ - { 377, -2 }, /* (305) signed ::= NK_MINUS NK_INTEGER */ - { 377, -1 }, /* (306) signed ::= NK_FLOAT */ - { 377, -2 }, /* (307) signed ::= NK_PLUS NK_FLOAT */ - { 377, -2 }, /* (308) signed ::= NK_MINUS NK_FLOAT */ - { 342, -1 }, /* (309) signed_literal ::= signed */ - { 342, -1 }, /* (310) signed_literal ::= NK_STRING */ - { 342, -1 }, /* (311) signed_literal ::= NK_BOOL */ - { 342, -2 }, /* (312) signed_literal ::= TIMESTAMP NK_STRING */ - { 342, -1 }, /* (313) signed_literal ::= duration_literal */ - { 342, -1 }, /* (314) signed_literal ::= NULL */ - { 342, -1 }, /* (315) signed_literal ::= literal_func */ - { 342, -1 }, /* (316) signed_literal ::= NK_QUESTION */ - { 379, -1 }, /* (317) literal_list ::= signed_literal */ - { 379, -3 }, /* (318) literal_list ::= literal_list NK_COMMA signed_literal */ - { 320, -1 }, /* (319) db_name ::= NK_ID */ - { 348, -1 }, /* (320) table_name ::= NK_ID */ - { 340, -1 }, /* (321) column_name ::= NK_ID */ - { 355, -1 }, /* (322) function_name ::= NK_ID */ - { 380, -1 }, /* (323) table_alias ::= NK_ID */ - { 381, -1 }, /* (324) column_alias ::= NK_ID */ - { 314, -1 }, /* (325) user_name ::= NK_ID */ - { 367, -1 }, /* (326) topic_name ::= NK_ID */ - { 374, -1 }, /* (327) stream_name ::= NK_ID */ - { 369, -1 }, /* (328) cgroup_name ::= NK_ID */ - { 382, -1 }, /* (329) expression ::= literal */ - { 382, -1 }, /* (330) expression ::= pseudo_column */ - { 382, -1 }, /* (331) expression ::= column_reference */ - { 382, -1 }, /* (332) expression ::= function_expression */ - { 382, -1 }, /* (333) expression ::= subquery */ - { 382, -3 }, /* (334) expression ::= NK_LP expression NK_RP */ - { 382, -2 }, /* (335) expression ::= NK_PLUS expression */ - { 382, -2 }, /* (336) expression ::= NK_MINUS expression */ - { 382, -3 }, /* (337) expression ::= expression NK_PLUS expression */ - { 382, -3 }, /* (338) expression ::= expression NK_MINUS expression */ - { 382, -3 }, /* (339) expression ::= expression NK_STAR expression */ - { 382, -3 }, /* (340) expression ::= expression NK_SLASH expression */ - { 382, -3 }, /* (341) expression ::= expression NK_REM expression */ - { 382, -3 }, /* (342) expression ::= column_reference NK_ARROW NK_STRING */ - { 382, -3 }, /* (343) expression ::= expression NK_BITAND expression */ - { 382, -3 }, /* (344) expression ::= expression NK_BITOR expression */ - { 345, -1 }, /* (345) expression_list ::= expression */ - { 345, -3 }, /* (346) expression_list ::= expression_list NK_COMMA expression */ - { 384, -1 }, /* (347) column_reference ::= column_name */ - { 384, -3 }, /* (348) column_reference ::= table_name NK_DOT column_name */ - { 383, -1 }, /* (349) pseudo_column ::= ROWTS */ - { 383, -1 }, /* (350) pseudo_column ::= TBNAME */ - { 383, -3 }, /* (351) pseudo_column ::= table_name NK_DOT TBNAME */ - { 383, -1 }, /* (352) pseudo_column ::= QSTART */ - { 383, -1 }, /* (353) pseudo_column ::= QEND */ - { 383, -1 }, /* (354) pseudo_column ::= QDURATION */ - { 383, -1 }, /* (355) pseudo_column ::= WSTART */ - { 383, -1 }, /* (356) pseudo_column ::= WEND */ - { 383, -1 }, /* (357) pseudo_column ::= WDURATION */ - { 385, -4 }, /* (358) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 385, -4 }, /* (359) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 385, -6 }, /* (360) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 385, -1 }, /* (361) function_expression ::= literal_func */ - { 378, -3 }, /* (362) literal_func ::= noarg_func NK_LP NK_RP */ - { 378, -1 }, /* (363) literal_func ::= NOW */ - { 389, -1 }, /* (364) noarg_func ::= NOW */ - { 389, -1 }, /* (365) noarg_func ::= TODAY */ - { 389, -1 }, /* (366) noarg_func ::= TIMEZONE */ - { 389, -1 }, /* (367) noarg_func ::= DATABASE */ - { 389, -1 }, /* (368) noarg_func ::= CLIENT_VERSION */ - { 389, -1 }, /* (369) noarg_func ::= SERVER_VERSION */ - { 389, -1 }, /* (370) noarg_func ::= SERVER_STATUS */ - { 389, -1 }, /* (371) noarg_func ::= CURRENT_USER */ - { 389, -1 }, /* (372) noarg_func ::= USER */ - { 387, -1 }, /* (373) star_func ::= COUNT */ - { 387, -1 }, /* (374) star_func ::= FIRST */ - { 387, -1 }, /* (375) star_func ::= LAST */ - { 387, -1 }, /* (376) star_func ::= LAST_ROW */ - { 388, -1 }, /* (377) star_func_para_list ::= NK_STAR */ - { 388, -1 }, /* (378) star_func_para_list ::= other_para_list */ - { 390, -1 }, /* (379) other_para_list ::= star_func_para */ - { 390, -3 }, /* (380) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 391, -1 }, /* (381) star_func_para ::= expression */ - { 391, -3 }, /* (382) star_func_para ::= table_name NK_DOT NK_STAR */ - { 392, -3 }, /* (383) predicate ::= expression compare_op expression */ - { 392, -5 }, /* (384) predicate ::= expression BETWEEN expression AND expression */ - { 392, -6 }, /* (385) predicate ::= expression NOT BETWEEN expression AND expression */ - { 392, -3 }, /* (386) predicate ::= expression IS NULL */ - { 392, -4 }, /* (387) predicate ::= expression IS NOT NULL */ - { 392, -3 }, /* (388) predicate ::= expression in_op in_predicate_value */ - { 393, -1 }, /* (389) compare_op ::= NK_LT */ - { 393, -1 }, /* (390) compare_op ::= NK_GT */ - { 393, -1 }, /* (391) compare_op ::= NK_LE */ - { 393, -1 }, /* (392) compare_op ::= NK_GE */ - { 393, -1 }, /* (393) compare_op ::= NK_NE */ - { 393, -1 }, /* (394) compare_op ::= NK_EQ */ - { 393, -1 }, /* (395) compare_op ::= LIKE */ - { 393, -2 }, /* (396) compare_op ::= NOT LIKE */ - { 393, -1 }, /* (397) compare_op ::= MATCH */ - { 393, -1 }, /* (398) compare_op ::= NMATCH */ - { 393, -1 }, /* (399) compare_op ::= CONTAINS */ - { 394, -1 }, /* (400) in_op ::= IN */ - { 394, -2 }, /* (401) in_op ::= NOT IN */ - { 395, -3 }, /* (402) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 396, -1 }, /* (403) boolean_value_expression ::= boolean_primary */ - { 396, -2 }, /* (404) boolean_value_expression ::= NOT boolean_primary */ - { 396, -3 }, /* (405) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 396, -3 }, /* (406) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 397, -1 }, /* (407) boolean_primary ::= predicate */ - { 397, -3 }, /* (408) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 398, -1 }, /* (409) common_expression ::= expression */ - { 398, -1 }, /* (410) common_expression ::= boolean_value_expression */ - { 399, 0 }, /* (411) from_clause_opt ::= */ - { 399, -2 }, /* (412) from_clause_opt ::= FROM table_reference_list */ - { 400, -1 }, /* (413) table_reference_list ::= table_reference */ - { 400, -3 }, /* (414) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 401, -1 }, /* (415) table_reference ::= table_primary */ - { 401, -1 }, /* (416) table_reference ::= joined_table */ - { 402, -2 }, /* (417) table_primary ::= table_name alias_opt */ - { 402, -4 }, /* (418) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 402, -2 }, /* (419) table_primary ::= subquery alias_opt */ - { 402, -1 }, /* (420) table_primary ::= parenthesized_joined_table */ - { 404, 0 }, /* (421) alias_opt ::= */ - { 404, -1 }, /* (422) alias_opt ::= table_alias */ - { 404, -2 }, /* (423) alias_opt ::= AS table_alias */ - { 405, -3 }, /* (424) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 405, -3 }, /* (425) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 403, -6 }, /* (426) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 406, 0 }, /* (427) join_type ::= */ - { 406, -1 }, /* (428) join_type ::= INNER */ - { 408, -12 }, /* (429) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 409, 0 }, /* (430) set_quantifier_opt ::= */ - { 409, -1 }, /* (431) set_quantifier_opt ::= DISTINCT */ - { 409, -1 }, /* (432) set_quantifier_opt ::= ALL */ - { 410, -1 }, /* (433) select_list ::= select_item */ - { 410, -3 }, /* (434) select_list ::= select_list NK_COMMA select_item */ - { 418, -1 }, /* (435) select_item ::= NK_STAR */ - { 418, -1 }, /* (436) select_item ::= common_expression */ - { 418, -2 }, /* (437) select_item ::= common_expression column_alias */ - { 418, -3 }, /* (438) select_item ::= common_expression AS column_alias */ - { 418, -3 }, /* (439) select_item ::= table_name NK_DOT NK_STAR */ - { 376, 0 }, /* (440) where_clause_opt ::= */ - { 376, -2 }, /* (441) where_clause_opt ::= WHERE search_condition */ - { 411, 0 }, /* (442) partition_by_clause_opt ::= */ - { 411, -3 }, /* (443) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 415, 0 }, /* (444) twindow_clause_opt ::= */ - { 415, -6 }, /* (445) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 415, -4 }, /* (446) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 415, -6 }, /* (447) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 415, -8 }, /* (448) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 363, 0 }, /* (449) sliding_opt ::= */ - { 363, -4 }, /* (450) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 414, 0 }, /* (451) fill_opt ::= */ - { 414, -4 }, /* (452) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 414, -6 }, /* (453) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 419, -1 }, /* (454) fill_mode ::= NONE */ - { 419, -1 }, /* (455) fill_mode ::= PREV */ - { 419, -1 }, /* (456) fill_mode ::= NULL */ - { 419, -1 }, /* (457) fill_mode ::= LINEAR */ - { 419, -1 }, /* (458) fill_mode ::= NEXT */ - { 416, 0 }, /* (459) group_by_clause_opt ::= */ - { 416, -3 }, /* (460) group_by_clause_opt ::= GROUP BY group_by_list */ - { 420, -1 }, /* (461) group_by_list ::= expression */ - { 420, -3 }, /* (462) group_by_list ::= group_by_list NK_COMMA expression */ - { 417, 0 }, /* (463) having_clause_opt ::= */ - { 417, -2 }, /* (464) having_clause_opt ::= HAVING search_condition */ - { 412, 0 }, /* (465) range_opt ::= */ - { 412, -6 }, /* (466) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 413, 0 }, /* (467) every_opt ::= */ - { 413, -4 }, /* (468) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 368, -4 }, /* (469) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 421, -1 }, /* (470) query_expression_body ::= query_primary */ - { 421, -4 }, /* (471) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 421, -3 }, /* (472) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 425, -1 }, /* (473) query_primary ::= query_specification */ - { 425, -6 }, /* (474) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 422, 0 }, /* (475) order_by_clause_opt ::= */ - { 422, -3 }, /* (476) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 423, 0 }, /* (477) slimit_clause_opt ::= */ - { 423, -2 }, /* (478) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 423, -4 }, /* (479) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 423, -4 }, /* (480) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 424, 0 }, /* (481) limit_clause_opt ::= */ - { 424, -2 }, /* (482) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 424, -4 }, /* (483) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 424, -4 }, /* (484) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 386, -3 }, /* (485) subquery ::= NK_LP query_expression NK_RP */ - { 407, -1 }, /* (486) search_condition ::= common_expression */ - { 426, -1 }, /* (487) sort_specification_list ::= sort_specification */ - { 426, -3 }, /* (488) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 427, -3 }, /* (489) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 428, 0 }, /* (490) ordering_specification_opt ::= */ - { 428, -1 }, /* (491) ordering_specification_opt ::= ASC */ - { 428, -1 }, /* (492) ordering_specification_opt ::= DESC */ - { 429, 0 }, /* (493) null_ordering_opt ::= */ - { 429, -2 }, /* (494) null_ordering_opt ::= NULLS FIRST */ - { 429, -2 }, /* (495) null_ordering_opt ::= NULLS LAST */ + { 313, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 313, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 314, 0 }, /* (2) account_options ::= */ + { 314, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 314, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 314, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 314, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 314, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 314, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 314, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 314, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 314, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 315, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 315, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 317, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 317, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 317, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 317, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 317, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 317, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 317, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 317, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 317, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 317, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 313, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 313, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 313, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 313, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 313, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 319, 0 }, /* (29) sysinfo_opt ::= */ + { 319, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 313, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 313, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 320, -1 }, /* (33) privileges ::= ALL */ + { 320, -1 }, /* (34) privileges ::= priv_type_list */ + { 322, -1 }, /* (35) priv_type_list ::= priv_type */ + { 322, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 323, -1 }, /* (37) priv_type ::= READ */ + { 323, -1 }, /* (38) priv_type ::= WRITE */ + { 321, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 321, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 313, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 313, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 313, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 313, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 313, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 313, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 313, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 313, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 325, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 325, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 325, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 313, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 313, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 313, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 313, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 313, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 313, -2 }, /* (64) cmd ::= USE db_name */ + { 313, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 313, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ + { 313, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ + { 326, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ + { 326, 0 }, /* (69) not_exists_opt ::= */ + { 328, -2 }, /* (70) exists_opt ::= IF EXISTS */ + { 328, 0 }, /* (71) exists_opt ::= */ + { 327, 0 }, /* (72) db_options ::= */ + { 327, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ + { 327, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ + { 327, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 327, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ + { 327, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ + { 327, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ + { 327, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ + { 327, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ + { 327, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ + { 327, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ + { 327, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ + { 327, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 327, -3 }, /* (85) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 327, -3 }, /* (86) db_options ::= db_options PRECISION NK_STRING */ + { 327, -3 }, /* (87) db_options ::= db_options REPLICA NK_INTEGER */ + { 327, -3 }, /* (88) db_options ::= db_options STRICT NK_STRING */ + { 327, -3 }, /* (89) db_options ::= db_options VGROUPS NK_INTEGER */ + { 327, -3 }, /* (90) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 327, -3 }, /* (91) db_options ::= db_options RETENTIONS retention_list */ + { 327, -3 }, /* (92) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 327, -3 }, /* (93) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 327, -3 }, /* (94) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 327, -3 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 327, -4 }, /* (96) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 327, -3 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 327, -4 }, /* (98) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 327, -3 }, /* (99) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 327, -3 }, /* (100) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 327, -3 }, /* (101) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 327, -3 }, /* (102) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 327, -3 }, /* (103) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 329, -1 }, /* (104) alter_db_options ::= alter_db_option */ + { 329, -2 }, /* (105) alter_db_options ::= alter_db_options alter_db_option */ + { 333, -2 }, /* (106) alter_db_option ::= CACHEMODEL NK_STRING */ + { 333, -2 }, /* (107) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 333, -2 }, /* (108) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 333, -2 }, /* (109) alter_db_option ::= KEEP integer_list */ + { 333, -2 }, /* (110) alter_db_option ::= KEEP variable_list */ + { 333, -2 }, /* (111) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 333, -2 }, /* (112) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 330, -1 }, /* (113) integer_list ::= NK_INTEGER */ + { 330, -3 }, /* (114) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 331, -1 }, /* (115) variable_list ::= NK_VARIABLE */ + { 331, -3 }, /* (116) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 332, -1 }, /* (117) retention_list ::= retention */ + { 332, -3 }, /* (118) retention_list ::= retention_list NK_COMMA retention */ + { 334, -3 }, /* (119) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 313, -9 }, /* (120) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 313, -3 }, /* (121) cmd ::= CREATE TABLE multi_create_clause */ + { 313, -9 }, /* (122) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 313, -3 }, /* (123) cmd ::= DROP TABLE multi_drop_clause */ + { 313, -4 }, /* (124) cmd ::= DROP STABLE exists_opt full_table_name */ + { 313, -3 }, /* (125) cmd ::= ALTER TABLE alter_table_clause */ + { 313, -3 }, /* (126) cmd ::= ALTER STABLE alter_table_clause */ + { 342, -2 }, /* (127) alter_table_clause ::= full_table_name alter_table_options */ + { 342, -5 }, /* (128) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 342, -4 }, /* (129) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 342, -5 }, /* (130) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 342, -5 }, /* (131) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 342, -5 }, /* (132) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 342, -4 }, /* (133) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 342, -5 }, /* (134) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 342, -5 }, /* (135) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 342, -6 }, /* (136) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 339, -1 }, /* (137) multi_create_clause ::= create_subtable_clause */ + { 339, -2 }, /* (138) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 347, -10 }, /* (139) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 341, -1 }, /* (140) multi_drop_clause ::= drop_table_clause */ + { 341, -2 }, /* (141) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 350, -2 }, /* (142) drop_table_clause ::= exists_opt full_table_name */ + { 348, 0 }, /* (143) specific_cols_opt ::= */ + { 348, -3 }, /* (144) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 335, -1 }, /* (145) full_table_name ::= table_name */ + { 335, -3 }, /* (146) full_table_name ::= db_name NK_DOT table_name */ + { 336, -1 }, /* (147) column_def_list ::= column_def */ + { 336, -3 }, /* (148) column_def_list ::= column_def_list NK_COMMA column_def */ + { 353, -2 }, /* (149) column_def ::= column_name type_name */ + { 353, -4 }, /* (150) column_def ::= column_name type_name COMMENT NK_STRING */ + { 345, -1 }, /* (151) type_name ::= BOOL */ + { 345, -1 }, /* (152) type_name ::= TINYINT */ + { 345, -1 }, /* (153) type_name ::= SMALLINT */ + { 345, -1 }, /* (154) type_name ::= INT */ + { 345, -1 }, /* (155) type_name ::= INTEGER */ + { 345, -1 }, /* (156) type_name ::= BIGINT */ + { 345, -1 }, /* (157) type_name ::= FLOAT */ + { 345, -1 }, /* (158) type_name ::= DOUBLE */ + { 345, -4 }, /* (159) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 345, -1 }, /* (160) type_name ::= TIMESTAMP */ + { 345, -4 }, /* (161) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 345, -2 }, /* (162) type_name ::= TINYINT UNSIGNED */ + { 345, -2 }, /* (163) type_name ::= SMALLINT UNSIGNED */ + { 345, -2 }, /* (164) type_name ::= INT UNSIGNED */ + { 345, -2 }, /* (165) type_name ::= BIGINT UNSIGNED */ + { 345, -1 }, /* (166) type_name ::= JSON */ + { 345, -4 }, /* (167) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 345, -1 }, /* (168) type_name ::= MEDIUMBLOB */ + { 345, -1 }, /* (169) type_name ::= BLOB */ + { 345, -4 }, /* (170) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 345, -1 }, /* (171) type_name ::= DECIMAL */ + { 345, -4 }, /* (172) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 345, -6 }, /* (173) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 337, 0 }, /* (174) tags_def_opt ::= */ + { 337, -1 }, /* (175) tags_def_opt ::= tags_def */ + { 340, -4 }, /* (176) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 338, 0 }, /* (177) table_options ::= */ + { 338, -3 }, /* (178) table_options ::= table_options COMMENT NK_STRING */ + { 338, -3 }, /* (179) table_options ::= table_options MAX_DELAY duration_list */ + { 338, -3 }, /* (180) table_options ::= table_options WATERMARK duration_list */ + { 338, -5 }, /* (181) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 338, -3 }, /* (182) table_options ::= table_options TTL NK_INTEGER */ + { 338, -5 }, /* (183) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 343, -1 }, /* (184) alter_table_options ::= alter_table_option */ + { 343, -2 }, /* (185) alter_table_options ::= alter_table_options alter_table_option */ + { 356, -2 }, /* (186) alter_table_option ::= COMMENT NK_STRING */ + { 356, -2 }, /* (187) alter_table_option ::= TTL NK_INTEGER */ + { 354, -1 }, /* (188) duration_list ::= duration_literal */ + { 354, -3 }, /* (189) duration_list ::= duration_list NK_COMMA duration_literal */ + { 355, -1 }, /* (190) rollup_func_list ::= rollup_func_name */ + { 355, -3 }, /* (191) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 358, -1 }, /* (192) rollup_func_name ::= function_name */ + { 358, -1 }, /* (193) rollup_func_name ::= FIRST */ + { 358, -1 }, /* (194) rollup_func_name ::= LAST */ + { 351, -1 }, /* (195) col_name_list ::= col_name */ + { 351, -3 }, /* (196) col_name_list ::= col_name_list NK_COMMA col_name */ + { 360, -1 }, /* (197) col_name ::= column_name */ + { 313, -2 }, /* (198) cmd ::= SHOW DNODES */ + { 313, -2 }, /* (199) cmd ::= SHOW USERS */ + { 313, -2 }, /* (200) cmd ::= SHOW DATABASES */ + { 313, -4 }, /* (201) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 313, -4 }, /* (202) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 313, -3 }, /* (203) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 313, -2 }, /* (204) cmd ::= SHOW MNODES */ + { 313, -2 }, /* (205) cmd ::= SHOW MODULES */ + { 313, -2 }, /* (206) cmd ::= SHOW QNODES */ + { 313, -2 }, /* (207) cmd ::= SHOW FUNCTIONS */ + { 313, -5 }, /* (208) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 313, -2 }, /* (209) cmd ::= SHOW STREAMS */ + { 313, -2 }, /* (210) cmd ::= SHOW ACCOUNTS */ + { 313, -2 }, /* (211) cmd ::= SHOW APPS */ + { 313, -2 }, /* (212) cmd ::= SHOW CONNECTIONS */ + { 313, -2 }, /* (213) cmd ::= SHOW LICENCES */ + { 313, -2 }, /* (214) cmd ::= SHOW GRANTS */ + { 313, -4 }, /* (215) cmd ::= SHOW CREATE DATABASE db_name */ + { 313, -4 }, /* (216) cmd ::= SHOW CREATE TABLE full_table_name */ + { 313, -4 }, /* (217) cmd ::= SHOW CREATE STABLE full_table_name */ + { 313, -2 }, /* (218) cmd ::= SHOW QUERIES */ + { 313, -2 }, /* (219) cmd ::= SHOW SCORES */ + { 313, -2 }, /* (220) cmd ::= SHOW TOPICS */ + { 313, -2 }, /* (221) cmd ::= SHOW VARIABLES */ + { 313, -3 }, /* (222) cmd ::= SHOW LOCAL VARIABLES */ + { 313, -4 }, /* (223) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 313, -2 }, /* (224) cmd ::= SHOW BNODES */ + { 313, -2 }, /* (225) cmd ::= SHOW SNODES */ + { 313, -2 }, /* (226) cmd ::= SHOW CLUSTER */ + { 313, -2 }, /* (227) cmd ::= SHOW TRANSACTIONS */ + { 313, -4 }, /* (228) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 313, -2 }, /* (229) cmd ::= SHOW CONSUMERS */ + { 313, -2 }, /* (230) cmd ::= SHOW SUBSCRIPTIONS */ + { 313, -5 }, /* (231) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 313, -3 }, /* (232) cmd ::= SHOW VNODES NK_INTEGER */ + { 313, -3 }, /* (233) cmd ::= SHOW VNODES NK_STRING */ + { 361, 0 }, /* (234) db_name_cond_opt ::= */ + { 361, -2 }, /* (235) db_name_cond_opt ::= db_name NK_DOT */ + { 362, 0 }, /* (236) like_pattern_opt ::= */ + { 362, -2 }, /* (237) like_pattern_opt ::= LIKE NK_STRING */ + { 363, -1 }, /* (238) table_name_cond ::= table_name */ + { 364, 0 }, /* (239) from_db_opt ::= */ + { 364, -2 }, /* (240) from_db_opt ::= FROM db_name */ + { 313, -8 }, /* (241) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 313, -4 }, /* (242) cmd ::= DROP INDEX exists_opt full_table_name */ + { 365, -10 }, /* (243) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 365, -12 }, /* (244) 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 */ + { 366, -1 }, /* (245) func_list ::= func */ + { 366, -3 }, /* (246) func_list ::= func_list NK_COMMA func */ + { 369, -4 }, /* (247) func ::= function_name NK_LP expression_list NK_RP */ + { 368, 0 }, /* (248) sma_stream_opt ::= */ + { 368, -3 }, /* (249) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 368, -3 }, /* (250) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 313, -6 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 313, -7 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 313, -9 }, /* (253) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 313, -7 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 313, -9 }, /* (255) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 313, -4 }, /* (256) cmd ::= DROP TOPIC exists_opt topic_name */ + { 313, -7 }, /* (257) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 313, -2 }, /* (258) cmd ::= DESC full_table_name */ + { 313, -2 }, /* (259) cmd ::= DESCRIBE full_table_name */ + { 313, -3 }, /* (260) cmd ::= RESET QUERY CACHE */ + { 313, -4 }, /* (261) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 374, 0 }, /* (262) analyze_opt ::= */ + { 374, -1 }, /* (263) analyze_opt ::= ANALYZE */ + { 375, 0 }, /* (264) explain_options ::= */ + { 375, -3 }, /* (265) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 375, -3 }, /* (266) explain_options ::= explain_options RATIO NK_FLOAT */ + { 313, -10 }, /* (267) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 313, -4 }, /* (268) cmd ::= DROP FUNCTION exists_opt function_name */ + { 376, 0 }, /* (269) agg_func_opt ::= */ + { 376, -1 }, /* (270) agg_func_opt ::= AGGREGATE */ + { 377, 0 }, /* (271) bufsize_opt ::= */ + { 377, -2 }, /* (272) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 313, -9 }, /* (273) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery */ + { 313, -4 }, /* (274) cmd ::= DROP STREAM exists_opt stream_name */ + { 370, 0 }, /* (275) stream_options ::= */ + { 370, -3 }, /* (276) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 370, -3 }, /* (277) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 370, -4 }, /* (278) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 370, -3 }, /* (279) stream_options ::= stream_options WATERMARK duration_literal */ + { 370, -4 }, /* (280) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 313, -3 }, /* (281) cmd ::= KILL CONNECTION NK_INTEGER */ + { 313, -3 }, /* (282) cmd ::= KILL QUERY NK_STRING */ + { 313, -3 }, /* (283) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 313, -2 }, /* (284) cmd ::= BALANCE VGROUP */ + { 313, -4 }, /* (285) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 313, -4 }, /* (286) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 313, -3 }, /* (287) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 379, -2 }, /* (288) dnode_list ::= DNODE NK_INTEGER */ + { 379, -3 }, /* (289) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 313, -4 }, /* (290) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 313, -1 }, /* (291) cmd ::= query_or_subquery */ + { 313, -7 }, /* (292) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 313, -4 }, /* (293) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 316, -1 }, /* (294) literal ::= NK_INTEGER */ + { 316, -1 }, /* (295) literal ::= NK_FLOAT */ + { 316, -1 }, /* (296) literal ::= NK_STRING */ + { 316, -1 }, /* (297) literal ::= NK_BOOL */ + { 316, -2 }, /* (298) literal ::= TIMESTAMP NK_STRING */ + { 316, -1 }, /* (299) literal ::= duration_literal */ + { 316, -1 }, /* (300) literal ::= NULL */ + { 316, -1 }, /* (301) literal ::= NK_QUESTION */ + { 357, -1 }, /* (302) duration_literal ::= NK_VARIABLE */ + { 381, -1 }, /* (303) signed ::= NK_INTEGER */ + { 381, -2 }, /* (304) signed ::= NK_PLUS NK_INTEGER */ + { 381, -2 }, /* (305) signed ::= NK_MINUS NK_INTEGER */ + { 381, -1 }, /* (306) signed ::= NK_FLOAT */ + { 381, -2 }, /* (307) signed ::= NK_PLUS NK_FLOAT */ + { 381, -2 }, /* (308) signed ::= NK_MINUS NK_FLOAT */ + { 346, -1 }, /* (309) signed_literal ::= signed */ + { 346, -1 }, /* (310) signed_literal ::= NK_STRING */ + { 346, -1 }, /* (311) signed_literal ::= NK_BOOL */ + { 346, -2 }, /* (312) signed_literal ::= TIMESTAMP NK_STRING */ + { 346, -1 }, /* (313) signed_literal ::= duration_literal */ + { 346, -1 }, /* (314) signed_literal ::= NULL */ + { 346, -1 }, /* (315) signed_literal ::= literal_func */ + { 346, -1 }, /* (316) signed_literal ::= NK_QUESTION */ + { 383, -1 }, /* (317) literal_list ::= signed_literal */ + { 383, -3 }, /* (318) literal_list ::= literal_list NK_COMMA signed_literal */ + { 324, -1 }, /* (319) db_name ::= NK_ID */ + { 352, -1 }, /* (320) table_name ::= NK_ID */ + { 344, -1 }, /* (321) column_name ::= NK_ID */ + { 359, -1 }, /* (322) function_name ::= NK_ID */ + { 384, -1 }, /* (323) table_alias ::= NK_ID */ + { 385, -1 }, /* (324) column_alias ::= NK_ID */ + { 318, -1 }, /* (325) user_name ::= NK_ID */ + { 371, -1 }, /* (326) topic_name ::= NK_ID */ + { 378, -1 }, /* (327) stream_name ::= NK_ID */ + { 373, -1 }, /* (328) cgroup_name ::= NK_ID */ + { 386, -1 }, /* (329) expr_or_subquery ::= expression */ + { 386, -1 }, /* (330) expr_or_subquery ::= subquery */ + { 387, -1 }, /* (331) expression ::= literal */ + { 387, -1 }, /* (332) expression ::= pseudo_column */ + { 387, -1 }, /* (333) expression ::= column_reference */ + { 387, -1 }, /* (334) expression ::= function_expression */ + { 387, -1 }, /* (335) expression ::= case_when_expression */ + { 387, -3 }, /* (336) expression ::= NK_LP expression NK_RP */ + { 387, -2 }, /* (337) expression ::= NK_PLUS expr_or_subquery */ + { 387, -2 }, /* (338) expression ::= NK_MINUS expr_or_subquery */ + { 387, -3 }, /* (339) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 387, -3 }, /* (340) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 387, -3 }, /* (341) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 387, -3 }, /* (342) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 387, -3 }, /* (343) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 387, -3 }, /* (344) expression ::= column_reference NK_ARROW NK_STRING */ + { 387, -3 }, /* (345) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 387, -3 }, /* (346) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 349, -1 }, /* (347) expression_list ::= expr_or_subquery */ + { 349, -3 }, /* (348) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 390, -1 }, /* (349) column_reference ::= column_name */ + { 390, -3 }, /* (350) column_reference ::= table_name NK_DOT column_name */ + { 389, -1 }, /* (351) pseudo_column ::= ROWTS */ + { 389, -1 }, /* (352) pseudo_column ::= TBNAME */ + { 389, -3 }, /* (353) pseudo_column ::= table_name NK_DOT TBNAME */ + { 389, -1 }, /* (354) pseudo_column ::= QSTART */ + { 389, -1 }, /* (355) pseudo_column ::= QEND */ + { 389, -1 }, /* (356) pseudo_column ::= QDURATION */ + { 389, -1 }, /* (357) pseudo_column ::= WSTART */ + { 389, -1 }, /* (358) pseudo_column ::= WEND */ + { 389, -1 }, /* (359) pseudo_column ::= WDURATION */ + { 391, -4 }, /* (360) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 391, -4 }, /* (361) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 391, -6 }, /* (362) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 391, -1 }, /* (363) function_expression ::= literal_func */ + { 382, -3 }, /* (364) literal_func ::= noarg_func NK_LP NK_RP */ + { 382, -1 }, /* (365) literal_func ::= NOW */ + { 395, -1 }, /* (366) noarg_func ::= NOW */ + { 395, -1 }, /* (367) noarg_func ::= TODAY */ + { 395, -1 }, /* (368) noarg_func ::= TIMEZONE */ + { 395, -1 }, /* (369) noarg_func ::= DATABASE */ + { 395, -1 }, /* (370) noarg_func ::= CLIENT_VERSION */ + { 395, -1 }, /* (371) noarg_func ::= SERVER_VERSION */ + { 395, -1 }, /* (372) noarg_func ::= SERVER_STATUS */ + { 395, -1 }, /* (373) noarg_func ::= CURRENT_USER */ + { 395, -1 }, /* (374) noarg_func ::= USER */ + { 393, -1 }, /* (375) star_func ::= COUNT */ + { 393, -1 }, /* (376) star_func ::= FIRST */ + { 393, -1 }, /* (377) star_func ::= LAST */ + { 393, -1 }, /* (378) star_func ::= LAST_ROW */ + { 394, -1 }, /* (379) star_func_para_list ::= NK_STAR */ + { 394, -1 }, /* (380) star_func_para_list ::= other_para_list */ + { 396, -1 }, /* (381) other_para_list ::= star_func_para */ + { 396, -3 }, /* (382) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 397, -1 }, /* (383) star_func_para ::= expr_or_subquery */ + { 397, -3 }, /* (384) star_func_para ::= table_name NK_DOT NK_STAR */ + { 392, -4 }, /* (385) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 392, -5 }, /* (386) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 398, -1 }, /* (387) when_then_list ::= when_then_expr */ + { 398, -2 }, /* (388) when_then_list ::= when_then_list when_then_expr */ + { 401, -4 }, /* (389) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 399, 0 }, /* (390) case_when_else_opt ::= */ + { 399, -2 }, /* (391) case_when_else_opt ::= ELSE common_expression */ + { 402, -3 }, /* (392) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 402, -5 }, /* (393) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 402, -6 }, /* (394) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 402, -3 }, /* (395) predicate ::= expr_or_subquery IS NULL */ + { 402, -4 }, /* (396) predicate ::= expr_or_subquery IS NOT NULL */ + { 402, -3 }, /* (397) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 403, -1 }, /* (398) compare_op ::= NK_LT */ + { 403, -1 }, /* (399) compare_op ::= NK_GT */ + { 403, -1 }, /* (400) compare_op ::= NK_LE */ + { 403, -1 }, /* (401) compare_op ::= NK_GE */ + { 403, -1 }, /* (402) compare_op ::= NK_NE */ + { 403, -1 }, /* (403) compare_op ::= NK_EQ */ + { 403, -1 }, /* (404) compare_op ::= LIKE */ + { 403, -2 }, /* (405) compare_op ::= NOT LIKE */ + { 403, -1 }, /* (406) compare_op ::= MATCH */ + { 403, -1 }, /* (407) compare_op ::= NMATCH */ + { 403, -1 }, /* (408) compare_op ::= CONTAINS */ + { 404, -1 }, /* (409) in_op ::= IN */ + { 404, -2 }, /* (410) in_op ::= NOT IN */ + { 405, -3 }, /* (411) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 406, -1 }, /* (412) boolean_value_expression ::= boolean_primary */ + { 406, -2 }, /* (413) boolean_value_expression ::= NOT boolean_primary */ + { 406, -3 }, /* (414) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 406, -3 }, /* (415) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 407, -1 }, /* (416) boolean_primary ::= predicate */ + { 407, -3 }, /* (417) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 400, -1 }, /* (418) common_expression ::= expr_or_subquery */ + { 400, -1 }, /* (419) common_expression ::= boolean_value_expression */ + { 408, 0 }, /* (420) from_clause_opt ::= */ + { 408, -2 }, /* (421) from_clause_opt ::= FROM table_reference_list */ + { 409, -1 }, /* (422) table_reference_list ::= table_reference */ + { 409, -3 }, /* (423) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 410, -1 }, /* (424) table_reference ::= table_primary */ + { 410, -1 }, /* (425) table_reference ::= joined_table */ + { 411, -2 }, /* (426) table_primary ::= table_name alias_opt */ + { 411, -4 }, /* (427) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 411, -2 }, /* (428) table_primary ::= subquery alias_opt */ + { 411, -1 }, /* (429) table_primary ::= parenthesized_joined_table */ + { 413, 0 }, /* (430) alias_opt ::= */ + { 413, -1 }, /* (431) alias_opt ::= table_alias */ + { 413, -2 }, /* (432) alias_opt ::= AS table_alias */ + { 414, -3 }, /* (433) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 414, -3 }, /* (434) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 412, -6 }, /* (435) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 415, 0 }, /* (436) join_type ::= */ + { 415, -1 }, /* (437) join_type ::= INNER */ + { 417, -12 }, /* (438) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 418, 0 }, /* (439) set_quantifier_opt ::= */ + { 418, -1 }, /* (440) set_quantifier_opt ::= DISTINCT */ + { 418, -1 }, /* (441) set_quantifier_opt ::= ALL */ + { 419, -1 }, /* (442) select_list ::= select_item */ + { 419, -3 }, /* (443) select_list ::= select_list NK_COMMA select_item */ + { 427, -1 }, /* (444) select_item ::= NK_STAR */ + { 427, -1 }, /* (445) select_item ::= common_expression */ + { 427, -2 }, /* (446) select_item ::= common_expression column_alias */ + { 427, -3 }, /* (447) select_item ::= common_expression AS column_alias */ + { 427, -3 }, /* (448) select_item ::= table_name NK_DOT NK_STAR */ + { 380, 0 }, /* (449) where_clause_opt ::= */ + { 380, -2 }, /* (450) where_clause_opt ::= WHERE search_condition */ + { 420, 0 }, /* (451) partition_by_clause_opt ::= */ + { 420, -3 }, /* (452) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 424, 0 }, /* (453) twindow_clause_opt ::= */ + { 424, -6 }, /* (454) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 424, -4 }, /* (455) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 424, -6 }, /* (456) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 424, -8 }, /* (457) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 367, 0 }, /* (458) sliding_opt ::= */ + { 367, -4 }, /* (459) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 423, 0 }, /* (460) fill_opt ::= */ + { 423, -4 }, /* (461) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 423, -6 }, /* (462) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 428, -1 }, /* (463) fill_mode ::= NONE */ + { 428, -1 }, /* (464) fill_mode ::= PREV */ + { 428, -1 }, /* (465) fill_mode ::= NULL */ + { 428, -1 }, /* (466) fill_mode ::= LINEAR */ + { 428, -1 }, /* (467) fill_mode ::= NEXT */ + { 425, 0 }, /* (468) group_by_clause_opt ::= */ + { 425, -3 }, /* (469) group_by_clause_opt ::= GROUP BY group_by_list */ + { 429, -1 }, /* (470) group_by_list ::= expr_or_subquery */ + { 429, -3 }, /* (471) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 426, 0 }, /* (472) having_clause_opt ::= */ + { 426, -2 }, /* (473) having_clause_opt ::= HAVING search_condition */ + { 421, 0 }, /* (474) range_opt ::= */ + { 421, -6 }, /* (475) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 422, 0 }, /* (476) every_opt ::= */ + { 422, -4 }, /* (477) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 430, -4 }, /* (478) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 431, -1 }, /* (479) query_simple ::= query_specification */ + { 431, -1 }, /* (480) query_simple ::= union_query_expression */ + { 435, -4 }, /* (481) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 435, -3 }, /* (482) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 436, -1 }, /* (483) query_simple_or_subquery ::= query_simple */ + { 436, -1 }, /* (484) query_simple_or_subquery ::= subquery */ + { 372, -1 }, /* (485) query_or_subquery ::= query_expression */ + { 372, -1 }, /* (486) query_or_subquery ::= subquery */ + { 432, 0 }, /* (487) order_by_clause_opt ::= */ + { 432, -3 }, /* (488) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 433, 0 }, /* (489) slimit_clause_opt ::= */ + { 433, -2 }, /* (490) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 433, -4 }, /* (491) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 433, -4 }, /* (492) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 434, 0 }, /* (493) limit_clause_opt ::= */ + { 434, -2 }, /* (494) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 434, -4 }, /* (495) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 434, -4 }, /* (496) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 388, -3 }, /* (497) subquery ::= NK_LP query_expression NK_RP */ + { 388, -3 }, /* (498) subquery ::= NK_LP subquery NK_RP */ + { 416, -1 }, /* (499) search_condition ::= common_expression */ + { 437, -1 }, /* (500) sort_specification_list ::= sort_specification */ + { 437, -3 }, /* (501) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 438, -3 }, /* (502) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 439, 0 }, /* (503) ordering_specification_opt ::= */ + { 439, -1 }, /* (504) ordering_specification_opt ::= ASC */ + { 439, -1 }, /* (505) ordering_specification_opt ::= DESC */ + { 440, 0 }, /* (506) null_ordering_opt ::= */ + { 440, -2 }, /* (507) null_ordering_opt ::= NULLS FIRST */ + { 440, -2 }, /* (508) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3429,11 +3507,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,310,&yymsp[0].minor); + yy_destructor(yypParser,314,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,311,&yymsp[0].minor); + yy_destructor(yypParser,315,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3447,20 +3525,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,310,&yymsp[-2].minor); +{ yy_destructor(yypParser,314,&yymsp[-2].minor); { } - yy_destructor(yypParser,312,&yymsp[0].minor); + yy_destructor(yypParser,316,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,313,&yymsp[0].minor); +{ yy_destructor(yypParser,317,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,311,&yymsp[-1].minor); +{ yy_destructor(yypParser,315,&yymsp[-1].minor); { } - yy_destructor(yypParser,313,&yymsp[0].minor); + yy_destructor(yypParser,317,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3474,72 +3552,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,312,&yymsp[0].minor); + yy_destructor(yypParser,316,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy0, yymsp[0].minor.yy363); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy659, &yymsp[-1].minor.yy0, yymsp[0].minor.yy341); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy149, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy149, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy149, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy659); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy363 = 1; } +{ yymsp[1].minor.yy341 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy363 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy341 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy49, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy459, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy49, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy459, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy49 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy49 = yymsp[0].minor.yy49; } - yymsp[0].minor.yy49 = yylhsminor.yy49; +{ yylhsminor.yy459 = yymsp[0].minor.yy459; } + yymsp[0].minor.yy459 = yylhsminor.yy459; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy49 = yymsp[-2].minor.yy49 | yymsp[0].minor.yy49; } - yymsp[-2].minor.yy49 = yylhsminor.yy49; +{ yylhsminor.yy459 = yymsp[-2].minor.yy459 | yymsp[0].minor.yy459; } + yymsp[-2].minor.yy459 = yylhsminor.yy459; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy49 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy49 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy459 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy149 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy149 = yylhsminor.yy149; +{ yylhsminor.yy659 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy659 = yylhsminor.yy659; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy149 = yymsp[-2].minor.yy149; } - yymsp[-2].minor.yy149 = yylhsminor.yy149; +{ yylhsminor.yy659 = yymsp[-2].minor.yy659; } + yymsp[-2].minor.yy659 = yylhsminor.yy659; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy149, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy659, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy659); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3566,21 +3644,21 @@ static YYACTIONTYPE yy_reduce( case 326: /* topic_name ::= NK_ID */ yytestcase(yyruleno==326); case 327: /* stream_name ::= NK_ID */ yytestcase(yyruleno==327); case 328: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==328); - case 364: /* noarg_func ::= NOW */ yytestcase(yyruleno==364); - case 365: /* noarg_func ::= TODAY */ yytestcase(yyruleno==365); - case 366: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==366); - case 367: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==367); - case 368: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==368); - case 369: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==369); - case 370: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==370); - case 371: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==371); - case 372: /* noarg_func ::= USER */ yytestcase(yyruleno==372); - case 373: /* star_func ::= COUNT */ yytestcase(yyruleno==373); - case 374: /* star_func ::= FIRST */ yytestcase(yyruleno==374); - case 375: /* star_func ::= LAST */ yytestcase(yyruleno==375); - case 376: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==376); -{ yylhsminor.yy149 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy149 = yylhsminor.yy149; + case 366: /* noarg_func ::= NOW */ yytestcase(yyruleno==366); + case 367: /* noarg_func ::= TODAY */ yytestcase(yyruleno==367); + case 368: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==368); + case 369: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==369); + case 370: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==370); + case 371: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==371); + case 372: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==372); + case 373: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==373); + case 374: /* noarg_func ::= USER */ yytestcase(yyruleno==374); + case 375: /* star_func ::= COUNT */ yytestcase(yyruleno==375); + case 376: /* star_func ::= FIRST */ yytestcase(yyruleno==376); + case 377: /* star_func ::= LAST */ yytestcase(yyruleno==377); + case 378: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==378); +{ yylhsminor.yy659 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy659 = yylhsminor.yy659; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3613,208 +3691,208 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy497, &yymsp[-1].minor.yy149, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy173, &yymsp[-1].minor.yy659, yymsp[0].minor.yy560); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy149, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy560); } break; case 66: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } break; case 67: /* cmd ::= TRIM DATABASE db_name */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } break; case 68: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy497 = true; } +{ yymsp[-2].minor.yy173 = true; } break; case 69: /* not_exists_opt ::= */ case 71: /* exists_opt ::= */ yytestcase(yyruleno==71); case 262: /* analyze_opt ::= */ yytestcase(yyruleno==262); case 269: /* agg_func_opt ::= */ yytestcase(yyruleno==269); - case 430: /* set_quantifier_opt ::= */ yytestcase(yyruleno==430); -{ yymsp[1].minor.yy497 = false; } + case 439: /* set_quantifier_opt ::= */ yytestcase(yyruleno==439); +{ yymsp[1].minor.yy173 = false; } break; case 70: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy497 = true; } +{ yymsp[-1].minor.yy173 = true; } break; case 72: /* db_options ::= */ -{ yymsp[1].minor.yy312 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy560 = createDefaultDatabaseOptions(pCxt); } break; case 73: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 74: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 75: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 76: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 77: /* db_options ::= db_options DURATION NK_INTEGER */ case 78: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==78); -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 80: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 81: /* db_options ::= db_options KEEP integer_list */ case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82); -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_KEEP, yymsp[0].minor.yy824); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_KEEP, yymsp[0].minor.yy334); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 83: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 85: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 86: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 87: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 88: /* db_options ::= db_options STRICT NK_STRING */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 89: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 90: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 91: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_RETENTIONS, yymsp[0].minor.yy824); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_RETENTIONS, yymsp[0].minor.yy334); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 92: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 93: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 94: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 95: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 96: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-3].minor.yy312, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-3].minor.yy560, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 97: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 98: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-3].minor.yy312, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-3].minor.yy560, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 99: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 100: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 101: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 102: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 103: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy312 = setDatabaseOption(pCxt, yymsp[-2].minor.yy312, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setDatabaseOption(pCxt, yymsp[-2].minor.yy560, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 104: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy312 = createAlterDatabaseOptions(pCxt); yylhsminor.yy312 = setAlterDatabaseOption(pCxt, yylhsminor.yy312, &yymsp[0].minor.yy405); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterDatabaseOptions(pCxt); yylhsminor.yy560 = setAlterDatabaseOption(pCxt, yylhsminor.yy560, &yymsp[0].minor.yy515); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 105: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy312 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy312, &yymsp[0].minor.yy405); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy560, &yymsp[0].minor.yy515); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 106: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy405.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 107: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy405.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 108: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy405.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 109: /* alter_db_option ::= KEEP integer_list */ case 110: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==110); -{ yymsp[-1].minor.yy405.type = DB_OPTION_KEEP; yymsp[-1].minor.yy405.pList = yymsp[0].minor.yy824; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_KEEP; yymsp[-1].minor.yy515.pList = yymsp[0].minor.yy334; } break; case 111: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy405.type = DB_OPTION_WAL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_WAL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy405.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 113: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy824 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy824 = yylhsminor.yy824; +{ yylhsminor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; case 114: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 289: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==289); -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-2].minor.yy824, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy824 = yylhsminor.yy824; +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy334 = yylhsminor.yy334; break; case 115: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy824 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy824 = yylhsminor.yy824; +{ yylhsminor.yy334 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; case 116: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-2].minor.yy824, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy824 = yylhsminor.yy824; +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy334 = yylhsminor.yy334; break; case 117: /* retention_list ::= retention */ case 137: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==137); @@ -3824,11 +3902,12 @@ static YYACTIONTYPE yy_reduce( case 195: /* col_name_list ::= col_name */ yytestcase(yyruleno==195); case 245: /* func_list ::= func */ yytestcase(yyruleno==245); case 317: /* literal_list ::= signed_literal */ yytestcase(yyruleno==317); - case 379: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==379); - case 433: /* select_list ::= select_item */ yytestcase(yyruleno==433); - case 487: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==487); -{ yylhsminor.yy824 = createNodeList(pCxt, yymsp[0].minor.yy312); } - yymsp[0].minor.yy824 = yylhsminor.yy824; + case 381: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==381); + case 387: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==387); + case 442: /* select_list ::= select_item */ yytestcase(yyruleno==442); + case 500: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==500); +{ yylhsminor.yy334 = createNodeList(pCxt, yymsp[0].minor.yy560); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; case 118: /* retention_list ::= retention_list NK_COMMA retention */ case 148: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==148); @@ -3836,253 +3915,254 @@ static YYACTIONTYPE yy_reduce( case 196: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==196); case 246: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==246); case 318: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==318); - case 380: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==380); - case 434: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==434); - case 488: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==488); -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-2].minor.yy824, yymsp[0].minor.yy312); } - yymsp[-2].minor.yy824 = yylhsminor.yy824; + case 382: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==382); + case 443: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==443); + case 501: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==501); +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } + yymsp[-2].minor.yy334 = yylhsminor.yy334; break; case 119: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy312 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 120: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 122: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==122); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy497, yymsp[-5].minor.yy312, yymsp[-3].minor.yy824, yymsp[-1].minor.yy824, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy173, yymsp[-5].minor.yy560, yymsp[-3].minor.yy334, yymsp[-1].minor.yy334, yymsp[0].minor.yy560); } break; case 121: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy824); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy334); } break; case 123: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy824); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy334); } break; case 124: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } break; case 125: /* cmd ::= ALTER TABLE alter_table_clause */ - case 291: /* cmd ::= query_expression */ yytestcase(yyruleno==291); -{ pCxt->pRootNode = yymsp[0].minor.yy312; } + case 291: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==291); +{ pCxt->pRootNode = yymsp[0].minor.yy560; } break; case 126: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy312); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy560); } break; case 127: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy312 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 128: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy312 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy149, yymsp[0].minor.yy84); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 129: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy312 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy312, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy560, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy659); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 130: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy312 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy149, yymsp[0].minor.yy84); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 131: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy312 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 132: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy312 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy149, yymsp[0].minor.yy84); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 133: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy312 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy312, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy560, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy659); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 134: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy312 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy149, yymsp[0].minor.yy84); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 135: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy312 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy312, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy560, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 136: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy312 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy312, &yymsp[-2].minor.yy149, yymsp[0].minor.yy312); } - yymsp[-5].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy560, &yymsp[-2].minor.yy659, yymsp[0].minor.yy560); } + yymsp[-5].minor.yy560 = yylhsminor.yy560; break; case 138: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 141: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==141); -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-1].minor.yy824, yymsp[0].minor.yy312); } - yymsp[-1].minor.yy824 = yylhsminor.yy824; + case 388: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==388); +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-1].minor.yy334, yymsp[0].minor.yy560); } + yymsp[-1].minor.yy334 = yylhsminor.yy334; break; case 139: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy312 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy497, yymsp[-8].minor.yy312, yymsp[-6].minor.yy312, yymsp[-5].minor.yy824, yymsp[-2].minor.yy824, yymsp[0].minor.yy312); } - yymsp[-9].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy173, yymsp[-8].minor.yy560, yymsp[-6].minor.yy560, yymsp[-5].minor.yy334, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } + yymsp[-9].minor.yy560 = yylhsminor.yy560; break; case 142: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy312 = createDropTableClause(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy312); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createDropTableClause(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 143: /* specific_cols_opt ::= */ case 174: /* tags_def_opt ::= */ yytestcase(yyruleno==174); - case 442: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==442); - case 459: /* group_by_clause_opt ::= */ yytestcase(yyruleno==459); - case 475: /* order_by_clause_opt ::= */ yytestcase(yyruleno==475); -{ yymsp[1].minor.yy824 = NULL; } + case 451: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==451); + case 468: /* group_by_clause_opt ::= */ yytestcase(yyruleno==468); + case 487: /* order_by_clause_opt ::= */ yytestcase(yyruleno==487); +{ yymsp[1].minor.yy334 = NULL; } break; case 144: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy824 = yymsp[-1].minor.yy824; } +{ yymsp[-2].minor.yy334 = yymsp[-1].minor.yy334; } break; case 145: /* full_table_name ::= table_name */ -{ yylhsminor.yy312 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy149, NULL); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy659, NULL); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 146: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy312 = createRealTableNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149, NULL); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRealTableNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, NULL); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 149: /* column_def ::= column_name type_name */ -{ yylhsminor.yy312 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy149, yymsp[0].minor.yy84, NULL); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy574, NULL); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 150: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy312 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-2].minor.yy84, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-2].minor.yy574, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 151: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 152: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 153: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 154: /* type_name ::= INT */ case 155: /* type_name ::= INTEGER */ yytestcase(yyruleno==155); -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_INT); } break; case 156: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 157: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 158: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 159: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy84 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 160: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 161: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy84 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 162: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy84 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 163: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy84 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 164: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy84 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 165: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy84 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy574 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 166: /* type_name ::= JSON */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 167: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy84 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 168: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 169: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 170: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy84 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy574 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 171: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy84 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 172: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy84 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 173: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy84 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 175: /* tags_def_opt ::= tags_def */ - case 378: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==378); -{ yylhsminor.yy824 = yymsp[0].minor.yy824; } - yymsp[0].minor.yy824 = yylhsminor.yy824; + case 380: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==380); +{ yylhsminor.yy334 = yymsp[0].minor.yy334; } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; case 176: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy824 = yymsp[-1].minor.yy824; } +{ yymsp[-3].minor.yy334 = yymsp[-1].minor.yy334; } break; case 177: /* table_options ::= */ -{ yymsp[1].minor.yy312 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy560 = createDefaultTableOptions(pCxt); } break; case 178: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-2].minor.yy312, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 179: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-2].minor.yy312, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy824); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy334); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 180: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-2].minor.yy312, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy824); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy334); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 181: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-4].minor.yy312, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy824); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-4].minor.yy560, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy334); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 182: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-2].minor.yy312, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-2].minor.yy560, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 183: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-4].minor.yy312, TABLE_OPTION_SMA, yymsp[-1].minor.yy824); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-4].minor.yy560, TABLE_OPTION_SMA, yymsp[-1].minor.yy334); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; case 184: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy312 = createAlterTableOptions(pCxt); yylhsminor.yy312 = setTableOption(pCxt, yylhsminor.yy312, yymsp[0].minor.yy405.type, &yymsp[0].minor.yy405.val); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createAlterTableOptions(pCxt); yylhsminor.yy560 = setTableOption(pCxt, yylhsminor.yy560, yymsp[0].minor.yy515.type, &yymsp[0].minor.yy515.val); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 185: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy312 = setTableOption(pCxt, yymsp[-1].minor.yy312, yymsp[0].minor.yy405.type, &yymsp[0].minor.yy405.val); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setTableOption(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy515.type, &yymsp[0].minor.yy515.val); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 186: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy405.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 187: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy405.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy405.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy515.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy515.val = yymsp[0].minor.yy0; } break; case 188: /* duration_list ::= duration_literal */ - case 345: /* expression_list ::= expression */ yytestcase(yyruleno==345); -{ yylhsminor.yy824 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy312)); } - yymsp[0].minor.yy824 = yylhsminor.yy824; + case 347: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==347); +{ yylhsminor.yy334 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; case 189: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 346: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==346); -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-2].minor.yy824, releaseRawExprNode(pCxt, yymsp[0].minor.yy312)); } - yymsp[-2].minor.yy824 = yylhsminor.yy824; + case 348: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==348); +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } + yymsp[-2].minor.yy334 = yylhsminor.yy334; break; case 192: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy312 = createFunctionNode(pCxt, &yymsp[0].minor.yy149, NULL); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[0].minor.yy659, NULL); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 193: /* rollup_func_name ::= FIRST */ case 194: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==194); -{ yylhsminor.yy312 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 197: /* col_name ::= column_name */ -{ yylhsminor.yy312 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy149); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 198: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -4094,13 +4174,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 201: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy312, yymsp[0].minor.yy312, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, OP_TYPE_LIKE); } break; case 202: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy312, yymsp[0].minor.yy312, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, OP_TYPE_LIKE); } break; case 203: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy312, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy560, NULL, OP_TYPE_LIKE); } break; case 204: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -4115,7 +4195,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 208: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy312, yymsp[-1].minor.yy312, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy560, yymsp[-1].minor.yy560, OP_TYPE_EQUAL); } break; case 209: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -4134,13 +4214,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; case 215: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } break; case 216: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy560); } break; case 217: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy560); } break; case 218: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -4173,7 +4253,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 228: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy560); } break; case 229: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -4182,7 +4262,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 231: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy312, yymsp[-1].minor.yy312, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy560, yymsp[-1].minor.yy560, OP_TYPE_EQUAL); } break; case 232: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -4192,144 +4272,145 @@ static YYACTIONTYPE yy_reduce( break; case 234: /* db_name_cond_opt ::= */ case 239: /* from_db_opt ::= */ yytestcase(yyruleno==239); -{ yymsp[1].minor.yy312 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy560 = createDefaultDatabaseCondValue(pCxt); } break; case 235: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy149); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy659); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 236: /* like_pattern_opt ::= */ - case 411: /* from_clause_opt ::= */ yytestcase(yyruleno==411); - case 440: /* where_clause_opt ::= */ yytestcase(yyruleno==440); - case 444: /* twindow_clause_opt ::= */ yytestcase(yyruleno==444); - case 449: /* sliding_opt ::= */ yytestcase(yyruleno==449); - case 451: /* fill_opt ::= */ yytestcase(yyruleno==451); - case 463: /* having_clause_opt ::= */ yytestcase(yyruleno==463); - case 465: /* range_opt ::= */ yytestcase(yyruleno==465); - case 467: /* every_opt ::= */ yytestcase(yyruleno==467); - case 477: /* slimit_clause_opt ::= */ yytestcase(yyruleno==477); - case 481: /* limit_clause_opt ::= */ yytestcase(yyruleno==481); -{ yymsp[1].minor.yy312 = NULL; } + case 390: /* case_when_else_opt ::= */ yytestcase(yyruleno==390); + case 420: /* from_clause_opt ::= */ yytestcase(yyruleno==420); + case 449: /* where_clause_opt ::= */ yytestcase(yyruleno==449); + case 453: /* twindow_clause_opt ::= */ yytestcase(yyruleno==453); + case 458: /* sliding_opt ::= */ yytestcase(yyruleno==458); + case 460: /* fill_opt ::= */ yytestcase(yyruleno==460); + case 472: /* having_clause_opt ::= */ yytestcase(yyruleno==472); + case 474: /* range_opt ::= */ yytestcase(yyruleno==474); + case 476: /* every_opt ::= */ yytestcase(yyruleno==476); + case 489: /* slimit_clause_opt ::= */ yytestcase(yyruleno==489); + case 493: /* limit_clause_opt ::= */ yytestcase(yyruleno==493); +{ yymsp[1].minor.yy560 = NULL; } break; case 237: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 238: /* table_name_cond ::= table_name */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy149); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy659); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 240: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy149); } +{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy659); } break; case 241: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy497, yymsp[-3].minor.yy312, yymsp[-1].minor.yy312, NULL, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy173, yymsp[-3].minor.yy560, yymsp[-1].minor.yy560, NULL, yymsp[0].minor.yy560); } break; case 242: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy497, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy560); } break; case 243: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy312 = createIndexOption(pCxt, yymsp[-7].minor.yy824, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), NULL, yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } +{ yymsp[-9].minor.yy560 = createIndexOption(pCxt, yymsp[-7].minor.yy334, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; case 244: /* 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.yy312 = createIndexOption(pCxt, yymsp[-9].minor.yy824, releaseRawExprNode(pCxt, yymsp[-5].minor.yy312), releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } +{ yymsp[-11].minor.yy560 = createIndexOption(pCxt, yymsp[-9].minor.yy334, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; case 247: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy312 = createFunctionNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy824); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy334); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 248: /* sma_stream_opt ::= */ case 275: /* stream_options ::= */ yytestcase(yyruleno==275); -{ yymsp[1].minor.yy312 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy560 = createStreamOptions(pCxt); } break; case 249: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ case 279: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==279); -{ ((SStreamOptions*)yymsp[-2].minor.yy312)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy312); yylhsminor.yy312 = yymsp[-2].minor.yy312; } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-2].minor.yy560)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-2].minor.yy560; } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 250: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy312)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy312); yylhsminor.yy312 = yymsp[-2].minor.yy312; } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-2].minor.yy560)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-2].minor.yy560; } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, yymsp[0].minor.yy312); } + case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy659, yymsp[0].minor.yy560); } break; case 252: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy497, &yymsp[-3].minor.yy149, &yymsp[0].minor.yy149, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy173, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy659, false); } break; case 253: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy497, &yymsp[-5].minor.yy149, &yymsp[0].minor.yy149, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, &yymsp[0].minor.yy659, true); } break; case 254: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy497, &yymsp[-3].minor.yy149, yymsp[0].minor.yy312, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy173, &yymsp[-3].minor.yy659, yymsp[0].minor.yy560, false); } break; case 255: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy497, &yymsp[-5].minor.yy149, yymsp[0].minor.yy312, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, yymsp[0].minor.yy560, true); } break; case 256: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } break; case 257: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } break; case 258: /* cmd ::= DESC full_table_name */ case 259: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==259); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy560); } break; case 260: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 261: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy497, yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } + case 261: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy173, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; case 263: /* analyze_opt ::= ANALYZE */ case 270: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==270); - case 431: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==431); -{ yymsp[0].minor.yy497 = true; } + case 440: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==440); +{ yymsp[0].minor.yy173 = true; } break; case 264: /* explain_options ::= */ -{ yymsp[1].minor.yy312 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy560 = createDefaultExplainOptions(pCxt); } break; case 265: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy312 = setExplainVerbose(pCxt, yymsp[-2].minor.yy312, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setExplainVerbose(pCxt, yymsp[-2].minor.yy560, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 266: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy312 = setExplainRatio(pCxt, yymsp[-2].minor.yy312, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = setExplainRatio(pCxt, yymsp[-2].minor.yy560, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 267: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy497, yymsp[-8].minor.yy497, &yymsp[-5].minor.yy149, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy84, yymsp[0].minor.yy160); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy173, yymsp[-8].minor.yy173, &yymsp[-5].minor.yy659, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy574, yymsp[0].minor.yy676); } break; case 268: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } break; case 271: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy160 = 0; } +{ yymsp[1].minor.yy676 = 0; } break; case 272: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy160 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 273: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy497, &yymsp[-5].minor.yy149, yymsp[-2].minor.yy312, yymsp[-4].minor.yy312, yymsp[0].minor.yy312); } + case 273: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy659, yymsp[-2].minor.yy560, yymsp[-4].minor.yy560, yymsp[0].minor.yy560); } break; case 274: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy497, &yymsp[0].minor.yy149); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy659); } break; case 276: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy312)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy312 = yymsp[-2].minor.yy312; } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-2].minor.yy560)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy560 = yymsp[-2].minor.yy560; } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 277: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy312)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy312 = yymsp[-2].minor.yy312; } - yymsp[-2].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-2].minor.yy560)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy560 = yymsp[-2].minor.yy560; } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; case 278: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy312)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy312)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy312); yylhsminor.yy312 = yymsp[-3].minor.yy312; } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-3].minor.yy560)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy560)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); yylhsminor.yy560 = yymsp[-3].minor.yy560; } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 280: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy312)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy312 = yymsp[-3].minor.yy312; } - yymsp[-3].minor.yy312 = yylhsminor.yy312; +{ ((SStreamOptions*)yymsp[-3].minor.yy560)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy560 = yymsp[-3].minor.yy560; } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; case 281: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -4347,552 +4428,566 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 286: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy824); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy334); } break; case 287: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 288: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy824 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy334 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 290: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; - case 292: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy312, yymsp[-2].minor.yy824, yymsp[0].minor.yy312); } + case 292: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy560, yymsp[-2].minor.yy334, yymsp[0].minor.yy560); } break; - case 293: /* cmd ::= INSERT INTO full_table_name query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy312, NULL, yymsp[0].minor.yy312); } + case 293: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy560, NULL, yymsp[0].minor.yy560); } break; case 294: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 295: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 296: /* literal ::= NK_STRING */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 297: /* literal ::= NK_BOOL */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 298: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 299: /* literal ::= duration_literal */ case 309: /* signed_literal ::= signed */ yytestcase(yyruleno==309); - case 329: /* expression ::= literal */ yytestcase(yyruleno==329); - case 330: /* expression ::= pseudo_column */ yytestcase(yyruleno==330); - case 331: /* expression ::= column_reference */ yytestcase(yyruleno==331); - case 332: /* expression ::= function_expression */ yytestcase(yyruleno==332); - case 333: /* expression ::= subquery */ yytestcase(yyruleno==333); - case 361: /* function_expression ::= literal_func */ yytestcase(yyruleno==361); - case 403: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==403); - case 407: /* boolean_primary ::= predicate */ yytestcase(yyruleno==407); - case 409: /* common_expression ::= expression */ yytestcase(yyruleno==409); - case 410: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==410); - case 413: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==413); - case 415: /* table_reference ::= table_primary */ yytestcase(yyruleno==415); - case 416: /* table_reference ::= joined_table */ yytestcase(yyruleno==416); - case 420: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==420); - case 470: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==470); - case 473: /* query_primary ::= query_specification */ yytestcase(yyruleno==473); -{ yylhsminor.yy312 = yymsp[0].minor.yy312; } - yymsp[0].minor.yy312 = yylhsminor.yy312; + case 329: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==329); + case 330: /* expr_or_subquery ::= subquery */ yytestcase(yyruleno==330); + case 331: /* expression ::= literal */ yytestcase(yyruleno==331); + case 332: /* expression ::= pseudo_column */ yytestcase(yyruleno==332); + case 333: /* expression ::= column_reference */ yytestcase(yyruleno==333); + case 334: /* expression ::= function_expression */ yytestcase(yyruleno==334); + case 335: /* expression ::= case_when_expression */ yytestcase(yyruleno==335); + case 363: /* function_expression ::= literal_func */ yytestcase(yyruleno==363); + case 412: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==412); + case 416: /* boolean_primary ::= predicate */ yytestcase(yyruleno==416); + case 418: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==418); + case 419: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==419); + case 422: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==422); + case 424: /* table_reference ::= table_primary */ yytestcase(yyruleno==424); + case 425: /* table_reference ::= joined_table */ yytestcase(yyruleno==425); + case 429: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==429); + case 479: /* query_simple ::= query_specification */ yytestcase(yyruleno==479); + case 480: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==480); + case 483: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==483); + case 485: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==485); +{ yylhsminor.yy560 = yymsp[0].minor.yy560; } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 300: /* literal ::= NULL */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 301: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 302: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 303: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 304: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; case 305: /* 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.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 306: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 307: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; case 308: /* 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.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; case 310: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 311: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 312: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 313: /* signed_literal ::= duration_literal */ case 315: /* signed_literal ::= literal_func */ yytestcase(yyruleno==315); - case 381: /* star_func_para ::= expression */ yytestcase(yyruleno==381); - case 436: /* select_item ::= common_expression */ yytestcase(yyruleno==436); - case 486: /* search_condition ::= common_expression */ yytestcase(yyruleno==486); -{ yylhsminor.yy312 = releaseRawExprNode(pCxt, yymsp[0].minor.yy312); } - yymsp[0].minor.yy312 = yylhsminor.yy312; + case 383: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==383); + case 445: /* select_item ::= common_expression */ yytestcase(yyruleno==445); + case 484: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==484); + case 486: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==486); + case 499: /* search_condition ::= common_expression */ yytestcase(yyruleno==499); +{ yylhsminor.yy560 = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 314: /* signed_literal ::= NULL */ -{ yylhsminor.yy312 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; case 316: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy312 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; +{ yylhsminor.yy560 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; - case 334: /* expression ::= NK_LP expression NK_RP */ - case 408: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==408); -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy312)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 336: /* expression ::= NK_LP expression NK_RP */ + case 417: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==417); + case 498: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==498); +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 335: /* expression ::= NK_PLUS expression */ + case 337: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy312)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 336: /* expression ::= NK_MINUS expression */ + case 338: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy312), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy560), NULL)); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 337: /* expression ::= expression NK_PLUS expression */ + case 339: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 338: /* expression ::= expression NK_MINUS expression */ + case 340: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 339: /* expression ::= expression NK_STAR expression */ + case 341: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 340: /* expression ::= expression NK_SLASH expression */ + case 342: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 341: /* expression ::= expression NK_REM expression */ + case 343: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 342: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 344: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 343: /* expression ::= expression NK_BITAND expression */ + case 345: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 344: /* expression ::= expression NK_BITOR expression */ + case 346: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 347: /* column_reference ::= column_name */ -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy149, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy149)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; + case 349: /* column_reference ::= column_name */ +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy659, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; - case 348: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149, createColumnNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 350: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659)); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 349: /* pseudo_column ::= ROWTS */ - case 350: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==350); - case 352: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==352); - case 353: /* pseudo_column ::= QEND */ yytestcase(yyruleno==353); - case 354: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==354); - case 355: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==355); - case 356: /* pseudo_column ::= WEND */ yytestcase(yyruleno==356); - case 357: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==357); - case 363: /* literal_func ::= NOW */ yytestcase(yyruleno==363); -{ yylhsminor.yy312 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy312 = yylhsminor.yy312; + case 351: /* pseudo_column ::= ROWTS */ + case 352: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==352); + case 354: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==354); + case 355: /* pseudo_column ::= QEND */ yytestcase(yyruleno==355); + case 356: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==356); + case 357: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==357); + case 358: /* pseudo_column ::= WEND */ yytestcase(yyruleno==358); + case 359: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==359); + case 365: /* literal_func ::= NOW */ yytestcase(yyruleno==365); +{ yylhsminor.yy560 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; - case 351: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy149)))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 353: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy659)))); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 358: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 359: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==359); -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy149, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy824)); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + case 360: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 361: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==361); +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy334)); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; - case 360: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), yymsp[-1].minor.yy84)); } - yymsp[-5].minor.yy312 = yylhsminor.yy312; + case 362: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy574)); } + yymsp[-5].minor.yy560 = yylhsminor.yy560; break; - case 362: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy149, NULL)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 364: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy659, NULL)); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 377: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy824 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy824 = yylhsminor.yy824; + case 379: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy334 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; - case 382: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 439: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==439); -{ yylhsminor.yy312 = createColumnNode(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 384: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 448: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==448); +{ yylhsminor.yy560 = createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 383: /* predicate ::= expression compare_op expression */ - case 388: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==388); + case 385: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy334, yymsp[-1].minor.yy560)); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; + break; + case 386: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-2].minor.yy334, yymsp[-1].minor.yy560)); } + yymsp[-4].minor.yy560 = yylhsminor.yy560; + break; + case 389: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy560 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560)); } + break; + case 391: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy560 = releaseRawExprNode(pCxt, yymsp[0].minor.yy560); } + break; + case 392: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 397: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==397); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy320, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy128, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 384: /* predicate ::= expression BETWEEN expression AND expression */ + case 393: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy312), releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy560), releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-4].minor.yy312 = yylhsminor.yy312; + yymsp[-4].minor.yy560 = yylhsminor.yy560; break; - case 385: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 394: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy312), releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-5].minor.yy312 = yylhsminor.yy312; + yymsp[-5].minor.yy560 = yylhsminor.yy560; break; - case 386: /* predicate ::= expression IS NULL */ + case 395: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), NULL)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 387: /* predicate ::= expression IS NOT NULL */ + case 396: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL)); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; - case 389: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy320 = OP_TYPE_LOWER_THAN; } + case 398: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy128 = OP_TYPE_LOWER_THAN; } break; - case 390: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy320 = OP_TYPE_GREATER_THAN; } + case 399: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy128 = OP_TYPE_GREATER_THAN; } break; - case 391: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy320 = OP_TYPE_LOWER_EQUAL; } + case 400: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy128 = OP_TYPE_LOWER_EQUAL; } break; - case 392: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy320 = OP_TYPE_GREATER_EQUAL; } + case 401: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy128 = OP_TYPE_GREATER_EQUAL; } break; - case 393: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy320 = OP_TYPE_NOT_EQUAL; } + case 402: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy128 = OP_TYPE_NOT_EQUAL; } break; - case 394: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy320 = OP_TYPE_EQUAL; } + case 403: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy128 = OP_TYPE_EQUAL; } break; - case 395: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy320 = OP_TYPE_LIKE; } + case 404: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy128 = OP_TYPE_LIKE; } break; - case 396: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy320 = OP_TYPE_NOT_LIKE; } + case 405: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy128 = OP_TYPE_NOT_LIKE; } break; - case 397: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy320 = OP_TYPE_MATCH; } + case 406: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy128 = OP_TYPE_MATCH; } break; - case 398: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy320 = OP_TYPE_NMATCH; } + case 407: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy128 = OP_TYPE_NMATCH; } break; - case 399: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy320 = OP_TYPE_JSON_CONTAINS; } + case 408: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy128 = OP_TYPE_JSON_CONTAINS; } break; - case 400: /* in_op ::= IN */ -{ yymsp[0].minor.yy320 = OP_TYPE_IN; } + case 409: /* in_op ::= IN */ +{ yymsp[0].minor.yy128 = OP_TYPE_IN; } break; - case 401: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy320 = OP_TYPE_NOT_IN; } + case 410: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy128 = OP_TYPE_NOT_IN; } break; - case 402: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy824)); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 411: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 404: /* boolean_value_expression ::= NOT boolean_primary */ + case 413: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy312), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy560), NULL)); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 405: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 414: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 406: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 415: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy312); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy312); - yylhsminor.yy312 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy560); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy560); + yylhsminor.yy560 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 412: /* from_clause_opt ::= FROM table_reference_list */ - case 441: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==441); - case 464: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==464); -{ yymsp[-1].minor.yy312 = yymsp[0].minor.yy312; } + case 421: /* from_clause_opt ::= FROM table_reference_list */ + case 450: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==450); + case 473: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==473); +{ yymsp[-1].minor.yy560 = yymsp[0].minor.yy560; } break; - case 414: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy312 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy312, yymsp[0].minor.yy312, NULL); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 423: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy560 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy560, yymsp[0].minor.yy560, NULL); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 417: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy312 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + case 426: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy560 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 418: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy312 = createRealTableNode(pCxt, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy149, &yymsp[0].minor.yy149); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + case 427: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy560 = createRealTableNode(pCxt, &yymsp[-3].minor.yy659, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; - case 419: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy312 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy312), &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + case 428: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy560 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560), &yymsp[0].minor.yy659); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 421: /* alias_opt ::= */ -{ yymsp[1].minor.yy149 = nil_token; } + case 430: /* alias_opt ::= */ +{ yymsp[1].minor.yy659 = nil_token; } break; - case 422: /* alias_opt ::= table_alias */ -{ yylhsminor.yy149 = yymsp[0].minor.yy149; } - yymsp[0].minor.yy149 = yylhsminor.yy149; + case 431: /* alias_opt ::= table_alias */ +{ yylhsminor.yy659 = yymsp[0].minor.yy659; } + yymsp[0].minor.yy659 = yylhsminor.yy659; break; - case 423: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy149 = yymsp[0].minor.yy149; } + case 432: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy659 = yymsp[0].minor.yy659; } break; - case 424: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 425: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==425); -{ yymsp[-2].minor.yy312 = yymsp[-1].minor.yy312; } + case 433: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 434: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==434); +{ yymsp[-2].minor.yy560 = yymsp[-1].minor.yy560; } break; - case 426: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy312 = createJoinTableNode(pCxt, yymsp[-4].minor.yy832, yymsp[-5].minor.yy312, yymsp[-2].minor.yy312, yymsp[0].minor.yy312); } - yymsp[-5].minor.yy312 = yylhsminor.yy312; + case 435: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy560 = createJoinTableNode(pCxt, yymsp[-4].minor.yy540, yymsp[-5].minor.yy560, yymsp[-2].minor.yy560, yymsp[0].minor.yy560); } + yymsp[-5].minor.yy560 = yylhsminor.yy560; break; - case 427: /* join_type ::= */ -{ yymsp[1].minor.yy832 = JOIN_TYPE_INNER; } + case 436: /* join_type ::= */ +{ yymsp[1].minor.yy540 = JOIN_TYPE_INNER; } break; - case 428: /* join_type ::= INNER */ -{ yymsp[0].minor.yy832 = JOIN_TYPE_INNER; } + case 437: /* join_type ::= INNER */ +{ yymsp[0].minor.yy540 = JOIN_TYPE_INNER; } break; - case 429: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 438: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy312 = createSelectStmt(pCxt, yymsp[-10].minor.yy497, yymsp[-9].minor.yy824, yymsp[-8].minor.yy312); - yymsp[-11].minor.yy312 = addWhereClause(pCxt, yymsp[-11].minor.yy312, yymsp[-7].minor.yy312); - yymsp[-11].minor.yy312 = addPartitionByClause(pCxt, yymsp[-11].minor.yy312, yymsp[-6].minor.yy824); - yymsp[-11].minor.yy312 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy312, yymsp[-2].minor.yy312); - yymsp[-11].minor.yy312 = addGroupByClause(pCxt, yymsp[-11].minor.yy312, yymsp[-1].minor.yy824); - yymsp[-11].minor.yy312 = addHavingClause(pCxt, yymsp[-11].minor.yy312, yymsp[0].minor.yy312); - yymsp[-11].minor.yy312 = addRangeClause(pCxt, yymsp[-11].minor.yy312, yymsp[-5].minor.yy312); - yymsp[-11].minor.yy312 = addEveryClause(pCxt, yymsp[-11].minor.yy312, yymsp[-4].minor.yy312); - yymsp[-11].minor.yy312 = addFillClause(pCxt, yymsp[-11].minor.yy312, yymsp[-3].minor.yy312); + yymsp[-11].minor.yy560 = createSelectStmt(pCxt, yymsp[-10].minor.yy173, yymsp[-9].minor.yy334, yymsp[-8].minor.yy560); + yymsp[-11].minor.yy560 = addWhereClause(pCxt, yymsp[-11].minor.yy560, yymsp[-7].minor.yy560); + yymsp[-11].minor.yy560 = addPartitionByClause(pCxt, yymsp[-11].minor.yy560, yymsp[-6].minor.yy334); + yymsp[-11].minor.yy560 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy560, yymsp[-2].minor.yy560); + yymsp[-11].minor.yy560 = addGroupByClause(pCxt, yymsp[-11].minor.yy560, yymsp[-1].minor.yy334); + yymsp[-11].minor.yy560 = addHavingClause(pCxt, yymsp[-11].minor.yy560, yymsp[0].minor.yy560); + yymsp[-11].minor.yy560 = addRangeClause(pCxt, yymsp[-11].minor.yy560, yymsp[-5].minor.yy560); + yymsp[-11].minor.yy560 = addEveryClause(pCxt, yymsp[-11].minor.yy560, yymsp[-4].minor.yy560); + yymsp[-11].minor.yy560 = addFillClause(pCxt, yymsp[-11].minor.yy560, yymsp[-3].minor.yy560); } break; - case 432: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy497 = false; } + case 441: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy173 = false; } break; - case 435: /* select_item ::= NK_STAR */ -{ yylhsminor.yy312 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy312 = yylhsminor.yy312; + case 444: /* select_item ::= NK_STAR */ +{ yylhsminor.yy560 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy560 = yylhsminor.yy560; break; - case 437: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy312 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy312), &yymsp[0].minor.yy149); } - yymsp[-1].minor.yy312 = yylhsminor.yy312; + case 446: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy560 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560), &yymsp[0].minor.yy659); } + yymsp[-1].minor.yy560 = yylhsminor.yy560; break; - case 438: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy312 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), &yymsp[0].minor.yy149); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 447: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy560 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), &yymsp[0].minor.yy659); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 443: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 460: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==460); - case 476: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==476); -{ yymsp[-2].minor.yy824 = yymsp[0].minor.yy824; } + case 452: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 469: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==469); + case 488: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==488); +{ yymsp[-2].minor.yy334 = yymsp[0].minor.yy334; } break; - case 445: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy312 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), releaseRawExprNode(pCxt, yymsp[-1].minor.yy312)); } + case 454: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy560 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } break; - case 446: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy312 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy312)); } + case 455: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy560 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } break; - case 447: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy312 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), NULL, yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } + case 456: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy560 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), NULL, yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; - case 448: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy312 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy312), releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), yymsp[-1].minor.yy312, yymsp[0].minor.yy312); } + case 457: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy560 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy560), releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), yymsp[-1].minor.yy560, yymsp[0].minor.yy560); } break; - case 450: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 468: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==468); -{ yymsp[-3].minor.yy312 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy312); } + case 459: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 477: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==477); +{ yymsp[-3].minor.yy560 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy560); } break; - case 452: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy312 = createFillNode(pCxt, yymsp[-1].minor.yy134, NULL); } + case 461: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy560 = createFillNode(pCxt, yymsp[-1].minor.yy18, NULL); } break; - case 453: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy312 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy824)); } + case 462: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy560 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } break; - case 454: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy134 = FILL_MODE_NONE; } + case 463: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy18 = FILL_MODE_NONE; } break; - case 455: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy134 = FILL_MODE_PREV; } + case 464: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy18 = FILL_MODE_PREV; } break; - case 456: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy134 = FILL_MODE_NULL; } + case 465: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy18 = FILL_MODE_NULL; } break; - case 457: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy134 = FILL_MODE_LINEAR; } + case 466: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy18 = FILL_MODE_LINEAR; } break; - case 458: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy134 = FILL_MODE_NEXT; } + case 467: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy18 = FILL_MODE_NEXT; } break; - case 461: /* group_by_list ::= expression */ -{ yylhsminor.yy824 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); } - yymsp[0].minor.yy824 = yylhsminor.yy824; + case 470: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy334 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } + yymsp[0].minor.yy334 = yylhsminor.yy334; break; - case 462: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy824 = addNodeToList(pCxt, yymsp[-2].minor.yy824, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy312))); } - yymsp[-2].minor.yy824 = yylhsminor.yy824; + case 471: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy560))); } + yymsp[-2].minor.yy334 = yylhsminor.yy334; break; - case 466: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy312 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy312), releaseRawExprNode(pCxt, yymsp[-1].minor.yy312)); } + case 475: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy560 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy560), releaseRawExprNode(pCxt, yymsp[-1].minor.yy560)); } break; - case 469: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ -{ - yylhsminor.yy312 = addOrderByClause(pCxt, yymsp[-3].minor.yy312, yymsp[-2].minor.yy824); - yylhsminor.yy312 = addSlimitClause(pCxt, yylhsminor.yy312, yymsp[-1].minor.yy312); - yylhsminor.yy312 = addLimitClause(pCxt, yylhsminor.yy312, yymsp[0].minor.yy312); + case 478: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +{ + yylhsminor.yy560 = addOrderByClause(pCxt, yymsp[-3].minor.yy560, yymsp[-2].minor.yy334); + yylhsminor.yy560 = addSlimitClause(pCxt, yylhsminor.yy560, yymsp[-1].minor.yy560); + yylhsminor.yy560 = addLimitClause(pCxt, yylhsminor.yy560, yymsp[0].minor.yy560); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; - case 471: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy312 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy312, yymsp[0].minor.yy312); } - yymsp[-3].minor.yy312 = yylhsminor.yy312; + case 481: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy560 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy560, yymsp[0].minor.yy560); } + yymsp[-3].minor.yy560 = yylhsminor.yy560; break; - case 472: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy312 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy312, yymsp[0].minor.yy312); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 482: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy560 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy560, yymsp[0].minor.yy560); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 474: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ - yymsp[-5].minor.yy312 = addOrderByClause(pCxt, yymsp[-4].minor.yy312, yymsp[-3].minor.yy824); - yymsp[-5].minor.yy312 = addSlimitClause(pCxt, yymsp[-5].minor.yy312, yymsp[-2].minor.yy312); - yymsp[-5].minor.yy312 = addLimitClause(pCxt, yymsp[-5].minor.yy312, yymsp[-1].minor.yy312); - } + case 490: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 494: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==494); +{ yymsp[-1].minor.yy560 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 478: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 482: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==482); -{ yymsp[-1].minor.yy312 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 491: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 495: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==495); +{ yymsp[-3].minor.yy560 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 479: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 483: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==483); -{ yymsp[-3].minor.yy312 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 492: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 496: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==496); +{ yymsp[-3].minor.yy560 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 480: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 484: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==484); -{ yymsp[-3].minor.yy312 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 497: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy560 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy560); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 485: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy312 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy312); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 502: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy560 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy560), yymsp[-1].minor.yy596, yymsp[0].minor.yy487); } + yymsp[-2].minor.yy560 = yylhsminor.yy560; break; - case 489: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy312 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy312), yymsp[-1].minor.yy158, yymsp[0].minor.yy417); } - yymsp[-2].minor.yy312 = yylhsminor.yy312; + case 503: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy596 = ORDER_ASC; } break; - case 490: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy158 = ORDER_ASC; } + case 504: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy596 = ORDER_ASC; } break; - case 491: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy158 = ORDER_ASC; } + case 505: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy596 = ORDER_DESC; } break; - case 492: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy158 = ORDER_DESC; } + case 506: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } break; - case 493: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy417 = NULL_ORDER_DEFAULT; } + case 507: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } break; - case 494: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_FIRST; } - break; - case 495: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_LAST; } + case 508: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 716dd7ffc0..79a7038401 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -60,6 +60,9 @@ TEST_F(ParserSelectTest, expression) { run("SELECT ts > 0, c1 between 10 and 20 and c2 = 'qaz' FROM t1"); run("SELECT c1 | 10, c2 & 20, c4 | c5 FROM t1"); + + run("SELECT CASE WHEN ts > '2020-1-1 10:10:10' THEN c1 + 10 ELSE c1 - 10 END FROM t1 " + "WHERE CASE c1 WHEN c3 + 20 THEN c3 - 1 WHEN c3 + 10 THEN c3 - 2 ELSE 10 END > 0"); } TEST_F(ParserSelectTest, condition) { @@ -312,6 +315,8 @@ TEST_F(ParserSelectTest, subquery) { run("SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)"); run("SELECT ts FROM (SELECT t1.ts FROM st1s1 t1)"); + + run("(((SELECT t1.ts FROM st1s1 t1)))"); } TEST_F(ParserSelectTest, subquerySemanticCheck) { @@ -445,4 +450,11 @@ TEST_F(ParserSelectTest, withoutFromSemanticCheck) { run("SELECT TBNAME", TSDB_CODE_PAR_INVALID_TBNAME); } +TEST_F(ParserSelectTest, joinSemanticCheck) { + useDb("root", "test"); + + run("SELECT * FROM (SELECT tag1, SUM(c1) s FROM st1 GROUP BY tag1) t1, st1 t2 where t1.tag1 = t2.tag1", + TSDB_CODE_PAR_NOT_SUPPORT_JOIN); +} + } // namespace ParserTest diff --git a/source/libs/parser/test/parTestUtil.cpp b/source/libs/parser/test/parTestUtil.cpp index 360b904c17..14c991917b 100644 --- a/source/libs/parser/test/parTestUtil.cpp +++ b/source/libs/parser/test/parTestUtil.cpp @@ -119,12 +119,18 @@ class ParserTestBaseImpl { TEST_INTERFACE_ASYNC_API }; - static void _destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) { + static void destoryParseContext(SParseContext* pCxt) { + taosArrayDestroy(pCxt->pTableMetaPos); + taosArrayDestroy(pCxt->pTableVgroupPos); + delete pCxt; + } + + static void destoryParseMetaCacheWarpper(SParseMetaCache* pMetaCache, bool request) { destoryParseMetaCache(pMetaCache, request); delete pMetaCache; } - static void _destroyQuery(SQuery** pQuery) { + static void destroyQuery(SQuery** pQuery) { if (nullptr == pQuery) { return; } @@ -303,10 +309,10 @@ class ParserTestBaseImpl { setParseContext(sql, &cxt); if (qIsInsertValuesSql(cxt.pSql, cxt.sqlLen)) { - unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery); + unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), destroyQuery); doParseInsertSql(&cxt, query.get(), nullptr); } else { - unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery); + unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), destroyQuery); doParse(&cxt, query.get()); SQuery* pQuery = *(query.get()); @@ -335,7 +341,7 @@ class ParserTestBaseImpl { SParseContext cxt = {0}; setParseContext(sql, &cxt); - unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery); + unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), destroyQuery); doParseSql(&cxt, query.get()); SQuery* pQuery = *(query.get()); @@ -354,26 +360,26 @@ class ParserTestBaseImpl { void runAsyncInternalFuncs(const string& sql, int32_t expect, ParserStage checkStage) { reset(expect, checkStage, TEST_INTERFACE_ASYNC_INTERNAL); try { - SParseContext cxt = {0}; - setParseContext(sql, &cxt, true); + unique_ptr > cxt(new SParseContext(), destoryParseContext); + setParseContext(sql, cxt.get(), true); - unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery); + unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), destroyQuery); bool request = true; unique_ptr > metaCache( - new SParseMetaCache(), bind(_destoryParseMetaCache, _1, cref(request))); - bool isInsertValues = qIsInsertValuesSql(cxt.pSql, cxt.sqlLen); + new SParseMetaCache(), bind(destoryParseMetaCacheWarpper, _1, cref(request))); + bool isInsertValues = qIsInsertValuesSql(cxt->pSql, cxt->sqlLen); if (isInsertValues) { - doParseInsertSyntax(&cxt, query.get(), metaCache.get()); + doParseInsertSyntax(cxt.get(), query.get(), metaCache.get()); } else { - doParse(&cxt, query.get()); - doCollectMetaKey(&cxt, *(query.get()), metaCache.get()); + doParse(cxt.get(), query.get()); + doCollectMetaKey(cxt.get(), *(query.get()), metaCache.get()); } SQuery* pQuery = *(query.get()); unique_ptr catalogReq(new SCatalogReq(), MockCatalogService::destoryCatalogReq); - doBuildCatalogReq(&cxt, metaCache.get(), catalogReq.get()); + doBuildCatalogReq(cxt.get(), metaCache.get(), catalogReq.get()); string err; thread t1([&]() { @@ -386,13 +392,13 @@ class ParserTestBaseImpl { doPutMetaDataToCache(catalogReq.get(), metaData.get(), metaCache.get(), isInsertValues); if (isInsertValues) { - doParseInsertSql(&cxt, query.get(), metaCache.get()); + doParseInsertSql(cxt.get(), query.get(), metaCache.get()); } else { - doAuthenticate(&cxt, pQuery, metaCache.get()); + doAuthenticate(cxt.get(), pQuery, metaCache.get()); - doTranslate(&cxt, pQuery, metaCache.get()); + doTranslate(cxt.get(), pQuery, metaCache.get()); - doCalculateConstant(&cxt, pQuery); + doCalculateConstant(cxt.get(), pQuery); } } catch (const TerminateFlag& e) { // success and terminate @@ -423,13 +429,13 @@ class ParserTestBaseImpl { void runAsyncApis(const string& sql, int32_t expect, ParserStage checkStage) { reset(expect, checkStage, TEST_INTERFACE_ASYNC_API); try { - SParseContext cxt = {0}; - setParseContext(sql, &cxt); + unique_ptr > cxt(new SParseContext(), destoryParseContext); + setParseContext(sql, cxt.get()); unique_ptr catalogReq(new SCatalogReq(), MockCatalogService::destoryCatalogReq); - unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), _destroyQuery); - doParseSqlSyntax(&cxt, query.get(), catalogReq.get()); + unique_ptr query((SQuery**)taosMemoryCalloc(1, sizeof(SQuery*)), destroyQuery); + doParseSqlSyntax(cxt.get(), query.get(), catalogReq.get()); SQuery* pQuery = *(query.get()); string err; @@ -438,7 +444,7 @@ class ParserTestBaseImpl { unique_ptr metaData(new SMetaData(), MockCatalogService::destoryMetaData); doGetAllMeta(catalogReq.get(), metaData.get()); - doAnalyseSqlSemantic(&cxt, catalogReq.get(), metaData.get(), pQuery); + doAnalyseSqlSemantic(cxt.get(), catalogReq.get(), metaData.get(), pQuery); } catch (const TerminateFlag& e) { // success and terminate } catch (const runtime_error& e) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index b160f45479..a700a21301 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -617,7 +617,7 @@ static bool pushDownCondOptIsPriKey(SNode* pNode, SNodeList* pTableCols) { return false; } SColumnNode* pCol = (SColumnNode*)pNode; - if (PRIMARYKEY_TIMESTAMP_COL_ID != pCol->colId) { + if (PRIMARYKEY_TIMESTAMP_COL_ID != pCol->colId || TSDB_SYSTEM_TABLE == pCol->tableType) { return false; } return pushDownCondOptBelongThisTable(pNode, pTableCols); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index beb938b161..106e674152 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -915,20 +915,30 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) } static int32_t stbSplSplitScanNodeWithoutPartTags(SSplitContext* pCxt, SStableSplitInfo* pInfo) { - int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pInfo->pSplitNode, SUBPLAN_TYPE_MERGE); + SLogicNode* pSplitNode = pInfo->pSplitNode; + if (NULL != pInfo->pSplitNode->pParent && QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pInfo->pSplitNode->pParent) && + NULL == pInfo->pSplitNode->pParent->pLimit && NULL == pInfo->pSplitNode->pParent->pSlimit) { + pSplitNode = pInfo->pSplitNode->pParent; + } + int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pSplitNode, SUBPLAN_TYPE_MERGE); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); } ++(pCxt->groupId); return code; } static int32_t stbSplSplitScanNodeWithPartTags(SSplitContext* pCxt, SStableSplitInfo* pInfo) { - int32_t code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pInfo->pSplitNode, NULL, pInfo->pSplitNode, true); + SLogicNode* pSplitNode = pInfo->pSplitNode; + if (NULL != pInfo->pSplitNode->pParent && QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pInfo->pSplitNode->pParent) && + NULL == pInfo->pSplitNode->pParent->pLimit && NULL == pInfo->pSplitNode->pParent->pSlimit) { + pSplitNode = pInfo->pSplitNode->pParent; + } + int32_t code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pSplitNode, NULL, pSplitNode, true); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + (SNode*)splCreateScanSubplan(pCxt, pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; ++(pCxt->groupId); @@ -997,6 +1007,7 @@ static int32_t stbSplSplitMergeScanNode(SSplitContext* pCxt, SLogicSubplan* pSub code = stbSplCreateMergeNode(pCxt, pSubplan, (SLogicNode*)pScan, pMergeKeys, pMergeScan, groupSort); } if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode((SNode*)pScan); code = nodesListMakeStrictAppend(&pSubplan->pChildren, (SNode*)splCreateScanSubplan(pCxt, pMergeScan, SPLIT_FLAG_STABLE_SPLIT)); } diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index 35903d45b1..e4f02f12e6 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -33,7 +33,10 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo SLogicSubplan* pLogicSubplan = NULL; SQueryLogicPlan* pLogicPlan = NULL; - int32_t code = createLogicPlan(pCxt, &pLogicSubplan); + int32_t code = nodesAcquireAllocator(pCxt->allocatorId); + if (TSDB_CODE_SUCCESS == code) { + code = createLogicPlan(pCxt, &pLogicSubplan); + } if (TSDB_CODE_SUCCESS == code) { code = optimizeLogicPlan(pCxt, pLogicSubplan); } @@ -49,6 +52,7 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo if (TSDB_CODE_SUCCESS == code) { dumpQueryPlan(*pPlan); } + nodesReleaseAllocator(pCxt->allocatorId); nodesDestroyNode((SNode*)pLogicSubplan); nodesDestroyNode((SNode*)pLogicPlan); diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 27ec409d52..c7769b15b1 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -40,6 +40,13 @@ TEST_F(PlanBasicTest, whereClause) { run("SELECT ts, c1 FROM t1 WHERE ts > NOW AND ts IS NULL AND (c1 > 0 OR c3 < 20)"); } +TEST_F(PlanBasicTest, caseWhen) { + useDb("root", "test"); + + run("SELECT CASE WHEN ts > '2020-1-1 10:10:10' THEN c1 + 10 ELSE c1 - 10 END FROM t1 " + "WHERE CASE c1 WHEN c2 + 20 THEN c4 - 1 WHEN c2 + 10 THEN c4 - 2 ELSE 10 END > 0"); +} + TEST_F(PlanBasicTest, func) { useDb("root", "test"); diff --git a/source/libs/planner/test/planGroupByTest.cpp b/source/libs/planner/test/planGroupByTest.cpp index a553d3addc..8b8f92bd4f 100644 --- a/source/libs/planner/test/planGroupByTest.cpp +++ b/source/libs/planner/test/planGroupByTest.cpp @@ -40,6 +40,8 @@ TEST_F(PlanGroupByTest, basic) { run("SELECT COUNT(*) FROM st1 GROUP BY c1"); run("SELECT SUM(c1) FROM st1 GROUP BY c2 HAVING SUM(c1) IS NOT NULL"); + + run("SELECT AVG(c1) FROM st1"); } TEST_F(PlanGroupByTest, withPartitionBy) { diff --git a/source/libs/planner/test/planJoinTest.cpp b/source/libs/planner/test/planJoinTest.cpp index 66ef4d3f19..535bb0b416 100644 --- a/source/libs/planner/test/planJoinTest.cpp +++ b/source/libs/planner/test/planJoinTest.cpp @@ -28,6 +28,8 @@ TEST_F(PlanJoinTest, basic) { run("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts"); run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts"); + + run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts"); } TEST_F(PlanJoinTest, complex) { @@ -56,9 +58,3 @@ TEST_F(PlanJoinTest, multiJoin) { run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts"); } - -TEST_F(PlanJoinTest, stable) { - useDb("root", "test"); - - run("SELECT t1.c1, t2.c1 FROM st1 t1 JOIN st2 t2 ON t1.ts = t2.ts "); -} diff --git a/source/libs/planner/test/planSetOpTest.cpp b/source/libs/planner/test/planSetOpTest.cpp index de6d7466b8..5348952db8 100644 --- a/source/libs/planner/test/planSetOpTest.cpp +++ b/source/libs/planner/test/planSetOpTest.cpp @@ -44,6 +44,8 @@ TEST_F(PlanSetOpTest, unionAllWithSubquery) { run("SELECT ts FROM (SELECT ts FROM st1s1) UNION ALL SELECT ts FROM (SELECT ts FROM st1s2)"); // super table run("SELECT ts FROM (SELECT ts FROM st1) UNION ALL SELECT ts FROM (SELECT ts FROM st1)"); + + run("(SELECT SERVER_STATUS()) UNION ALL (SELECT SERVER_STATUS())"); } TEST_F(PlanSetOpTest, unionAllWithOrderBy) { diff --git a/source/libs/planner/test/planTestMain.cpp b/source/libs/planner/test/planTestMain.cpp index 8f6fc832a2..df6e72ce46 100644 --- a/source/libs/planner/test/planTestMain.cpp +++ b/source/libs/planner/test/planTestMain.cpp @@ -22,6 +22,7 @@ #include "mockCatalog.h" #include "parser.h" #include "planTestUtil.h" +#include "tglobal.h" class PlannerEnv : public testing::Environment { public: @@ -30,6 +31,8 @@ class PlannerEnv : public testing::Environment { initMetaDataEnv(); generateMetaData(); initLog(TD_TMP_DIR_PATH "td"); + initCfg(); + nodesInitAllocatorSet(); } virtual void TearDown() { @@ -37,6 +40,7 @@ class PlannerEnv : public testing::Environment { qCleanupKeywordsTable(); fmFuncMgtDestroy(); taosCloseLog(); + nodesDestroyAllocatorSet(); } PlannerEnv() {} @@ -67,6 +71,8 @@ class PlannerEnv : public testing::Environment { std::cout << "failed to init log file" << std::endl; } } + + void initCfg() { tsQueryPlannerTrace = true; } }; static void parseArg(int argc, char* argv[]) { @@ -79,6 +85,7 @@ static void parseArg(int argc, char* argv[]) { {"limitSql", required_argument, NULL, 'i'}, {"log", required_argument, NULL, 'l'}, {"queryPolicy", required_argument, NULL, 'q'}, + {"useNodeAllocator", required_argument, NULL, 'a'}, {0, 0, 0, 0} }; // clang-format on @@ -99,6 +106,9 @@ static void parseArg(int argc, char* argv[]) { case 'q': setQueryPolicy(optarg); break; + case 'a': + setUseNodeAllocator(optarg); + break; default: break; } diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index bf19c7a222..73d695195c 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -41,6 +41,7 @@ using namespace testing; enum DumpModule { DUMP_MODULE_NOTHING = 1, + DUMP_MODULE_SQL, DUMP_MODULE_PARSER, DUMP_MODULE_LOGIC, DUMP_MODULE_OPTIMIZED, @@ -56,10 +57,13 @@ int32_t g_skipSql = 0; int32_t g_limitSql = 0; int32_t g_logLevel = 131; int32_t g_queryPolicy = QUERY_POLICY_VNODE; +bool g_useNodeAllocator = false; void setDumpModule(const char* pModule) { if (NULL == pModule) { g_dumpModule = DUMP_MODULE_ALL; + } else if (0 == strncasecmp(pModule, "sql", strlen(pModule))) { + g_dumpModule = DUMP_MODULE_SQL; } else if (0 == strncasecmp(pModule, "parser", strlen(pModule))) { g_dumpModule = DUMP_MODULE_PARSER; } else if (0 == strncasecmp(pModule, "logic", strlen(pModule))) { @@ -79,10 +83,11 @@ void setDumpModule(const char* pModule) { } } -void setSkipSqlNum(const char* pNum) { g_skipSql = stoi(pNum); } -void setLimitSqlNum(const char* pNum) { g_limitSql = stoi(pNum); } -void setLogLevel(const char* pLogLevel) { g_logLevel = stoi(pLogLevel); } -void setQueryPolicy(const char* pQueryPolicy) { g_queryPolicy = stoi(pQueryPolicy); } +void setSkipSqlNum(const char* pArg) { g_skipSql = stoi(pArg); } +void setLimitSqlNum(const char* pArg) { g_limitSql = stoi(pArg); } +void setLogLevel(const char* pArg) { g_logLevel = stoi(pArg); } +void setQueryPolicy(const char* pArg) { g_queryPolicy = stoi(pArg); } +void setUseNodeAllocator(const char* pArg) { g_useNodeAllocator = stoi(pArg); } int32_t getLogLevel() { return g_logLevel; } @@ -124,6 +129,12 @@ class PlannerTestBaseImpl { } void runImpl(const string& sql, int32_t queryPolicy) { + int64_t allocatorId = 0; + if (g_useNodeAllocator) { + nodesCreateAllocator(sqlNo_, 32 * 1024, &allocatorId); + nodesAcquireAllocator(allocatorId); + } + reset(); tsQueryPolicy = queryPolicy; try { @@ -155,8 +166,13 @@ class PlannerTestBaseImpl { dump(g_dumpModule); } catch (...) { dump(DUMP_MODULE_ALL); + nodesReleaseAllocator(allocatorId); + nodesDestroyAllocator(allocatorId); throw; } + + nodesReleaseAllocator(allocatorId); + nodesDestroyAllocator(allocatorId); } void prepare(const string& sql) { @@ -216,6 +232,8 @@ class PlannerTestBaseImpl { doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan); unique_ptr plan(pPlan, (void (*)(SQueryPlan*))nodesDestroyNode); + checkPlanMsg((SNode*)pPlan); + dump(g_dumpModule); } catch (...) { dump(DUMP_MODULE_ALL); @@ -252,7 +270,6 @@ class PlannerTestBaseImpl { string splitLogicPlan_; string scaledLogicPlan_; string physiPlan_; - string physiPlanMsg_; vector physiSubplans_; }; @@ -276,17 +293,16 @@ class PlannerTestBaseImpl { res_.splitLogicPlan_.clear(); res_.scaledLogicPlan_.clear(); res_.physiPlan_.clear(); - res_.physiPlanMsg_.clear(); res_.physiSubplans_.clear(); } void dump(DumpModule module) { - cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; - if (DUMP_MODULE_NOTHING == module) { return; } + cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; + if (DUMP_MODULE_ALL == module || DUMP_MODULE_PARSER == module) { if (res_.prepareAst_.empty()) { cout << "+++++++++++++++++++++syntax tree : " << endl; @@ -411,8 +427,6 @@ class PlannerTestBaseImpl { SNode* pSubplan; FOREACH(pSubplan, ((SNodeListNode*)pNode)->pNodeList) { res_.physiSubplans_.push_back(toString(pSubplan)); } } - res_.physiPlanMsg_ = toMsg((SNode*)(*pPlan)); - cout << "json len: " << res_.physiPlan_.length() << ", msg len: " << res_.physiPlanMsg_.length() << endl; } void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) { @@ -451,32 +465,22 @@ class PlannerTestBaseImpl { string toString(const SNode* pRoot) { char* pStr = NULL; int32_t len = 0; - - auto start = chrono::steady_clock::now(); DO_WITH_THROW(nodesNodeToString, pRoot, false, &pStr, &len) - if (QUERY_NODE_PHYSICAL_PLAN == nodeType(pRoot)) { - cout << "nodesNodeToString: " - << chrono::duration_cast(chrono::steady_clock::now() - start).count() << "us" << endl; - } - string str(pStr); taosMemoryFreeClear(pStr); return str; } - string toMsg(const SNode* pRoot) { + void checkPlanMsg(const SNode* pRoot) { char* pStr = NULL; int32_t len = 0; - - auto start = chrono::steady_clock::now(); DO_WITH_THROW(nodesNodeToMsg, pRoot, &pStr, &len) - cout << "nodesNodeToMsg: " - << chrono::duration_cast(chrono::steady_clock::now() - start).count() << "us" << endl; + string copyStr(pStr, len); SNode* pNode = NULL; char* pNewStr = NULL; int32_t newlen = 0; - DO_WITH_THROW(nodesMsgToNode, pStr, len, &pNode) + DO_WITH_THROW(nodesMsgToNode, copyStr.c_str(), len, &pNode) DO_WITH_THROW(nodesNodeToMsg, pNode, &pNewStr, &newlen) if (newlen != len || 0 != memcmp(pStr, pNewStr, len)) { cout << "nodesNodeToMsg error!!!!!!!!!!!!!! len = " << len << ", newlen = " << newlen << endl; @@ -490,9 +494,7 @@ class PlannerTestBaseImpl { nodesDestroyNode(pNode); taosMemoryFreeClear(pNewStr); - string str(pStr, len); taosMemoryFreeClear(pStr); - return str; } caseEnv caseEnv_; diff --git a/source/libs/planner/test/planTestUtil.h b/source/libs/planner/test/planTestUtil.h index b0ddd726a6..be8b51f769 100644 --- a/source/libs/planner/test/planTestUtil.h +++ b/source/libs/planner/test/planTestUtil.h @@ -41,11 +41,12 @@ class PlannerTestBase : public testing::Test { std::unique_ptr impl_; }; -extern void setDumpModule(const char* pModule); -extern void setSkipSqlNum(const char* pNum); -extern void setLimitSqlNum(const char* pNum); -extern void setLogLevel(const char* pLogLevel); -extern void setQueryPolicy(const char* pQueryPolicy); +extern void setDumpModule(const char* pArg); +extern void setSkipSqlNum(const char* pArg); +extern void setLimitSqlNum(const char* pArg); +extern void setLogLevel(const char* pArg); +extern void setQueryPolicy(const char* pArg); +extern void setUseNodeAllocator(const char* pArg); extern int32_t getLogLevel(); #endif // PLAN_TEST_UTIL_H diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 2acf3fad15..e4271dfcda 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -632,6 +632,7 @@ int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SD QW_ERR_JRET(qwProcessDelete(QW_FPARAMS(), &qwMsg, pRes)); + taosMemoryFreeClear(req.msg); QW_SCH_TASK_DLOG("processDelete end, node:%p", node); _return: diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index c7bf7ab7e7..581eea4a81 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -275,6 +275,7 @@ void qwFreeTaskHandle(qTaskInfo_t *taskHandle) { qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) { qDestroyTask(otaskHandle); + qDebug("task handle destryed"); } } @@ -305,6 +306,7 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) { if (ctx->sinkHandle) { dsDestroyDataSinker(ctx->sinkHandle); ctx->sinkHandle = NULL; + qDebug("sink handle destryed"); } } @@ -452,6 +454,10 @@ void qwDestroySchStatus(SQWSchStatus *pStatus) { taosHashCleanup(pStatus->tasksH void qwDestroyImpl(void *pMgmt) { SQWorker *mgmt = (SQWorker *)pMgmt; + int8_t nodeType = mgmt->nodeType; + int32_t nodeId = mgmt->nodeId; + + qDebug("start to destroy qworker, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); taosTmrStop(mgmt->hbTimer); mgmt->hbTimer = NULL; @@ -484,6 +490,8 @@ void qwDestroyImpl(void *pMgmt) { atomic_sub_fetch_32(&gQwMgmt.qwNum, 1); qwCloseRef(); + + qDebug("qworker destroyed, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); } int32_t qwOpenRef(void) { diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index e7695b2f04..5d243d86e8 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -99,7 +99,7 @@ typedef struct SFilterRange { typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t); typedef int32_t(*filter_desc_compare_func)(const void *, const void *); -typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SColumnDataAgg *, int16_t); +typedef bool(*filter_exec_func)(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols); typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char*, void **); typedef struct SFilterRangeCompare { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 9e67635437..dc6b505bb9 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -2976,14 +2976,12 @@ _return: return TSDB_CODE_SUCCESS; } -bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; uint32_t *unitIdx = NULL; - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - } + int8_t* p = (int8_t*)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); @@ -3002,35 +3000,35 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, uint8_t optr = cunit->optr; if (colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { - (*p)[i] = optr == OP_TYPE_IS_NULL ? true : false; + p[i] = (optr == OP_TYPE_IS_NULL) ? true : false; } else { if (optr == OP_TYPE_IS_NOT_NULL) { - (*p)[i] = 1; + p[i] = 1; } else if (optr == OP_TYPE_IS_NULL) { - (*p)[i] = 0; + p[i] = 0; } else if (cunit->rfunc >= 0) { - (*p)[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); + p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); } else { - (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } //FILTER_UNIT_SET_R(info, uidx, p[i]); //FILTER_UNIT_SET_F(info, uidx); } - if ((*p)[i] == 0) { + if (p[i] == 0) { break; } } - if ((*p)[i]) { + if (p[i]) { break; } unitIdx += unitNum; } - if ((*p)[i] == 0) { + if (p[i] == 0) { all = false; } } @@ -3040,7 +3038,7 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, -int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) { +int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) { if (statis && numOfRows >= FILTER_RM_UNIT_MIN_ROWS) { info->blkFlag = 0; @@ -3058,7 +3056,6 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t* assert(info->unitNum > 1); *all = filterExecuteBasedOnStatisImpl(info, numOfRows, p, statis, numOfCols); - goto _return; } } @@ -3067,59 +3064,55 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, int8_t* _return: info->blkFlag = 0; - return TSDB_CODE_SUCCESS; } - -static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols) { return true; } -static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { + +static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols) { return false; } -static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { + +static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; - if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { - return all; - } + int8_t* p = (int8_t*)pRes->pData; - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); + if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { + return all; } for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); - (*p)[i] = ((colData == NULL) || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); + p[i] = ((colData == NULL) || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); - if ((*p)[i] == 0) { + if (p[i] == 0) { all = false; } } return all; } -static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; - if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { + if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - } + int8_t* p = (int8_t*)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); - (*p)[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); - if ((*p)[i] == 0) { + p[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); + if (p[i] == 0) { all = false; } } @@ -3127,7 +3120,7 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows return all; } -bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; uint16_t dataSize = info->cunits[0].dataSize; @@ -3136,13 +3129,11 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD void *valData2 = info->cunits[0].valData2; __compar_fn_t func = gDataCompare[info->cunits[0].func]; - if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { + if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - } + int8_t* p = (int8_t*) pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { void *colData = colDataGetData((SColumnInfoData *)info->cunits[0].colData, i); @@ -3152,9 +3143,9 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD continue; } - (*p)[i] = (*rfunc)(colData, colData, valData, valData2, func); + p[i] = (*rfunc)(colData, colData, valData, valData2, func); - if ((*p)[i] == 0) { + if (p[i] == 0) { all = false; } } @@ -3162,23 +3153,21 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SColumnD return all; } -bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; - if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { + if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - } + int8_t* p = (int8_t*) pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); if (colData == NULL || colDataIsNull_s((SColumnInfoData *)info->cunits[uidx].colData, i)) { - (*p)[i] = 0; + p[i] = 0; all = false; continue; } @@ -3191,14 +3180,14 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa qError("castConvert1 taosUcs4ToMbs error"); }else{ varDataSetLen(newColData, len); - (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); + p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); } taosMemoryFreeClear(newColData); }else{ - (*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData); + p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData); } - if ((*p)[i] == 0) { + if (p[i] == 0) { all = false; } } @@ -3207,17 +3196,15 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa } -bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; bool all = true; - if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { + if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - if (*p == NULL) { - *p = taosMemoryCalloc(numOfRows, sizeof(int8_t)); - } + int8_t* p = (int8_t*) pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { //FILTER_UNIT_CLR_F(info); @@ -3235,14 +3222,14 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg uint8_t optr = cunit->optr; if (colData == NULL || colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { - (*p)[i] = optr == OP_TYPE_IS_NULL ? true : false; + p[i] = optr == OP_TYPE_IS_NULL ? true : false; } else { if (optr == OP_TYPE_IS_NOT_NULL) { - (*p)[i] = 1; + p[i] = 1; } else if (optr == OP_TYPE_IS_NULL) { - (*p)[i] = 0; + p[i] = 0; } else if (cunit->rfunc >= 0) { - (*p)[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); + p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); } else { if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)){ char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); @@ -3251,11 +3238,11 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg qError("castConvert1 taosUcs4ToMbs error"); }else{ varDataSetLen(newColData, len); - (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); } taosMemoryFreeClear(newColData); }else{ - (*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } } @@ -3263,17 +3250,17 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg //FILTER_UNIT_SET_F(info, uidx); } - if ((*p)[i] == 0) { + if (p[i] == 0) { break; } } - if ((*p)[i]) { + if (p[i]) { break; } } - if ((*p)[i] == 0) { + if (p[i] == 0) { all = false; } } @@ -4026,38 +4013,63 @@ _return: FLT_RET(code); } -bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t *pResultStatus) { if (NULL == info) { + *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; + return false; + } + + SScalarParam output = {0}; + SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; + + int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output); + if (code != TSDB_CODE_SUCCESS) { return false; } if (info->scalarMode) { - SScalarParam output = {0}; - - SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; - int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - SArray *pList = taosArrayInit(1, POINTER_BYTES); taosArrayPush(pList, &pSrc); FLT_ERR_RET(scalarCalculate(info->sclCtx.node, pList, &output)); - *p = taosMemoryMalloc(output.numOfRows * sizeof(bool)); - - memcpy(*p, output.columnData->pData, output.numOfRows); - colDataDestroy(output.columnData); - taosMemoryFree(output.columnData); + *p = output.columnData; taosArrayDestroy(pList); + + if (output.numOfQualified == output.numOfRows) { + *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; + } else if (output.numOfQualified == 0) { + *pResultStatus = FILTER_RESULT_NONE_QUALIFIED; + } else { + *pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED; + } return false; + } else { + *p = output.columnData; + output.numOfRows = pSrc->info.rows; + + bool keep = (*info->func)(info, pSrc->info.rows, *p, statis, numOfCols); + + // todo this should be return during filter procedure + int32_t num = 0; + for(int32_t i = 0; i < output.numOfRows; ++i) { + if (((int8_t*)((*p)->pData))[i] == 1) { + ++num; + } + } + + if (num == output.numOfRows) { + *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; + } else if (num == 0) { + *pResultStatus = FILTER_RESULT_NONE_QUALIFIED; + } else { + *pResultStatus = FILTER_RESULT_PARTIAL_QUALIFIED; + } + + return keep; } - - return (*info->func)(info, pSrc->info.rows, p, statis, numOfCols); } - typedef struct SClassifyConditionCxt { bool hasPrimaryKey; bool hasTagIndexCol; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cd1f6624bd..9cba94d85a 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -606,6 +606,8 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o SCL_ERR_JRET(code); } + int32_t numOfQualified = 0; + bool value = false; bool complete = true; for (int32_t i = 0; i < rowNum; ++i) { @@ -631,6 +633,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o if (complete) { colDataAppend(output->columnData, i, (char*) &value, false); + if (value) { + numOfQualified++; + } } } @@ -639,8 +644,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o output->numOfRows = 0; } -_return: + output->numOfQualified = numOfQualified; +_return: sclFreeParamList(params, paramNum); SCL_RET(code); } @@ -847,7 +853,7 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { memcpy(res->datum.p, output.columnData->pData, len); } else if (IS_VAR_DATA_TYPE(type)) { //res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1); - res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData), 1); + res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1, 1); res->node.resType.bytes = varDataTLen(output.columnData->pData); memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData)); } else { @@ -1242,6 +1248,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { colInfoDataEnsureCapacity(pDst->columnData, res->numOfRows); colDataAssign(pDst->columnData, res->columnData, res->numOfRows, NULL); pDst->numOfRows = res->numOfRows; + pDst->numOfQualified = res->numOfQualified; } sclFreeParam(res); @@ -1249,7 +1256,6 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { } _return: - //nodesDestroyNode(pNode); sclFreeRes(ctx.pRes); return code; } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index a003315fca..fe2a970aaa 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -1475,19 +1475,19 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; - pOut->numOfRows = pLeft->numOfRows; -// if (IS_HELPER_NULL(pRight->columnData, 0)) { if(colDataIsNull_s(pRight->columnData, 0)){ - for (int32_t i = 0; i < pOut->numOfRows; ++i) { - colDataAppend(pOutputCol, i, NULL, true); - } + colDataAppendNNULL(pOutputCol, 0, pOut->numOfRows); } else { + char* d = colDataGetData(pRight->columnData, 0); for (int32_t i = 0; i < pOut->numOfRows; ++i) { - colDataAppend(pOutputCol, i, colDataGetData(pRight->columnData, 0), false); + colDataAppend(pOutputCol, i, d, false); } } + + ASSERT(pRight->numOfQualified == 1 || pRight->numOfQualified == 0); + pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows; } void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { @@ -1646,38 +1646,60 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, doReleaseVec(pRightCol, rightConvert); } -#define VEC_COM_INNER(pCol, index1, index2) \ - for (; i < pCol->numOfRows && i >= 0; i += step) {\ - if (IS_HELPER_NULL(pLeft->columnData, index1) || IS_HELPER_NULL(pRight->columnData, index2)) {\ - bool res = false;\ - colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);\ - continue;\ - }\ - char *pLeftData = colDataGetData(pLeft->columnData, index1);\ - char *pRightData = colDataGetData(pRight->columnData, index2);\ - int64_t leftOut = 0;\ - int64_t rightOut = 0;\ - bool freeLeft = false;\ - bool freeRight = false;\ - bool isJsonnull = false;\ - bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight),\ - &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);\ - if(isJsonnull){\ - ASSERT(0);\ - }\ - if(!pLeftData || !pRightData){\ - result = false;\ - }\ - if(!result){\ - colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);\ - }else{\ - bool res = filterDoCompare(fp, optr, pLeftData, pRightData);\ - colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);\ - }\ - if(freeLeft) taosMemoryFreeClear(pLeftData);\ - if(freeRight) taosMemoryFreeClear(pRightData);\ +int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t startIndex, int32_t step, __compar_fn_t fp, + SScalarParam *pLeft, SScalarParam *pRight, int32_t optr) { + int32_t num = 0; + + for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) { + int32_t leftIndex = (i >= pLeft->numOfRows)? 0:i; + int32_t rightIndex = (i >= pRight->numOfRows)? 0:i; + + if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) { + bool res = false; + colDataAppendInt8(pOut->columnData, i, (int8_t *)&res); + continue; + } + + char * pLeftData = colDataGetData(pLeft->columnData, leftIndex); + char * pRightData = colDataGetData(pRight->columnData, rightIndex); + int64_t leftOut = 0; + int64_t rightOut = 0; + bool freeLeft = false; + bool freeRight = false; + bool isJsonnull = false; + + bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, + &leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight); + if (isJsonnull) { + ASSERT(0); + } + + if (!pLeftData || !pRightData) { + result = false; + } + + if (!result) { + colDataAppendInt8(pOut->columnData, i, (int8_t *)&result); + } else { + bool res = filterDoCompare(fp, optr, pLeftData, pRightData); + colDataAppendInt8(pOut->columnData, i, (int8_t *)&res); + if (res) { + ++num; + } + } + + if (freeLeft) { + taosMemoryFreeClear(pLeftData); + } + + if (freeRight) { + taosMemoryFreeClear(pRightData); + } } + return num; +} + void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; @@ -1704,16 +1726,12 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam * char *pLeftData = colDataGetData(pLeft->columnData, i); bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter); colDataAppendInt8(pOut->columnData, i, (int8_t*)&res); + if (res) { + pOut->numOfQualified++; + } } - return; - } - - if (pLeft->numOfRows == pRight->numOfRows) { - VEC_COM_INNER(pLeft, i, i) - } else if (pRight->numOfRows == 1) { - VEC_COM_INNER(pLeft, i, 0) - } else if (pLeft->numOfRows == 1) { - VEC_COM_INNER(pRight, 0, i) + } else { // normal compare + pOut->numOfQualified = doVectorCompareImpl(pOut->numOfRows, pOut, i, step, fp, pLeft, pRight, optr); } } diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 14776fc927..e017606035 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -256,7 +256,8 @@ typedef struct SSchJob { SRequestConnInfo conn; SArray *nodeList; // qnode/vnode list, SArray SArray *levels; // starting from 0. SArray - SQueryPlan *pDag; + SQueryPlan *pDag; + int64_t allocatorRefId; SArray *dataSrcTasks; // SArray int32_t levelIdx; diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index a314ffaa30..5e47c0a0ed 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -673,6 +673,7 @@ void schFreeJobImpl(void *job) { destroyQueryExecRes(&pJob->execRes); qDestroyQueryPlan(pJob->pDag); + nodesReleaseAllocatorWeakRef(pJob->allocatorRefId); taosMemoryFreeClear(pJob->userRes.execRes); taosMemoryFreeClear(pJob->fetchRes); @@ -725,6 +726,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { pJob->sql = strdup(pReq->sql); } pJob->pDag = pReq->pDag; + pJob->allocatorRefId = nodesMakeAllocatorWeakRef(pReq->allocatorRefId); pJob->chkKillFp = pReq->chkKillFp; pJob->chkKillParam = pReq->chkKillParam; pJob->userRes.execFp = pReq->execFp; diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index d540b17c90..1b59c06140 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -404,8 +404,7 @@ _return: taosMemoryFreeClear(msg); SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); -} - +} int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index d6e87c2736..4a63cd3bb2 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -182,7 +182,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S pReq->upstreamTaskId); streamTaskEnqueue(pTask, pReq, pRsp); - tFreeStreamDispatchReq(pReq); + tDeleteStreamDispatchReq(pReq); if (exec) { if (streamTryExec(pTask) < 0) { diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index cd5f499c34..e6705a77b2 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -179,5 +179,15 @@ void streamFreeQitem(SStreamQueueItem* data) { taosArrayDestroy(pMerge->reqs); taosArrayDestroy(pMerge->dataRefs); taosFreeQitem(pMerge); + } else if (type == STREAM_INPUT__REF_DATA_BLOCK) { + SStreamRefDataBlock* pRefBlock = (SStreamRefDataBlock*)data; + + int32_t ref = atomic_sub_fetch_32(pRefBlock->dataRef, 1); + ASSERT(ref >= 0); + if (ref == 0) { + blockDataDestroy(pRefBlock->pBlock); + taosMemoryFree(pRefBlock->dataRef); + } + taosFreeQitem(pRefBlock); } } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 7cdb7c0db9..e6960ae350 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -62,7 +62,7 @@ int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) { return 0; } -void tFreeStreamDispatchReq(SStreamDispatchReq* pReq) { +void tDeleteStreamDispatchReq(SStreamDispatchReq* pReq) { taosArrayDestroyP(pReq->data, taosMemoryFree); taosArrayDestroy(pReq->dataLen); } @@ -95,7 +95,10 @@ int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) { return 0; } +void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq) { taosMemoryFree(pReq->pRetrieve); } + int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) { + int32_t code = -1; SRetrieveTableRsp* pRetrieve = NULL; void* buf = NULL; int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); @@ -143,7 +146,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) buf = rpcMallocCont(sizeof(SMsgHead) + len); if (buf == NULL) { - goto FAIL; + goto CLEAR; } ((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId); @@ -151,6 +154,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) SEncoder encoder; tEncoderInit(&encoder, abuf, len); tEncodeStreamRetrieveReq(&encoder, &req); + tEncoderClear(&encoder); SRpcMsg rpcMsg = { .code = 0, @@ -161,17 +165,18 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) if (tmsgSendReq(&pEpInfo->epSet, &rpcMsg) < 0) { ASSERT(0); - return -1; + goto CLEAR; } + buf = NULL; qDebug("task %d(child %d) send retrieve req to task %d at node %d, reqId %" PRId64, pTask->taskId, pTask->selfChildId, pEpInfo->taskId, pEpInfo->nodeId, req.reqId); } - return 0; -FAIL: - if (pRetrieve) taosMemoryFree(pRetrieve); - if (buf) taosMemoryFree(buf); - return -1; + code = 0; +CLEAR: + taosMemoryFree(pRetrieve); + rpcFreeCont(buf); + return code; } static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDispatchReq* pReq) { diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 102bad7426..5ad5aa549d 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -38,6 +38,9 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray* SArray* blocks = pMerged->reqs; qDebug("task %d %p set submit input (merged), batch num: %d", pTask->taskId, pTask, (int32_t)blocks->size); qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT); + } else if (pItem->type == STREAM_INPUT__REF_DATA_BLOCK) { + const SStreamRefDataBlock* pRefBlock = (const SStreamRefDataBlock*)data; + qSetMultiStreamInput(exec, pRefBlock->pBlock, 1, STREAM_INPUT__DATA_BLOCK); } else { ASSERT(0); } diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 6cd5132bb9..fde8bca77b 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -18,14 +18,19 @@ #include "tcommon.h" #include "ttimer.h" -SStreamState* streamStateOpen(char* path, SStreamTask* pTask) { +SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState)); if (pState == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + char statePath[300]; - sprintf(statePath, "%s/%d", path, pTask->taskId); + if (!specPath) { + sprintf(statePath, "%s/%d", path, pTask->taskId); + } else { + memcpy(statePath, path, 300); + } if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) { goto _err; } @@ -135,15 +140,9 @@ int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void* if (streamStateGet(pState, key, pVal, pVLen) == 0) { return 0; } - void* tmp = taosMemoryCalloc(1, size); - if (streamStatePut(pState, key, &tmp, size) == 0) { - taosMemoryFree(tmp); - int32_t code = streamStateGet(pState, key, pVal, pVLen); - ASSERT(code == 0); - return code; - } - taosMemoryFree(tmp); - return -1; + *pVal = tdbRealloc(NULL, size); + memset(*pVal, 0, size); + return 0; } int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal) { @@ -191,9 +190,14 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key if (pCur == NULL) { return NULL; } + if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) { + taosMemoryFree(pCur); + return NULL; + } int32_t c; if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) { + tdbTbcClose(pCur->pCur); taosMemoryFree(pCur); return NULL; } @@ -212,9 +216,14 @@ SStreamStateCur* streamStateSeekKeyPrev(SStreamState* pState, const SWinKey* key if (pCur == NULL) { return NULL; } + if (tdbTbcOpen(pState->pStateDb, &pCur->pCur, NULL) < 0) { + taosMemoryFree(pCur); + return NULL; + } int32_t c; if (tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c) < 0) { + tdbTbcClose(pCur->pCur); taosMemoryFree(pCur); return NULL; } diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 1e68fe346c..b604d25816 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -69,15 +69,26 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { if (agree) { // term - SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); - ASSERT(pEntry != NULL); - + SSyncRaftEntry* pEntry = NULL; + SLRUCache* pCache = pSyncNode->pLogStore->pCache; + LRUHandle* h = taosLRUCacheLookup(pCache, &index, sizeof(index)); + if (h) { + pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h); + } else { + pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); + ASSERT(pEntry != NULL); + } // cannot commit, even if quorum agree. need check term! if (pEntry->term <= pSyncNode->pRaftStore->currentTerm) { // update commit index newCommitIndex = index; - syncEntryDestory(pEntry); + if (h) { + taosLRUCacheRelease(pCache, h, false); + } else { + syncEntryDestory(pEntry); + } + break; } else { do { @@ -88,7 +99,11 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { } while (0); } - syncEntryDestory(pEntry); + if (h) { + taosLRUCacheRelease(pCache, h, false); + } else { + syncEntryDestory(pEntry); + } } } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 6f29b54f80..17157fbd23 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2581,6 +2581,20 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) { return ret; } +static void deleteCacheEntry(const void* key, size_t keyLen, void* value) { taosMemoryFree(value); } + +static int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHandle** h) { + int code = 0; + int entryLen = sizeof(*pEntry) + pEntry->dataLen; + LRUStatus status = taosLRUCacheInsert(pLogStore->pCache, &pEntry->index, sizeof(pEntry->index), pEntry, entryLen, + deleteCacheEntry, h, TAOS_LRU_PRIORITY_LOW); + if (status != TAOS_LRU_STATUS_OK) { + code = -1; + } + + return code; +} + static int32_t syncNodeAppendNoop(SSyncNode* ths) { int32_t ret = 0; @@ -2589,13 +2603,21 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) { SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index, ths->vgId); ASSERT(pEntry != NULL); + LRUHandle* h = NULL; + syncCacheEntry(ths->pLogStore, pEntry, &h); + if (ths->state == TAOS_SYNC_STATE_LEADER) { int32_t code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); ASSERT(code == 0); syncNodeReplicate(ths, false); } - syncEntryDestory(pEntry); + if (h) { + taosLRUCacheRelease(ths->pLogStore->pCache, h, false); + } else { + syncEntryDestory(pEntry); + } + return ret; } @@ -2654,6 +2676,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI SSyncRaftEntry* pEntry = syncEntryBuild2((SyncClientRequest*)pMsg, term, index); ASSERT(pEntry != NULL); + LRUHandle* h = NULL; + syncCacheEntry(ths->pLogStore, pEntry, &h); + if (ths->state == TAOS_SYNC_STATE_LEADER) { // append entry code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry); @@ -2685,7 +2710,12 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncI } } - syncEntryDestory(pEntry); + if (h) { + taosLRUCacheRelease(ths->pLogStore->pCache, h, false); + } else { + syncEntryDestory(pEntry); + } + return ret; } @@ -2973,9 +3003,15 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, for (SyncIndex i = beginIndex; i <= endIndex; ++i) { if (i != SYNC_INDEX_INVALID) { SSyncRaftEntry* pEntry; - code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry); - ASSERT(code == 0); - ASSERT(pEntry != NULL); + SLRUCache* pCache = ths->pLogStore->pCache; + LRUHandle* h = taosLRUCacheLookup(pCache, &i, sizeof(i)); + if (h) { + pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h); + } else { + code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry); + ASSERT(code == 0); + ASSERT(pEntry != NULL); + } SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); @@ -3058,7 +3094,11 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, } rpcFreeCont(rpcMsg.pCont); - syncEntryDestory(pEntry); + if (h) { + taosLRUCacheRelease(pCache, h, false); + } else { + syncEntryDestory(pEntry); + } } } } diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 0649e064e4..496c8419de 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -53,6 +53,15 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { SSyncLogStore* pLogStore = taosMemoryMalloc(sizeof(SSyncLogStore)); ASSERT(pLogStore != NULL); + pLogStore->pCache = taosLRUCacheInit(10 * 1024 * 1024, 1, .5); + if (pLogStore->pCache == NULL) { + terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + taosMemoryFree(pLogStore); + return NULL; + } + + taosLRUCacheSetStrictCapacity(pLogStore->pCache, false); + pLogStore->data = taosMemoryMalloc(sizeof(SSyncLogStoreData)); ASSERT(pLogStore->data != NULL); @@ -102,6 +111,10 @@ void logStoreDestory(SSyncLogStore* pLogStore) { taosThreadMutexDestroy(&(pData->mutex)); taosMemoryFree(pLogStore->data); + + taosLRUCacheEraseUnrefEntries(pLogStore->pCache); + taosLRUCacheCleanup(pLogStore->pCache); + taosMemoryFree(pLogStore); } } @@ -243,7 +256,7 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; - int32_t code; + int32_t code = 0; *ppEntry = NULL; @@ -257,6 +270,7 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, taosThreadMutexLock(&(pData->mutex)); code = walReadVer(pWalHandle, index); + // code = walReadVerCached(pWalHandle, index); if (code != 0) { int32_t err = terrno; const char* errStr = tstrerror(err); @@ -412,6 +426,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { ASSERT(pWalHandle != NULL); int32_t code = walReadVer(pWalHandle, index); + // int32_t code = walReadVerCached(pWalHandle, index); if (code != 0) { int32_t err = terrno; const char* errStr = tstrerror(err); diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index c6ecd37680..c5204ef59e 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -841,6 +841,10 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx // copy content to the parent page tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); tdbPageCopy(pNews[0], pParent, 1); + + if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) { + ((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno; + } } for (int i = 0; i < 3; i++) { diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 1e2eefabf4..f4878ea861 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -80,6 +80,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) ASSERT(xFree); for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) { + tdbDebug("tdbPage/destroy/free ovfl cell: %p/%p", pPage->apOvfl[iOvfl], pPage); tdbOsFree(pPage->apOvfl[iOvfl]); } @@ -152,7 +153,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl pNewCell = (SCell *)tdbOsMalloc(szCell); memcpy(pNewCell, pCell, szCell); - tdbDebug("tdbPage/new ovfl cell: %p", pNewCell); + tdbDebug("tdbPage/insert/new ovfl cell: %p/%p", pNewCell, pPage); pPage->apOvfl[iOvfl] = pNewCell; pPage->aiOvfl[iOvfl] = idx; @@ -202,7 +203,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) { if (pPage->aiOvfl[iOvfl] == idx) { // remove the over flow cell tdbOsFree(pPage->apOvfl[iOvfl]); - tdbDebug("tdbPage/free ovfl cell: %p", pPage->apOvfl[iOvfl]); + tdbDebug("tdbPage/drop/free ovfl cell: %p", pPage->apOvfl[iOvfl]); for (; (++iOvfl) < pPage->nOverflow;) { pPage->aiOvfl[iOvfl - 1] = pPage->aiOvfl[iOvfl] - 1; pPage->apOvfl[iOvfl - 1] = pPage->apOvfl[iOvfl]; @@ -255,6 +256,7 @@ void tdbPageCopy(SPage *pFromPage, SPage *pToPage, int deepCopyOvfl) { int szCell = (*pFromPage->xCellSize)(pFromPage, pFromPage->apOvfl[iOvfl], 0, NULL, NULL); pNewCell = (SCell *)tdbOsMalloc(szCell); memcpy(pNewCell, pFromPage->apOvfl[iOvfl], szCell); + tdbDebug("tdbPage/copy/new ovfl cell: %p/%p/%p", pNewCell, pToPage, pFromPage); } pToPage->apOvfl[iOvfl] = pNewCell; diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 2cc62d3d6a..04711eb6a0 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -248,6 +248,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { return 0; } + // loop to write the dirty pages to file SRBTreeIter iter = tRBTreeIterCreate(&pPager->rbt, 1); SRBTreeNode *pNode = NULL; while ((pNode = tRBTreeIterNext(&iter)) != NULL) { @@ -257,37 +258,23 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { ASSERT(0); return -1; } + } + + tdbTrace("tdbttl commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize); + pPager->dbOrigSize = pPager->dbFileSize; + + // release the page + iter = tRBTreeIterCreate(&pPager->rbt, 1); + while ((pNode = tRBTreeIterNext(&iter)) != NULL) { + pPage = (SPage *)pNode; pPage->isDirty = 0; - // tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); + tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } tRBTreeCreate(&pPager->rbt, pageCmpFn); - /* - // loop to write the dirty pages to file - for (pPage = pPager->pDirty; pPage; pPage = pPage->pDirtyNext) { - // TODO: update the page footer - ret = tdbPagerWritePageToDB(pPager, pPage); - if (ret < 0) { - ASSERT(0); - return -1; - } - } - - // release the page - for (pPage = pPager->pDirty; pPage; pPage = pPager->pDirty) { - pPager->pDirty = pPage->pDirtyNext; - pPage->pDirtyNext = NULL; - - pPage->isDirty = 0; - - tdbPCacheRelease(pPager->pCache, pPage, pTxn); - } - */ - tdbTrace("tdbttl commit:%p, %d", pPager, pPager->dbOrigSize); - pPager->dbOrigSize = pPager->dbFileSize; // sync the db file tdbOsFSync(pPager->fd); @@ -353,7 +340,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; - // tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); + tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index dcfa93431b..191011111d 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1498,9 +1498,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran pCtx->ahandle = pReq->info.ahandle; pCtx->msgType = pReq->msgType; - if (ctx != NULL) { - pCtx->appCtx = *ctx; - } + if (ctx != NULL) pCtx->appCtx = *ctx; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); cliMsg->ctx = pCtx; diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index d3277d1cc1..70a47fe079 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -1148,6 +1148,7 @@ int transReleaseSrvHandle(void* handle) { tTrace("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); transAsyncSend(pThrd->asyncPool, &m->q); + transReleaseExHandle(transGetRefMgt(), refId); return 0; _return1: @@ -1177,8 +1178,10 @@ int transSendResponse(const STransMsg* msg) { STraceId* trace = (STraceId*)&msg->info.traceId; tGTrace("conn %p start to send resp (1/2)", exh->handle); transAsyncSend(pThrd->asyncPool, &m->q); + transReleaseExHandle(transGetRefMgt(), refId); return 0; + _return1: tTrace("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); @@ -1207,6 +1210,7 @@ int transRegisterMsg(const STransMsg* msg) { STrans* pTransInst = pThrd->pTransInst; tTrace("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle); transAsyncSend(pThrd->asyncPool, &m->q); + transReleaseExHandle(transGetRefMgt(), refId); return 0; diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 93ced912f8..c69046f707 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -116,7 +116,6 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { } #endif } - // TODO truncate file if (found == NULL) { // file corrupted, no complete log @@ -125,8 +124,20 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal) { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } + + // truncate file SWalCkHead* lastEntry = (SWalCkHead*)found; int64_t retVer = lastEntry->head.version; + int64_t lastEntryBeginOffset = offset + (int64_t)((char*)found - (char*)buf); + int64_t lastEntryEndOffset = lastEntryBeginOffset + sizeof(SWalCkHead) + lastEntry->head.bodyLen; + if (lastEntryEndOffset != fileSize) { + wWarn("vgId:%d repair meta truncate file %s to %ld, orig size %ld", pWal->cfg.vgId, fnameStr, lastEntryEndOffset, + fileSize); + taosFtruncateFile(pFile, lastEntryEndOffset); + ((SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet))->fileSize = lastEntryEndOffset; + pWal->totSize -= (fileSize - lastEntryEndOffset); + } + taosCloseFile(&pFile); taosMemoryFree(buf); @@ -226,16 +237,92 @@ int walCheckAndRepairMeta(SWal* pWal) { } } - // TODO: set fileSize and lastVer if necessary - return 0; } int walCheckAndRepairIdx(SWal* pWal) { - // TODO: iterate all log files - // if idx not found, scan log and write idx - // if found, check complete by first and last entry of each idx file - // if idx incomplete, binary search last valid entry, and then build other part + int32_t sz = taosArrayGetSize(pWal->fileInfoSet); + for (int32_t i = 0; i < sz; i++) { + SWalFileInfo* pFileInfo = taosArrayGet(pWal->fileInfoSet, i); + + char fnameStr[WAL_FILE_LEN]; + walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr); + int64_t fsize; + TdFilePtr pIdxFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE); + if (pIdxFile == NULL) { + ASSERT(0); + terrno = TAOS_SYSTEM_ERROR(errno); + wError("vgId:%d, cannot open file %s, since %s", pWal->cfg.vgId, fnameStr, terrstr()); + return -1; + } + + taosFStatFile(pIdxFile, &fsize, NULL); + if (fsize == (pFileInfo->lastVer - pFileInfo->firstVer + 1) * sizeof(SWalIdxEntry)) { + taosCloseFile(&pIdxFile); + continue; + } + + int32_t left = fsize % sizeof(SWalIdxEntry); + int64_t offset = taosLSeekFile(pIdxFile, -left, SEEK_END); + if (left != 0) { + taosFtruncateFile(pIdxFile, offset); + wWarn("vgId:%d wal truncate file %s to offset %ld since size invalid, file size %ld", pWal->cfg.vgId, fnameStr, + offset, fsize); + } + offset -= sizeof(SWalIdxEntry); + + SWalIdxEntry idxEntry = {.ver = pFileInfo->firstVer}; + while (1) { + if (offset < 0) { + taosLSeekFile(pIdxFile, 0, SEEK_SET); + taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)); + break; + } + taosLSeekFile(pIdxFile, offset, SEEK_SET); + int64_t contLen = taosReadFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)); + if (contLen < 0 || contLen != sizeof(SWalIdxEntry)) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + if ((idxEntry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry) != offset) { + taosFtruncateFile(pIdxFile, offset); + wWarn("vgId:%d wal truncate file %s to offset %ld since entry invalid, entry ver %ld, entry offset %ld", + pWal->cfg.vgId, fnameStr, offset, idxEntry.ver, idxEntry.offset); + offset -= sizeof(SWalIdxEntry); + } else { + break; + } + } + + if (idxEntry.ver < pFileInfo->lastVer) { + char fLogNameStr[WAL_FILE_LEN]; + walBuildLogName(pWal, pFileInfo->firstVer, fLogNameStr); + TdFilePtr pLogFile = taosOpenFile(fLogNameStr, TD_FILE_READ); + if (pLogFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + wError("vgId:%d, cannot open file %s, since %s", pWal->cfg.vgId, fLogNameStr, terrstr()); + return -1; + } + while (idxEntry.ver < pFileInfo->lastVer) { + taosLSeekFile(pLogFile, idxEntry.offset, SEEK_SET); + SWalCkHead ckHead; + taosReadFile(pLogFile, &ckHead, sizeof(SWalCkHead)); + if (idxEntry.ver != ckHead.head.version) { + // todo truncate this idx also + taosCloseFile(&pLogFile); + wError("vgId:%d, invalid repair case, log seek to %ld to find ver %ld, actual ver %ld", pWal->cfg.vgId, + idxEntry.offset, idxEntry.ver, ckHead.head.version); + return -1; + } + idxEntry.ver = ckHead.head.version + 1; + idxEntry.offset = idxEntry.offset + sizeof(SWalCkHead) + ckHead.head.bodyLen; + wWarn("vgId:%d wal idx append new entry %ld %ld", pWal->cfg.vgId, idxEntry.ver, idxEntry.offset); + taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)); + } + taosCloseFile(&pLogFile); + } + taosCloseFile(&pIdxFile); + } return 0; } @@ -268,7 +355,7 @@ int walRollFileInfo(SWal* pWal) { char* walMetaSerialize(SWal* pWal) { char buf[30]; ASSERT(pWal->fileInfoSet); - int sz = pWal->fileInfoSet->size; + int sz = taosArrayGetSize(pWal->fileInfoSet); cJSON* pRoot = cJSON_CreateObject(); cJSON* pMeta = cJSON_CreateObject(); cJSON* pFiles = cJSON_CreateArray(); @@ -384,8 +471,10 @@ static int walFindCurMetaVer(SWal* pWal) { int code = regexec(&walMetaRegexPattern, name, 0, NULL, 0); if (code == 0) { sscanf(name, "meta-ver%d", &metaVer); + wDebug("vgId:%d, wal find current meta: %s is the meta file, ver %d", pWal->cfg.vgId, name, metaVer); break; } + wDebug("vgId:%d, wal find current meta: %s is not meta file", pWal->cfg.vgId, name); } taosCloseDir(&pDir); regfree(&walMetaRegexPattern); @@ -422,6 +511,7 @@ int walLoadMeta(SWal* pWal) { // find existing meta file int metaVer = walFindCurMetaVer(pWal); if (metaVer == -1) { + wDebug("vgId:%d wal find meta ver %d", pWal->cfg.vgId, metaVer); return -1; } char fnameStr[WAL_FILE_LEN]; diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index c939c8c436..a55f00d277 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -149,15 +149,21 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { walLoadMeta(pWal); if (walCheckAndRepairMeta(pWal) < 0) { + wError("vgId:%d cannot open wal since repair meta file failed", pWal->cfg.vgId); taosHashCleanup(pWal->pRefHash); taosRemoveRef(tsWal.refSetId, pWal->refId); taosThreadMutexDestroy(&pWal->mutex); taosArrayDestroy(pWal->fileInfoSet); - taosMemoryFree(pWal); return NULL; } if (walCheckAndRepairIdx(pWal) < 0) { + wError("vgId:%d cannot open wal since repair idx file failed", pWal->cfg.vgId); + taosHashCleanup(pWal->pRefHash); + taosRemoveRef(tsWal.refSetId, pWal->refId); + taosThreadMutexDestroy(&pWal->mutex); + taosArrayDestroy(pWal->fileInfoSet); + return NULL; } wDebug("vgId:%d, wal:%p is opened, level:%d fsyncPeriod:%d", pWal->cfg.vgId, pWal, pWal->cfg.level, diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 3dfb1458ad..418e86a40a 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -31,6 +31,15 @@ typedef struct TdDir { HANDLE hFind; } TdDir; +enum + { + WRDE_NOSPACE = 1, /* Ran out of memory. */ + WRDE_BADCHAR, /* A metachar appears in the wrong place. */ + WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */ + WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */ + WRDE_SYNTAX /* Shell syntax error. */ + }; + int wordexp(char *words, wordexp_t *pwordexp, int flags) { pwordexp->we_offs = 0; pwordexp->we_wordc = 1; @@ -265,9 +274,21 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) { int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) { wordexp_t full_path; - if (0 != wordexp(dirname, &full_path, 0)) { - printf("failed to expand path:%s since %s", dirname, strerror(errno)); - wordfree(&full_path); + switch (wordexp (dirname, &full_path, 0)) { + case 0: + break; + case WRDE_NOSPACE: + wordfree (&full_path); + // printf("failed to expand path:%s since Out of memory\n", dirname); + return -1; + case WRDE_BADCHAR: + // printf("failed to expand path:%s since illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }\n", dirname); + return -1; + case WRDE_SYNTAX: + // printf("failed to expand path:%s since Shell syntax error, such as unbalanced parentheses or unmatched quotes\n", dirname); + return -1; + default: + // printf("failed to expand path:%s since %s\n", dirname, strerror(errno)); return -1; } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 454739348e..4f170c203c 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -386,11 +386,12 @@ void* taosArrayDestroy(SArray* pArray) { } void taosArrayDestroyP(SArray* pArray, FDelete fp) { - if(!pArray) return; - for (int32_t i = 0; i < pArray->size; i++) { - fp(*(void**)TARRAY_GET_ELEM(pArray, i)); + if (pArray) { + for (int32_t i = 0; i < pArray->size; i++) { + fp(*(void**)TARRAY_GET_ELEM(pArray, i)); + } + taosArrayDestroy(pArray); } - taosArrayDestroy(pArray); } void taosArrayDestroyEx(SArray* pArray, FDelete fp) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index ba877915b1..62b9d87628 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -50,6 +50,7 @@ #define _DEFAULT_SOURCE #include "tcompression.h" #include "lz4.h" +#include "tRealloc.h" #include "tlog.h" #ifdef TD_TSZ @@ -814,24 +815,24 @@ int32_t tsCompressFloatImp(const char *const input, const int32_t nelements, cha uint32_t predicted = prev_value; uint32_t diff = curr.bits ^ predicted; - int32_t leading_zeros = FLOAT_BYTES * BITS_PER_BYTE; - int32_t trailing_zeros = leading_zeros; + int32_t clz = FLOAT_BYTES * BITS_PER_BYTE; + int32_t ctz = clz; if (diff) { - trailing_zeros = BUILDIN_CTZ(diff); - leading_zeros = BUILDIN_CLZ(diff); + ctz = BUILDIN_CTZ(diff); + clz = BUILDIN_CLZ(diff); } uint8_t nbytes = 0; uint8_t flag; - if (trailing_zeros > leading_zeros) { - nbytes = (uint8_t)(FLOAT_BYTES - trailing_zeros / BITS_PER_BYTE); + if (ctz > clz) { + nbytes = (uint8_t)(FLOAT_BYTES - ctz / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = ((uint8_t)1 << 3) | nbytes; } else { - nbytes = (uint8_t)(FLOAT_BYTES - leading_zeros / BITS_PER_BYTE); + nbytes = (uint8_t)(FLOAT_BYTES - clz / BITS_PER_BYTE); if (nbytes > 0) nbytes--; flag = nbytes; } @@ -994,3 +995,621 @@ int32_t tsDecompressDoubleLossyImp(const char *input, int32_t compressedSize, co return tdszDecompress(SZ_DOUBLE, input + 1, compressedSize - 1, nelements, output); } #endif + +/************************************************************************* + * STREAM COMPRESSION + *************************************************************************/ +#define I64_SAFE_ADD(a, b) (((a) >= 0 && (b) <= INT64_MAX - (b)) || ((a) < 0 && (b) >= INT64_MIN - (a))) +typedef struct SCompressor SCompressor; + +static int32_t tCompBool(SCompressor *pCmprsor, const void *pData, int32_t nData); +static int32_t tCompInt(SCompressor *pCmprsor, const void *pData, int32_t nData); +static int32_t tCompFloat(SCompressor *pCmprsor, const void *pData, int32_t nData); +static int32_t tCompDouble(SCompressor *pCmprsor, const void *pData, int32_t nData); +static int32_t tCompTimestamp(SCompressor *pCmprsor, const void *pData, int32_t nData); +static int32_t tCompBinary(SCompressor *pCmprsor, const void *pData, int32_t nData); +static struct { + int8_t type; + int32_t bytes; + int8_t isVarLen; + int32_t (*cmprFn)(SCompressor *, const void *, int32_t nData); +} DATA_TYPE_INFO[] = { + {TSDB_DATA_TYPE_NULL, 0, 0, NULL}, // TSDB_DATA_TYPE_NULL + {TSDB_DATA_TYPE_BOOL, 1, 0, tCompBool}, // TSDB_DATA_TYPE_BOOL + {TSDB_DATA_TYPE_TINYINT, 1, 0, tCompInt}, // TSDB_DATA_TYPE_TINYINT + {TSDB_DATA_TYPE_SMALLINT, 2, 0, tCompInt}, // TSDB_DATA_TYPE_SMALLINT + {TSDB_DATA_TYPE_INT, 4, 0, tCompInt}, // TSDB_DATA_TYPE_INT + {TSDB_DATA_TYPE_BIGINT, 8, 0, tCompInt}, // TSDB_DATA_TYPE_BIGINT + {TSDB_DATA_TYPE_FLOAT, 4, 0, tCompFloat}, // TSDB_DATA_TYPE_FLOAT + {TSDB_DATA_TYPE_DOUBLE, 8, 0, tCompDouble}, // TSDB_DATA_TYPE_DOUBLE + {TSDB_DATA_TYPE_VARCHAR, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_VARCHAR + {TSDB_DATA_TYPE_TIMESTAMP, 8, 0, tCompTimestamp}, // pTSDB_DATA_TYPE_TIMESTAMP + {TSDB_DATA_TYPE_NCHAR, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_NCHAR + {TSDB_DATA_TYPE_UTINYINT, 1, 0, tCompInt}, // TSDB_DATA_TYPE_UTINYINT + {TSDB_DATA_TYPE_USMALLINT, 2, 0, tCompInt}, // TSDB_DATA_TYPE_USMALLINT + {TSDB_DATA_TYPE_UINT, 4, 0, tCompInt}, // TSDB_DATA_TYPE_UINT + {TSDB_DATA_TYPE_UBIGINT, 8, 0, tCompInt}, // TSDB_DATA_TYPE_UBIGINT + {TSDB_DATA_TYPE_JSON, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_JSON + {TSDB_DATA_TYPE_VARBINARY, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_VARBINARY + {TSDB_DATA_TYPE_DECIMAL, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_DECIMAL + {TSDB_DATA_TYPE_BLOB, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_BLOB + {TSDB_DATA_TYPE_MEDIUMBLOB, 1, 1, tCompBinary}, // TSDB_DATA_TYPE_MEDIUMBLOB +}; + +struct SCompressor { + int8_t type; + int8_t cmprAlg; + int8_t autoAlloc; + int32_t nVal; + uint8_t *aBuf[2]; + int64_t nBuf[2]; + union { + // Timestamp ---- + struct { + int64_t ts_prev_val; + int64_t ts_prev_delta; + uint8_t *ts_flag_p; + }; + // Integer ---- + struct { + int64_t i_prev; + int32_t i_selector; + int32_t i_start; + int32_t i_end; + uint64_t i_aZigzag[241]; + int8_t i_aBitN[241]; + }; + // Float ---- + struct { + uint32_t f_prev; + uint8_t *f_flag_p; + }; + // Double ---- + struct { + uint64_t d_prev; + uint8_t *d_flag_p; + }; + }; +}; + +// Timestamp ===================================================== +static int32_t tCompSetCopyMode(SCompressor *pCmprsor) { + int32_t code = 0; + + if (pCmprsor->nVal) { + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[1], sizeof(int64_t) * pCmprsor->nVal); + if (code) return code; + } + pCmprsor->nBuf[1] = 0; + + int64_t n = 1; + int64_t value; + int64_t delta; + uint64_t vZigzag; + while (n < pCmprsor->nBuf[0]) { + uint8_t aN[2]; + aN[0] = pCmprsor->aBuf[0][n] & 0xf; + aN[1] = pCmprsor->aBuf[0][n] >> 4; + + n++; + + for (int32_t i = 0; i < 2; i++) { + vZigzag = 0; + for (uint8_t j = 0; j < aN[i]; j++) { + vZigzag |= (((uint64_t)pCmprsor->aBuf[0][n]) << (8 * j)); + n++; + } + + int64_t delta_of_delta = ZIGZAG_DECODE(int64_t, vZigzag); + if (pCmprsor->nBuf[1] == 0) { + delta = 0; + value = delta_of_delta; + } else { + delta = delta_of_delta + delta; + value = delta + value; + } + + memcpy(pCmprsor->aBuf[1] + pCmprsor->nBuf[1], &value, sizeof(int64_t)); + pCmprsor->nBuf[1] += sizeof(int64_t); + + if (n >= pCmprsor->nBuf[0]) break; + } + } + + ASSERT(n == pCmprsor->nBuf[0]); + + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[1] + 1); + if (code) return code; + } + memcpy(pCmprsor->aBuf[0] + 1, pCmprsor->aBuf[1], pCmprsor->nBuf[1]); + pCmprsor->nBuf[0] = 1 + pCmprsor->nBuf[1]; + } + pCmprsor->aBuf[0][0] = 0; + + return code; +} +static int32_t tCompTimestamp(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + int64_t ts = *(int64_t *)pData; + ASSERT(pCmprsor->type == TSDB_DATA_TYPE_TIMESTAMP); + ASSERT(nData == 8); + + if (pCmprsor->aBuf[0][0] == 1) { + if (pCmprsor->nVal == 0) { + pCmprsor->ts_prev_val = ts; + pCmprsor->ts_prev_delta = -ts; + } + + if (!I64_SAFE_ADD(ts, -pCmprsor->ts_prev_val)) { + code = tCompSetCopyMode(pCmprsor); + if (code) return code; + goto _copy_cmpr; + } + int64_t delta = ts - pCmprsor->ts_prev_val; + + if (!I64_SAFE_ADD(delta, -pCmprsor->ts_prev_delta)) { + code = tCompSetCopyMode(pCmprsor); + if (code) return code; + goto _copy_cmpr; + } + int64_t delta_of_delta = delta - pCmprsor->ts_prev_delta; + uint64_t vZigzag = ZIGZAG_ENCODE(int64_t, delta_of_delta); + + pCmprsor->ts_prev_val = ts; + pCmprsor->ts_prev_delta = delta; + + if ((pCmprsor->nVal & 0x1) == 0) { + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + 17); + if (code) return code; + } + + pCmprsor->ts_flag_p = pCmprsor->aBuf[0] + pCmprsor->nBuf[0]; + pCmprsor->nBuf[0]++; + pCmprsor->ts_flag_p[0] = 0; + while (vZigzag) { + pCmprsor->aBuf[0][pCmprsor->nBuf[0]] = (vZigzag & 0xff); + pCmprsor->nBuf[0]++; + pCmprsor->ts_flag_p[0]++; + vZigzag >>= 8; + } + } else { + while (vZigzag) { + pCmprsor->aBuf[0][pCmprsor->nBuf[0]] = (vZigzag & 0xff); + pCmprsor->nBuf[0]++; + pCmprsor->ts_flag_p[0] += 0x10; + vZigzag >>= 8; + } + } + } else { + _copy_cmpr: + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + sizeof(ts)); + if (code) return code; + } + + memcpy(pCmprsor->aBuf[0] + pCmprsor->nBuf[0], &ts, sizeof(ts)); + pCmprsor->nBuf[0] += sizeof(ts); + } + pCmprsor->nVal++; + + return code; +} + +// Integer ===================================================== +#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL) +static const uint8_t BIT_PER_INTEGER[] = {0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 20, 30, 60}; +static const int32_t SELECTOR_TO_ELEMS[] = {240, 120, 60, 30, 20, 15, 12, 10, 8, 7, 6, 5, 4, 3, 2, 1}; +static const uint8_t BIT_TO_SELECTOR[] = {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 12, + 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}; + +static int32_t tCompInt(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + ASSERT(nData == DATA_TYPE_INFO[pCmprsor->type].bytes); + + if (pCmprsor->aBuf[0][0] == 0) { + int64_t val; + + switch (pCmprsor->type) { + case TSDB_DATA_TYPE_TINYINT: + val = *(int8_t *)pData; + break; + case TSDB_DATA_TYPE_SMALLINT: + val = *(int16_t *)pData; + break; + case TSDB_DATA_TYPE_INT: + val = *(int32_t *)pData; + break; + case TSDB_DATA_TYPE_BIGINT: + val = *(int64_t *)pData; + break; + case TSDB_DATA_TYPE_UTINYINT: + val = *(uint8_t *)pData; + break; + case TSDB_DATA_TYPE_USMALLINT: + val = *(uint16_t *)pData; + break; + case TSDB_DATA_TYPE_UINT: + val = *(uint32_t *)pData; + break; + case TSDB_DATA_TYPE_UBIGINT: + val = *(int64_t *)pData; + break; + default: + ASSERT(0); + break; + } + + if (!I64_SAFE_ADD(val, -pCmprsor->i_prev)) { + // TODO + goto _copy_cmpr; + } + + int64_t diff = val - pCmprsor->i_prev; + uint64_t vZigzag = ZIGZAG_ENCODE(int64_t, diff); + if (vZigzag >= SIMPLE8B_MAX) { + // TODO + goto _copy_cmpr; + } + + int8_t nBit = (vZigzag) ? (64 - BUILDIN_CLZL(vZigzag)) : 0; + pCmprsor->i_prev = val; + + while (1) { + int32_t nEle = (pCmprsor->i_end + 241 - pCmprsor->i_start) % 241; + + if (nEle + 1 <= SELECTOR_TO_ELEMS[pCmprsor->i_selector] && nEle + 1 <= SELECTOR_TO_ELEMS[BIT_TO_SELECTOR[nBit]]) { + if (pCmprsor->i_selector < BIT_TO_SELECTOR[nBit]) { + pCmprsor->i_selector = BIT_TO_SELECTOR[nBit]; + } + pCmprsor->i_end = (pCmprsor->i_end + 1) % 241; + pCmprsor->i_aZigzag[pCmprsor->i_end] = vZigzag; + pCmprsor->i_aBitN[pCmprsor->i_end] = nBit; + break; + } else { + while (nEle < SELECTOR_TO_ELEMS[pCmprsor->i_selector]) { + pCmprsor->i_selector++; + } + nEle = SELECTOR_TO_ELEMS[pCmprsor->i_selector]; + + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + sizeof(uint64_t)); + if (code) return code; + } + + uint64_t *bp = (uint64_t *)(pCmprsor->aBuf[0] + pCmprsor->nBuf[0]); + pCmprsor->nBuf[0] += sizeof(uint64_t); + bp[0] = pCmprsor->i_selector; + uint8_t bits = BIT_PER_INTEGER[pCmprsor->i_selector]; + for (int32_t iVal = 0; iVal < nEle; iVal++) { + bp[0] |= ((pCmprsor->i_aZigzag[pCmprsor->i_start] & ((((uint64_t)1) << bits) - 1)) << (bits * iVal + 4)); + pCmprsor->i_start = (pCmprsor->i_start + 1) % 241; + } + + // reset and continue + pCmprsor->i_selector = 0; + for (int32_t iVal = pCmprsor->i_start; iVal < pCmprsor->i_end; iVal = (iVal + 1) % 241) { + if (pCmprsor->i_selector < BIT_TO_SELECTOR[pCmprsor->i_aBitN[iVal]]) { + pCmprsor->i_selector = BIT_TO_SELECTOR[pCmprsor->i_aBitN[iVal]]; + } + } + } + } + } else { + _copy_cmpr: + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + nData); + if (code) return code; + + memcpy(pCmprsor->aBuf[0] + pCmprsor->nBuf[0], pData, nData); + pCmprsor->nBuf[0] += nData; + } + pCmprsor->nVal++; + + return code; +} + +// Float ===================================================== +static int32_t tCompFloat(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + ASSERT(nData == sizeof(float)); + + union { + float f; + uint32_t u; + } val = {.f = *(float *)pData}; + + uint32_t diff = val.u ^ pCmprsor->f_prev; + pCmprsor->f_prev = val.u; + + int32_t clz, ctz; + if (diff) { + clz = BUILDIN_CLZ(diff); + ctz = BUILDIN_CTZ(diff); + } else { + clz = 32; + ctz = 32; + } + + uint8_t nBytes; + if (clz < ctz) { + nBytes = sizeof(uint32_t) - ctz / BITS_PER_BYTE; + if (nBytes) diff >>= (32 - nBytes * BITS_PER_BYTE); + } else { + nBytes = sizeof(uint32_t) - clz / BITS_PER_BYTE; + } + if (nBytes == 0) nBytes++; + + if ((pCmprsor->nVal & 0x1) == 0) { + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + 9); + if (code) return code; + } + + pCmprsor->f_flag_p = &pCmprsor->aBuf[0][pCmprsor->nBuf[0]]; + pCmprsor->nBuf[0]++; + + if (clz < ctz) { + pCmprsor->f_flag_p[0] = (0x08 | (nBytes - 1)); + } else { + pCmprsor->f_flag_p[0] = nBytes - 1; + } + } else { + if (clz < ctz) { + pCmprsor->f_flag_p[0] |= ((0x08 | (nBytes - 1)) << 4); + } else { + pCmprsor->f_flag_p[0] |= ((nBytes - 1) << 4); + } + } + for (; nBytes; nBytes--) { + pCmprsor->aBuf[0][pCmprsor->nBuf[0]] = (diff & 0xff); + pCmprsor->nBuf[0]++; + diff >>= BITS_PER_BYTE; + } + pCmprsor->nVal++; + + return code; +} + +// Double ===================================================== +static int32_t tCompDouble(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + ASSERT(nData == sizeof(double)); + + union { + double d; + uint64_t u; + } val = {.d = *(double *)pData}; + + uint64_t diff = val.u ^ pCmprsor->d_prev; + pCmprsor->d_prev = val.u; + + int32_t clz, ctz; + if (diff) { + clz = BUILDIN_CLZL(diff); + ctz = BUILDIN_CTZL(diff); + } else { + clz = 64; + ctz = 64; + } + + uint8_t nBytes; + if (clz < ctz) { + nBytes = sizeof(uint64_t) - ctz / BITS_PER_BYTE; + if (nBytes) diff >>= (64 - nBytes * BITS_PER_BYTE); + } else { + nBytes = sizeof(uint64_t) - clz / BITS_PER_BYTE; + } + if (nBytes == 0) nBytes++; + + if ((pCmprsor->nVal & 0x1) == 0) { + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + 17); + if (code) return code; + } + + pCmprsor->d_flag_p = &pCmprsor->aBuf[0][pCmprsor->nBuf[0]]; + pCmprsor->nBuf[0]++; + + if (clz < ctz) { + pCmprsor->d_flag_p[0] = (0x08 | (nBytes - 1)); + } else { + pCmprsor->d_flag_p[0] = nBytes - 1; + } + } else { + if (clz < ctz) { + pCmprsor->d_flag_p[0] |= ((0x08 | (nBytes - 1)) << 4); + } else { + pCmprsor->d_flag_p[0] |= ((nBytes - 1) << 4); + } + } + for (; nBytes; nBytes--) { + pCmprsor->aBuf[0][pCmprsor->nBuf[0]] = (diff & 0xff); + pCmprsor->nBuf[0]++; + diff >>= BITS_PER_BYTE; + } + pCmprsor->nVal++; + + return code; +} + +// Binary ===================================================== +static int32_t tCompBinary(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + if (nData) { + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0] + nData); + if (code) return code; + } + + memcpy(pCmprsor->aBuf[0] + pCmprsor->nBuf[0], pData, nData); + pCmprsor->nBuf[0] += nData; + } + pCmprsor->nVal++; + + return code; +} + +// Bool ===================================================== +static const uint8_t BOOL_CMPR_TABLE[] = {0b01, 0b0100, 0b010000, 0b01000000}; + +static int32_t tCompBool(SCompressor *pCmprsor, const void *pData, int32_t nData) { + int32_t code = 0; + + bool vBool = *(int8_t *)pData; + + int32_t mod4 = pCmprsor->nVal & 3; + if (mod4 == 0) { + pCmprsor->nBuf[0]++; + + if (pCmprsor->autoAlloc) { + code = tRealloc(&pCmprsor->aBuf[0], pCmprsor->nBuf[0]); + if (code) return code; + } + + pCmprsor->aBuf[0][pCmprsor->nBuf[0] - 1] = 0; + } + if (vBool) { + pCmprsor->aBuf[0][pCmprsor->nBuf[0] - 1] |= BOOL_CMPR_TABLE[mod4]; + } + pCmprsor->nVal++; + + return code; +} + +// SCompressor ===================================================== +int32_t tCompressorCreate(SCompressor **ppCmprsor) { + int32_t code = 0; + + *ppCmprsor = (SCompressor *)taosMemoryCalloc(1, sizeof(SCompressor)); + if ((*ppCmprsor) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + code = tRealloc(&(*ppCmprsor)->aBuf[0], 1024); + if (code) { + taosMemoryFree(*ppCmprsor); + *ppCmprsor = NULL; + goto _exit; + } + +_exit: + return code; +} + +int32_t tCompressorDestroy(SCompressor *pCmprsor) { + int32_t code = 0; + + if (pCmprsor) { + int32_t nBuf = sizeof(pCmprsor->aBuf) / sizeof(pCmprsor->aBuf[0]); + for (int32_t iBuf = 0; iBuf < nBuf; iBuf++) { + tFree(pCmprsor->aBuf[iBuf]); + } + + taosMemoryFree(pCmprsor); + } + + return code; +} + +int32_t tCompressorReset(SCompressor *pCmprsor, int8_t type, int8_t cmprAlg, int8_t autoAlloc) { + int32_t code = 0; + + pCmprsor->type = type; + pCmprsor->cmprAlg = cmprAlg; + pCmprsor->autoAlloc = autoAlloc; + pCmprsor->nVal = 0; + + switch (type) { + case TSDB_DATA_TYPE_TIMESTAMP: + pCmprsor->ts_prev_val = 0; + pCmprsor->ts_prev_delta = 0; + pCmprsor->ts_flag_p = NULL; + pCmprsor->aBuf[0][0] = 1; // For timestamp, 1 means compressed, 0 otherwise + pCmprsor->nBuf[0] = 1; + break; + case TSDB_DATA_TYPE_BOOL: + pCmprsor->nBuf[0] = 0; + break; + case TSDB_DATA_TYPE_BINARY: + pCmprsor->nBuf[0] = 0; + break; + case TSDB_DATA_TYPE_FLOAT: + pCmprsor->f_prev = 0; + pCmprsor->f_flag_p = NULL; + pCmprsor->aBuf[0][0] = 0; // 0 means compressed, 1 otherwise (for backward compatibility) + pCmprsor->nBuf[0] = 1; + break; + case TSDB_DATA_TYPE_DOUBLE: + pCmprsor->d_prev = 0; + pCmprsor->d_flag_p = NULL; + pCmprsor->aBuf[0][0] = 0; // 0 means compressed, 1 otherwise (for backward compatibility) + pCmprsor->nBuf[0] = 1; + break; + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_UBIGINT: + pCmprsor->i_prev = 0; + pCmprsor->i_selector = 0; + pCmprsor->i_start = 0; + pCmprsor->i_end = 0; + pCmprsor->aBuf[0][0] = 0; // 0 means compressed, 1 otherwise (for backward compatibility) + pCmprsor->nBuf[0] = 1; + break; + default: + break; + } + + return code; +} + +int32_t tCompGen(SCompressor *pCmprsor, const uint8_t **ppData, int64_t *nData) { + int32_t code = 0; + + if (pCmprsor->nVal == 0) { + *ppData = NULL; + *nData = 0; + return code; + } + + if (pCmprsor->cmprAlg == TWO_STAGE_COMP /*|| IS_VAR_DATA_TYPE(pCmprsor->type)*/) { + code = tRealloc(&pCmprsor->aBuf[1], pCmprsor->nBuf[0] + 1); + if (code) return code; + + int64_t ret = LZ4_compress_default(pCmprsor->aBuf[0], pCmprsor->aBuf[1] + 1, pCmprsor->nBuf[0], pCmprsor->nBuf[0]); + if (ret) { + pCmprsor->aBuf[1][0] = 0; + pCmprsor->nBuf[1] = ret + 1; + } else { + pCmprsor->aBuf[1][0] = 1; + memcpy(pCmprsor->aBuf[1] + 1, pCmprsor->aBuf[0], pCmprsor->nBuf[0]); + pCmprsor->nBuf[1] = pCmprsor->nBuf[0] + 1; + } + + *ppData = pCmprsor->aBuf[1]; + *nData = pCmprsor->nBuf[1]; + } else { + *ppData = pCmprsor->aBuf[0]; + *nData = pCmprsor->nBuf[0]; + } + + return code; +} + +int32_t tCompress(SCompressor *pCmprsor, const void *pData, int64_t nData) { + return DATA_TYPE_INFO[pCmprsor->type].cmprFn(pCmprsor, pData, nData); +} \ No newline at end of file diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 50c42ff170..1906a77127 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -621,6 +621,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP, "Rsma fetch msg is m TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_EMPTY_INFO, "Rsma info is empty") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_SCHEMA, "Rsma invalid schema") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_REGEX_MATCH, "Rsma regex match") +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_STREAM_STATE_OPEN, "Rsma stream state open") +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_STREAM_STATE_COMMIT, "Rsma stream state commit") //index TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding") diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 2767fed937..e1a8697ad5 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -284,7 +284,6 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) { // all pages are referenced by user, try to allocate new space if (pn == NULL) { - assert(0); int32_t prev = pBuf->inMemPages; // increase by 50% of previous mem pages @@ -304,7 +303,6 @@ static char* evacOneDataPage(SDiskbasedBuf* pBuf) { bufPage = flushPageToDisk(pBuf, d); } - ASSERT((bufPage != NULL) || terrno != TSDB_CODE_SUCCESS); return bufPage; } @@ -377,12 +375,6 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { char* availablePage = NULL; if (NO_IN_MEM_AVAILABLE_PAGES(pBuf)) { availablePage = evacOneDataPage(pBuf); - - // Failed to allocate a new buffer page, and there is an error occurs. - if (availablePage == NULL) { - assert(0); - return NULL; - } } SPageInfo* pi = NULL; @@ -652,4 +644,4 @@ void clearDiskbasedBuf(SDiskbasedBuf* pBuf) { pBuf->totalBufSize = 0; pBuf->allocateId = -1; pBuf->fileSize = 0; -} \ No newline at end of file +} diff --git a/tests/docs-examples-test/csharp.sh b/tests/docs-examples-test/csharp.sh index a8f1ce4119..8d1031ab8f 100644 --- a/tests/docs-examples-test/csharp.sh +++ b/tests/docs-examples-test/csharp.sh @@ -6,23 +6,32 @@ pgrep taosd || taosd >> /dev/null 2>&1 & pgrep taosadapter || taosadapter >> /dev/null 2>&1 & cd ../../docs/examples/csharp -dotnet run --project connect.csproj +dotnet run --project connect/connect.csproj taos -s "drop database if exists power" -dotnet run --project sqlinsert.csproj -dotnet run --project query.csproj -dotnet run --project asyncquery.csproj -dotnet run --project subscribe.csproj +dotnet run --project sqlInsert/sqlinsert.csproj +dotnet run --project query/query.csproj +dotnet run --project asyncQuery/asyncquery.csproj +dotnet run --project subscribe/subscribe.csproj taos -s "drop topic if exists topic_example" taos -s "drop database if exists power" -dotnet run --project stmtinsert.csproj +dotnet run --project stmtInsert/stmtinsert.csproj taos -s "drop database if exists test" -dotnet run --project influxdbline.csproj +dotnet run --project influxdbLine/influxdbline.csproj taos -s "drop database if exists test" -dotnet run --project optstelnet.csproj +dotnet run --project optsTelnet/optstelnet.csproj taos -s "drop database if exists test" -dotnet run --project optsjson.csproj \ No newline at end of file +dotnet run --project optsJSON/optsJSON.csproj + +taos -s "create database if exists test" +dotnet run --project wsConnect/wsConnect.csproj +dotnet run --project wsInsert/wsInsert.csproj +dotnet run --project wsStmt/wsStmt.csproj +dotnet run --project wsQuery/wsQuery.csproj + +taos -s "drop database if exists test" +taos -s "drop database if exists power" \ No newline at end of file diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh index f0ee9be46f..bb57f238f0 100755 --- a/tests/parallel_test/run_container.sh +++ b/tests/parallel_test/run_container.sh @@ -79,9 +79,11 @@ fi ulimit -c unlimited TMP_DIR=$WORKDIR/tmp - +SOURCEDIR=$WORKDIR/src MOUNT_DIR="" +packageName="TDengine-server-3.0.1.0-Linux-x64.tar.gz" rm -rf ${TMP_DIR}/thread_volume/$thread_no/sim +mkdir -p $SOURCEDIR mkdir -p ${TMP_DIR}/thread_volume/$thread_no/sim/tsim mkdir -p ${TMP_DIR}/thread_volume/$thread_no/coredump rm -rf ${TMP_DIR}/thread_volume/$thread_no/coredump/* @@ -90,6 +92,11 @@ if [ ! -d "${TMP_DIR}/thread_volume/$thread_no/$exec_dir" ]; then echo "cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/" cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/ fi + +if [ ! -f "${SOURCEDIR}/${packageName}" ]; then + wget -P ${SOURCEDIR} https://taosdata.com/assets-download/3.0/${packageName} +fi + MOUNT_DIR="$TMP_DIR/thread_volume/$thread_no/$exec_dir:$CONTAINER_TESTDIR/tests/$exec_dir" echo "$thread_no -> ${exec_dir}:$cmd" coredump_dir=`cat /proc/sys/kernel/core_pattern | xargs dirname` @@ -97,6 +104,7 @@ coredump_dir=`cat /proc/sys/kernel/core_pattern | xargs dirname` docker run \ -v $REP_MOUNT_PARAM \ -v $MOUNT_DIR \ + -v ${SOURCEDIR}:/usr/local/src/ \ -v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \ -v ${TMP_DIR}/thread_volume/$thread_no/coredump:$coredump_dir \ -v $WORKDIR/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \ diff --git a/tests/script/sh/gpd.c b/tests/script/sh/gpd.c new file mode 100644 index 0000000000..8d69bacb5e --- /dev/null +++ b/tests/script/sh/gpd.c @@ -0,0 +1,74 @@ +#include +#include +#include +#ifdef LINUX +#include +#endif +#ifdef WINDOWS +#include +#endif +#include "taosudf.h" + +TAOS* taos = NULL; + +DLL_EXPORT int32_t gpd_init() { + taos = taos_connect("localhost", "root", "taosdata", "", 7100); + return 0; +} + +DLL_EXPORT int32_t gpd_destroy() { + taos_close(taos); + taos_cleanup(); + return 0; +} + +DLL_EXPORT int32_t gpd(SUdfDataBlock* block, SUdfColumn *resultCol) { + SUdfColumnMeta *meta = &resultCol->colMeta; + meta->bytes = 4; + meta->type = TSDB_DATA_TYPE_INT; + meta->scale = 0; + meta->precision = 0; + + SUdfColumnData *resultData = &resultCol->colData; + resultData->numOfRows = block->numOfRows; + for (int32_t i = 0; i < resultData->numOfRows; ++i) { + int j = 0; + for (; j < block->numOfCols; ++j) { + if (udfColDataIsNull(block->udfCols[j], i)) { + udfColDataSetNull(resultCol, i); + break; + } + } + if ( j == block->numOfCols) { + int32_t luckyNum = 88; + udfColDataSet(resultCol, i, (char *)&luckyNum, false); + } + } + TAOS_RES* res = taos_query(taos, "create database if not exists gpd"); + if (taos_errno(res) != 0) { + char* errstr = taos_errstr(res); + } + res = taos_query(taos, "create table gpd.st (ts timestamp, f int) tags(t int)"); + if (taos_errno(res) != 0) { + char* errstr = taos_errstr(res); + } + + taos_query(taos, "insert into gpd.t using gpd.st tags(1) values(now, 1) "); + if (taos_errno(res) != 0) { + char* errstr = taos_errstr(res); + } + + taos_query(taos, "select * from gpd.t"); + if (taos_errno(res) != 0) { + char* errstr = taos_errstr(res); + } + + //to simulate actual processing delay by udf +#ifdef LINUX + usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second) +#endif +#ifdef WINDOWS + Sleep(1); +#endif + return 0; +} diff --git a/tests/script/tsim/insert/basic.sim b/tests/script/tsim/insert/basic.sim index c4ef3e39da..c926cbc8b0 100644 --- a/tests/script/tsim/insert/basic.sim +++ b/tests/script/tsim/insert/basic.sim @@ -12,7 +12,7 @@ $tb = $tbPrefix . $i print =============== step1 sql drop database -x step1 step1: -sql create database $db +sql create database $db vgroups 2 sql use $db sql create table $tb (ts timestamp, speed int) diff --git a/tests/script/tsim/parser/union.sim b/tests/script/tsim/parser/union.sim index 8bafeff444..8dc19912c8 100644 --- a/tests/script/tsim/parser/union.sim +++ b/tests/script/tsim/parser/union.sim @@ -116,7 +116,7 @@ sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 l sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 limit 1) limit 1 # sql with parenthese -sql (((select c1 from union_tb0))) +sql (select c1 from union_tb0) if $rows != 10000 then return -1 endi diff --git a/tests/script/tsim/query/udf.sim b/tests/script/tsim/query/udf.sim index 7f8b1044ef..0b48a815e2 100644 --- a/tests/script/tsim/query/udf.sim +++ b/tests/script/tsim/query/udf.sim @@ -144,18 +144,18 @@ if $data20 != 8.000000000 then return -1 endi -sql drop function bit_and; -sql show functions; -if $rows != 1 then - return -1 -endi -if $data00 != @l2norm@ then - return -1 - endi -sql drop function l2norm; -sql show functions; -if $rows != 0 then - return -1 -endi +#sql drop function bit_and; +#sql show functions; +#if $rows != 1 then +# return -1 +#endi +#if $data00 != @l2norm@ then +# return -1 +# endi +#sql drop function l2norm; +#sql show functions; +#if $rows != 0 then +# return -1 +#endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/trans/create_db.sim b/tests/script/tsim/trans/create_db.sim index 8543bec144..f04e505dd5 100644 --- a/tests/script/tsim/trans/create_db.sim +++ b/tests/script/tsim/trans/create_db.sim @@ -56,7 +56,7 @@ if $data[0][2] != redoAction then return -1 endi -if $data[0][3] != d1 then +if $data[0][4] != d1 then return -1 endi @@ -120,7 +120,7 @@ if $system_content != Windows_NT then return -1 endi - if $data[0][3] != d2 then + if $data[0][4] != d2 then return -1 endi diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py new file mode 100644 index 0000000000..25b023bb76 --- /dev/null +++ b/tests/system-test/0-others/compatibility.py @@ -0,0 +1,157 @@ +from urllib.parse import uses_relative +import taos +import sys +import os +import time + + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.dnodes import TDDnodes +from util.dnodes import TDDnode +from util.cluster import * + + +class TDTestCase: + def caseDescription(self): + ''' + 3.0 data compatibility test + case1: basedata version is 3.0.1.0 + ''' + return + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def getCfgPath(self): + buildPath = self.getBuildPath() + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + cfgPath = buildPath + "/../sim/dnode1/cfg/" + else: + cfgPath = buildPath + "/../sim/dnode1/cfg/" + + return cfgPath + + def installTaosd(self,bPath,cPath): + # os.system(f"rmtaos && mkdir -p {self.getBuildPath()}/build/lib/temp && mv {self.getBuildPath()}/build/lib/libtaos.so* {self.getBuildPath()}/build/lib/temp/ ") + # os.system(f" mv {bPath}/build {bPath}/build_bak ") + # os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so {self.getBuildPath()}/build/lib/libtaos.so_bak ") + # os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so.1 {self.getBuildPath()}/build/lib/libtaos.so.1_bak ") + + packagePath="/usr/local/src/" + packageName="TDengine-server-3.0.1.0-Linux-x64.tar.gz" + os.system(f"cd {packagePath} && tar xvf TDengine-server-3.0.1.0-Linux-x64.tar.gz && cd TDengine-server-3.0.1.0 && ./install.sh -e no " ) + tdDnodes.stop(1) + print(f"start taosd: nohup taosd -c {cPath} & ") + os.system(f" nohup taosd -c {cPath} & " ) + sleep(1) + + + + def buildTaosd(self,bPath): + # os.system(f"mv {bPath}/build_bak {bPath}/build ") + os.system(f" cd {bPath} && make install ") + + + def run(self): + bPath=self.getBuildPath() + cPath=self.getCfgPath() + dbname = "test" + stb = f"{dbname}.meters" + self.installTaosd(bPath,cPath) + tableNumbers=100 + recordNumbers1=100 + recordNumbers2=1000 + tdsqlF=tdCom.newTdSql() + print(tdsqlF) + tdsqlF.query(f"SELECT SERVER_VERSION();") + print(tdsqlF.query(f"SELECT SERVER_VERSION();")) + oldServerVersion=tdsqlF.queryResult[0][0] + tdLog.info(f"Base server version is {oldServerVersion}") + tdsqlF.query(f"SELECT CLIENT_VERSION();") + # the oldClientVersion can't be updated in the same python process,so the version is new compiled verison + oldClientVersion=tdsqlF.queryResult[0][0] + tdLog.info(f"Base client version is {oldClientVersion}") + + tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{oldServerVersion}") + tdLog.info(f"taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") + os.system(f"taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") + sleep(3) + + # tdsqlF.query(f"select count(*) from {stb}") + # tdsqlF.checkData(0,0,tableNumbers*recordNumbers1) + os.system("pkill taosd") + sleep(1) + + tdLog.printNoPrefix("==========step2:update new version ") + self.buildTaosd(bPath) + tdDnodes.start(1) + sleep(1) + tdsql=tdCom.newTdSql() + print(tdsql) + + + tdsql.query(f"SELECT SERVER_VERSION();") + nowServerVersion=tdsql.queryResult[0][0] + tdLog.info(f"New server version is {nowServerVersion}") + tdsql.query(f"SELECT CLIENT_VERSION();") + nowClientVersion=tdsql.queryResult[0][0] + tdLog.info(f"New client version is {nowClientVersion}") + + tdLog.printNoPrefix(f"==========step3:prepare and check data in new version-{nowServerVersion}") + tdsql.query(f"select count(*) from {stb}") + tdsql.checkData(0,0,tableNumbers*recordNumbers1) + os.system(f"taosBenchmark -t {tableNumbers} -n {recordNumbers2} -y ") + tdsql.query(f"select count(*) from {stb}") + tdsql.checkData(0,0,tableNumbers*recordNumbers2) + + tdsql=tdCom.newTdSql() + tdLog.printNoPrefix(f"==========step4:verify backticks in taos Sql-TD18542") + tdsql.execute("drop database if exists db") + tdsql.execute("create database db") + tdsql.execute("use db") + tdsql.execute("create stable db.stb1 (ts timestamp, c1 int) tags (t1 int);") + tdsql.execute("insert into db.ct1 using db.stb1 TAGS(1) values(now(),11);") + tdsql.error(" insert into `db.ct2` using db.stb1 TAGS(9) values(now(),11);") + tdsql.error(" insert into db.`db.ct2` using db.stb1 TAGS(9) values(now(),11);") + tdsql.execute("insert into `db`.ct3 using db.stb1 TAGS(3) values(now(),13);") + tdsql.query("select * from db.ct3") + tdsql.checkData(0,1,13) + tdsql.execute("insert into db.`ct4` using db.stb1 TAGS(4) values(now(),14);") + tdsql.query("select * from db.ct4") + tdsql.checkData(0,1,14) + tdsql.query("describe information_schema.ins_databases;") + qRows=tdsql.queryRows + for i in range(qRows) : + if tdsql.queryResult[i][0]=="retentions" : + return True + else: + return False + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/database_pre_suf.py b/tests/system-test/1-insert/database_pre_suf.py new file mode 100755 index 0000000000..fc4bf7f5de --- /dev/null +++ b/tests/system-test/1-insert/database_pre_suf.py @@ -0,0 +1,377 @@ +################################################################### +# 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 -*- + +import random +import os +import time +import taos +import subprocess +from faker import Faker +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * + +class TDTestCase: + updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.testcasePath = os.path.split(__file__)[0] + self.testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.db = "pre_suf" + + def dropandcreateDB_random(self,database,n,vgroups,table_prefix,table_suffix,check_result): + ts = 1630000000000 + num_random = 100 + fake = Faker('zh_CN') + tdSql.execute('''drop database if exists %s ;''' %database) + tdSql.execute('''create database %s keep 36500 vgroups %d table_prefix %d table_suffix %d;'''%(database,vgroups,table_prefix,table_suffix)) + tdSql.execute('''use %s;'''%database) + + tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + + for i in range(10*n): + tdSql.execute('''create table bj_%d (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i) + tdSql.execute('''create table sh_%d (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i) + tdSql.execute('''create table bj_table_%d_r (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i) + tdSql.execute('''create table sh_table_%d_r (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp ) ;'''%i) + tdSql.execute('''create table hn_table_%d_r \ + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;'''%i) + tdSql.execute('''create table bj_stable_1_%d using stable_1 tags('bj_stable_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table sh_table_%d_a using stable_1 tags('sh_a_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table sh_table_%d_b using stable_1 tags('sh_b_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table sh_table_%d_c using stable_1 tags('sh_c_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + tdSql.execute('''create table bj_table_%d_a using stable_1 tags('bj_a_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table bj_table_%d_b using stable_1 tags('bj_b_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table bj_table_%d_c using stable_1 tags('bj_c_table_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + + tdSql.execute('''create table tj_table_%d_a using stable_2 tags('tj_a_table_2_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table tj_table_%d_b using stable_2 tags('tj_b_table_2_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(i,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + + # create stream + tdSql.execute('''create stream current_stream into stream_max_stable_1 as select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s);''') + + # insert data + for i in range(num_random*n): + tdSql.execute('''insert into bj_stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + tdSql.execute('''insert into hn_table_1_r (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.execute('''insert into bj_stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8)\ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + tdSql.execute('''insert into hn_table_2_r (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.execute('''insert into bj_stable_1_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.execute('''insert into bj_stable_1_4 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +1, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.execute('''insert into bj_stable_1_5 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +10, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.query("select count(*) from stable_1;") + tdSql.checkData(0,0,5*num_random*n) + tdSql.query("select count(*) from hn_table_1_r;") + tdSql.checkData(0,0,num_random*n) + + # stream data check + tdSql.query("select start,wend,max_int from stream_max_stable_1 ;") + tdSql.checkRows(20) + tdSql.query("select sum(max_int) from stream_max_stable_1 ;") + stream_data_1 = tdSql.queryResult[0][0] + tdSql.query("select sum(min_int) from stream_max_stable_1 ;") + stream_data_2 = tdSql.queryResult[0][0] + tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 where ts is not null interval (5s));") + sql_data_1 = tdSql.queryResult[0][0] + sql_data_2 = tdSql.queryResult[0][1] + + self.stream_value_check(stream_data_1,sql_data_1) + self.stream_value_check(stream_data_2,sql_data_2) + + tdSql.query("select sum(max_int),sum(min_int) from (select _wstart as start, _wend as wend, max(q_int) as max_int, min(q_bigint) as min_int from stable_1 interval (5s));") + sql_data_1 = tdSql.queryResult[0][0] + sql_data_2 = tdSql.queryResult[0][1] + + self.stream_value_check(stream_data_1,sql_data_1) + self.stream_value_check(stream_data_2,sql_data_2) + + tdSql.query("select max(max_int) from stream_max_stable_1 ;") + stream_data_1 = tdSql.queryResult[0][0] + tdSql.query("select min(min_int) from stream_max_stable_1 ;") + stream_data_2 = tdSql.queryResult[0][0] + tdSql.query("select max(q_int) as max_int, min(q_bigint) as min_int from stable_1;") + sql_data_1 = tdSql.queryResult[0][0] + sql_data_2 = tdSql.queryResult[0][1] + + self.stream_value_check(stream_data_1,sql_data_1) + self.stream_value_check(stream_data_2,sql_data_2) + + + tdSql.query(" select * from information_schema.ins_databases where name = '%s';" %database) + print(tdSql.queryResult) + + # tdSql.query(" select table_prefix,table_suffix from information_schema.ins_databases where name = '%s';" %database) + # print(tdSql.queryResult) + #TD-19082 + + #tdSql.query(" select * from information_schema.ins_tables where db_name = '%s';" %database) + #print(tdSql.queryResult) + + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s';" %database) + queryRows = len(tdSql.queryResult) + for i in range(queryRows): + print("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0])) + + tdLog.info("\n=============flush database ====================\n") + + tdSql.execute(" flush database %s;" %database) + + tdSql.query(" select * from information_schema.ins_databases where name = '%s';" %database) + print(tdSql.queryResult) + + # tdSql.query(" select table_prefix,table_suffix from information_schema.ins_databases where name = '%s';" %database) + # print(tdSql.queryResult) + #TD-19082 + + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s';" %database) + queryRows = len(tdSql.queryResult) + for i in range(queryRows): + print("row=%d, vgroup_id=%s, tbname=%s " %(i,tdSql.queryResult[i][1],tdSql.queryResult[i][0])) + + + # check in one vgroup + if check_result == 'Y': + #base table : sh_table_0_a + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_0_a';" %(database)) + base_value_table_name = tdSql.queryResult[0][0] + base_value_table_vgroup = tdSql.queryResult[0][1] + + #check table :sh_table_i_a + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_a';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_a';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :sh_table_i_b + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_b';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_b';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :sh_table_i_c + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_c';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_c';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :sh_table_i_r + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'sh_table_%%_r';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='sh_table_%d_r';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :bj_table_i_a + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_a';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_a';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :bj_table_i_b + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_b';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_b';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :bj_table_i_c + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_c';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_c';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :bj_table_i_r + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'bj_table_%%_r';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='bj_table_%d_r';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :hn_table_i_r + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'hn_table_%%_r';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='hn_table_%d_r';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :tj_table_i_a + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'tj_table_%%_a';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_%d_a';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + #check table :tj_table_i_b + check_rows = tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name like 'tj_table_%%_b';" %(database)) + for i in range(check_rows): + tdSql.query(" select table_name,vgroup_id from information_schema.ins_tables where db_name = '%s' and table_name='tj_table_%d_b';" %(database,i)) + self.value_check(base_value_table_name,base_value_table_vgroup) + + else: + pass + + def value_check(self,base_value_table_name,base_value_table_vgroup): + check_value_table_name = tdSql.queryResult[0][0] + check_value_table_vgroup = tdSql.queryResult[0][1] + #tdLog.info(f"{base_value_table_name},{base_value_table_vgroup},{check_value_table_name},{check_value_table_vgroup}") + + if base_value_table_vgroup==check_value_table_vgroup: + tdLog.info(f"checkEqual success, base_table_name={base_value_table_name},base_table_host={base_value_table_vgroup} ,check_table_name={check_value_table_name},check_table_host={check_value_table_vgroup}") + else : + tdLog.exit(f"checkEqual error, base_table_name=={base_value_table_name},base_table_host={base_value_table_vgroup} ,check_table_name={check_value_table_name},check_table_host={check_value_table_vgroup}") + + def stream_value_check(self,stream_data,sql_data): + if stream_data==sql_data: + tdLog.info(f"checkEqual success, stream_data={stream_data},sql_data={sql_data}") + else : + tdLog.exit(f"checkEqual error, stream_data=={stream_data},sql_data={sql_data}") + + def run(self): + startTime = time.time() + + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + #(self,database,n,vgroups,table_prefix,table_suffix) + self.dropandcreateDB_random("%s" %self.db, 1,2,0,0,'N') + self.dropandcreateDB_random("%s" %self.db, 1,2,0,2,'N') + self.dropandcreateDB_random("%s" %self.db, 1,2,2,0,'N') + self.dropandcreateDB_random("%s" %self.db, 1,2,3,3,'Y') + self.dropandcreateDB_random("%s" %self.db, 1,3,3,3,'Y') + self.dropandcreateDB_random("%s" %self.db, 1,4,4,4,'Y') + self.dropandcreateDB_random("%s" %self.db, 1,5,5,5,'Y') + + + #taos -f sql + print("taos -f sql start!") + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + _ = subprocess.check_output(taos_cmd1, shell=True) + print("taos -f sql over!") + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index 5ef6548789..21c591b07e 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -31,45 +31,57 @@ class TDTestCase: tdSql.prepare() for i in range(self.tbnum): - tdSql.execute(f'create table {self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.ttl_param}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.ttl_param}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) for i in range(self.tbnum): - tdSql.execute(f'create table {self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.default_ttl}') + tdSql.execute(f'create table db.{self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.default_ttl}') for i in range(int(self.tbnum/2)): - tdSql.execute(f'alter table {self.ntbname}_{i} ttl {self.modify_ttl}') + tdSql.execute(f'alter table db.{self.ntbname}_{i} ttl {self.modify_ttl}') sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum - int(self.tbnum/2)) tdSql.execute('drop database db') def ttl_check_ctb(self): tdSql.prepare() - tdSql.execute(f'create table {self.stbname} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table db.{self.stbname} (ts timestamp,c0 int) tags(t0 int)') for i in range(self.tbnum): - tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.ttl_param}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.ttl_param}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(0) for i in range(self.tbnum): - tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({i}) ttl {self.default_ttl}') - tdSql.query(f'show tables') + tdSql.execute(f'create table db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.default_ttl}') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) for i in range(int(self.tbnum/2)): - tdSql.execute(f'alter table {self.stbname}_{i} ttl {self.modify_ttl}') + tdSql.execute(f'alter table db.{self.stbname}_{i} ttl {self.modify_ttl}') sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval']) - tdSql.query(f'show tables') + tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum - int(self.tbnum/2)) tdSql.execute('drop database db') + def ttl_check_insert(self): + tdSql.prepare() + tdSql.execute(f'create table db.{self.stbname} (ts timestamp,c0 int) tags(t0 int)') + for i in range(self.tbnum): + tdSql.execute(f'insert into db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.ttl_param} values(now,1)') + tdSql.query(f'show db.tables') + tdSql.checkRows(self.tbnum) + sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']) + tdSql.query(f'show db.tables') + tdSql.checkRows(0) + tdSql.execute('drop database db') def run(self): self.ttl_check_ntb() self.ttl_check_ctb() + self.ttl_check_insert() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/interp.py b/tests/system-test/2-query/interp.py index 5550519e05..7bf0191ec1 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -595,11 +595,11 @@ class TDTestCase: tdSql.checkData(2, i, 15) tdSql.query(f"select interp(c0),interp(c1),interp(c2),interp(c3) from {dbname}.{tbname} range('2020-02-09 00:00:05', '2020-02-13 00:00:05') every(1d) fill(linear)") - tdSql.checkRows(1) + tdSql.checkRows(3) tdSql.checkCols(4) for i in range (tdSql.queryCols): - tdSql.checkData(0, i, 15) + tdSql.checkData(0, i, 13) tdLog.printNoPrefix("==========step10:test error cases") diff --git a/tests/system-test/7-tmq/tmqDelete-multiCtb.py b/tests/system-test/7-tmq/tmqDelete-multiCtb.py index e59040305a..c9d90b45be 100644 --- a/tests/system-test/7-tmq/tmqDelete-multiCtb.py +++ b/tests/system-test/7-tmq/tmqDelete-multiCtb.py @@ -325,7 +325,9 @@ class TDTestCase: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) elif self.snapshot == 1: consumerId = 5 - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) + # expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) + # fix case: sometimes only 200 rows are deleted + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) topicList = topicFromStb1 ifcheckdata = 1 diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 07602ec29f..626e935733 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -31,18 +31,20 @@ class TDTestCase: while True: dst = queryFile.readline() src = consumeFile.readline() - - if dst: + if src: if dst != src: - tdLog.exit("compare error: %s != %s"%src, dst) + tdLog.exit("compare error: %s != %s"%(src, dst)) else: break return - def checkDropData(self): + def checkDropData(self, drop): tdSql.execute('use db_taosx') tdSql.query("show tables") - tdSql.checkRows(2) + if drop: + tdSql.checkRows(10) + else: + tdSql.checkRows(15) tdSql.query("select * from jt order by i") tdSql.checkRows(2) tdSql.checkData(0, 1, 1) @@ -50,15 +52,72 @@ class TDTestCase: tdSql.checkData(0, 2, '{"k1":1,"k2":"hello"}') tdSql.checkData(1, 2, None) + tdSql.query("select * from sttb order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 13) + tdSql.checkData(1, 1, 16) + tdSql.checkData(0, 2, 22) + tdSql.checkData(1, 2, 25) + tdSql.checkData(0, 5, "sttb3") + tdSql.checkData(1, 5, "sttb4") + + tdSql.query("select * from stt order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 21) + tdSql.checkData(0, 2, 2) + tdSql.checkData(1, 2, 21) + tdSql.checkData(0, 5, "stt3") + tdSql.checkData(1, 5, "stt4") + tdSql.execute('use abc1') tdSql.query("show tables") - tdSql.checkRows(2) + if drop: + tdSql.checkRows(10) + else: + tdSql.checkRows(15) tdSql.query("select * from jt order by i") tdSql.checkRows(2) tdSql.checkData(0, 1, 1) tdSql.checkData(1, 1, 11) tdSql.checkData(0, 2, '{"k1":1,"k2":"hello"}') tdSql.checkData(1, 2, None) + + tdSql.query("select * from sttb order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 13) + tdSql.checkData(1, 1, 16) + tdSql.checkData(0, 2, 22) + tdSql.checkData(1, 2, 25) + tdSql.checkData(0, 5, "sttb3") + tdSql.checkData(1, 5, "sttb4") + + tdSql.query("select * from stt order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 21) + tdSql.checkData(0, 2, 2) + tdSql.checkData(1, 2, 21) + tdSql.checkData(0, 5, "stt3") + tdSql.checkData(1, 5, "stt4") + + return + + def checkDataTable(self): + tdSql.execute('use db_taosx') + tdSql.query("select * from meters_summary") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 120) + tdSql.checkData(0, 2, 1) + tdSql.checkData(0, 3, "San Francisco") + + tdSql.execute('use abc1') + tdSql.query("select * from meters_summary") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 120) + tdSql.checkData(0, 2, 1) + tdSql.checkData(0, 3, "San Francisco") + return def checkData(self): @@ -145,6 +204,19 @@ class TDTestCase: self.checkJson(cfgPath, "tmq_taosx_tmp") self.checkData() + self.checkDropData(False) + + return + + def checkWal1VgroupTable(self): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -c %s -sv 1 -dv 1 -t'%(buildPath, cfgPath) + tdLog.info(cmdStr) + os.system(cmdStr) + + self.checkJson(cfgPath, "tmq_taosx_tmp") + self.checkDataTable() return @@ -155,6 +227,7 @@ class TDTestCase: os.system(cmdStr) self.checkData() + self.checkDropData(False) return @@ -164,7 +237,7 @@ class TDTestCase: tdLog.info(cmdStr) os.system(cmdStr) - self.checkDropData() + self.checkDropData(True) return @@ -177,6 +250,19 @@ class TDTestCase: self.checkJson(cfgPath, "tmq_taosx_tmp_snapshot") self.checkData() + self.checkDropData(False) + + return + + def checkSnapshot1VgroupTable(self): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -c %s -sv 1 -dv 1 -s -t'%(buildPath, cfgPath) + tdLog.info(cmdStr) + os.system(cmdStr) + + self.checkJson(cfgPath, "tmq_taosx_tmp_snapshot") + self.checkDataTable() return @@ -187,6 +273,7 @@ class TDTestCase: os.system(cmdStr) self.checkData() + self.checkDropData(False) return @@ -196,7 +283,7 @@ class TDTestCase: tdLog.info(cmdStr) os.system(cmdStr) - self.checkDropData() + self.checkDropData(True) return @@ -205,6 +292,9 @@ class TDTestCase: self.checkWal1Vgroup() self.checkSnapshot1Vgroup() + self.checkWal1VgroupTable() + self.checkSnapshot1VgroupTable() + self.checkWalMultiVgroups() self.checkSnapshotMultiVgroups() diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 4e8e9b4906..3ae3f62886 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -17,6 +17,7 @@ python3 ./test.py -f 0-others/udf_cfg2.py python3 ./test.py -f 0-others/sysinfo.py python3 ./test.py -f 0-others/user_control.py python3 ./test.py -f 0-others/fsync.py +python3 ./test.py -f 0-others/compatibility.py python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py @@ -32,9 +33,10 @@ python3 ./test.py -f 1-insert/block_wise.py python3 ./test.py -f 1-insert/create_retentions.py python3 ./test.py -f 1-insert/table_param_ttl.py python3 ./test.py -f 1-insert/mutil_stage.py - +python3 ./test.py -f 1-insert/table_param_ttl.py -R python3 ./test.py -f 1-insert/update_data_muti_rows.py python3 ./test.py -f 1-insert/db_tb_name_check.py +python3 ./test.py -f 1-insert/database_pre_suf.py python3 ./test.py -f 2-query/abs.py python3 ./test.py -f 2-query/abs.py -R @@ -156,8 +158,8 @@ python3 ./test.py -f 2-query/sin.py python3 ./test.py -f 2-query/sin.py -R python3 ./test.py -f 2-query/smaTest.py python3 ./test.py -f 2-query/smaTest.py -R -#python3 ./test.py -f 2-query/sml.py -#python3 ./test.py -f 2-query/sml.py -R +python3 ./test.py -f 2-query/sml.py +python3 ./test.py -f 2-query/sml.py -R python3 ./test.py -f 2-query/spread.py python3 ./test.py -f 2-query/spread.py -R python3 ./test.py -f 2-query/sqrt.py @@ -512,7 +514,7 @@ python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3 python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 -#python3 ./test.py -f 2-query/sml.py -Q 3 +python3 ./test.py -f 2-query/sml.py -Q 3 python3 ./test.py -f 2-query/interp.py -Q 3 diff --git a/tools/shell/src/shellUtil.c b/tools/shell/src/shellUtil.c index 0430428c38..8c47d16555 100644 --- a/tools/shell/src/shellUtil.c +++ b/tools/shell/src/shellUtil.c @@ -143,7 +143,7 @@ void shellCheckConnectMode() { shell.args.port = 6041; } shell.args.dsn = taosMemoryCalloc(1, 1024); - snprintf(shell.args.dsn, 1024, "ws://%s:%d/rest/ws", + snprintf(shell.args.dsn, 1024, "ws://%s:%d", shell.args.host, shell.args.port); } shell.args.cloud = false; diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index b8b8392b96..94bb909e29 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -206,26 +206,31 @@ void shellRunSingleCommandWebsocketImp(char *command) { printMode = true; // When output to a file, the switch does not work. } - if (!shell.ws_conn && shell_conn_ws_server(0)) { - return; - } - shell.stop_query = false; - st = taosGetTimestampUs(); + WS_RES* res; - WS_RES* res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout); - int code = ws_errno(res); - if (code != 0) { - et = taosGetTimestampUs(); - fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); - if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { - fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); - } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) { - fprintf(stderr, "TDengine server is down, will try to reconnect\n"); - shell.ws_conn = NULL; + for (int reconnectNum = 0; reconnectNum < 2; reconnectNum++) { + if (!shell.ws_conn && shell_conn_ws_server(0)) { + return; } - ws_free_result(res); - return; + st = taosGetTimestampUs(); + + res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout); + int code = ws_errno(res); + if (code != 0 && !shell.stop_query) { + et = taosGetTimestampUs(); + fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); + if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { + fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); + } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) { + fprintf(stderr, "TDengine server is down, will try to reconnect\n"); + shell.ws_conn = NULL; + } + ws_free_result(res); + if (reconnectNum == 0) continue; + return; + } + break; } double execute_time = ws_take_timing(res)/1E6; diff --git a/utils/test/c/sdbDump.c b/utils/test/c/sdbDump.c index b90b781e44..b056fe58a3 100644 --- a/utils/test/c/sdbDump.c +++ b/utils/test/c/sdbDump.c @@ -294,8 +294,8 @@ void dumpTrans(SSdb *pSdb, SJson *json) { tjsonAddIntegerToObject(item, "conflict", pObj->conflict); tjsonAddIntegerToObject(item, "exec", pObj->exec); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); - tjsonAddStringToObject(item, "dbname1", pObj->dbname1); - tjsonAddStringToObject(item, "dbname2", pObj->dbname2); + tjsonAddStringToObject(item, "dbname", pObj->dbname); + tjsonAddStringToObject(item, "stbname", pObj->stbname); tjsonAddIntegerToObject(item, "commitLogNum", taosArrayGetSize(pObj->commitActions)); tjsonAddIntegerToObject(item, "redoActionNum", taosArrayGetSize(pObj->redoActions)); tjsonAddIntegerToObject(item, "undoActionNum", taosArrayGetSize(pObj->undoActions)); diff --git a/utils/test/c/tmqSim.c b/utils/test/c/tmqSim.c index 71b31ba107..a043aa7a6d 100644 --- a/utils/test/c/tmqSim.c +++ b/utils/test/c/tmqSim.c @@ -653,23 +653,23 @@ static int32_t meta_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn int32_t code = tmq_get_raw(msg, &raw); if(code == TSDB_CODE_SUCCESS){ - int retCode = queryDB(pInfo->taos, "use metadb"); - if (retCode != 0) { - taosFprintfFile(g_fp, "error when use metadb\n"); - taosCloseFile(&g_fp); - exit(-1); - } - taosFprintfFile(g_fp, "raw:%p\n", &raw); - - tmq_write_raw(pInfo->taos, raw); +// int retCode = queryDB(pInfo->taos, "use metadb"); +// if (retCode != 0) { +// taosFprintfFile(g_fp, "error when use metadb\n"); +// taosCloseFile(&g_fp); +// exit(-1); +// } +// taosFprintfFile(g_fp, "raw:%p\n", &raw); +// +// tmq_write_raw(pInfo->taos, raw); } char* result = tmq_get_json_meta(msg); - if(result){ + if(result && strcmp(result, "") != 0){ //printf("meta result: %s\n", result); taosFprintfFile(pInfo->pConsumeMetaFile, "%s\n", result); - taosMemoryFree(result); } + tmq_free_json_meta(result); } totalRows++; @@ -818,8 +818,12 @@ void loop_consume(SThreadInfo* pInfo) { tmq_res_t msgType = tmq_get_res_type(tmqMsg); if (msgType == TMQ_RES_TABLE_META) { totalRows += meta_msg_process(tmqMsg, pInfo, totalMsgs); - } else if (msgType == TMQ_RES_DATA) - totalRows += data_msg_process(tmqMsg, pInfo, totalMsgs); + } else if (msgType == TMQ_RES_DATA){ + totalRows += data_msg_process(tmqMsg, pInfo, totalMsgs); + } else if (msgType == TMQ_RES_METADATA){ + meta_msg_process(tmqMsg, pInfo, totalMsgs); + totalRows += data_msg_process(tmqMsg, pInfo, totalMsgs); + } } taos_free_result(tmqMsg); diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c index f917b9159e..3a598ba98b 100644 --- a/utils/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -54,24 +54,24 @@ static void msg_process(TAOS_RES* msg) { printf("db: %s\n", tmq_get_db_name(msg)); printf("vg: %d\n", tmq_get_vgroup_id(msg)); TAOS *pConn = use_db(); - if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { + if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META || tmq_get_res_type(msg) == TMQ_RES_METADATA) { char* result = tmq_get_json_meta(msg); if (result) { printf("meta result: %s\n", result); + if(g_fp && strcmp(result, "") != 0){ + taosFprintfFile(g_fp, result); + taosFprintfFile(g_fp, "\n"); + } } - if(g_fp){ - taosFprintfFile(g_fp, result); - taosFprintfFile(g_fp, "\n"); - } - tmq_free_json_meta(result); } tmq_raw_data raw = {0}; tmq_get_raw(msg, &raw); + printf("write raw data type: %d\n", raw.raw_type); int32_t ret = tmq_write_raw(pConn, raw); printf("write raw data: %s\n", tmq_err2str(ret)); - + tmq_free_raw(raw); taos_close(pConn); } @@ -309,6 +309,41 @@ int buildDatabase(TAOS* pConn, TAOS_RES* pRes){ } taos_free_result(pRes); } + + pRes = taos_query(pConn, + "create stable if not exists stt (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " + "nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table stt, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, + "create stable if not exists sttb (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " + "nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table sttb, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table if not exists stt1 using stt tags(2, \"stt1\", true) sttb1 using sttb tags(4, \"sttb1\", true) " + "stt2 using stt tags(43, \"stt2\", false) sttb2 using sttb tags(54, \"sttb2\", true)"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table stt1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into stt3 using stt tags(23, \"stt3\", true) values(now + 1s, 1, 2, 'stt3') sttb3 using sttb tags(4, \"sttb3\", true) values(now + 2s, 13, 22, 'sttb3') " + "stt4 using stt tags(433, \"stt4\", false) values(now + 3s, 21, 21, 'stt4') sttb4 using sttb tags(543, \"sttb4\", true) values(now + 4s, 16, 25, 'sttb4')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table stt1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + return 0; } @@ -542,47 +577,83 @@ void initLogFile() { } if(g_conf.snapShot){ - char *result[] = { - "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":64},{\"name\":\"c4\",\"type\":5}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1},{\"name\":\"t2\",\"type\":8,\"length\":64}]}", - "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", - "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":5000}]}", - "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c2\",\"type\":10,\"length\":8},{\"name\":\"cc3\",\"type\":5}],\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", - "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}", - }; - - for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ - taosFprintfFile(pFile2, result[i]); - taosFprintfFile(pFile2, "\n"); + if(g_conf.subTable){ + char *result[] = { + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"meters_summary\",\"columns\":[{\"name\":\"_wstart\",\"type\":9},{\"name\":\"current\",\"type\":6},{\"name\":\"groupid\",\"type\":4},{\"name\":\"location\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"group_id\",\"type\":14}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"t_d2a450ee819dcf7576f0282d9ac22dbc\",\"using\":\"meters_summary\",\"tagNum\":1,\"tags\":[{\"name\":\"group_id\",\"type\":14,\"value\":1.313555008277358e+19}],\"createList\":[]}" + }; + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } + }else{ + char *result[] = { + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":64},{\"name\":\"c4\",\"type\":5}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1},{\"name\":\"t2\",\"type\":8,\"length\":64}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":5000}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c2\",\"type\":10,\"length\":8},{\"name\":\"cc3\",\"type\":5}],\"tags\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb1\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb1\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt2\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":43},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb2\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":54},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb3\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb3\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt4\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":433},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt4\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"sttb4\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":543},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb4\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}" + }; + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } } }else{ - char *result[] = { - "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", - "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}", - "{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}", - "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}", - "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", - "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}" - }; + if(g_conf.subTable){ + char *result[] = { + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"meters_summary\",\"columns\":[{\"name\":\"_wstart\",\"type\":9},{\"name\":\"current\",\"type\":6},{\"name\":\"groupid\",\"type\":4},{\"name\":\"location\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"group_id\",\"type\":14}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"t_d2a450ee819dcf7576f0282d9ac22dbc\",\"using\":\"meters_summary\",\"tagNum\":1,\"tags\":[{\"name\":\"group_id\",\"type\":14,\"value\":1.313555008277358e+19}],\"createList\":[]}" + }; - for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ - taosFprintfFile(pFile2, result[i]); - taosFprintfFile(pFile2, "\n"); + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } + }else{ + char *result[] = { + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"st1\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct0\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct1\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct2\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}],\"createList\":[]}", + "{\"type\":\"alter\",\"tableType\":\"super\",\"tableName\":\"st1\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}", + "{\"type\":\"alter\",\"tableType\":\"super\",\"tableName\":\"st1\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableType\":\"super\",\"tableName\":\"st1\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableType\":\"child\",\"tableName\":\"ct3\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}", + "{\"type\":\"create\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}", + "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}", + "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}", + "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}", + "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":9}", + "{\"type\":\"alter\",\"tableType\":\"normal\",\"tableName\":\"n1\",\"alterType\":6,\"colName\":\"c1\"}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"jt\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt1\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"jt2\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[],\"createList\":[]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"stt\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"super\",\"tableName\":\"sttb\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt1\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt1\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]},{\"tableName\":\"sttb1\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb1\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]},{\"tableName\":\"stt2\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":43},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}]},{\"tableName\":\"sttb2\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":54},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb2\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}]}", + "{\"type\":\"create\",\"tableType\":\"child\",\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}],\"createList\":[{\"tableName\":\"stt3\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":23},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt3\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]},{\"tableName\":\"sttb3\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":4},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb3\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]},{\"tableName\":\"stt4\",\"using\":\"stt\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":433},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"stt4\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":0}]},{\"tableName\":\"sttb4\",\"using\":\"sttb\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":543},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"sttb4\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}]}" + }; + + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } } } @@ -619,5 +690,6 @@ int main(int argc, char* argv[]) { tmq_t* tmq = build_consumer(); tmq_list_t* topic_list = build_topic_list(); basic_consume_loop(tmq, topic_list); + tmq_list_destroy(topic_list); taosCloseFile(&g_fp); }