diff --git a/CMakeLists.txt b/CMakeLists.txt index 66a6fd328d..ac368c29fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ add_subdirectory(source) add_subdirectory(tools) add_subdirectory(utils) add_subdirectory(examples/c) +add_subdirectory(tests) include(${TD_SUPPORT_DIR}/cmake.install) # docs diff --git a/deps/arm/dm_static/libdmodule.a b/deps/arm/dm_static/libdmodule.a index fff5943606..dbad0112cf 100644 Binary files a/deps/arm/dm_static/libdmodule.a and b/deps/arm/dm_static/libdmodule.a differ diff --git a/deps/darwin/arm/dm_static/libdmodule.a b/deps/darwin/arm/dm_static/libdmodule.a index 09c501f2ef..2aab587b18 100644 Binary files a/deps/darwin/arm/dm_static/libdmodule.a and b/deps/darwin/arm/dm_static/libdmodule.a differ diff --git a/deps/darwin/x64/dm_static/libdmodule.a b/deps/darwin/x64/dm_static/libdmodule.a index 2230393565..1fb6794f65 100644 Binary files a/deps/darwin/x64/dm_static/libdmodule.a and b/deps/darwin/x64/dm_static/libdmodule.a differ diff --git a/deps/x86/dm_static/libdmodule.a b/deps/x86/dm_static/libdmodule.a index 995713ce7b..9d37818a79 100644 Binary files a/deps/x86/dm_static/libdmodule.a and b/deps/x86/dm_static/libdmodule.a differ diff --git a/docs/en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md index 3f09f9fb6a..11375bd060 100644 --- a/docs/en/07-develop/01-connect/index.md +++ b/docs/en/07-develop/01-connect/index.md @@ -177,7 +177,7 @@ Just need to add the reference to [TDengine.Connector](https://www.nuget.org/pac - + diff --git a/docs/en/07-develop/04-query-data/_cs_async.mdx b/docs/en/07-develop/04-query-data/_cs_async.mdx deleted file mode 100644 index 19c8e58f32..0000000000 --- a/docs/en/07-develop/04-query-data/_cs_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs/examples/csharp/asyncQuery/Program.cs}} -``` diff --git a/docs/en/07-develop/04-query-data/index.mdx b/docs/en/07-develop/04-query-data/index.mdx index 413baf6b2c..70b1140748 100644 --- a/docs/en/07-develop/04-query-data/index.mdx +++ b/docs/en/07-develop/04-query-data/index.mdx @@ -15,7 +15,6 @@ import CQuery from "./_c.mdx"; import PhpQuery from "./_php.mdx"; import PyAsync from "./_py_async.mdx"; import NodeAsync from "./_js_async.mdx"; -import CsAsync from "./_cs_async.mdx"; import CAsync from "./_c_async.mdx"; ## Introduction @@ -174,9 +173,6 @@ Please note that async query can only be used with a native connection. - - - diff --git a/docs/en/07-develop/07-tmq.mdx b/docs/en/07-develop/07-tmq.mdx index 8e7bbf22e9..b920d61a59 100644 --- a/docs/en/07-develop/07-tmq.mdx +++ b/docs/en/07-develop/07-tmq.mdx @@ -248,23 +248,23 @@ function close() ```csharp +class ConsumerBuilder + ConsumerBuilder(IEnumerable> config) -virtual IConsumer Build() - -Consumer(ConsumerBuilder builder) +public IConsumer Build() void Subscribe(IEnumerable topics) void Subscribe(string topic) -ConsumeResult Consume(int millisecondsTimeout) +ConsumeResult Consume(int millisecondsTimeout) List Subscription() void Unsubscribe() -void Commit(ConsumeResult consumerResult) +List Commit() void Close() ``` @@ -500,25 +500,19 @@ let consumer = taos.consumer({ ```csharp -using TDengineTMQ; - -// Create consumer groups on demand (GourpID) and enable automatic commits (EnableAutoCommit), -// an automatic commit interval (AutoCommitIntervalMs), and a username (TDConnectUser) and password (TDConnectPasswd) -var cfg = new ConsumerConfig - { - EnableAutoCommit = "true" - AutoCommitIntervalMs = "1000" - GourpId = "TDengine-TMQ-C#", - TDConnectUser = "root", - TDConnectPasswd = "taosdata", - AutoOffsetReset = "latest" - MsgWithTableName = "true", - TDConnectIp = "127.0.0.1", - TDConnectPort = "6030" - }; - -var consumer = new ConsumerBuilder(cfg).Build(); - +var cfg = new Dictionary() +{ + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); ``` @@ -747,10 +741,12 @@ while(true){ ## Consume data while (true) { - var consumerRes = consumer.Consume(100); - // process ConsumeResult - ProcessMsg(consumerRes); - consumer.Commit(consumerRes); + using (var result = consumer.Consume(500)) + { + if (result == null) continue; + ProcessMsg(result); + consumer.Commit(); + } } ``` diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md index e5f502c563..f6e39a9734 100644 --- a/docs/en/12-taos-sql/05-insert.md +++ b/docs/en/12-taos-sql/05-insert.md @@ -158,8 +158,8 @@ Automatically creating table and the table name is specified through the `tbname ```sql INSERT INTO meters(tbname, location, groupId, ts, current, phase) - values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 219, 0.32) - values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 217, 0.33) - values('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 217, 0.33) + values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 0.32) + ('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 0.33) + ('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 0.33) ``` diff --git a/docs/en/14-reference/02-rest-api/02-rest-api.mdx b/docs/en/14-reference/02-rest-api/02-rest-api.mdx index 8f8e966f8d..5cb680e34b 100644 --- a/docs/en/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs/en/14-reference/02-rest-api/02-rest-api.mdx @@ -262,6 +262,63 @@ The following types may be returned: - "INT UNSIGNED" - "BIGINT UNSIGNED" - "JSON" +- "VARBINARY" +- "GEOMETRY" + +`VARBINARY` and `GEOMETRY` types return data as Hex string, example: + +Prepare data + +```bash +create database demo +use demo +create table t(ts timestamp,c1 varbinary(20),c2 geometry(100)) +insert into t values(now,'\x7f8290','point(100 100)') +``` + +Execute query + +```bash +curl --location 'http://:/rest/sql' \ +--header 'Content-Type: text/plain' \ +--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \ +--data 'select * from demo.t' +``` + +Return results + +```json +{ + "code": 0, + "column_meta": [ + [ + "ts", + "TIMESTAMP", + 8 + ], + [ + "c1", + "VARBINARY", + 20 + ], + [ + "c2", + "GEOMETRY", + 100 + ] + ], + "data": [ + [ + "2023-11-01T06:28:15.210Z", + "7f8290", + "010100000000000000000059400000000000005940" + ] + ], + "rows": 1 +} +``` + +- `010100000000000000000059400000000000005940` is [Well-Known Binary (WKB)](https://libgeos.org/specifications/wkb/) format for `point(100 100)` #### Errors diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx index 282be3af6b..25bef1cf51 100644 --- a/docs/en/14-reference/03-connector/09-csharp.mdx +++ b/docs/en/14-reference/03-connector/09-csharp.mdx @@ -1,5 +1,5 @@ --- -title: C# Connector +title: TDengine C# Connector sidebar_label: C# description: This document describes the TDengine C# connector. toc_max_heading_level: 4 @@ -8,21 +8,16 @@ toc_max_heading_level: 4 import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Preparition from "./_preparation.mdx" -import CSInsert from "../../07-develop/03-insert-data/_cs_sql.mdx" -import CSInfluxLine from "../../07-develop/03-insert-data/_cs_line.mdx" -import CSOpenTSDBTelnet from "../../07-develop/03-insert-data/_cs_opts_telnet.mdx" -import CSOpenTSDBJson from "../../07-develop/03-insert-data/_cs_opts_json.mdx" -import CSQuery from "../../07-develop/04-query-data/_cs.mdx" -import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx" +`TDengine.Connector` is the C# language connector provided by TDengine. C# developers can use it to develop C# application software that accesses TDengine cluster data. -`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 establishing a connection with the TDengine running instance through the TDengine client driver (taosc), and provides functions such as data writing, query, data subscription, schemaless data writing, and parameter binding interface data writing. `TDengine.Connector` also supports WebSocket since v3.0.1, establishes WebSocket connection, and provides functions such as data writing, query, and parameter binding interface data writing. -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 from v3.0.1 and developers can build connection through DSN, which supports data writing, querying, and parameter binding, etc. +This article introduces how to install `TDengine.Connector` in a Linux or Windows environment, and connect to the TDengine cluster through `TDengine.Connector` to perform basic operations such as data writing and querying. -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. - -Note: TDengine Connector 3.x is not compatible with TDengine 2.x. In an environment with TDengine 2.x, you must use TDengine.Connector 1.x for the C# connector. +:::warning +* `TDengine.Connector` version 3.1.0 has been completely refactored and is no longer compatible with 3.0.2 and previous versions. For 3.0.2 documents, please refer to [nuget](https://www.nuget.org/packages/TDengine.Connector/3.0.2) +* `TDengine.Connector` 3.x is not compatible with TDengine 2.x. If you need to use the C# connector in an environment running TDengine 2.x version, please use the 1.x version of TDengine.Connector. +::: The source code of `TDengine.Connector` is hosted on [GitHub](https://github.com/taosdata/taos-connector-dotnet/tree/3.0). @@ -30,286 +25,1164 @@ The source code of `TDengine.Connector` is hosted on [GitHub](https://github.com The supported platforms are the same as those supported by the TDengine client driver. -:::note -Please note TDengine does not support 32bit Windows any more. +:::warning +TDengine no longer supports 32-bit Windows platforms. ::: ## Version support -Please refer to [version support list](../#version-support) +| **Connector version** | **TDengine version** | +|-----------------------|----------------------| +| 3.1.0 | 3.2.1.0/3.1.1.18 | -## Supported features +## Handling exceptions - +`TDengine.Connector` will throw an exception and the application needs to handle the exception. The taosc exception type `TDengineError` contains error code and error information, and the application can handle it based on the error code and error information. - +## TDengine DataType vs. C# DataType -1. Connection Management -2. General Query -3. Continuous Query -4. Parameter Binding -5. Subscription -6. Schemaless +| TDengine DataType | C# Type | +|-------------------|-------------------------| +| TIMESTAMP | DateTime | +| TINYINT | sbyte | +| SMALLINT | short | +| INT | int | +| BIGINT | long | +| TINYINT UNSIGNED | byte | +| SMALLINT UNSIGNED | ushort | +| INT UNSIGNED | uint | +| BIGINT UNSIGNED | ulong | +| FLOAT | float | +| DOUBLE | double | +| BOOL | bool | +| BINARY | byte[] | +| NCHAR | string (utf-8 encoding) | +| JSON | byte[] | - - - - -1. Connection Management -2. General Query -3. Continuous Query -4. Parameter Binding - - - +**Note**: JSON type is only supported in tag. ## Installation Steps ### Pre-installation preparation -* Install the [.NET SDK](https://dotnet.microsoft.com/download) +* Install [.NET SDK](https://dotnet.microsoft.com/download) * [Nuget Client](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) (optional installation) -* Install TDengine client driver, please refer to [Install client driver](../#install-client-driver) for details +* Install the TDengine client driver. For specific steps, please refer to [Installing the client driver](../#install-client-driver) -### Install `TDengine.Connector` +### Install the connectors - - +Nuget package `TDengine.Connector` can be added to the current project through dotnet CLI under the path of the current .NET project. -You can reference the `TDengine.Connector` published in Nuget to the current project via the `dotnet` CLI under the path of the existing .NET project. - -``` bash +```bash dotnet add package TDengine.Connector ``` -You may also modify the current.NET project file. You can include the following 'ItemGroup' in your project file (.csproj). +You can also modify the `.csproj` file of the current project and add the following ItemGroup. ``` XML - - - + + + ``` - - +## Establishing a connection -In this scenario, modifying your project file is required in order to copy the WebSocket dependency dynamic library from the nuget package into your project. -```XML - - - - - - - - - -``` - -Notice: `TDengine.Connector` only version>= 3.0.2 includes the dynamic library for WebSocket. - - - - -## Establish a Connection - - - - - + + ``` csharp -using TDengineDriver; - -namespace TDengineExample +var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); +using (var client = DbDriver.Open(builder)) { - - internal class EstablishConnection - { - static void Main(String[] args) - { - 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"); - } - else - { - Console.WriteLine("Connect to TDengine success"); - } - TDengine.Close(conn); - TDengine.Cleanup(); - } - } + Console.WriteLine("connected") } - ``` + - - -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}} +```csharp +var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); +using (var client = DbDriver.Open(builder)) +{ + Console.WriteLine("connected") +} ``` +The parameters supported by `ConnectionStringBuilder` are as follows: +* protocol: connection protocol, optional value is Native or WebSocket, default is Native +* host: the address of the running instance of TDengine or taosadapter, +* port: The port of the running instance of TDengine or taosadapter. + * When using WebSocket without SSL, the default is 6041. + * When using WebSocket with SSL, the default is 443. +* useSSL: Whether to use SSL, the default is false, only valid when the protocol is WebSocket +* token: The token used to connect to TDengine Cloud, only valid when the protocol is WebSocket +* username: username to connect to TDengine +* password: password to connect to TDengine +* db: database connected to TDengine +* timezone: The time zone for parsing time results, the default is `TimeZoneInfo.Local`, use the `TimeZoneInfo.FindSystemTimeZoneById` method to parse the string into a `TimeZoneInfo` object. +* connTimeout: WebSocket connection timeout, only valid when the protocol is WebSocket, the default is 1 minute, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. +* readTimeout: WebSocket read timeout, only valid when the protocol is WebSocket, the default is 5 minutes, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. +* writeTimeout: WebSocket write timeout, only valid when the protocol is WebSocket, the default is 10 seconds, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. + +### Specify the URL and Properties to get the connection + +The C# connector does not support this feature + +### Priority of configuration parameters + +The C# connector does not support this feature + ## Usage examples -### Write data +### Create database and tables -#### SQL Write - - - - - - - - - - + + ```csharp -{{#include docs/examples/csharp/wsInsert/Program.cs}} +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` -#### InfluxDB line protocol write +### Insert data - + + -#### OpenTSDB Telnet line protocol write +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; - - -#### OpenTSDB JSON line protocol write - - - -#### Parameter Binding - - - - - -``` csharp -{{#include docs/examples/csharp/stmtInsert/Program.cs}} +namespace NativeQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` - - + ```csharp -{{#include docs/examples/csharp/wsStmt/Program.cs}} +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` -### Query data +### Querying data -#### Synchronous Query - - - - - - - - - - + + ```csharp -{{#include docs/examples/csharp/wsQuery/Program.cs}} +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) + { + while (rows.Read()) + { + Console.WriteLine($"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) + { + while (rows.Read()) + { + Console.WriteLine($"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` -#### Asynchronous query +### execute SQL with reqId - + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQueryWithReqID +{ + internal abstract class QueryWithReqID + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec($"create database if not exists test_db",ReqId.GetReqId()); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQueryWithReqID +{ + internal abstract class QueryWithReqID + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec($"create database if not exists test_db",ReqId.GetReqId()); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +### Writing data via parameter binding + + + + +```csharp +using System; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeStmt +{ + internal abstract class NativeStmt + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSStmt +{ + internal abstract class WSStmt + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +Note: When using BindRow, you need to pay attention to the one-to-one correspondence between the original C# column type and the TDengine column type. For the specific correspondence, please refer to [TDengine DataType and C# DataType](#tdengine-datatype-vs-c-datatype). + +### Schemaless Writing + + + + +```csharp +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeSchemaless +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = + new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + client.Exec("create database sml"); + client.Exec("use sml"); + var influxDBData = + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; + client.SchemalessInsert(new string[] { influxDBData }, + TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NANO_SECONDS, 0, ReqId.GetReqId()); + var telnetData = "stb0_0 1626006833 4 host=host0 interface=eth0"; + client.SchemalessInsert(new string[] { telnetData }, + TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + var jsonData = + "{\"metric\": \"meter_current\",\"timestamp\": 1626846400,\"value\": 10.3, \"tags\": {\"groupid\": 2, \"location\": \"California.SanFrancisco\", \"id\": \"d1001\"}}"; + client.SchemalessInsert(new string[] { jsonData }, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + } + } + } +} +``` + + + + +```csharp +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSSchemaless +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = + new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + client.Exec("create database sml"); + client.Exec("use sml"); + var influxDBData = + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; + client.SchemalessInsert(new string[] { influxDBData }, + TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NANO_SECONDS, 0, ReqId.GetReqId()); + var telnetData = "stb0_0 1626006833 4 host=host0 interface=eth0"; + client.SchemalessInsert(new string[] { telnetData }, + TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + var jsonData = + "{\"metric\": \"meter_current\",\"timestamp\": 1626846400,\"value\": 10.3, \"tags\": {\"groupid\": 2, \"location\": \"California.SanFrancisco\", \"id\": \"d1001\"}}"; + client.SchemalessInsert(new string[] { jsonData }, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + } + } + } +} +``` + + + + +### Schemaless with reqId + +```csharp +public void SchemalessInsert(string[] lines, TDengineSchemalessProtocol protocol, + TDengineSchemalessPrecision precision, + int ttl, long reqId) +``` + +### Data Subscription + +#### Create a Topic + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +#### Create a Consumer + + + + +```csharp +var cfg = new Dictionary() +{ + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); +``` + + + + +```csharp +var cfg = new Dictionary() +{ + { "td.connect.type", "WebSocket" }, + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "localhost" }, + { "td.connect.port","6041"}, + { "useSSL", "false" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); +``` + + + + +The configuration parameters supported by consumer are as follows: +* td.connect.type: connection type, optional value is Native or WebSocket, default is Native +* td.connect.ip: The address of the TDengine running instance or taosadapter +* td.connect.port: The port of the running instance of TDengine or taosadapter. + * When using WebSocket without SSL, the default is 6041. + * When using WebSocket with SSL, the default is 443. +* useSSL: Whether to use SSL, the default is false, only valid when the protocol is WebSocket +* token: The token used to connect to TDengine Cloud, only valid when the protocol is WebSocket +* td.connect.user: username to connect to TDengine +* td.connect.pass: Password for connecting to TDengine +* group.id: consumer group ID +* client.id: consumer ID +* enable.auto.commit: Whether to automatically commit offset, the default is true +* auto.commit.interval.ms: The interval for automatically submitting offsets, the default is 5000 milliseconds +* auto.offset.reset: When offset does not exist, where to start consumption, the optional value is earliest or latest, the default is latest +* msg.with.table.name: Whether the message contains the table name + +Supports subscribing to the result set `Dictionary` where the key is the column name and the value is the column value. + +If you use object to receive column values, you need to pay attention to: +* There needs to be a one-to-one correspondence between the original C# column type and the TDengine column type. For specific correspondence, please refer to [TDengine DataType and C# DataType] (#tdengine-datatype-and-c-datatype). +* The column name is consistent with the class attribute name and can be get and set. +* Explicitly set the value parser `ConsumerBuilder.SetValueDeserializer(new ReferenceDeserializer());` + +An example is as follows + +Result class + +```csharp + class Result + { + public DateTime ts { get; set; } + public float current { get; set; } + public int voltage { get; set; } + public float phase { get; set; } + } +``` + +Set up parser + +```csharp +var tmqBuilder = new ConsumerBuilder(cfg); +tmqBuilder.SetValueDeserializer(new ReferenceDeserializer()); +var consumer = tmqBuilder.Build(); +``` + +You can also implement a custom deserializer, implement the `IDeserializer` interface and pass it in through the `ConsumerBuilder.SetValueDeserializer` method. + +```csharp + public interface IDeserializer + { + T Deserialize(ITMQRows data, bool isNull, SerializationContext context); + } +``` + +#### Subscribe to consume data + +```csharp +consumer.Subscribe(new List() { "topic_meters" }); +while (true) +{ + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + } +} +``` + +#### Assignment subscription Offset + +```csharp +consumer.Assignment.ForEach(a => +{ + Console.WriteLine($"{a}, seek to 0"); + consumer.Seek(new TopicPartitionOffset(a.Topic, a.Partition, 0)); + Thread.Sleep(TimeSpan.FromSeconds(1)); +}); +``` + +#### Commit offset + +```csharp +public void Commit(ConsumeResult consumerResult) +public List Commit() +public void Commit(IEnumerable offsets) +``` + +#### Close subscriptions + +```csharp +consumer.Unsubscribe(); +consumer.Close(); +``` + +#### Full Sample Code + + + + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using TDengine.Driver; +using TDengine.Driver.Client; +using TDengine.TMQ; + +namespace NativeSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("CREATE DATABASE power"); + client.Exec("USE power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + var cfg = new Dictionary() + { + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + consumer.Subscribe(new List() { "topic_meters" }); + Task.Run(InsertData); + while (true) + { + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + consumer.Commit(); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + + static void InsertData() + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + while (true) + { + client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)"); + Task.Delay(1000).Wait(); + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using TDengine.Driver; +using TDengine.Driver.Client; +using TDengine.TMQ; + +namespace WSSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("CREATE DATABASE power"); + client.Exec("USE power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + var cfg = new Dictionary() + { + { "td.connect.type", "WebSocket" }, + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "localhost" }, + { "td.connect.port","6041"}, + { "useSSL", "false" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + consumer.Subscribe(new List() { "topic_meters" }); + Task.Run(InsertData); + while (true) + { + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + consumer.Commit(); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + + static void InsertData() + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + while (true) + { + client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)"); + Task.Delay(1000).Wait(); + } + } + } + } +} +``` + + + + +### ADO.NET + +The C# connector supports the ADO.NET interface, and you can connect to the TDengine running instance through the ADO.NET interface to perform operations such as data writing and querying. + + + + +```csharp +using System; +using TDengine.Data.Client; + +namespace NativeADO +{ + internal class Program + { + public static void Main(string[] args) + { + const string connectionString = "host=localhost;port=6030;username=root;password=taosdata"; + using (var connection = new TDengineConnection(connectionString)) + { + try + { + connection.Open(); + using (var command = new TDengineCommand(connection)) + { + command.CommandText = "create database power"; + command.ExecuteNonQuery(); + connection.ChangeDatabase("power"); + command.CommandText = + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"; + command.ExecuteNonQuery(); + command.CommandText = "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "(?,?,?,?)"; + var parameters = command.Parameters; + parameters.Add(new TDengineParameter("@0", new DateTime(2023,10,03,14,38,05,000))); + parameters.Add(new TDengineParameter("@1", (float)10.30000)); + parameters.Add(new TDengineParameter("@2", (int)219)); + parameters.Add(new TDengineParameter("@3", (float)0.31000)); + command.ExecuteNonQuery(); + command.Parameters.Clear(); + command.CommandText = "SELECT * FROM meters"; + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + Console.WriteLine( + $"{((DateTime) reader.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {reader.GetValue(1)}, {reader.GetValue(2)}, {reader.GetValue(3)}, {reader.GetValue(4)}, {System.Text.Encoding.UTF8.GetString((byte[]) reader.GetValue(5))}"); + } + } + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using TDengine.Data.Client; + +namespace WSADO +{ + internal class Program + { + public static void Main(string[] args) + { + const string connectionString = "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"; + using (var connection = new TDengineConnection(connectionString)) + { + try + { + connection.Open(); + using (var command = new TDengineCommand(connection)) + { + command.CommandText = "create database power"; + command.ExecuteNonQuery(); + connection.ChangeDatabase("power"); + command.CommandText = + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"; + command.ExecuteNonQuery(); + command.CommandText = "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "(?,?,?,?)"; + var parameters = command.Parameters; + parameters.Add(new TDengineParameter("@0", new DateTime(2023,10,03,14,38,05,000))); + parameters.Add(new TDengineParameter("@1", (float)10.30000)); + parameters.Add(new TDengineParameter("@2", (int)219)); + parameters.Add(new TDengineParameter("@3", (float)0.31000)); + command.ExecuteNonQuery(); + command.Parameters.Clear(); + command.CommandText = "SELECT * FROM meters"; + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + Console.WriteLine( + $"{((DateTime) reader.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {reader.GetValue(1)}, {reader.GetValue(2)}, {reader.GetValue(3)}, {reader.GetValue(4)}, {System.Text.Encoding.UTF8.GetString((byte[]) reader.GetValue(5))}"); + } + } + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +* The connection parameters are consistent with those in [Establishing a connection](#establishing-a-connection). +* The name of TDengineParameter needs to start with @, such as @0, @1, @2, etc. The value needs to have a one-to-one correspondence between the C# column type and the TDengine column type. For the specific correspondence, please refer to [TDengine DataType and C# DataType](#tdengine-datatype-vs-c-datatype). ### More sample programs -|Sample program |Sample program description | -|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| -| [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/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/NET6Examples/JSONTag) | Writing and querying JSON tag data with TDengine Connector | -| [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/NET6Examples/Stmt) | Parameter binding with TDengine Connector | -| [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/schemaless) | Schemaless writes with TDengine Connector | -| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/AsyncQuery/QueryAsync.cs) | Asynchronous queries with TDengine Connector | -| [Subscription](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/TMQ/TMQ.cs) | Subscription example with TDengine Connector | -| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/FrameWork45/WS/WebSocketSample.cs) | WebSocket basic data in and out with TDengine connector | -| [WebSocket Parameter Binding](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/FrameWork45/WS/WebSocketSTMT.cs) | WebSocket parameter binding example | - -## Important update records - -| TDengine.Connector | Description | -|--------------------|--------------------------------| -| 3.0.2 | Support .NET Framework 4.5 and above. Support .Net standard 2.0. Nuget package includes dynamic library for WebSocket.| -| 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. | -| 1.0.5 | Fix Windows sync query Chinese error bug. | 1.0.4 | Fix schemaless bug. | -| 1.0.4 | Add asynchronous query, subscription, and other functions. Fix the binding parameter bug. | -| 1.0.3 | Add parameter binding, schemaless, JSON tag, etc. | -| 1.0.2 | Add connection management, synchronous query, error messages, etc. | - -## Other descriptions - -### Third-party driver - -`Taos` is an ADO.NET connector for TDengine, supporting Linux and Windows platforms. Community contributor `Maikebing@@maikebing contributes the connector`. Please refer to: - -* Interface download: - -## Frequently Asked Questions - -1. "Unable to establish connection", "Unable to resolve FQDN" - - Usually, it's caused by an incorrect FQDN configuration. Please refer to this section in the [FAQ](https://docs.tdengine.com/2.4/train-faq/faq/#2-how-to-handle-unable-to-establish-connection) to troubleshoot. - -2. Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: The specified module cannot be found. - - This is usually because the program did not find the dependent client driver. The solution is to copy `C:\TDengine\driver\taos.dll` to the `C:\Windows\System32\` directory on Windows, and create the following soft link on Linux `ln -s /usr/local/taos/driver/libtaos.so.x.x .x.x /usr/lib/libtaos.so` will work. - -## API Reference - -[API Reference](https://docs.taosdata.com/api/connector-csharp/html/860d2ac1-dd52-39c9-e460-0829c4e5a40b.htm) +[sample program](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples) \ No newline at end of file diff --git a/docs/examples/csharp/.gitignore b/docs/examples/csharp/.gitignore index c228f1be2a..b0df020f44 100644 --- a/docs/examples/csharp/.gitignore +++ b/docs/examples/csharp/.gitignore @@ -1,5 +1,5 @@ .vs -asyncQuery/bin +.idea connect/bin influxdbLine/bin optsJSON/bin @@ -12,7 +12,6 @@ wsConnect/bin wsInsert/bin wsQuery/bin wsStmt/bin -asyncQuery/obj connect/obj influxdbLine/obj optsJSON/obj diff --git a/docs/examples/csharp/asyncQuery/Program.cs b/docs/examples/csharp/asyncQuery/Program.cs deleted file mode 100644 index 864f06a15e..0000000000 --- a/docs/examples/csharp/asyncQuery/Program.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using TDengineDriver; -using TDengineDriver.Impl; -using System.Runtime.InteropServices; - -namespace TDengineExample -{ - public class AsyncQueryExample - { - static void Main() - { - IntPtr conn = GetConnection(); - 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) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - FetchRawBlockAsyncCallback fetchRowAsyncCallback = new FetchRawBlockAsyncCallback(FetchRawBlockCallback); - TDengine.FetchRawBlockAsync(taosRes, fetchRowAsyncCallback, param); - } - else - { - throw new Exception($"async query data failed,code:{code},reason:{TDengine.Error(taosRes)}"); - } - } - - // Iteratively call this interface until "numOfRows" is no greater than 0. - static void FetchRawBlockCallback(IntPtr param, IntPtr taosRes, int numOfRows) - { - if (numOfRows > 0) - { - Console.WriteLine($"{numOfRows} rows async retrieved"); - IntPtr pdata = TDengine.GetRawBlock(taosRes); - List metaList = TDengine.FetchFields(taosRes); - List dataList = LibTaos.ReadRawBlock(pdata, metaList, numOfRows); - - for (int i = 0; i < dataList.Count; i++) - { - if (i != 0 && (i + 1) % metaList.Count == 0) - { - Console.WriteLine("{0}\t|", dataList[i]); - } - else - { - Console.Write("{0}\t|", dataList[i]); - } - } - Console.WriteLine(""); - TDengine.FetchRawBlockAsync(taosRes, FetchRawBlockCallback, param); - } - else - { - if (numOfRows == 0) - { - Console.WriteLine("async retrieve complete."); - } - else - { - throw new Exception($"FetchRawBlockCallback callback error, error code {numOfRows}"); - } - TDengine.FreeResult(taosRes); - } - } - - 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 -// // 8 rows async retrieved - -// // 1538548685500 | 11.8 | 221 | 0.28 | california.losangeles | 2 | -// // 1538548696600 | 13.4 | 223 | 0.29 | california.losangeles | 2 | -// // 1538548685000 | 10.8 | 223 | 0.29 | california.losangeles | 3 | -// // 1538548686500 | 11.5 | 221 | 0.35 | california.losangeles | 3 | -// // 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 | -// // async retrieve complete. \ No newline at end of file diff --git a/docs/examples/csharp/asyncQuery/asyncquery.csproj b/docs/examples/csharp/asyncQuery/asyncquery.csproj deleted file mode 100644 index 7c5b693f28..0000000000 --- a/docs/examples/csharp/asyncQuery/asyncquery.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net6.0 - enable - enable - TDengineExample.AsyncQueryExample - - - - - - - diff --git a/docs/examples/csharp/connect/Program.cs b/docs/examples/csharp/connect/Program.cs index 955db40c7c..0152b61b03 100644 --- a/docs/examples/csharp/connect/Program.cs +++ b/docs/examples/csharp/connect/Program.cs @@ -1,4 +1,5 @@ -using TDengineDriver; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { @@ -7,23 +8,11 @@ namespace TDengineExample { static void Main(String[] args) { - 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) + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - throw new Exception("Connect to TDengine failed"); + Console.WriteLine("connected"); } - else - { - Console.WriteLine("Connect to TDengine success"); - } - TDengine.Close(conn); - TDengine.Cleanup(); } } } diff --git a/docs/examples/csharp/connect/connect.csproj b/docs/examples/csharp/connect/connect.csproj index a08e86d4b4..e4412a68db 100644 --- a/docs/examples/csharp/connect/connect.csproj +++ b/docs/examples/csharp/connect/connect.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/csharp.sln b/docs/examples/csharp/csharp.sln index 560dde55cb..59c198b4c9 100644 --- a/docs/examples/csharp/csharp.sln +++ b/docs/examples/csharp/csharp.sln @@ -3,8 +3,6 @@ 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}" @@ -38,10 +36,6 @@ Global 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 diff --git a/docs/examples/csharp/influxdbLine/Program.cs b/docs/examples/csharp/influxdbLine/Program.cs index a620c01609..fcf2928f0c 100644 --- a/docs/examples/csharp/influxdbLine/Program.cs +++ b/docs/examples/csharp/influxdbLine/Program.cs @@ -1,4 +1,5 @@ -using TDengineDriver; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { @@ -6,60 +7,23 @@ namespace TDengineExample { static void Main() { - IntPtr conn = GetConnection(); - PrepareDatabase(conn); - string[] lines = { - "meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", - "meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", - "meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", - "meters,location=California.LosAngeles,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250" - }; - 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) + var builder = + new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - 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); - - } - 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 PrepareDatabase(IntPtr conn) - { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to create database, reason: " + TDengine.Error(res)); - } - res = TDengine.Query(conn, "USE test"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to change database, reason: " + TDengine.Error(res)); + client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); + client.Exec("use test"); + string[] lines = { + "meters,location=California.LosAngeles,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=California.LosAngeles,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=California.LosAngeles,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250" + }; + client.SchemalessInsert(lines, + TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); } } - } } diff --git a/docs/examples/csharp/influxdbLine/influxdbline.csproj b/docs/examples/csharp/influxdbLine/influxdbline.csproj index 4889f8fde9..4fe883b6cb 100644 --- a/docs/examples/csharp/influxdbLine/influxdbline.csproj +++ b/docs/examples/csharp/influxdbLine/influxdbline.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/optsJSON/Program.cs b/docs/examples/csharp/optsJSON/Program.cs index 8dcc1dce92..a93c4dad0f 100644 --- a/docs/examples/csharp/optsJSON/Program.cs +++ b/docs/examples/csharp/optsJSON/Program.cs @@ -1,69 +1,28 @@ -using TDengineDriver; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { internal class OptsJsonExample { - static void Main() + public static void Main(string[] args) { - IntPtr conn = GetConnection(); - try + var builder = + new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - 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) + client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); + client.Exec("use test"); + string[] lines = { - 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); - } - 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 PrepareDatabase(IntPtr conn) - { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to create database, reason: " + TDengine.Error(res)); - } - res = TDengine.Query(conn, "USE test"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to change database, reason: " + TDengine.Error(res)); + "[{\"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}}]" + }; + client.SchemalessInsert(lines, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); } } } -} +} \ No newline at end of file diff --git a/docs/examples/csharp/optsJSON/optsJSON.csproj b/docs/examples/csharp/optsJSON/optsJSON.csproj index 208f04c82d..9c3edf53e3 100644 --- a/docs/examples/csharp/optsJSON/optsJSON.csproj +++ b/docs/examples/csharp/optsJSON/optsJSON.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/optsTelnet/Program.cs b/docs/examples/csharp/optsTelnet/Program.cs index ccd29d0cfc..b64aa9fe2d 100644 --- a/docs/examples/csharp/optsTelnet/Program.cs +++ b/docs/examples/csharp/optsTelnet/Program.cs @@ -1,72 +1,31 @@ -using TDengineDriver; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { internal class OptsTelnetExample { - static void Main() + public static void Main(string[] args) { - IntPtr conn = GetConnection(); - try + var builder = + new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - PrepareDatabase(conn); + client.Exec("CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); + client.Exec("USE test"); 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", - "meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3", - "meters.voltage 1648432611249 219 location=California.SanFrancisco groupid=2", - "meters.voltage 1648432611250 218 location=California.SanFrancisco groupid=2", - "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) - { - 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); - } - catch - { - 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 PrepareDatabase(IntPtr conn) - { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to create database, reason: " + TDengine.Error(res)); - } - res = TDengine.Query(conn, "USE test"); - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception("failed to change database, reason: " + TDengine.Error(res)); + "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", + "meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3", + "meters.voltage 1648432611249 219 location=California.SanFrancisco groupid=2", + "meters.voltage 1648432611250 218 location=California.SanFrancisco groupid=2", + "meters.voltage 1648432611249 221 location=California.LosAngeles groupid=3", + "meters.voltage 1648432611250 217 location=California.LosAngeles groupid=3", + }; + client.SchemalessInsert(lines, + TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); } } } diff --git a/docs/examples/csharp/optsTelnet/optstelnet.csproj b/docs/examples/csharp/optsTelnet/optstelnet.csproj index 32c76ec418..4d6941e962 100644 --- a/docs/examples/csharp/optsTelnet/optstelnet.csproj +++ b/docs/examples/csharp/optsTelnet/optstelnet.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/query/Program.cs b/docs/examples/csharp/query/Program.cs index 84c7f9db1f..4c354d9a5e 100644 --- a/docs/examples/csharp/query/Program.cs +++ b/docs/examples/csharp/query/Program.cs @@ -1,80 +1,35 @@ -using TDengineDriver; -using TDengineDriver.Impl; -using System.Runtime.InteropServices; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { internal class QueryExample { - static void Main() + public static void Main(string[] args) { - IntPtr conn = GetConnection(); - try + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - // run query - IntPtr res = TDengine.Query(conn, "SELECT * FROM meters LIMIT 2"); - if (TDengine.ErrorNo(res) != 0) + try { - 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)) + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) { - Console.WriteLine(""); + while (rows.Read()) + { + Console.WriteLine( + $"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } } } - Console.WriteLine(); - - // Free result after use - TDengine.FreeResult(res); + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } } - 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 +} \ No newline at end of file diff --git a/docs/examples/csharp/query/query.csproj b/docs/examples/csharp/query/query.csproj index 360d73b2c0..9924d331af 100644 --- a/docs/examples/csharp/query/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 index 25a945a459..c3c700aba2 100644 --- a/docs/examples/csharp/sqlInsert/Program.cs +++ b/docs/examples/csharp/sqlInsert/Program.cs @@ -1,69 +1,47 @@ -using TDengineDriver; - +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { internal class SQLInsertExample { - static void Main() + public static void Main(string[] args) { - IntPtr conn = GetConnection(); - try + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600"); - 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)}"); + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } } } - } } - -// output: -// Connect to TDengine success -// affectedRows 8 diff --git a/docs/examples/csharp/sqlInsert/sqlinsert.csproj b/docs/examples/csharp/sqlInsert/sqlinsert.csproj index 1b6f745c82..aa8e1402ae 100644 --- a/docs/examples/csharp/sqlInsert/sqlinsert.csproj +++ b/docs/examples/csharp/sqlInsert/sqlinsert.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/stmtInsert/Program.cs b/docs/examples/csharp/stmtInsert/Program.cs index 2e856a49bb..e6b11a63e4 100644 --- a/docs/examples/csharp/stmtInsert/Program.cs +++ b/docs/examples/csharp/stmtInsert/Program.cs @@ -1,109 +1,38 @@ -using TDengineDriver; +using TDengine.Driver; +using TDengine.Driver.Client; namespace TDengineExample { internal class StmtInsertExample { - private static IntPtr conn; - private static IntPtr stmt; - static void Main() + public static void Main(string[] args) { - conn = GetConnection(); - try + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - PrepareSTable(); - // 1. init and prepare - stmt = TDengine.StmtInit(conn); - if (stmt == IntPtr.Zero) + try { - throw new Exception("failed to init stmt."); + client.Exec($"create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } } - 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"); - - // 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"); - - // 4. add batch - res = TDengine.StmtAddBatch(stmt); - CheckStmtRes(res, "failed to add batch"); - - // 5. execute - res = TDengine.StmtExecute(stmt); - CheckStmtRes(res, "failed to execute"); - - // 6. free - TaosMultiBind.FreeTaosBind(tags); - TaosMultiBind.FreeTaosBind(values); - } - 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 PrepareSTable() - { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600"); - CheckResPtr(res, "failed to create database"); - res = TDengine.Query(conn, "USE power"); - CheckResPtr(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)"); - CheckResPtr(res, "failed to create stable"); - } - - static void CheckStmtRes(int res, string errorMsg) - { - if (res != 0) - { - Console.WriteLine(errorMsg + ", " + TDengine.StmtErrorStr(stmt)); - int code = TDengine.StmtClose(stmt); - if (code != 0) + catch (Exception e) { - throw new Exception($"failed to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} "); + Console.WriteLine(e); + throw; } } } - - static void CheckResPtr(IntPtr res, string errorMsg) - { - if (TDengine.ErrorNo(res) != 0) - { - throw new Exception(errorMsg + " since:" + TDengine.Error(res)); - } - } - } -} +} \ No newline at end of file diff --git a/docs/examples/csharp/stmtInsert/stmtinsert.csproj b/docs/examples/csharp/stmtInsert/stmtinsert.csproj index f5b2b67397..9fa3109b80 100644 --- a/docs/examples/csharp/stmtInsert/stmtinsert.csproj +++ b/docs/examples/csharp/stmtInsert/stmtinsert.csproj @@ -9,7 +9,7 @@ - + diff --git a/docs/examples/csharp/subscribe/Program.cs b/docs/examples/csharp/subscribe/Program.cs index 1fba209f22..d7c1a52117 100644 --- a/docs/examples/csharp/subscribe/Program.cs +++ b/docs/examples/csharp/subscribe/Program.cs @@ -1,95 +1,72 @@ -using System; -using TDengineTMQ; -using TDengineDriver; -using System.Runtime.InteropServices; + +using TDengine.Driver; +using TDengine.Driver.Client; +using TDengine.TMQ; namespace TMQExample { internal class SubscribeDemo { - static void Main(string[] args) + public static void Main(string[] args) { - IntPtr conn = GetConnection(); - string topic = "topic_example"; - //create topic - IntPtr res = TDengine.Query(conn, $"create topic if not exists {topic} as select * from meters"); - - if (TDengine.ErrorNo(res) != 0 ) + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - throw new Exception($"create topic failed, reason:{TDengine.Error(res)}"); - } - - var cfg = new ConsumerConfig - { - GourpId = "group_1", - TDConnectUser = "root", - TDConnectPasswd = "taosdata", - MsgWithTableName = "true", - TDConnectIp = "127.0.0.1", - }; - - // create consumer - var consumer = new ConsumerBuilder(cfg) - .Build(); - - // subscribe - consumer.Subscribe(topic); - - // consume - for (int i = 0; i < 5; i++) - { - var consumeRes = consumer.Consume(300); - // print consumeResult - foreach (KeyValuePair kv in consumeRes.Message) + try { - Console.WriteLine("topic partitions:\n{0}", kv.Key.ToString()); - - kv.Value.Metas.ForEach(meta => + client.Exec("CREATE DATABASE power"); + client.Exec("USE power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + var cfg = new Dictionary() { - Console.Write("{0} {1}({2}) \t|", meta.name, meta.TypeName(), meta.size); - }); - Console.WriteLine(""); - kv.Value.Datas.ForEach(data => + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + consumer.Subscribe(new List() { "topic_meters" }); + Task.Run(InsertData); + while (true) { - Console.WriteLine(data.ToString()); - }); + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; } - - consumer.Commit(consumeRes); - Console.WriteLine("\n================ {0} done ", i); - } - - // retrieve topic list - List topics = consumer.Subscription(); - topics.ForEach(t => Console.WriteLine("topic name:{0}", t)); - - // unsubscribe - consumer.Unsubscribe(); - - // close consumer after use.Otherwise will lead memory leak. - consumer.Close(); - TDengine.Close(conn); - } - static IntPtr GetConnection() + static void InsertData() { - 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) + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - throw new Exception("Connect to TDengine failed"); + while (true) + { + client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)"); + Task.Delay(1000).Wait(); + } } - else - { - Console.WriteLine("Connect to TDengine success"); - } - return conn; } } diff --git a/docs/examples/csharp/subscribe/subscribe.csproj b/docs/examples/csharp/subscribe/subscribe.csproj index 191b3f9e9b..df6618d214 100644 --- a/docs/examples/csharp/subscribe/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 index a534bb8a65..edf0eb31e6 100644 --- a/docs/examples/csharp/wsConnect/Program.cs +++ b/docs/examples/csharp/wsConnect/Program.cs @@ -1,28 +1,18 @@ using System; -using TDengineWS.Impl; +using TDengine.Driver; +using TDengine.Driver.Client; namespace Examples { public class WSConnExample { - static int Main(string[] args) + 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) + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - Console.WriteLine("get WS connection failed"); - return -1; + Console.WriteLine("connected"); } - else - { - Console.WriteLine("Establish connect success."); - // close connection. - LibTaosWS.WSClose(wsConn); - } - - return 0; } } } diff --git a/docs/examples/csharp/wsConnect/wsConnect.csproj b/docs/examples/csharp/wsConnect/wsConnect.csproj index c7988b6e9c..01ab149af5 100644 --- a/docs/examples/csharp/wsConnect/wsConnect.csproj +++ b/docs/examples/csharp/wsConnect/wsConnect.csproj @@ -6,7 +6,7 @@ - + diff --git a/docs/examples/csharp/wsInsert/Program.cs b/docs/examples/csharp/wsInsert/Program.cs index 7fa6af805c..73136477e7 100644 --- a/docs/examples/csharp/wsInsert/Program.cs +++ b/docs/examples/csharp/wsInsert/Program.cs @@ -1,61 +1,46 @@ using System; -using TDengineWS.Impl; +using TDengine.Driver; +using TDengine.Driver.Client; namespace Examples { public class WSInsertExample { - static int Main(string[] args) + public 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) + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - Console.WriteLine("get WS connection failed"); - return -1; - } - 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); - - return 0; - } - - static void ValidInsert(string desc, IntPtr wsRes) - { - int code = LibTaosWS.WSErrorNo(wsRes); - if (code != 0) - { - Console.WriteLine($"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)); + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } } } } - } -// Establish connect success. -// create table success affect 0 rows, cost 3717542 nanoseconds -// insert data success affect 8 rows, cost 2613637 nanoseconds diff --git a/docs/examples/csharp/wsInsert/wsInsert.csproj b/docs/examples/csharp/wsInsert/wsInsert.csproj index 5aa419b2c8..0459e8e38b 100644 --- a/docs/examples/csharp/wsInsert/wsInsert.csproj +++ b/docs/examples/csharp/wsInsert/wsInsert.csproj @@ -6,7 +6,7 @@ enable - + diff --git a/docs/examples/csharp/wsQuery/Program.cs b/docs/examples/csharp/wsQuery/Program.cs index 8ee900a05a..40aac24597 100644 --- a/docs/examples/csharp/wsQuery/Program.cs +++ b/docs/examples/csharp/wsQuery/Program.cs @@ -1,79 +1,36 @@ using System; -using TDengineWS.Impl; -using System.Collections.Generic; -using TDengineDriver; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; namespace Examples { public class WSQueryExample { - static int Main(string[] args) + public 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) + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - Console.WriteLine("get WS connection failed"); - return -1; - } - 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) - { - Console.WriteLine($"execute SQL failed: reason: {LibTaosWS.WSErrorStr(wsRes)}, code:{code}"); - LibTaosWS.WSFreeResult(wsRes); - return -1; - } - - // 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++) + try { - Console.Write("{0}\t|\t", dataSet[i]); - i++; + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) + { + while (rows.Read()) + { + Console.WriteLine( + $"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; } - Console.WriteLine(""); } - - // Free result after use. - LibTaosWS.WSFreeResult(wsRes); - - // close connection. - LibTaosWS.WSClose(wsConn); - - return 0; } } -} - -// 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 index bcc7c19a59..ff283947b4 100644 --- a/docs/examples/csharp/wsQuery/wsQuery.csproj +++ b/docs/examples/csharp/wsQuery/wsQuery.csproj @@ -7,7 +7,7 @@ - + diff --git a/docs/examples/csharp/wsStmt/Program.cs b/docs/examples/csharp/wsStmt/Program.cs index f8673357db..5166dfea92 100644 --- a/docs/examples/csharp/wsStmt/Program.cs +++ b/docs/examples/csharp/wsStmt/Program.cs @@ -1,98 +1,41 @@ using System; -using TDengineWS.Impl; -using TDengineDriver; -using System.Runtime.InteropServices; +using TDengine.Driver; +using TDengine.Driver.Client; namespace Examples { public class WSStmtExample { - static int Main(string[] args) + public 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) + var builder = + new ConnectionStringBuilder( + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - Console.WriteLine($"get WS connection failed"); - return -1; - } - 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 - { - Console.WriteLine("Init STMT failed..."); - } - - // close connection. - LibTaosWS.WSClose(wsConn); - - return 0; - } - - static void ValidStmtStep(int code, IntPtr wsStmt, string desc) - { - if (code != 0) - { - Console.WriteLine($"{desc} failed,reason: {LibTaosWS.WSErrorStr(wsStmt)}, code: {code}"); - } - else - { - Console.WriteLine("{0} success...", desc); + try + { + client.Exec($"create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } } } } -} - -// 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 index bcc7c19a59..ff283947b4 100644 --- a/docs/examples/csharp/wsStmt/wsStmt.csproj +++ b/docs/examples/csharp/wsStmt/wsStmt.csproj @@ -7,7 +7,7 @@ - + diff --git a/docs/zh/07-develop/01-connect/index.md b/docs/zh/07-develop/01-connect/index.md index 83032067d9..9d954f78ce 100644 --- a/docs/zh/07-develop/01-connect/index.md +++ b/docs/zh/07-develop/01-connect/index.md @@ -176,7 +176,7 @@ npm install @tdengine/rest - + diff --git a/docs/zh/07-develop/04-query-data/_cs_async.mdx b/docs/zh/07-develop/04-query-data/_cs_async.mdx deleted file mode 100644 index 19c8e58f32..0000000000 --- a/docs/zh/07-develop/04-query-data/_cs_async.mdx +++ /dev/null @@ -1,3 +0,0 @@ -```csharp -{{#include docs/examples/csharp/asyncQuery/Program.cs}} -``` diff --git a/docs/zh/07-develop/04-query-data/index.mdx b/docs/zh/07-develop/04-query-data/index.mdx index d4d6d8192d..e892f9fc8d 100644 --- a/docs/zh/07-develop/04-query-data/index.mdx +++ b/docs/zh/07-develop/04-query-data/index.mdx @@ -16,7 +16,6 @@ import CQuery from "./_c.mdx"; import PhpQuery from "./_php.mdx"; import PyAsync from "./_py_async.mdx"; import NodeAsync from "./_js_async.mdx"; -import CsAsync from "./_cs_async.mdx"; import CAsync from "./_c_async.mdx"; ## 主要查询功能 @@ -175,9 +174,6 @@ Query OK, 6 rows in database (0.005515s) - - - diff --git a/docs/zh/07-develop/07-tmq.mdx b/docs/zh/07-develop/07-tmq.mdx index d3b27fedc3..f945f53b5c 100644 --- a/docs/zh/07-develop/07-tmq.mdx +++ b/docs/zh/07-develop/07-tmq.mdx @@ -248,23 +248,23 @@ function close() ```csharp +class ConsumerBuilder + ConsumerBuilder(IEnumerable> config) -virtual IConsumer Build() - -Consumer(ConsumerBuilder builder) +public IConsumer Build() void Subscribe(IEnumerable topics) void Subscribe(string topic) -ConsumeResult Consume(int millisecondsTimeout) +ConsumeResult Consume(int millisecondsTimeout) List Subscription() void Unsubscribe() -void Commit(ConsumeResult consumerResult) +List Commit() void Close() ``` @@ -501,25 +501,19 @@ let consumer = taos.consumer({ ```csharp -using TDengineTMQ; - -// 根据需要,设置消费组 (GourpId)、自动提交 (EnableAutoCommit)、 -// 自动提交时间间隔 (AutoCommitIntervalMs)、用户名 (TDConnectUser)、密码 (TDConnectPasswd) 等参数 -var cfg = new ConsumerConfig - { - EnableAutoCommit = "true" - AutoCommitIntervalMs = "1000" - GourpId = "TDengine-TMQ-C#", - TDConnectUser = "root", - TDConnectPasswd = "taosdata", - AutoOffsetReset = "latest" - MsgWithTableName = "true", - TDConnectIp = "127.0.0.1", - TDConnectPort = "6030" - }; - -var consumer = new ConsumerBuilder(cfg).Build(); - +var cfg = new Dictionary() +{ + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); ``` @@ -748,10 +742,12 @@ while(true){ // 消费数据 while (true) { - var consumerRes = consumer.Consume(100); - // process ConsumeResult - ProcessMsg(consumerRes); - consumer.Commit(consumerRes); + using (var result = consumer.Consume(500)) + { + if (result == null) continue; + ProcessMsg(result); + consumer.Commit(); + } } ``` diff --git a/docs/zh/08-connector/02-rest-api.mdx b/docs/zh/08-connector/02-rest-api.mdx index f3f1e087d8..904b06cfe1 100644 --- a/docs/zh/08-connector/02-rest-api.mdx +++ b/docs/zh/08-connector/02-rest-api.mdx @@ -257,6 +257,63 @@ curl -L -u username:password -d "" :/rest/sql/[db_name][?tz=timez - "INT UNSIGNED" - "BIGINT UNSIGNED" - "JSON" +- "VARBINARY" +- "GEOMETRY" + +`VARBINARY` 和 `GEOMETRY` 类型返回数据为 Hex 字符串,样例: + +准备数据 + +```bash +create database demo +use demo +create table t(ts timestamp,c1 varbinary(20),c2 geometry(100)) +insert into t values(now,'\x7f8290','point(100 100)') +``` + +执行查询 + +```bash +curl --location 'http://:/rest/sql' \ +--header 'Content-Type: text/plain' \ +--header 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' \ +--data 'select * from demo.t' +``` + +返回结果 + +```json +{ + "code": 0, + "column_meta": [ + [ + "ts", + "TIMESTAMP", + 8 + ], + [ + "c1", + "VARBINARY", + 20 + ], + [ + "c2", + "GEOMETRY", + 100 + ] + ], + "data": [ + [ + "2023-11-01T06:28:15.210Z", + "7f8290", + "010100000000000000000059400000000000005940" + ] + ], + "rows": 1 +} +``` + +- `010100000000000000000059400000000000005940` 为 `point(100 100)` 的 [Well-Known Binary (WKB)](https://libgeos.org/specifications/wkb/) 格式 #### 错误 diff --git a/docs/zh/08-connector/40-csharp.mdx b/docs/zh/08-connector/40-csharp.mdx index 325c71da88..f88002d3dc 100644 --- a/docs/zh/08-connector/40-csharp.mdx +++ b/docs/zh/08-connector/40-csharp.mdx @@ -1,27 +1,22 @@ --- toc_max_heading_level: 4 sidebar_label: C# -title: C# Connector +title: TDengine C# Connector --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Preparation from "./_preparation.mdx" -import CSInsert from "../07-develop/03-insert-data/_cs_sql.mdx" -import CSInfluxLine from "../07-develop/03-insert-data/_cs_line.mdx" -import CSOpenTSDBTelnet from "../07-develop/03-insert-data/_cs_opts_telnet.mdx" -import CSOpenTSDBJson from "../07-develop/03-insert-data/_cs_opts_json.mdx" -import CSQuery from "../07-develop/04-query-data/_cs.mdx" -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` 自 v3.0.1 起还支持 WebSocket,通过 DSN 建立 WebSocket 连接,提供数据写入、查询、参数绑定接口数据写入等功能。 +`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、数据订阅、schemaless 数据写入、参数绑定接口数据写入等功能。 `TDengine.Connector` 自 v3.0.1 起还支持 WebSocket 连接,提供数据写入、查询、参数绑定接口数据写入等功能。 本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。 -注意:`TDengine.Connector` 3.x 不兼容 TDengine 2.x,如果在运行 TDengine 2.x 版本的环境下需要使用 C# 连接器请使用 TDengine.Connector 的 1.x 版本 。 +:::warning +* `TDengine.Connector` 3.1.0 版本进行了完整的重构,不再兼容 3.0.2 及以前版本。3.0.2 文档请参考 [nuget](https://www.nuget.org/packages/TDengine.Connector/3.0.2) +* `TDengine.Connector` 3.x 不兼容 TDengine 2.x,如果在运行 TDengine 2.x 版本的环境下需要使用 C# 连接器请使用 TDengine.Connector 的 1.x 版本。 +::: `TDengine.Connector` 的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-dotnet/tree/3.0)。 @@ -29,39 +24,43 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx" 支持的平台和 TDengine 客户端驱动支持的平台一致。 -:::note -注意 TDengine 不再支持 32 位 Windows 平台。 +:::warning +TDengine 不再支持 32 位 Windows 平台。 ::: ## 版本支持 -请参考[版本支持列表](../#版本支持) +| **Connector version** | **TDengine version** | +|-----------------------|----------------------| +| 3.1.0 | 3.2.1.0/3.1.1.18 | -## 支持的功能特性 +## 处理异常 - +`TDengine.Connector` 会抛出异常,应用程序需要处理异常。taosc 异常类型 `TDengineError`,包含错误码和错误信息,应用程序可以根据错误码和错误信息进行处理。 - +## TDengine DataType 和 C# DataType -1. 连接管理 -2. 普通查询 -3. 连续查询 -4. 参数绑定 -5. 数据订阅(TMQ) -6. Schemaless - - +| TDengine DataType | C# Type | +|-------------------|------------------| +| TIMESTAMP | DateTime | +| TINYINT | sbyte | +| SMALLINT | short | +| INT | int | +| BIGINT | long | +| TINYINT UNSIGNED | byte | +| SMALLINT UNSIGNED | ushort | +| INT UNSIGNED | uint | +| BIGINT UNSIGNED | ulong | +| FLOAT | float | +| DOUBLE | double | +| BOOL | bool | +| BINARY | byte[] | +| NCHAR | string (utf-8编码) | +| JSON | byte[] | - - -1. 连接管理 -2. 普通查询 -3. 连续查询 -4. 参数绑定 - - - - +:::note +JSON 类型仅在 tag 中支持。 +::: ## 安装步骤 @@ -71,10 +70,7 @@ import CSAsyncQuery from "../07-develop/04-query-data/_cs_async.mdx" * [Nuget 客户端](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) (可选安装) * 安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](../#安装客户端驱动) -### 安装 TDengine.Connector - - - +### 安装连接器 可以在当前 .NET 项目的路径下,通过 dotnet CLI 添加 Nuget package `TDengine.Connector` 到当前项目。 @@ -86,234 +82,1109 @@ dotnet add package TDengine.Connector ``` XML - + ``` - - - - -需要修改目标项目的 `.csproj` 项目文件,将 `.nupkg` 中的 `runtimes` 目录中的动态库复制到当前项目的 `$(OutDir)` 目录下。 - -```XML - - - - - - - - - -``` - -注意:`TDengine.Connector` 自 version>= 3.0.2 的 nuget package 中才会有动态库( taosws.dll,libtaows.so )。 - - - - ## 建立连接 - - + -使用 host、username、password、port 等信息建立连接。 - ``` csharp -using TDengineDriver; - -namespace TDengineExample +var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); +using (var client = DbDriver.Open(builder)) { + Console.WriteLine("connected"); +} +``` - internal class EstablishConnection + + + +```csharp +var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); +using (var client = DbDriver.Open(builder)) +{ + Console.WriteLine("connected"); +} +``` + + + +ConnectionStringBuilder 支持的参数如下: +* protocol: 连接协议,可选值为 Native 或 WebSocket,默认为 Native +* host: TDengine 或 taosadapter 运行实例的地址 +* port: TDengine 或 taosadapter 运行实例的端口 + * 当 protocol 为 WebSocket 时 useSSL 为 false 时,port 默认为 6041 + * 当 protocol 为 WebSocket 时 useSSL 为 true 时,port 默认为 443 +* useSSL: 是否使用 SSL 连接,仅当 protocol 为 WebSocket 时有效,默认为 false +* token: 连接 TDengine cloud 的 token,仅当 protocol 为 WebSocket 时有效 +* username: 连接 TDengine 的用户名 +* password: 连接 TDengine 的密码 +* db: 连接 TDengine 的数据库 +* timezone: 解析时间结果的时区,默认为 `TimeZoneInfo.Local`,使用 `TimeZoneInfo.FindSystemTimeZoneById` 方法解析字符串为 `TimeZoneInfo` 对象。 +* connTimeout: WebSocket 连接超时时间,仅当 protocol 为 WebSocket 时有效,默认为 1 分钟,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 +* readTimeout: WebSocket 读超时时间,仅当 protocol 为 WebSocket 时有效,默认为 5 分钟,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 +* writeTimeout: WebSocket 写超时时间,仅当 protocol 为 WebSocket 时有效,默认为 10 秒,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 + +### 指定 URL 和 Properties 获取连接 + +C# 连接器不支持此功能 + +### 配置参数的优先级 + +C# 连接器不支持此功能 + +## 使用示例 + +### 创建数据库和表 + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQuery +{ + internal class Query { - static void Main(String[] args) + public static void Main(string[] args) { - 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) + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) { - Console.WriteLine("Connect to TDengine failed"); + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } } - else - { - Console.WriteLine("Connect to TDengine success"); - } - TDengine.Close(conn); - TDengine.Cleanup(); } } } ``` + - +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; -使用 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}} +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` -## 使用示例 - -### 写入数据 - -#### SQL 写入 - - +### 插入数据 + - +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` - - + ```csharp -{{#include docs/examples/csharp/wsInsert/Program.cs}} +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + string insertQuery = + "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.30000, 219, 0.31000) " + + "('2023-10-03 14:38:15.000', 12.60000, 218, 0.33000) " + + "('2023-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "power.d1002 USING power.meters TAGS(3, 'California.SanFrancisco') " + + "VALUES " + + "('2023-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "power.d1003 USING power.meters TAGS(2,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.500', 11.80000, 221, 0.28000) " + + "('2023-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "power.d1004 USING power.meters TAGS(3,'California.LosAngeles') " + + "VALUES " + + "('2023-10-03 14:38:05.000', 10.80000, 223, 0.29000) " + + "('2023-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + client.Exec(insertQuery); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` - - - -#### InfluxDB 行协议写入 - - - -#### OpenTSDB Telnet 行协议写入 - - - -#### OpenTSDB JSON 行协议写入 - - - -#### 参数绑定 - - - - - -``` csharp -{{#include docs/examples/csharp/stmtInsert/Program.cs}} -``` - - - - - -```csharp -{{#include docs/examples/csharp/wsStmt/Program.cs}} -``` - - - ### 查询数据 -#### 同步查询 - - - + - - - - - - ```csharp -{{#include docs/examples/csharp/wsQuery/Program.cs}} +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) + { + while (rows.Read()) + { + Console.WriteLine($"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} ``` + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQuery +{ + internal class Query + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("use power"); + string query = "SELECT * FROM meters"; + using (var rows = client.Query(query)) + { + while (rows.Read()) + { + Console.WriteLine($"{((DateTime)rows.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {rows.GetValue(1)}, {rows.GetValue(2)}, {rows.GetValue(3)}, {rows.GetValue(4)}, {Encoding.UTF8.GetString((byte[])rows.GetValue(5))}"); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + -#### 异步查询 +### 执行带有 reqId 的 SQL - + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeQueryWithReqID +{ + internal abstract class QueryWithReqID + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec($"create database if not exists test_db",ReqId.GetReqId()); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSQueryWithReqID +{ + internal abstract class QueryWithReqID + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec($"create database if not exists test_db",ReqId.GetReqId()); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +### 通过参数绑定写入数据 + + + + +```csharp +using System; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeStmt +{ + internal abstract class NativeStmt + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSStmt +{ + internal abstract class WSStmt + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + using (var stmt = client.StmtInit()) + { + stmt.Prepare( + "Insert into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(?,?,?,?)"); + var ts = new DateTime(2023, 10, 03, 14, 38, 05, 000); + stmt.BindRow(new object[] { ts, (float)10.30000, (int)219, (float)0.31000 }); + stmt.AddBatch(); + stmt.Exec(); + var affected = stmt.Affected(); + Console.WriteLine($"affected rows: {affected}"); + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +注意:使用 BindRow 需要注意原始 C# 列类型与 TDengine 列类型的需要一一对应,具体对应关系请参考 [TDengine DataType 和 C# DataType](#tdengine-datatype-和-c-datatype)。 + +### 无模式写入 + + + + +```csharp +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeSchemaless +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = + new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + client.Exec("create database sml"); + client.Exec("use sml"); + var influxDBData = + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; + client.SchemalessInsert(new string[] { influxDBData }, + TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NANO_SECONDS, 0, ReqId.GetReqId()); + var telnetData = "stb0_0 1626006833 4 host=host0 interface=eth0"; + client.SchemalessInsert(new string[] { telnetData }, + TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + var jsonData = + "{\"metric\": \"meter_current\",\"timestamp\": 1626846400,\"value\": 10.3, \"tags\": {\"groupid\": 2, \"location\": \"California.SanFrancisco\", \"id\": \"d1001\"}}"; + client.SchemalessInsert(new string[] { jsonData }, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + } + } + } +} +``` + + + + +```csharp +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSSchemaless +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = + new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + client.Exec("create database sml"); + client.Exec("use sml"); + var influxDBData = + "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; + client.SchemalessInsert(new string[] { influxDBData }, + TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NANO_SECONDS, 0, ReqId.GetReqId()); + var telnetData = "stb0_0 1626006833 4 host=host0 interface=eth0"; + client.SchemalessInsert(new string[] { telnetData }, + TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + var jsonData = + "{\"metric\": \"meter_current\",\"timestamp\": 1626846400,\"value\": 10.3, \"tags\": {\"groupid\": 2, \"location\": \"California.SanFrancisco\", \"id\": \"d1001\"}}"; + client.SchemalessInsert(new string[] { jsonData }, TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, + TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS, 0, ReqId.GetReqId()); + } + } + } +} +``` + + + + +### 执行带有 reqId 的无模式写入 + +```csharp +public void SchemalessInsert(string[] lines, TDengineSchemalessProtocol protocol, + TDengineSchemalessPrecision precision, + int ttl, long reqId) +``` + +### 数据订阅 + +#### 创建 Topic + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace NativeSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Text; +using TDengine.Driver; +using TDengine.Driver.Client; + +namespace WSSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("create database power"); + client.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + } +} +``` + + + + +#### 创建 Consumer + + + + +```csharp +var cfg = new Dictionary() +{ + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); +``` + + + + +```csharp +var cfg = new Dictionary() +{ + { "td.connect.type", "WebSocket" }, + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "localhost" }, + { "td.connect.port", "6041" }, + { "useSSL", "false" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, +}; +var consumer = new ConsumerBuilder>(cfg).Build(); +``` + + + + +consumer 支持的配置参数如下: +* td.connect.type: 连接类型,可选值为 Native 或 WebSocket,默认为 Native +* td.connect.ip: TDengine 或 taosadapter 运行实例的地址 +* td.connect.port: TDengine 或 taosadapter 运行实例的端口 + * 当 td.connect.type 为 WebSocket 且 useSSL 为 false 时,td.connect.port 默认为 6041 + * 当 td.connect.type 为 WebSocket 且 useSSL 为 true 时,td.connect.port 默认为 443 +* useSSL: 是否使用 SSL 连接,仅当 td.connect.type 为 WebSocket 时有效,默认为 false +* token: 连接 TDengine cloud 的 token,仅当 td.connect.type 为 WebSocket 时有效 + +* td.connect.user: 连接 TDengine 的用户名 +* td.connect.pass: 连接 TDengine 的密码 +* group.id: 消费者组 ID +* client.id: 消费者 ID +* enable.auto.commit: 是否自动提交 offset,默认为 true +* auto.commit.interval.ms: 自动提交 offset 的间隔时间,默认为 5000 毫秒 +* auto.offset.reset: 当 offset 不存在时,从哪里开始消费,可选值为 earliest 或 latest,默认为 latest +* msg.with.table.name: 消息是否包含表名 + + +支持订阅结果集 `Dictionary` key 为列名,value 为列值。 + +如果使用 object 接收列值,需要注意: +* 原始 C# 列类型与 TDengine 列类型的需要一一对应,具体对应关系请参考 [TDengine DataType 和 C# DataType](#tdengine-datatype-和-c-datatype)。 +* 列名与 class 属性名一致,并可读写。 +* 明确设置 value 解析器`ConsumerBuilder.SetValueDeserializer(new ReferenceDeserializer());` + +样例如下 + +结果 class + +```csharp + class Result + { + public DateTime ts { get; set; } + public float current { get; set; } + public int voltage { get; set; } + public float phase { get; set; } + } +``` + +设置解析器 + +```csharp +var tmqBuilder = new ConsumerBuilder(cfg); +tmqBuilder.SetValueDeserializer(new ReferenceDeserializer()); +var consumer = tmqBuilder.Build(); +``` + +也可实现自定义解析器,实现 `IDeserializer` 接口并通过`ConsumerBuilder.SetValueDeserializer`方法传入。 + +```csharp + public interface IDeserializer + { + T Deserialize(ITMQRows data, bool isNull, SerializationContext context); + } +``` + +#### 订阅消费数据 + +```csharp +consumer.Subscribe(new List() { "topic_meters" }); +while (true) +{ + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + } +} +``` + +#### 指定订阅 Offset + +```csharp +consumer.Assignment.ForEach(a => +{ + Console.WriteLine($"{a}, seek to 0"); + consumer.Seek(new TopicPartitionOffset(a.Topic, a.Partition, 0)); + Thread.Sleep(TimeSpan.FromSeconds(1)); +}); +``` + +#### 提交 Offset + +```csharp +public void Commit(ConsumeResult consumerResult) +public List Commit() +public void Commit(IEnumerable offsets) +``` + +#### 关闭订阅 + +```csharp +consumer.Unsubscribe(); +consumer.Close(); +``` + +#### 完整示例 + + + + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using TDengine.Driver; +using TDengine.Driver.Client; +using TDengine.TMQ; + +namespace NativeSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("CREATE DATABASE power"); + client.Exec("USE power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + var cfg = new Dictionary() + { + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + consumer.Subscribe(new List() { "topic_meters" }); + Task.Run(InsertData); + while (true) + { + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + consumer.Commit(); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + + static void InsertData() + { + var builder = new ConnectionStringBuilder("host=localhost;port=6030;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + while (true) + { + client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)"); + Task.Delay(1000).Wait(); + } + } + } + } +} +``` + + + + +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using TDengine.Driver; +using TDengine.Driver.Client; +using TDengine.TMQ; + +namespace WSSubscription +{ + internal class Program + { + public static void Main(string[] args) + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + try + { + client.Exec("CREATE DATABASE power"); + client.Exec("USE power"); + client.Exec( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"); + client.Exec("CREATE TOPIC topic_meters as SELECT * from power.meters"); + var cfg = new Dictionary() + { + { "td.connect.type", "WebSocket" }, + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "localhost" }, + { "td.connect.port", "6041" }, + { "useSSL", "false" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + consumer.Subscribe(new List() { "topic_meters" }); + Task.Run(InsertData); + while (true) + { + using (var cr = consumer.Consume(500)) + { + if (cr == null) continue; + foreach (var message in cr.Message) + { + Console.WriteLine( + $"message {{{((DateTime)message.Value["ts"]).ToString("yyyy-MM-dd HH:mm:ss.fff")}, " + + $"{message.Value["current"]}, {message.Value["voltage"]}, {message.Value["phase"]}}}"); + } + consumer.Commit(); + } + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + throw; + } + } + } + + static void InsertData() + { + var builder = new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + using (var client = DbDriver.Open(builder)) + { + while (true) + { + client.Exec("INSERT into power.d1001 using power.meters tags(2,'California.SanFrancisco') values(now,11.5,219,0.30)"); + Task.Delay(1000).Wait(); + } + } + } + } +} +``` + + + + +### ADO.NET + +C# 连接器支持 ADO.NET 接口,可以通过 ADO.NET 接口连接 TDengine 运行实例,进行数据写入、查询等操作。 + + + + +```csharp +using System; +using TDengine.Data.Client; + +namespace NativeADO +{ + internal class Program + { + public static void Main(string[] args) + { + const string connectionString = "host=localhost;port=6030;username=root;password=taosdata"; + using (var connection = new TDengineConnection(connectionString)) + { + try + { + connection.Open(); + using (var command = new TDengineCommand(connection)) + { + command.CommandText = "create database power"; + command.ExecuteNonQuery(); + connection.ChangeDatabase("power"); + command.CommandText = + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"; + command.ExecuteNonQuery(); + command.CommandText = "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "(?,?,?,?)"; + var parameters = command.Parameters; + parameters.Add(new TDengineParameter("@0", new DateTime(2023,10,03,14,38,05,000))); + parameters.Add(new TDengineParameter("@1", (float)10.30000)); + parameters.Add(new TDengineParameter("@2", (int)219)); + parameters.Add(new TDengineParameter("@3", (float)0.31000)); + command.ExecuteNonQuery(); + command.Parameters.Clear(); + command.CommandText = "SELECT * FROM meters"; + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + Console.WriteLine( + $"{((DateTime) reader.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {reader.GetValue(1)}, {reader.GetValue(2)}, {reader.GetValue(3)}, {reader.GetValue(4)}, {System.Text.Encoding.UTF8.GetString((byte[]) reader.GetValue(5))}"); + } + } + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +```csharp +using System; +using TDengine.Data.Client; + +namespace WSADO +{ + internal class Program + { + public static void Main(string[] args) + { + const string connectionString = "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"; + using (var connection = new TDengineConnection(connectionString)) + { + try + { + connection.Open(); + using (var command = new TDengineCommand(connection)) + { + command.CommandText = "create database power"; + command.ExecuteNonQuery(); + connection.ChangeDatabase("power"); + command.CommandText = + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (groupId INT, location BINARY(24))"; + command.ExecuteNonQuery(); + command.CommandText = "INSERT INTO " + + "power.d1001 USING power.meters TAGS(2,'California.SanFrancisco') " + + "VALUES " + + "(?,?,?,?)"; + var parameters = command.Parameters; + parameters.Add(new TDengineParameter("@0", new DateTime(2023,10,03,14,38,05,000))); + parameters.Add(new TDengineParameter("@1", (float)10.30000)); + parameters.Add(new TDengineParameter("@2", (int)219)); + parameters.Add(new TDengineParameter("@3", (float)0.31000)); + command.ExecuteNonQuery(); + command.Parameters.Clear(); + command.CommandText = "SELECT * FROM meters"; + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + Console.WriteLine( + $"{((DateTime) reader.GetValue(0)):yyyy-MM-dd HH:mm:ss.fff}, {reader.GetValue(1)}, {reader.GetValue(2)}, {reader.GetValue(3)}, {reader.GetValue(4)}, {System.Text.Encoding.UTF8.GetString((byte[]) reader.GetValue(5))}"); + } + } + } + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} +``` + + + + +* 连接参数与[建立连接](#建立连接)中的连接参数一致。 +* TDengineParameter 的 name 需要以 @ 开头,如 @0、@1、@2 等,value 需要 C# 列类型与 TDengine 列类型一一对应,具体对应关系请参考 [TDengine DataType 和 C# DataType](#tdengine-datatype-和-c-datatype)。 ### 更多示例程序 -|示例程序 | 示例程序描述 | -|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| -| [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/Query/Query.cs) | 使用 TDengine.Connector 实现的建表、插入、查询示例 | -| [JSON Tag](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/JSONTag) | 使用 TDengine.Connector 实现的写入和查询 JSON tag 类型数据的示例 | -| [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/NET6Examples/Stmt) | 使用 TDengine.Connector 实现的参数绑定插入和查询的示例 | -| [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/schemaless) | 使用 TDengine.Connector 实现的使用 schemaless 写入的示例 | -| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/AsyncQuery/QueryAsync.cs) | 使用 TDengine.Connector 实现的异步查询的示例 | -| [数据订阅(TMQ)](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/NET6Examples/TMQ/TMQ.cs) | 使用 TDengine.Connector 实现的订阅数据的示例 | -| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/FrameWork45/WS/WebSocketSample.cs) | 使用 TDengine.Connector 的 WebSocket 基本的示例 | -| [Basic WebSocket STMT](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/FrameWork45/WS/WebSocketSTMT.cs) | 使用 TDengine.Connector 的 WebSocket STMT 基本的示例 | - -## 重要更新记录 - -| TDengine.Connector | 说明 | -|--------------------|--------------------------------| -| 3.0.2 | 支持 .NET Framework 4.5 及以上,支持 .NET standard 2.0。Nuget Package 包含 WebSocket 动态库。 | -| 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。 | -| 1.0.5 | 修复 Windows 同步查询中文报错 bug。 | -| 1.0.4 | 新增异步查询,订阅等功能。修复绑定参数 bug。 | -| 1.0.3 | 新增参数绑定、schemaless、 json tag等功能。 | -| 1.0.2 | 新增连接管理、同步查询、错误信息等功能。 | - -## 其他说明 - -### 第三方驱动 - -[`IoTSharp.Data.Taos`](https://github.com/IoTSharp/EntityFrameworkCore.Taos) 是一个 TDengine 的 ADO.NET 连接器,其中包含了用于EntityFrameworkCore 的提供程序 IoTSharp.EntityFrameworkCore.Taos 和健康检查组件 IoTSharp.HealthChecks.Taos ,支持 Linux,Windows 平台。该连接器由社区贡献者`麦壳饼@@maikebing` 提供,具体请参考: - -* 接口下载: -* 用法说明: - -## 常见问题 - -1. "Unable to establish connection","Unable to resolve FQDN" - - 一般是因为 FQDN 配置不正确。可以参考[如何彻底搞懂 TDengine 的 FQDN](https://www.taosdata.com/blog/2021/07/29/2741.html)解决。 - -2. Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: 找不到指定的模块。 - - 一般是因为程序没有找到依赖的客户端驱动。解决方法为:Windows 下可以将 `C:\TDengine\driver\taos.dll` 拷贝到 `C:\Windows\System32\ ` 目录下,Linux 下建立如下软链接 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 - -## API 参考 - -[API 参考](https://docs.taosdata.com/api/connector-csharp/html/860d2ac1-dd52-39c9-e460-0829c4e5a40b.htm) +[示例程序](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples) \ No newline at end of file diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md index efcd5dd962..583d047c43 100644 --- a/docs/zh/12-taos-sql/05-insert.md +++ b/docs/zh/12-taos-sql/05-insert.md @@ -158,7 +158,7 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/c 自动建表, 表名通过tbname列指定 ```sql INSERT INTO meters(tbname, location, groupId, ts, current, phase) - values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 219, 0.32) - values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 217, 0.33) - values('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 217, 0.33) + values('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:34.630', 10.2, 0.32) + ('d31001', 'California.SanFrancisco', 2, '2021-07-13 14:06:35.779', 10.15, 0.33) + ('d31002', NULL, 2, '2021-07-13 14:06:34.255', 10.15, 0.33) ``` diff --git a/include/common/cos.h b/include/common/cos.h index c6b159c1da..afeca3ca03 100644 --- a/include/common/cos.h +++ b/include/common/cos.h @@ -34,7 +34,7 @@ extern int32_t tsS3UploadDelaySec; int32_t s3Init(); void s3CleanUp(); int32_t s3PutObjectFromFile(const char *file, const char *object); -int32_t s3PutObjectFromFile2(const char *file, const char *object); +int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp); void s3DeleteObjectsByPrefix(const char *prefix); void s3DeleteObjects(const char *object_name[], int nobject); bool s3Exists(const char *object_name); diff --git a/include/common/cos_cp.h b/include/common/cos_cp.h new file mode 100644 index 0000000000..fd778b1a1d --- /dev/null +++ b/include/common/cos_cp.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_COMMON_COS_CP_H_ +#define _TD_COMMON_COS_CP_H_ + +#include "os.h" +#include "tdef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + COS_CP_TYPE_UPLOAD, // upload + COS_CP_TYPE_DOWNLOAD // download +} ECpType; + +typedef struct { + int32_t index; // the index of part, start from 0 + int64_t offset; // the offset point of part + int64_t size; // the size of part + int completed; // COS_TRUE completed, COS_FALSE uncompleted + char etag[128]; // the etag of part, for upload + uint64_t crc64; +} SCheckpointPart; + +typedef struct { + ECpType cp_type; // 0 upload, 1 download + char md5[64]; // the md5 of checkout content + TdFilePtr thefile; // the handle of checkpoint file + + char file_path[TSDB_FILENAME_LEN]; // local file path + int64_t file_size; // local file size, for upload + int32_t file_last_modified; // local file last modified time, for upload + char file_md5[64]; // md5 of the local file content, for upload, reserved + + char object_name[128]; // object name + int64_t object_size; // object size, for download + char object_last_modified[64]; // object last modified time, for download + char object_etag[128]; // object etag, for download + + char upload_id[128]; // upload id + + int part_num; // the total number of parts + int64_t part_size; // the part size, byte + SCheckpointPart* parts; // the parts of local or object, from 0 +} SCheckpoint; + +int32_t cos_cp_open(char const* cp_path, SCheckpoint* checkpoint); +void cos_cp_close(TdFilePtr fd); +void cos_cp_remove(char const* filepath); + +int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint); +int32_t cos_cp_dump(SCheckpoint* checkpoint); +void cos_cp_get_undo_parts(SCheckpoint* checkpoint, int* part_num, SCheckpointPart* parts, int64_t* consume_bytes); +void cos_cp_update(SCheckpoint* checkpoint, int32_t part_index, char const* etag, uint64_t crc64); +void cos_cp_build_upload(SCheckpoint* checkpoint, char const* filepath, int64_t size, int32_t mtime, + char const* upload_id, int64_t part_size); +bool cos_cp_is_valid_upload(SCheckpoint* checkpoint, int64_t size, int32_t mtime); + +void cos_cp_build_download(SCheckpoint* checkpoint, char const* filepath, char const* object_name, int64_t object_size, + char const* object_lmtime, char const* object_etag, int64_t part_size); +bool cos_cp_is_valid_download(SCheckpoint* checkpoint, char const* object_name, int64_t object_size, + char const* object_lmtime, char const* object_etag); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_COMMON_COS_CP_H_*/ diff --git a/include/common/systable.h b/include/common/systable.h index b44d8ce1d6..92e7915424 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -50,6 +50,8 @@ extern "C" { #define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks" #define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges" #define TSDB_INS_TABLE_VIEWS "ins_views" +#define TSDB_INS_TABLE_COMPACTS "ins_compacts" +#define TSDB_INS_TABLE_COMPACT_DETAILS "ins_compact_details" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 87a6a90a7e..24e5d186b9 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -253,6 +253,7 @@ typedef struct SQueryTableDataCond { STimeWindow twindows; int64_t startVersion; int64_t endVersion; + bool notLoadData; // response the actual data, not only the rows in the attribute of info.row of ssdatablock } SQueryTableDataCond; int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock); diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 31b98a0121..85c4108299 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -107,8 +107,9 @@ extern int32_t tsMonitorMaxLogs; extern bool tsMonitorComp; // audit -extern bool tsEnableAudit; -extern bool tsEnableAuditCreateTable; +extern bool tsEnableAudit; +extern bool tsEnableAuditCreateTable; +extern int32_t tsAuditInterval; // telem extern bool tsEnableTelem; @@ -195,6 +196,7 @@ extern int64_t tsWalFsyncDataSizeLimit; // internal extern int32_t tsTransPullupInterval; +extern int32_t tsCompactPullupInterval; extern int32_t tsMqRebalanceInterval; extern int32_t tsStreamCheckpointInterval; extern float tsSinkDataRate; @@ -214,6 +216,7 @@ extern int32_t tsMaxStreamBackendCache; extern int32_t tsPQSortMemThreshold; extern int32_t tsResolveFQDNRetryTime; +extern bool tsExperimental; // #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e6ed0f250c..8c62739803 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -144,6 +144,8 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_STREAM_TASKS, TSDB_MGMT_TABLE_PRIVILEGES, TSDB_MGMT_TABLE_VIEWS, + TSDB_MGMT_TABLE_COMPACT, + TSDB_MGMT_TABLE_COMPACT_DETAIL, TSDB_MGMT_TABLE_MAX, } EShowType; @@ -307,6 +309,7 @@ typedef enum ENodeType { QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, QUERY_NODE_KILL_TRANSACTION_STMT, + QUERY_NODE_KILL_COMPACT_STMT, QUERY_NODE_DELETE_STMT, QUERY_NODE_INSERT_STMT, QUERY_NODE_QUERY, @@ -353,6 +356,8 @@ typedef enum ENodeType { QUERY_NODE_SHOW_VNODES_STMT, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT, QUERY_NODE_SHOW_VIEWS_STMT, + QUERY_NODE_SHOW_COMPACTS_STMT, + QUERY_NODE_SHOW_COMPACT_DETAILS_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, @@ -1385,6 +1390,24 @@ int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq); int32_t tDeserializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq); void tFreeSCompactDbReq(SCompactDbReq* pReq); +typedef struct { + int32_t compactId; + int8_t bAccepted; +} SCompactDbRsp; + +int32_t tSerializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp); +int32_t tDeserializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp); + +typedef struct { + int32_t compactId; + int32_t sqlLen; + char* sql; +} SKillCompactReq; + +int32_t tSerializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq); +int32_t tDeserializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq); +void tFreeSKillCompactReq(SKillCompactReq *pReq); + typedef struct { char name[TSDB_FUNC_NAME_LEN]; int8_t igExists; @@ -1663,6 +1686,26 @@ int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pR int32_t tDeserializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq); int32_t tFreeSCreateVnodeReq(SCreateVnodeReq* pReq); +typedef struct { + int32_t compactId; + int32_t vgId; + int32_t dnodeId; +} SQueryCompactProgressReq; + +int32_t tSerializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq); +int32_t tDeserializeSQueryCompactProgressReq(void* buf, int32_t bufLen, SQueryCompactProgressReq* pReq); + +typedef struct { + int32_t compactId; + int32_t vgId; + int32_t dnodeId; + int32_t numberFileset; + int32_t finished; +} SQueryCompactProgressRsp; + +int32_t tSerializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq); +int32_t tDeserializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq); + typedef struct { int32_t vgId; int32_t dnodeId; @@ -1690,11 +1733,21 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t compactStartTime; STimeWindow tw; + int32_t compactId; } SCompactVnodeReq; int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); +typedef struct { + int32_t compactId; + int32_t vgId; + int32_t dnodeId; +} SVKillCompactReq; + +int32_t tSerializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq); +int32_t tDeserializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq); + typedef struct { int32_t vgVersion; int32_t buffer; @@ -1890,8 +1943,9 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; char tb[TSDB_TABLE_NAME_LEN]; char user[TSDB_USER_LEN]; - char filterTb[TSDB_TABLE_NAME_LEN]; + char filterTb[TSDB_TABLE_NAME_LEN]; // for ins_columns int64_t showId; + int64_t compactId; // for compact } SRetrieveTableReq; typedef struct SSysTableSchema { diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 61b471912f..5ad66c64e7 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -26,10 +26,10 @@ #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) "null", #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) MSG, MSG "-rsp", - #define TD_CLOSE_MSG_TYPE(TYPE) + #define TD_CLOSE_MSG_SEG(TYPE) char *tMsgInfo[] = { @@ -37,20 +37,20 @@ #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) - #define TD_CLOSE_MSG_TYPE(TYPE) TYPE, + #define TD_CLOSE_MSG_SEG(TYPE) TYPE, int32_t tMsgRangeDict[] = { #elif defined(TD_MSG_NUMBER_) #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM, #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE##_NUM, TYPE##_RSP_NUM, - #define TD_CLOSE_MSG_TYPE(TYPE) + #define TD_CLOSE_MSG_SEG(TYPE) enum { @@ -58,10 +58,10 @@ #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) TYPE##_NUM, #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) - #define TD_CLOSE_MSG_TYPE(type) + #define TD_CLOSE_MSG_SEG(type) int32_t tMsgDict[] = { @@ -70,10 +70,10 @@ #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) TYPE##_SEG_CODE, #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) - #define TD_CLOSE_MSG_TYPE(TYPE) + #define TD_CLOSE_MSG_SEG(TYPE) enum { @@ -82,10 +82,10 @@ #undef TD_NEW_MSG_SEG #undef TD_DEF_MSG_TYPE - #undef TD_CLOSE_MSG_TYPE + #undef TD_CLOSE_MSG_SEG #define TD_NEW_MSG_SEG(TYPE) TYPE = ((TYPE##_SEG_CODE) << 8), #define TD_DEF_MSG_TYPE(TYPE, MSG, REQ, RSP) TYPE, TYPE##_RSP, - #define TD_CLOSE_MSG_TYPE(TYPE) TYPE, + #define TD_CLOSE_MSG_SEG(TYPE) TYPE, enum { // WARN: new msg should be appended to segment tail #endif @@ -109,7 +109,7 @@ TD_DEF_MSG_TYPE(TDMT_DND_ALTER_VNODE_TYPE, "dnode-alter-vnode-type", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP, "dnode-check-vnode-learner-catchup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_DND_MAX_MSG, "dnd-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_DND_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_DND_MSG) TD_NEW_MSG_SEG(TDMT_MND_MSG) // 1<<8 TD_DEF_MSG_TYPE(TDMT_MND_CONNECT, "connect", NULL, NULL) @@ -217,8 +217,10 @@ TD_DEF_MSG_TYPE(TDMT_MND_CREATE_VIEW, "create-view", SCMCreateViewReq, NULL) TD_DEF_MSG_TYPE(TDMT_MND_DROP_VIEW, "drop-view", SCMDropViewReq, NULL) TD_DEF_MSG_TYPE(TDMT_MND_VIEW_META, "view-meta", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_KILL_COMPACT, "kill-compact", SKillCompactReq, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_COMPACT_TIMER, "compact-tmr", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_MND_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG) TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8 TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp) @@ -256,7 +258,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_EXEC_RSMA, "vnode-exec-rsma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp) TD_DEF_MSG_TYPE(TDMT_VND_BATCH_DEL, "batch-delete", SBatchDeleteReq, NULL) -TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIRM, "alter-confirm", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL) @@ -267,8 +269,10 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_INDEX, "vnode-create-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_INDEX, "vnode-drop-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DISABLE_WRITE, "vnode-disable-write", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_QUERY_COMPACT_PROGRESS, "vnode-query-compact-progress", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_KILL_COMPACT, "kill-compact", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MAX_MSG, "vnd-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_VND_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_VND_MSG) TD_NEW_MSG_SEG(TDMT_SCH_MSG) // 3<<8 TD_DEF_MSG_TYPE(TDMT_SCH_QUERY, "query", NULL, NULL) @@ -283,7 +287,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SCH_TASK_NOTIFY, "task-notify", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SCH_MAX_MSG, "sch-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_SCH_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_SCH_MSG) TD_NEW_MSG_SEG(TDMT_STREAM_MSG) //4 << 8 @@ -301,11 +305,11 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_STOP, "stream-task-stop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_HTASK_DROP, "stream-htask-drop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_STREAM_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_STREAM_MSG) TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8 TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_MON_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_MON_MSG) TD_NEW_MSG_SEG(TDMT_SYNC_MSG) //6 << 8 TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL) @@ -337,7 +341,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_SYNC_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_SYNC_MSG) TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) //7 << 8 @@ -348,7 +352,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_VND_STREAM_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG) TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) //8 << 8 TD_DEF_MSG_TYPE(TDMT_VND_TMQ_SUBSCRIBE, "vnode-tmq-subscribe", SMqRebVgReq, SMqRebVgRsp) @@ -362,10 +366,10 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_WALINFO, "vnode-tmq-vg-walinfo", SMqPollReq, SMqDataBlkRsp) TD_DEF_MSG_TYPE(TDMT_VND_TMQ_VG_COMMITTEDINFO, "vnode-tmq-committedinfo", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL) - TD_CLOSE_MSG_TYPE(TDMT_END_TMQ_MSG) + TD_CLOSE_MSG_SEG(TDMT_END_TMQ_MSG) TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark - + TD_CLOSE_MSG_SEG(TDMT_END_MAX_MSG) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index cb080ab118..bdee3934fe 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -189,184 +189,180 @@ #define TK_ALIVE 170 #define TK_VIEWS 171 #define TK_VIEW 172 -#define TK_NORMAL 173 -#define TK_CHILD 174 -#define TK_LIKE 175 -#define TK_TBNAME 176 -#define TK_QTAGS 177 -#define TK_AS 178 -#define TK_SYSTEM 179 -#define TK_INDEX 180 -#define TK_FUNCTION 181 -#define TK_INTERVAL 182 -#define TK_COUNT 183 -#define TK_LAST_ROW 184 -#define TK_META 185 -#define TK_ONLY 186 -#define TK_TOPIC 187 -#define TK_CONSUMER 188 -#define TK_GROUP 189 -#define TK_DESC 190 -#define TK_DESCRIBE 191 -#define TK_RESET 192 -#define TK_QUERY 193 -#define TK_CACHE 194 -#define TK_EXPLAIN 195 -#define TK_ANALYZE 196 -#define TK_VERBOSE 197 -#define TK_NK_BOOL 198 -#define TK_RATIO 199 -#define TK_NK_FLOAT 200 -#define TK_OUTPUTTYPE 201 -#define TK_AGGREGATE 202 -#define TK_BUFSIZE 203 -#define TK_LANGUAGE 204 -#define TK_REPLACE 205 -#define TK_STREAM 206 -#define TK_INTO 207 -#define TK_PAUSE 208 -#define TK_RESUME 209 -#define TK_TRIGGER 210 -#define TK_AT_ONCE 211 -#define TK_WINDOW_CLOSE 212 -#define TK_IGNORE 213 -#define TK_EXPIRED 214 -#define TK_FILL_HISTORY 215 -#define TK_UPDATE 216 -#define TK_SUBTABLE 217 -#define TK_UNTREATED 218 -#define TK_KILL 219 -#define TK_CONNECTION 220 -#define TK_TRANSACTION 221 -#define TK_BALANCE 222 -#define TK_VGROUP 223 -#define TK_LEADER 224 -#define TK_MERGE 225 -#define TK_REDISTRIBUTE 226 -#define TK_SPLIT 227 -#define TK_DELETE 228 -#define TK_INSERT 229 -#define TK_NULL 230 -#define TK_NK_QUESTION 231 -#define TK_NK_ALIAS 232 -#define TK_NK_ARROW 233 -#define TK_ROWTS 234 -#define TK_QSTART 235 -#define TK_QEND 236 -#define TK_QDURATION 237 -#define TK_WSTART 238 -#define TK_WEND 239 -#define TK_WDURATION 240 -#define TK_IROWTS 241 -#define TK_ISFILLED 242 -#define TK_CAST 243 -#define TK_NOW 244 -#define TK_TODAY 245 -#define TK_TIMEZONE 246 -#define TK_CLIENT_VERSION 247 -#define TK_SERVER_VERSION 248 -#define TK_SERVER_STATUS 249 -#define TK_CURRENT_USER 250 -#define TK_CASE 251 -#define TK_WHEN 252 -#define TK_THEN 253 -#define TK_ELSE 254 -#define TK_BETWEEN 255 -#define TK_IS 256 -#define TK_NK_LT 257 -#define TK_NK_GT 258 -#define TK_NK_LE 259 -#define TK_NK_GE 260 -#define TK_NK_NE 261 -#define TK_MATCH 262 -#define TK_NMATCH 263 -#define TK_CONTAINS 264 -#define TK_IN 265 -#define TK_JOIN 266 -#define TK_INNER 267 -#define TK_SELECT 268 -#define TK_NK_HINT 269 -#define TK_DISTINCT 270 -#define TK_WHERE 271 -#define TK_PARTITION 272 -#define TK_BY 273 -#define TK_SESSION 274 -#define TK_STATE_WINDOW 275 -#define TK_EVENT_WINDOW 276 -#define TK_SLIDING 277 -#define TK_FILL 278 -#define TK_VALUE 279 -#define TK_VALUE_F 280 -#define TK_NONE 281 -#define TK_PREV 282 -#define TK_NULL_F 283 -#define TK_LINEAR 284 -#define TK_NEXT 285 -#define TK_HAVING 286 -#define TK_RANGE 287 -#define TK_EVERY 288 -#define TK_ORDER 289 -#define TK_SLIMIT 290 -#define TK_SOFFSET 291 -#define TK_LIMIT 292 -#define TK_OFFSET 293 -#define TK_ASC 294 -#define TK_NULLS 295 -#define TK_ABORT 296 -#define TK_AFTER 297 -#define TK_ATTACH 298 -#define TK_BEFORE 299 -#define TK_BEGIN 300 -#define TK_BITAND 301 -#define TK_BITNOT 302 -#define TK_BITOR 303 -#define TK_BLOCKS 304 -#define TK_CHANGE 305 -#define TK_COMMA 306 -#define TK_CONCAT 307 -#define TK_CONFLICT 308 -#define TK_COPY 309 -#define TK_DEFERRED 310 -#define TK_DELIMITERS 311 -#define TK_DETACH 312 -#define TK_DIVIDE 313 -#define TK_DOT 314 -#define TK_EACH 315 -#define TK_FAIL 316 -#define TK_FILE 317 -#define TK_FOR 318 -#define TK_GLOB 319 -#define TK_ID 320 -#define TK_IMMEDIATE 321 -#define TK_IMPORT 322 -#define TK_INITIALLY 323 -#define TK_INSTEAD 324 -#define TK_ISNULL 325 -#define TK_KEY 326 -#define TK_MODULES 327 -#define TK_NK_BITNOT 328 -#define TK_NK_SEMI 329 -#define TK_NOTNULL 330 -#define TK_OF 331 -#define TK_PLUS 332 -#define TK_PRIVILEGE 333 -#define TK_RAISE 334 -#define TK_RESTRICT 335 -#define TK_ROW 336 -#define TK_SEMI 337 -#define TK_STAR 338 -#define TK_STATEMENT 339 -#define TK_STRICT 340 -#define TK_STRING 341 -#define TK_TIMES 342 -#define TK_VALUES 343 -#define TK_VARIABLE 344 -#define TK_WAL 345 - - - - - +#define TK_COMPACTS 173 +#define TK_NORMAL 174 +#define TK_CHILD 175 +#define TK_LIKE 176 +#define TK_TBNAME 177 +#define TK_QTAGS 178 +#define TK_AS 179 +#define TK_SYSTEM 180 +#define TK_INDEX 181 +#define TK_FUNCTION 182 +#define TK_INTERVAL 183 +#define TK_COUNT 184 +#define TK_LAST_ROW 185 +#define TK_META 186 +#define TK_ONLY 187 +#define TK_TOPIC 188 +#define TK_CONSUMER 189 +#define TK_GROUP 190 +#define TK_DESC 191 +#define TK_DESCRIBE 192 +#define TK_RESET 193 +#define TK_QUERY 194 +#define TK_CACHE 195 +#define TK_EXPLAIN 196 +#define TK_ANALYZE 197 +#define TK_VERBOSE 198 +#define TK_NK_BOOL 199 +#define TK_RATIO 200 +#define TK_NK_FLOAT 201 +#define TK_OUTPUTTYPE 202 +#define TK_AGGREGATE 203 +#define TK_BUFSIZE 204 +#define TK_LANGUAGE 205 +#define TK_REPLACE 206 +#define TK_STREAM 207 +#define TK_INTO 208 +#define TK_PAUSE 209 +#define TK_RESUME 210 +#define TK_TRIGGER 211 +#define TK_AT_ONCE 212 +#define TK_WINDOW_CLOSE 213 +#define TK_IGNORE 214 +#define TK_EXPIRED 215 +#define TK_FILL_HISTORY 216 +#define TK_UPDATE 217 +#define TK_SUBTABLE 218 +#define TK_UNTREATED 219 +#define TK_KILL 220 +#define TK_CONNECTION 221 +#define TK_TRANSACTION 222 +#define TK_BALANCE 223 +#define TK_VGROUP 224 +#define TK_LEADER 225 +#define TK_MERGE 226 +#define TK_REDISTRIBUTE 227 +#define TK_SPLIT 228 +#define TK_DELETE 229 +#define TK_INSERT 230 +#define TK_NULL 231 +#define TK_NK_QUESTION 232 +#define TK_NK_ALIAS 233 +#define TK_NK_ARROW 234 +#define TK_ROWTS 235 +#define TK_QSTART 236 +#define TK_QEND 237 +#define TK_QDURATION 238 +#define TK_WSTART 239 +#define TK_WEND 240 +#define TK_WDURATION 241 +#define TK_IROWTS 242 +#define TK_ISFILLED 243 +#define TK_CAST 244 +#define TK_NOW 245 +#define TK_TODAY 246 +#define TK_TIMEZONE 247 +#define TK_CLIENT_VERSION 248 +#define TK_SERVER_VERSION 249 +#define TK_SERVER_STATUS 250 +#define TK_CURRENT_USER 251 +#define TK_CASE 252 +#define TK_WHEN 253 +#define TK_THEN 254 +#define TK_ELSE 255 +#define TK_BETWEEN 256 +#define TK_IS 257 +#define TK_NK_LT 258 +#define TK_NK_GT 259 +#define TK_NK_LE 260 +#define TK_NK_GE 261 +#define TK_NK_NE 262 +#define TK_MATCH 263 +#define TK_NMATCH 264 +#define TK_CONTAINS 265 +#define TK_IN 266 +#define TK_JOIN 267 +#define TK_INNER 268 +#define TK_SELECT 269 +#define TK_NK_HINT 270 +#define TK_DISTINCT 271 +#define TK_WHERE 272 +#define TK_PARTITION 273 +#define TK_BY 274 +#define TK_SESSION 275 +#define TK_STATE_WINDOW 276 +#define TK_EVENT_WINDOW 277 +#define TK_SLIDING 278 +#define TK_FILL 279 +#define TK_VALUE 280 +#define TK_VALUE_F 281 +#define TK_NONE 282 +#define TK_PREV 283 +#define TK_NULL_F 284 +#define TK_LINEAR 285 +#define TK_NEXT 286 +#define TK_HAVING 287 +#define TK_RANGE 288 +#define TK_EVERY 289 +#define TK_ORDER 290 +#define TK_SLIMIT 291 +#define TK_SOFFSET 292 +#define TK_LIMIT 293 +#define TK_OFFSET 294 +#define TK_ASC 295 +#define TK_NULLS 296 +#define TK_ABORT 297 +#define TK_AFTER 298 +#define TK_ATTACH 299 +#define TK_BEFORE 300 +#define TK_BEGIN 301 +#define TK_BITAND 302 +#define TK_BITNOT 303 +#define TK_BITOR 304 +#define TK_BLOCKS 305 +#define TK_CHANGE 306 +#define TK_COMMA 307 +#define TK_CONCAT 308 +#define TK_CONFLICT 309 +#define TK_COPY 310 +#define TK_DEFERRED 311 +#define TK_DELIMITERS 312 +#define TK_DETACH 313 +#define TK_DIVIDE 314 +#define TK_DOT 315 +#define TK_EACH 316 +#define TK_FAIL 317 +#define TK_FILE 318 +#define TK_FOR 319 +#define TK_GLOB 320 +#define TK_ID 321 +#define TK_IMMEDIATE 322 +#define TK_IMPORT 323 +#define TK_INITIALLY 324 +#define TK_INSTEAD 325 +#define TK_ISNULL 326 +#define TK_KEY 327 +#define TK_MODULES 328 +#define TK_NK_BITNOT 329 +#define TK_NK_SEMI 330 +#define TK_NOTNULL 331 +#define TK_OF 332 +#define TK_PLUS 333 +#define TK_PRIVILEGE 334 +#define TK_RAISE 335 +#define TK_RESTRICT 336 +#define TK_ROW 337 +#define TK_SEMI 338 +#define TK_STAR 339 +#define TK_STATEMENT 340 +#define TK_STRICT 341 +#define TK_STRING 342 +#define TK_TIMES 343 +#define TK_VALUES 344 +#define TK_VARIABLE 345 +#define TK_WAL 346 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/audit/audit.h b/include/libs/audit/audit.h index 85d462b96b..dd3df27866 100644 --- a/include/libs/audit/audit.h +++ b/include/libs/audit/audit.h @@ -23,13 +23,13 @@ #include "tjson.h" #include "tmsgcb.h" #include "trpc.h" -#include "mnode.h" #ifdef __cplusplus extern "C" { #endif #define AUDIT_DETAIL_MAX 65472 +#define AUDIT_OPERATION_LEN 20 typedef struct { const char *server; @@ -37,13 +37,28 @@ typedef struct { bool comp; } SAuditCfg; +typedef struct { + int64_t curTime; + char strClusterId[TSDB_CLUSTER_ID_LEN]; + char clientAddress[50]; + char user[TSDB_USER_LEN]; + char operation[AUDIT_OPERATION_LEN]; + char target1[TSDB_DB_NAME_LEN]; //put db name + char target2[TSDB_STREAM_NAME_LEN]; //put stb name, table name, topic name, user name, stream name, use max + char* detail; +} SAuditRecord; + int32_t auditInit(const SAuditCfg *pCfg); +void auditCleanup(); void auditSend(SJson *pJson); void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail, int32_t len); +void auditAddRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, + char *detail, int32_t len); +void auditSendRecordsInBatch(); #ifdef __cplusplus } #endif -#endif /*_TD_MONITOR_H_*/ +#endif /*_TD_AUDIT_H_*/ diff --git a/include/libs/executor/storageapi.h b/include/libs/executor/storageapi.h index 32b60b55ae..1dbc8f2f76 100644 --- a/include/libs/executor/storageapi.h +++ b/include/libs/executor/storageapi.h @@ -38,8 +38,8 @@ extern "C" { #define META_READER_NOLOCK 0x1 -#define STREAM_STATE_BUFF_HASH 1 -#define STREAM_STATE_BUFF_SORT 2 +#define STREAM_STATE_BUFF_HASH 1 +#define STREAM_STATE_BUFF_SORT 2 typedef struct SMeta SMeta; typedef TSKEY (*GetTsFun)(void*); @@ -102,14 +102,14 @@ typedef struct SMTbCursor { } SMTbCursor; typedef struct SMCtbCursor { - SMeta *pMeta; - void *pCur; + SMeta* pMeta; + void* pCur; tb_uid_t suid; - void *pKey; - void *pVal; + void* pKey; + void* pVal; int kLen; int vLen; - int8_t paused; + int8_t paused; int lock; } SMCtbCursor; @@ -153,7 +153,8 @@ typedef struct { // clang-format off /*-------------------------------------------------new api format---------------------------------------------------*/ typedef enum { - TSD_READER_NOTIFY_DURATION_START + TSD_READER_NOTIFY_DURATION_START, + TSD_READER_NOTIFY_NEXT_DURATION_BLOCK, } ETsdReaderNotifyType; typedef union { @@ -166,8 +167,7 @@ typedef void (*TsdReaderNotifyCbFn)(ETsdReaderNotifyType type, STsdReaderNotifyI typedef struct TsdReader { int32_t (*tsdReaderOpen)(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables, - SSDataBlock* pResBlock, void** ppReader, const char* idstr, bool countOnly, - SHashObj** pIgnoreTables); + SSDataBlock* pResBlock, void** ppReader, const char* idstr, SHashObj** pIgnoreTables); void (*tsdReaderClose)(); void (*tsdSetReaderTaskId)(void *pReader, const char *pId); int32_t (*tsdSetQueryTableList)(); @@ -263,22 +263,23 @@ typedef struct SStoreMeta { void* (*storeGetIndexInfo)(); void* (*getInvertIndex)(void* pVnode); // support filter and non-filter cases. [vnodeGetCtbIdList & vnodeGetCtbIdListByFilter] - int32_t (*getChildTableList)( void* pVnode, int64_t suid, SArray* list); + int32_t (*getChildTableList)(void* pVnode, int64_t suid, SArray* list); int32_t (*storeGetTableList)(void* pVnode, int8_t type, SArray* pList); void* storeGetVersionRange; void* storeGetLastTimestamp; int32_t (*getTableSchema)(void* pVnode, int64_t uid, STSchema** pSchema, int64_t* suid); // tsdbGetTableSchema - int32_t (*getNumOfChildTables)( void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols); - void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables, int64_t* numOfNormalTables); + int32_t (*getNumOfChildTables)(void* pVnode, int64_t uid, int64_t* numOfTables, int32_t* numOfCols); + void (*getBasicInfo)(void* pVnode, const char** dbname, int32_t* vgId, int64_t* numOfTables, + int64_t* numOfNormalTables); int64_t (*getNumOfRowsInMem)(void* pVnode); - SMCtbCursor* (*openCtbCursor)(void *pVnode, tb_uid_t uid, int lock); - int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first); - void (*pauseCtbCursor)(SMCtbCursor* pCtbCur); - void (*closeCtbCursor)(SMCtbCursor *pCtbCur); - tb_uid_t (*ctbCursorNext)(SMCtbCursor* pCur); + SMCtbCursor* (*openCtbCursor)(void* pVnode, tb_uid_t uid, int lock); + int32_t (*resumeCtbCursor)(SMCtbCursor* pCtbCur, int8_t first); + void (*pauseCtbCursor)(SMCtbCursor* pCtbCur); + void (*closeCtbCursor)(SMCtbCursor* pCtbCur); + tb_uid_t (*ctbCursorNext)(SMCtbCursor* pCur); } SStoreMeta; typedef struct SStoreMetaReader { @@ -363,14 +364,14 @@ typedef struct SStateStore { const SSessionKey* pKey, void** pVal, int32_t* pVLen); SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp); - TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol); - bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); - bool (*updateInfoIsTableInserted)(SUpdateInfo* pInfo, int64_t tbUid); - bool (*isIncrementalTimeStamp)(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts); + TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol); + bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); + bool (*updateInfoIsTableInserted)(SUpdateInfo* pInfo, int64_t tbUid); + bool (*isIncrementalTimeStamp)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); void (*updateInfoDestroy)(SUpdateInfo* pInfo); - void (*windowSBfDelete)(SUpdateInfo *pInfo, uint64_t count); - void (*windowSBfAdd)(SUpdateInfo *pInfo, uint64_t count); + void (*windowSBfDelete)(SUpdateInfo* pInfo, uint64_t count); + void (*windowSBfAdd)(SUpdateInfo* pInfo, uint64_t count); SUpdateInfo* (*updateInfoInitP)(SInterval* pInterval, int64_t watermark, bool igUp); void (*updateInfoAddCloseWindowSBF)(SUpdateInfo* pInfo); @@ -397,6 +398,7 @@ typedef struct SStateStore { void (*streamStateDestroy)(SStreamState* pState, bool remove); int32_t (*streamStateDeleteCheckPoint)(SStreamState* pState, TSKEY mark); void (*streamStateReloadInfo)(SStreamState* pState, TSKEY ts); + void (*streamStateCopyBackend)(SStreamState* src, SStreamState* dst); } SStateStore; typedef struct SStorageAPI { diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 49435a6317..003e9b900a 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -171,6 +171,7 @@ typedef struct { int32_t taskId; int64_t streamId; int64_t streamBackendRid; + int8_t dump; } SStreamState; typedef struct SFunctionStateStore { diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index ac4f5bea0e..6aa1796963 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -46,6 +46,10 @@ extern "C" { #define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) #define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE) +#define COMPACT_DB_RESULT_COLS 3 +#define COMPACT_DB_RESULT_FIELD1_LEN 32 +#define COMPACT_DB_RESULT_FIELD3_LEN 128 + #define SHOW_ALIVE_RESULT_COLS 1 #define BIT_FLAG_MASK(n) (1 << n) @@ -335,6 +339,15 @@ typedef struct SShowTableTagsStmt { SNodeList* pTags; } SShowTableTagsStmt; +typedef struct SShowCompactsStmt { + ENodeType type; +} SShowCompactsStmt; + +typedef struct SShowCompactDetailsStmt { + ENodeType type; + SNode* pCompactId; +} SShowCompactDetailsStmt; + typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT, INDEX_TYPE_NORMAL } EIndexType; typedef struct SIndexOptions { diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index ba90c0dc7a..24222677a4 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -50,7 +50,7 @@ void streamStateSetNumber(SStreamState* pState, int32_t number); int32_t streamStateSaveInfo(SStreamState* pState, void* pKey, int32_t keyLen, void* pVal, int32_t vLen); int32_t streamStateGetInfo(SStreamState* pState, void* pKey, int32_t keyLen, void** pVal, int32_t* pLen); -//session window +// session window int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, TSKEY gap, void** pVal, int32_t* pVLen); int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, void* value, int32_t vLen); int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen); @@ -65,7 +65,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key); SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, const SSessionKey* key); -//state window +// state window int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen, state_key_cmpr_fn fn, void** pVal, int32_t* pVLen); @@ -96,6 +96,9 @@ int32_t streamStatePutParName(SStreamState* pState, int64_t groupId, const char* int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal); void streamStateReloadInfo(SStreamState* pState, TSKEY ts); + +void streamStateCopyBackend(SStreamState* src, SStreamState* dst); + SStreamStateCur* createStreamStateCursor(); /***compare func **/ diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 8f3e100db6..f6737b4e27 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -509,11 +509,8 @@ typedef struct SStreamMeta { SArray* chkpSaved; SArray* chkpInUse; SRWLatch chkpDirLock; - - void* qHandle; - int32_t pauseTaskNum; - - void* bkdChkptMgt; + void* qHandle; + void* bkdChkptMgt; } SStreamMeta; int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo); @@ -840,11 +837,10 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int3 int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta); SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask); -int32_t streamMetaReopen(SStreamMeta* pMeta); +void streamMetaClear(SStreamMeta* pMeta); void streamMetaInitBackend(SStreamMeta* pMeta); int32_t streamMetaCommit(SStreamMeta* pMeta); int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta); -int32_t streamMetaReloadAllTasks(SStreamMeta* pMeta); int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta); void streamMetaNotifyClose(SStreamMeta* pMeta); int32_t streamTaskSetDb(SStreamMeta* pMeta, void* pTask, char* key); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index a428a9ae6a..e54237fe8b 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -33,11 +33,12 @@ extern "C" { #define SYNC_MAX_PROGRESS_WAIT_MS 4000 #define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20) #define SYNC_MAX_RECV_TIME_RANGE_MS 1200 -#define SYNC_DEL_WAL_MS (1000 * 60) #define SYNC_ADD_QUORUM_COUNT 3 #define SYNC_VNODE_LOG_RETENTION (TSDB_SYNC_LOG_BUFFER_RETENTION + 1) #define SNAPSHOT_WAIT_MS 1000 * 5 +#define SYNC_WAL_LOG_RETENTION_SIZE (8LL * 1024 * 1024 * 1024) + #define SYNC_MAX_RETRY_BACKOFF 5 #define SYNC_LOG_REPL_RETRY_WAIT_MS 100 #define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000 @@ -219,6 +220,7 @@ typedef struct SSyncLogStore { SyncIndex (*syncLogWriteIndex)(struct SSyncLogStore* pLogStore); SyncIndex (*syncLogLastIndex)(struct SSyncLogStore* pLogStore); + SyncIndex (*syncLogIndexRetention)(struct SSyncLogStore* pLogStore, int64_t bytes); SyncTerm (*syncLogLastTerm)(struct SSyncLogStore* pLogStore); int32_t (*syncLogAppendEntry)(struct SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, bool forcSync); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index a56a5567eb..7c00ff5178 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -225,6 +225,7 @@ bool walIsEmpty(SWal *); int64_t walGetFirstVer(SWal *); int64_t walGetSnapshotVer(SWal *); int64_t walGetLastVer(SWal *); +int64_t walGetVerRetention(SWal *pWal, int64_t bytes); int64_t walGetCommittedVer(SWal *); int64_t walGetAppliedVer(SWal *); diff --git a/include/os/osString.h b/include/os/osString.h index 4982ac8bfd..8e8f1546e7 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -47,18 +47,13 @@ typedef int32_t TdUcs4; #define strtof STR_TO_F_FUNC_TAOS_FORBID #endif -#ifdef WINDOWS -#define tstrdup(str) _strdup(str) -#else -#define tstrdup(str) strdup(str) -#endif - #define tstrncpy(dst, src, size) \ do { \ strncpy((dst), (src), (size)); \ (dst)[(size)-1] = 0; \ } while (0) +char *tstrdup(const char *src); int32_t taosUcs4len(TdUcs4 *ucs4); int64_t taosStr2int64(const char *str); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 6ab06d06a3..06e6b8d041 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -427,6 +427,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_VIEW_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x04A0) #define TSDB_CODE_MND_VIEW_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x04A1) +//mnode-compact +#define TSDB_CODE_MND_INVALID_COMPACT_ID TAOS_DEF_ERROR_CODE(0, 0x04B1) + // vnode // #define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) // 2.x diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 75003d76d8..b4ee619332 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -205,7 +205,7 @@ typedef struct SRequestSendRecvBody { __taos_async_fn_t queryFp; __taos_async_fn_t fetchFp; EQueryExecMode execMode; - void* param; + void* interParam; SDataBuf requestMsg; int64_t queryJob; // query job, created according to sql query DAG. int32_t subplanNum; @@ -287,6 +287,7 @@ typedef struct SRequestObj { typedef struct SSyncQueryParam { tsem_t sem; SRequestObj* pRequest; + void* userParam; } SSyncQueryParam; void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); @@ -420,6 +421,7 @@ int32_t buildPreviousRequest(SRequestObj *pRequest, const char* sql, SRequestObj int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *pRequest, bool updateMetaForce); void returnToUser(SRequestObj* pRequest); void stopAllQueries(SRequestObj *pRequest); +void doRequestCallback(SRequestObj* pRequest, int32_t code); void freeQueryParam(SSyncQueryParam* param); #ifdef TD_ENTERPRISE diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 85624c31c5..77cda347a4 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -316,6 +316,15 @@ void *createRequest(uint64_t connId, int32_t type, int64_t reqid) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } + SSyncQueryParam *interParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + if (interParam == NULL) { + doDestroyRequest(pRequest); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + tsem_init(&interParam->sem, 0, 0); + interParam->pRequest = pRequest; + pRequest->body.interParam = interParam; pRequest->resType = RES_TYPE__QUERY; pRequest->requestId = reqid == 0 ? generateRequestId() : reqid; @@ -437,12 +446,10 @@ void doDestroyRequest(void *p) { deregisterRequest(pRequest); } - if (pRequest->syncQuery) { - if (pRequest->body.param) { - tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); - } - taosMemoryFree(pRequest->body.param); + if (pRequest->body.interParam) { + tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem); } + taosMemoryFree(pRequest->body.interParam); qDestroyQuery(pRequest->pQuery); nodesDestroyAllocator(pRequest->allocatorRefId); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 4462bd9c9d..f615111b7f 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -196,21 +196,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, (*pRequest)->sqlLen = sqlLen; (*pRequest)->validateOnly = validateSql; - SSyncQueryParam* newpParam = NULL; - if (param == NULL) { - newpParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); - if (newpParam == NULL) { - destroyRequest(*pRequest); - *pRequest = NULL; - return TSDB_CODE_OUT_OF_MEMORY; - } - - tsem_init(&newpParam->sem, 0, 0); - newpParam->pRequest = (*pRequest); - param = newpParam; - } - - (*pRequest)->body.param = param; + ((SSyncQueryParam*)(*pRequest)->body.interParam)->userParam = param; STscObj* pTscObj = (*pRequest)->pTscObj; int32_t err = taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, @@ -218,7 +204,6 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, if (err) { tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); - freeQueryParam(newpParam); destroyRequest(*pRequest); *pRequest = NULL; return TSDB_CODE_OUT_OF_MEMORY; @@ -230,7 +215,6 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) { tscError("%" PRId64 " failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); - freeQueryParam(newpParam); destroyRequest(*pRequest); *pRequest = NULL; return TSDB_CODE_OUT_OF_MEMORY; @@ -336,7 +320,7 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) { return pRequest->pTscOb void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; if (pRequest->validateOnly) { - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + doRequestCallback(pRequest, 0); return; } @@ -358,18 +342,18 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { pRequest->requestId); } - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { if (pRequest->validateOnly) { - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + doRequestCallback(pRequest, 0); return TSDB_CODE_SUCCESS; } // drop table if exists not_exists_table if (NULL == pQuery->pCmdMsg) { - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + doRequestCallback(pRequest, 0); return TSDB_CODE_SUCCESS; } @@ -384,7 +368,7 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { int64_t transporterId = 0; int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg); if (code) { - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } return code; } @@ -913,7 +897,7 @@ void continuePostSubQuery(SRequestObj* pRequest, TAOS_ROW row) { void returnToUser(SRequestObj* pRequest) { if (pRequest->relation.userRefId == pRequest->self || 0 == pRequest->relation.userRefId) { // return to client - pRequest->body.queryFp(pRequest->body.param, pRequest, pRequest->code); + doRequestCallback(pRequest, pRequest->code); return; } @@ -921,7 +905,7 @@ void returnToUser(SRequestObj* pRequest) { if (pUserReq) { pUserReq->code = pRequest->code; // return to client - pUserReq->body.queryFp(pUserReq->body.param, pUserReq, pUserReq->code); + doRequestCallback(pUserReq, pUserReq->code); releaseRequest(pRequest->relation.userRefId); return; } else { @@ -1031,7 +1015,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { pRequest->pWrapper = NULL; // return to client - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } } @@ -1186,7 +1170,7 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat pRequest->code = terrno; } - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } // todo not to be released here @@ -1199,7 +1183,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM int32_t code = 0; if (pRequest->parseOnly) { - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + doRequestCallback(pRequest, 0); return; } @@ -1233,11 +1217,11 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM } case QUERY_EXEC_MODE_EMPTY_RESULT: pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + doRequestCallback(pRequest, 0); break; default: tscError("0x%" PRIx64 " invalid execMode %d", pRequest->self, pQuery->execMode); - pRequest->body.queryFp(pRequest->body.param, pRequest, -1); + doRequestCallback(pRequest, -1); break; } } @@ -1703,8 +1687,8 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) } static void syncFetchFn(void* param, TAOS_RES* res, int32_t numOfRows) { - SSyncQueryParam* pParam = param; - tsem_post(&pParam->sem); + tsem_t* sem = param; + tsem_post(sem); } void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) { @@ -1722,10 +1706,11 @@ void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertU // convert ucs4 to native multi-bytes string pResultInfo->convertUcs4 = convertUcs4; - - SSyncQueryParam* pParam = pRequest->body.param; - taos_fetch_rows_a(pRequest, syncFetchFn, pParam); - tsem_wait(&pParam->sem); + tsem_t sem; + tsem_init(&sem, 0, 0); + taos_fetch_rows_a(pRequest, syncFetchFn, &sem); + tsem_wait(&sem); + tsem_destroy(&sem); } if (pResultInfo->numOfRows == 0 || pRequest->code != TSDB_CODE_SUCCESS) { @@ -2492,6 +2477,10 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { tscDebug("taos_query start with sql:%s", sql); SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + if (NULL == param) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } tsem_init(¶m->sem, 0, 0); taosAsyncQueryImpl(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly); @@ -2501,9 +2490,8 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { if (param->pRequest != NULL) { param->pRequest->syncQuery = true; pRequest = param->pRequest; - } else { - taosMemoryFree(param); } + taosMemoryFree(param); tscDebug("taos_query end with sql:%s", sql); @@ -2517,19 +2505,20 @@ TAOS_RES* taosQueryImplWithReqid(TAOS* taos, const char* sql, bool validateOnly, } SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); + if (param == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } tsem_init(¶m->sem, 0, 0); taosAsyncQueryImplWithReqid(*(int64_t*)taos, sql, syncQueryFn, param, validateOnly, reqid); tsem_wait(¶m->sem); - SRequestObj* pRequest = NULL; if (param->pRequest != NULL) { param->pRequest->syncQuery = true; pRequest = param->pRequest; - } else { - taosMemoryFree(param); } - + taosMemoryFree(param); return pRequest; } @@ -2547,13 +2536,13 @@ static void fetchCallback(void* pResult, void* param, int32_t code) { if (code != TSDB_CODE_SUCCESS) { pRequest->code = code; taosMemoryFreeClear(pResultInfo->pData); - pRequest->body.fetchFp(pRequest->body.param, pRequest, 0); + pRequest->body.fetchFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, 0); return; } if (pRequest->code != TSDB_CODE_SUCCESS) { taosMemoryFreeClear(pResultInfo->pData); - pRequest->body.fetchFp(pRequest->body.param, pRequest, 0); + pRequest->body.fetchFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, 0); return; } @@ -2574,20 +2563,12 @@ static void fetchCallback(void* pResult, void* param, int32_t code) { atomic_add_fetch_64((int64_t*)&pActivity->fetchBytes, pRequest->body.resInfo.payloadLen); } - pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows); + pRequest->body.fetchFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, pResultInfo->numOfRows); } void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param) { - if (pRequest->syncQuery && pRequest->body.param != param) { - if (pRequest->body.param) { - tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem); - } - taosMemoryFree(pRequest->body.param); - pRequest->syncQuery = false; - } - pRequest->body.fetchFp = fp; - pRequest->body.param = param; + ((SSyncQueryParam *)pRequest->body.interParam)->userParam = param; SReqResultInfo* pResultInfo = &pRequest->body.resInfo; @@ -2625,6 +2606,10 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param schedulerFetchRows(pRequest->body.queryJob, &req); } +void doRequestCallback(SRequestObj* pRequest, int32_t code) { + pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code); +} + int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes) { #ifndef TD_ENTERPRISE return TSDB_CODE_SUCCESS; @@ -2633,4 +2618,3 @@ int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool pa #endif } - diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 3a91ae82d5..1ce7c02dcf 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1095,7 +1095,7 @@ static void doAsyncQueryFromParse(SMetaData *pResultMeta, void *param, int32_t c pRequest->pWrapper = NULL; terrno = code; pRequest->code = code; - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } } @@ -1112,7 +1112,7 @@ void continueInsertFromCsv(SSqlCallbackWrapper *pWrapper, SRequestObj *pRequest) pRequest->pWrapper = NULL; terrno = code; pRequest->code = code; - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } } @@ -1210,7 +1210,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { terrno = code; pRequest->code = code; tscDebug("call sync query cb with code: %s", tstrerror(code)); - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); return; } @@ -1242,7 +1242,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) { terrno = code; pRequest->code = code; - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } } @@ -1545,12 +1545,12 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); - code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, pRequest->body.param, NULL); + code = catalogAsyncGetAllMeta(pCtg, &conn, &catalogReq, syncCatalogFn, pRequest->body.interParam, NULL); if (code) { goto _return; } - SSyncQueryParam *pParam = pRequest->body.param; + SSyncQueryParam *pParam = pRequest->body.interParam; tsem_wait(&pParam->sem); _return: diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 693efbc364..e0cedb9924 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -16,6 +16,7 @@ #include "catalog.h" #include "clientInt.h" #include "clientLog.h" +#include "cmdnodes.h" #include "os.h" #include "query.h" #include "systable.h" @@ -41,7 +42,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); if (pRequest->body.queryFp != NULL) { - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } @@ -199,7 +200,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) { } if (pRequest->body.queryFp) { - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } @@ -235,7 +236,8 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); if (pRequest->body.queryFp != NULL) { - pRequest->body.queryFp(pRequest->body.param, pRequest, pRequest->code); + doRequestCallback(pRequest, pRequest->code); + } else { tsem_post(&pRequest->body.rspSem); } @@ -299,7 +301,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { - pRequest->body.queryFp(pRequest->body.param, pRequest, pRequest->code); + doRequestCallback(pRequest, pRequest->code); } else { tsem_post(&pRequest->body.rspSem); } @@ -343,7 +345,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { } } - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } @@ -380,7 +382,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } @@ -420,7 +422,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) { } } - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } @@ -534,13 +536,125 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { - pRequest->body.queryFp(pRequest->body.param, pRequest, code); + doRequestCallback(pRequest, code); } else { tsem_post(&pRequest->body.rspSem); } return code; } +static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + pBlock->info.hasVarCol = true; + + pBlock->pDataBlock = taosArrayInit(COMPACT_DB_RESULT_COLS, sizeof(SColumnInfoData)); + + SColumnInfoData infoData = {0}; + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = COMPACT_DB_RESULT_FIELD1_LEN; + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_INT; + infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = COMPACT_DB_RESULT_FIELD3_LEN; + taosArrayPush(pBlock->pDataBlock, &infoData); + + blockDataEnsureCapacity(pBlock, 1); + + SColumnInfoData* pResultCol = taosArrayGet(pBlock->pDataBlock, 0); + SColumnInfoData* pIdCol = taosArrayGet(pBlock->pDataBlock, 1); + SColumnInfoData* pReasonCol = taosArrayGet(pBlock->pDataBlock, 2); + char result[COMPACT_DB_RESULT_FIELD1_LEN] = {0}; + char reason[COMPACT_DB_RESULT_FIELD3_LEN] = {0}; + if (pRsp->bAccepted) { + STR_TO_VARSTR(result, "accepted"); + colDataSetVal(pResultCol, 0, result, false); + colDataSetVal(pIdCol, 0, (void*)&pRsp->compactId, false); + STR_TO_VARSTR(reason, "success"); + colDataSetVal(pReasonCol, 0, reason, false); + } else { + STR_TO_VARSTR(result, "rejected"); + colDataSetVal(pResultCol, 0, result, false); + colDataSetNULL(pIdCol, 0); + STR_TO_VARSTR(reason, "compaction is ongoing"); + colDataSetVal(pReasonCol, 0, reason, false); + } + pBlock->info.rows = 1; + + *block = pBlock; + + return TSDB_CODE_SUCCESS; +} + +static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = NULL; + int32_t code = buildCompactDbBlock(pCompactDb, &pBlock); + if (code) { + return code; + } + + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + *pRsp = taosMemoryCalloc(1, rspSize); + if (NULL == *pRsp) { + blockDataDestroy(pBlock); + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows); + (*pRsp)->numOfCols = htonl(COMPACT_DB_RESULT_COLS); + + int32_t len = blockEncode(pBlock, (*pRsp)->data, COMPACT_DB_RESULT_COLS); + blockDataDestroy(pBlock); + + if (len != rspSize - sizeof(SRetrieveTableRsp)) { + uError("buildRetriveTableRspForCompactDb error, len:%d != rspSize - sizeof(SRetrieveTableRsp):%" PRIu64, len, + (uint64_t)(rspSize - sizeof(SRetrieveTableRsp))); + return TSDB_CODE_TSC_INVALID_INPUT; + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) { + SRequestObj* pRequest = param; + if (code != TSDB_CODE_SUCCESS) { + setErrno(pRequest, code); + } else { + SCompactDbRsp rsp = {0}; + SRetrieveTableRsp* pRes = NULL; + code = tDeserializeSCompactDbRsp(pMsg->pData, pMsg->len, &rsp); + if (TSDB_CODE_SUCCESS == code) { + code = buildRetriveTableRspForCompactDb(&rsp, &pRes); + } + if (TSDB_CODE_SUCCESS == code) { + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true); + } + + if (code != 0) { + taosMemoryFree(pRes); + } + } + + taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); + + if (pRequest->body.queryFp != NULL) { + pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code); + } else { + tsem_post(&pRequest->body.rspSem); + } + return code; +} + __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) { switch (msgType) { case TDMT_MND_CONNECT: @@ -557,6 +671,8 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) { return processAlterStbRsp; case TDMT_MND_SHOW_VARIABLES: return processShowVariablesRsp; + case TDMT_MND_COMPACT_DB: + return processCompactDbRsp; default: return genericRspCallback; } diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 7c8676e9f5..fcc777ac99 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -1,6 +1,8 @@ #define ALLOW_FORBID_FUNC #include "cos.h" +#include "cos_cp.h" +#include "tdef.h" extern char tsS3Endpoint[]; extern char tsS3AccessKeyId[]; @@ -86,7 +88,7 @@ typedef struct { char err_msg[128]; S3Status status; uint64_t content_length; - char * buf; + char *buf; int64_t buf_pos; } TS3SizeCBD; @@ -270,7 +272,7 @@ typedef struct list_parts_callback_data { typedef struct MultipartPartData { put_object_callback_data put_object_data; int seq; - UploadManager * manager; + UploadManager *manager; } MultipartPartData; static int putObjectDataCallback(int bufferSize, char *buffer, void *callbackData) { @@ -317,12 +319,23 @@ S3Status MultipartResponseProperiesCallback(const S3ResponseProperties *properti MultipartPartData *data = (MultipartPartData *)callbackData; int seq = data->seq; - const char * etag = properties->eTag; + const char *etag = properties->eTag; data->manager->etags[seq - 1] = strdup(etag); data->manager->next_etags_pos = seq; return S3StatusOK; } +S3Status MultipartResponseProperiesCallbackWithCp(const S3ResponseProperties *properties, void *callbackData) { + responsePropertiesCallbackNull(properties, callbackData); + + MultipartPartData *data = (MultipartPartData *)callbackData; + int seq = data->seq; + const char *etag = properties->eTag; + data->manager->etags[seq - 1] = strdup(etag); + // data->manager->next_etags_pos = seq; + return S3StatusOK; +} + static int multipartPutXmlCallback(int bufferSize, char *buffer, void *callbackData) { UploadManager *manager = (UploadManager *)callbackData; int ret = 0; @@ -446,37 +459,343 @@ static int try_get_parts_info(const char *bucketName, const char *key, UploadMan return 0; } */ -int32_t s3PutObjectFromFile2(const char *file, const char *object) { - int32_t code = 0; - const char *key = object; - // const char *uploadId = 0; - const char * filename = 0; + +static int32_t s3PutObjectFromFileSimple(S3BucketContext *bucket_context, char const *object_name, int64_t size, + S3PutProperties *put_prop, put_object_callback_data *data) { + int32_t code = 0; + S3PutObjectHandler putObjectHandler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, + &putObjectDataCallback}; + + do { + S3_put_object(bucket_context, object_name, size, put_prop, 0, 0, &putObjectHandler, data); + } while (S3_status_is_retryable(data->status) && should_retry()); + + if (data->status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, data->status, data->err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + } else if (data->contentLength) { + uError("%s Failed to read remaining %llu bytes from input", __func__, (unsigned long long)data->contentLength); + code = TAOS_SYSTEM_ERROR(EIO); + } + + return code; +} + +static int32_t s3PutObjectFromFileWithoutCp(S3BucketContext *bucket_context, char const *object_name, + int64_t contentLength, S3PutProperties *put_prop, + put_object_callback_data *data) { + int32_t code = 0; + uint64_t totalContentLength = contentLength; + uint64_t todoContentLength = contentLength; + UploadManager manager = {0}; + + uint64_t chunk_size = MULTIPART_CHUNK_SIZE >> 3; + int totalSeq = (contentLength + chunk_size - 1) / chunk_size; + const int max_part_num = 10000; + if (totalSeq > max_part_num) { + chunk_size = (contentLength + max_part_num - contentLength % max_part_num) / max_part_num; + totalSeq = (contentLength + chunk_size - 1) / chunk_size; + } + + MultipartPartData partData; + memset(&partData, 0, sizeof(MultipartPartData)); + int partContentLength = 0; + + S3MultipartInitialHandler handler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, + &initial_multipart_callback}; + + S3PutObjectHandler putObjectHandler = {{&MultipartResponseProperiesCallback, &responseCompleteCallback}, + &putObjectDataCallback}; + + S3MultipartCommitHandler commit_handler = { + {&responsePropertiesCallbackNull, &responseCompleteCallback}, &multipartPutXmlCallback, 0}; + + manager.etags = (char **)taosMemoryCalloc(totalSeq, sizeof(char *)); + manager.next_etags_pos = 0; + do { + S3_initiate_multipart(bucket_context, object_name, 0, &handler, 0, timeoutMsG, &manager); + } while (S3_status_is_retryable(manager.status) && should_retry()); + + if (manager.upload_id == 0 || manager.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + +upload: + todoContentLength -= chunk_size * manager.next_etags_pos; + for (int seq = manager.next_etags_pos + 1; seq <= totalSeq; seq++) { + partData.manager = &manager; + partData.seq = seq; + if (partData.put_object_data.gb == NULL) { + partData.put_object_data = *data; + } + partContentLength = ((contentLength > chunk_size) ? chunk_size : contentLength); + // printf("%s Part Seq %d, length=%d\n", srcSize ? "Copying" : "Sending", seq, partContentLength); + partData.put_object_data.contentLength = partContentLength; + partData.put_object_data.originalContentLength = partContentLength; + partData.put_object_data.totalContentLength = todoContentLength; + partData.put_object_data.totalOriginalContentLength = totalContentLength; + put_prop->md5 = 0; + do { + S3_upload_part(bucket_context, object_name, put_prop, &putObjectHandler, seq, manager.upload_id, + partContentLength, 0, timeoutMsG, &partData); + } while (S3_status_is_retryable(partData.put_object_data.status) && should_retry()); + if (partData.put_object_data.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, partData.put_object_data.status, partData.put_object_data.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + contentLength -= chunk_size; + todoContentLength -= chunk_size; + } + + int i; + int size = 0; + size += growbuffer_append(&(manager.gb), "", strlen("")); + char buf[256]; + int n; + for (i = 0; i < totalSeq; i++) { + if (!manager.etags[i]) { + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + n = snprintf(buf, sizeof(buf), + "%d" + "%s", + i + 1, manager.etags[i]); + size += growbuffer_append(&(manager.gb), buf, n); + } + size += growbuffer_append(&(manager.gb), "", strlen("")); + manager.remaining = size; + + do { + S3_complete_multipart_upload(bucket_context, object_name, &commit_handler, manager.upload_id, manager.remaining, 0, + timeoutMsG, &manager); + } while (S3_status_is_retryable(manager.status) && should_retry()); + if (manager.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + +clean: + if (manager.upload_id) { + taosMemoryFree(manager.upload_id); + } + for (i = 0; i < manager.next_etags_pos; i++) { + taosMemoryFree(manager.etags[i]); + } + growbuffer_destroy(manager.gb); + taosMemoryFree(manager.etags); + + return code; +} + +static int32_t s3PutObjectFromFileWithCp(S3BucketContext *bucket_context, const char *file, int32_t lmtime, + char const *object_name, int64_t contentLength, S3PutProperties *put_prop, + put_object_callback_data *data) { + int32_t code = 0; + + uint64_t totalContentLength = contentLength; + // uint64_t todoContentLength = contentLength; + UploadManager manager = {0}; + + uint64_t chunk_size = MULTIPART_CHUNK_SIZE >> 3; + int totalSeq = (contentLength + chunk_size - 1) / chunk_size; + const int max_part_num = 10000; + if (totalSeq > max_part_num) { + chunk_size = (contentLength + max_part_num - contentLength % max_part_num) / max_part_num; + totalSeq = (contentLength + chunk_size - 1) / chunk_size; + } + + bool need_init_upload = true; + char file_cp_path[TSDB_FILENAME_LEN]; + snprintf(file_cp_path, TSDB_FILENAME_LEN, "%s.cp", file); + + SCheckpoint cp = {0}; + cp.parts = taosMemoryCalloc(max_part_num, sizeof(SCheckpointPart)); + + if (taosCheckExistFile(file_cp_path)) { + if (!cos_cp_load(file_cp_path, &cp) && cos_cp_is_valid_upload(&cp, contentLength, lmtime)) { + manager.upload_id = strdup(cp.upload_id); + need_init_upload = false; + } else { + cos_cp_remove(file_cp_path); + } + } + + if (need_init_upload) { + S3MultipartInitialHandler handler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, + &initial_multipart_callback}; + do { + S3_initiate_multipart(bucket_context, object_name, 0, &handler, 0, timeoutMsG, &manager); + } while (S3_status_is_retryable(manager.status) && should_retry()); + + if (manager.upload_id == 0 || manager.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + + cos_cp_build_upload(&cp, file, contentLength, lmtime, manager.upload_id, chunk_size); + } + + if (cos_cp_open(file_cp_path, &cp)) { + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + + int part_num = 0; + int64_t consume_bytes = 0; + // SCheckpointPart *parts = taosMemoryCalloc(cp.part_num, sizeof(SCheckpointPart)); + // cos_cp_get_undo_parts(&cp, &part_num, parts, &consume_bytes); + + MultipartPartData partData; + memset(&partData, 0, sizeof(MultipartPartData)); + int partContentLength = 0; + + S3PutObjectHandler putObjectHandler = {{&MultipartResponseProperiesCallbackWithCp, &responseCompleteCallback}, + &putObjectDataCallback}; + + S3MultipartCommitHandler commit_handler = { + {&responsePropertiesCallbackNull, &responseCompleteCallback}, &multipartPutXmlCallback, 0}; + + manager.etags = (char **)taosMemoryCalloc(totalSeq, sizeof(char *)); + manager.next_etags_pos = 0; + +upload: + // todoContentLength -= chunk_size * manager.next_etags_pos; + for (int i = 0; i < cp.part_num; ++i) { + if (cp.parts[i].completed) { + continue; + } + + if (i > 0 && cp.parts[i - 1].completed) { + if (taosLSeekFile(data->infileFD, cp.parts[i].offset, SEEK_SET) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto clean; + } + } + + int seq = cp.parts[i].index + 1; + + partData.manager = &manager; + partData.seq = seq; + if (partData.put_object_data.gb == NULL) { + partData.put_object_data = *data; + } + + partContentLength = cp.parts[i].size; + partData.put_object_data.contentLength = partContentLength; + partData.put_object_data.originalContentLength = partContentLength; + // partData.put_object_data.totalContentLength = todoContentLength; + partData.put_object_data.totalOriginalContentLength = totalContentLength; + put_prop->md5 = 0; + do { + S3_upload_part(bucket_context, object_name, put_prop, &putObjectHandler, seq, manager.upload_id, + partContentLength, 0, timeoutMsG, &partData); + } while (S3_status_is_retryable(partData.put_object_data.status) && should_retry()); + if (partData.put_object_data.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, partData.put_object_data.status, partData.put_object_data.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + + //(void)cos_cp_dump(&cp); + goto clean; + } + + if (!manager.etags[seq - 1]) { + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + + cos_cp_update(&cp, cp.parts[seq - 1].index, manager.etags[seq - 1], 0); + (void)cos_cp_dump(&cp); + + contentLength -= chunk_size; + // todoContentLength -= chunk_size; + } + + cos_cp_close(cp.thefile); + cp.thefile = 0; + + int size = 0; + size += growbuffer_append(&(manager.gb), "", strlen("")); + char buf[256]; + int n; + for (int i = 0; i < cp.part_num; ++i) { + n = snprintf(buf, sizeof(buf), + "%d" + "%s", + // i + 1, manager.etags[i]); + cp.parts[i].index + 1, cp.parts[i].etag); + size += growbuffer_append(&(manager.gb), buf, n); + } + size += growbuffer_append(&(manager.gb), "", strlen("")); + manager.remaining = size; + + do { + S3_complete_multipart_upload(bucket_context, object_name, &commit_handler, manager.upload_id, manager.remaining, 0, + timeoutMsG, &manager); + } while (S3_status_is_retryable(manager.status) && should_retry()); + if (manager.status != S3StatusOK) { + s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); + code = TAOS_SYSTEM_ERROR(EIO); + goto clean; + } + + cos_cp_remove(file_cp_path); + +clean: + /* + if (parts) { + taosMemoryFree(parts); + } + */ + if (cp.thefile) { + cos_cp_close(cp.thefile); + } + if (cp.parts) { + taosMemoryFree(cp.parts); + } + + if (manager.upload_id) { + taosMemoryFree(manager.upload_id); + } + for (int i = 0; i < cp.part_num; ++i) { + if (manager.etags[i]) { + taosMemoryFree(manager.etags[i]); + } + } + taosMemoryFree(manager.etags); + growbuffer_destroy(manager.gb); + + return code; +} + +int32_t s3PutObjectFromFile2(const char *file, const char *object_name, int8_t withcp) { + int32_t code = 0; + int32_t lmtime = 0; + const char *filename = 0; uint64_t contentLength = 0; - const char * cacheControl = 0, *contentType = 0, *md5 = 0; - const char * contentDispositionFilename = 0, *contentEncoding = 0; + const char *cacheControl = 0, *contentType = 0, *md5 = 0; + const char *contentDispositionFilename = 0, *contentEncoding = 0; int64_t expires = -1; S3CannedAcl cannedAcl = S3CannedAclPrivate; int metaPropertiesCount = 0; S3NameValue metaProperties[S3_MAX_METADATA_COUNT]; char useServerSideEncryption = 0; put_object_callback_data data = {0}; - // int noStatus = 0; - // data.infile = 0; - // data.gb = 0; - // data.infileFD = NULL; - // data.noStatus = noStatus; - - // uError("ERROR: %s stat file %s: ", __func__, file); - if (taosStatFile(file, &contentLength, NULL, NULL) < 0) { - uError("ERROR: %s Failed to stat file %s: ", __func__, file); + if (taosStatFile(file, &contentLength, &lmtime, NULL) < 0) { code = TAOS_SYSTEM_ERROR(errno); + uError("ERROR: %s Failed to stat file %s: ", __func__, file); return code; } if (!(data.infileFD = taosOpenFile(file, TD_FILE_READ))) { - uError("ERROR: %s Failed to open file %s: ", __func__, file); code = TAOS_SYSTEM_ERROR(errno); + uError("ERROR: %s Failed to open file %s: ", __func__, file); return code; } @@ -493,143 +812,13 @@ int32_t s3PutObjectFromFile2(const char *file, const char *object) { metaProperties, useServerSideEncryption}; if (contentLength <= MULTIPART_CHUNK_SIZE) { - S3PutObjectHandler putObjectHandler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, - &putObjectDataCallback}; - - do { - S3_put_object(&bucketContext, key, contentLength, &putProperties, 0, 0, &putObjectHandler, &data); - } while (S3_status_is_retryable(data.status) && should_retry()); - - if (data.status != S3StatusOK) { - s3PrintError(__FILE__, __LINE__, __func__, data.status, data.err_msg); - code = TAOS_SYSTEM_ERROR(EIO); - } else if (data.contentLength) { - uError("ERROR: %s Failed to read remaining %llu bytes from input", __func__, - (unsigned long long)data.contentLength); - code = TAOS_SYSTEM_ERROR(EIO); - } + code = s3PutObjectFromFileSimple(&bucketContext, object_name, contentLength, &putProperties, &data); } else { - uint64_t totalContentLength = contentLength; - uint64_t todoContentLength = contentLength; - UploadManager manager = {0}; - // manager.upload_id = 0; - // manager.gb = 0; - - // div round up - int seq; - uint64_t chunk_size = MULTIPART_CHUNK_SIZE >> 3; - int totalSeq = (contentLength + chunk_size - 1) / chunk_size; - const int max_part_num = 10000; - if (totalSeq > max_part_num) { - chunk_size = (contentLength + max_part_num - contentLength % max_part_num) / max_part_num; - totalSeq = (contentLength + chunk_size - 1) / chunk_size; + if (withcp) { + code = s3PutObjectFromFileWithCp(&bucketContext, file, lmtime, object_name, contentLength, &putProperties, &data); + } else { + code = s3PutObjectFromFileWithoutCp(&bucketContext, object_name, contentLength, &putProperties, &data); } - - MultipartPartData partData; - memset(&partData, 0, sizeof(MultipartPartData)); - int partContentLength = 0; - - S3MultipartInitialHandler handler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, - &initial_multipart_callback}; - - S3PutObjectHandler putObjectHandler = {{&MultipartResponseProperiesCallback, &responseCompleteCallback}, - &putObjectDataCallback}; - - S3MultipartCommitHandler commit_handler = { - {&responsePropertiesCallbackNull, &responseCompleteCallback}, &multipartPutXmlCallback, 0}; - - manager.etags = (char **)taosMemoryCalloc(totalSeq, sizeof(char *)); - manager.next_etags_pos = 0; - /* - if (uploadId) { - manager.upload_id = strdup(uploadId); - manager.remaining = contentLength; - if (!try_get_parts_info(tsS3BucketName, key, &manager)) { - fseek(data.infile, -(manager.remaining), 2); - taosLSeekFile(data.infileFD, -(manager.remaining), SEEK_END); - contentLength = manager.remaining; - goto upload; - } else { - goto clean; - } - } - */ - do { - S3_initiate_multipart(&bucketContext, key, 0, &handler, 0, timeoutMsG, &manager); - } while (S3_status_is_retryable(manager.status) && should_retry()); - - if (manager.upload_id == 0 || manager.status != S3StatusOK) { - s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); - code = TAOS_SYSTEM_ERROR(EIO); - goto clean; - } - - upload: - todoContentLength -= chunk_size * manager.next_etags_pos; - for (seq = manager.next_etags_pos + 1; seq <= totalSeq; seq++) { - partData.manager = &manager; - partData.seq = seq; - if (partData.put_object_data.gb == NULL) { - partData.put_object_data = data; - } - partContentLength = ((contentLength > chunk_size) ? chunk_size : contentLength); - // printf("%s Part Seq %d, length=%d\n", srcSize ? "Copying" : "Sending", seq, partContentLength); - partData.put_object_data.contentLength = partContentLength; - partData.put_object_data.originalContentLength = partContentLength; - partData.put_object_data.totalContentLength = todoContentLength; - partData.put_object_data.totalOriginalContentLength = totalContentLength; - putProperties.md5 = 0; - do { - S3_upload_part(&bucketContext, key, &putProperties, &putObjectHandler, seq, manager.upload_id, - partContentLength, 0, timeoutMsG, &partData); - } while (S3_status_is_retryable(partData.put_object_data.status) && should_retry()); - if (partData.put_object_data.status != S3StatusOK) { - s3PrintError(__FILE__, __LINE__, __func__, partData.put_object_data.status, partData.put_object_data.err_msg); - code = TAOS_SYSTEM_ERROR(EIO); - goto clean; - } - contentLength -= chunk_size; - todoContentLength -= chunk_size; - } - - int i; - int size = 0; - size += growbuffer_append(&(manager.gb), "", strlen("")); - char buf[256]; - int n; - for (i = 0; i < totalSeq; i++) { - if (!manager.etags[i]) { - code = TAOS_SYSTEM_ERROR(EIO); - goto clean; - } - n = snprintf(buf, sizeof(buf), - "%d" - "%s", - i + 1, manager.etags[i]); - size += growbuffer_append(&(manager.gb), buf, n); - } - size += growbuffer_append(&(manager.gb), "", strlen("")); - manager.remaining = size; - - do { - S3_complete_multipart_upload(&bucketContext, key, &commit_handler, manager.upload_id, manager.remaining, 0, - timeoutMsG, &manager); - } while (S3_status_is_retryable(manager.status) && should_retry()); - if (manager.status != S3StatusOK) { - s3PrintError(__FILE__, __LINE__, __func__, manager.status, manager.err_msg); - code = TAOS_SYSTEM_ERROR(EIO); - goto clean; - } - - clean: - if (manager.upload_id) { - taosMemoryFree(manager.upload_id); - } - for (i = 0; i < manager.next_etags_pos; i++) { - taosMemoryFree(manager.etags[i]); - } - growbuffer_destroy(manager.gb); - taosMemoryFree(manager.etags); } if (data.infileFD) { @@ -648,7 +837,7 @@ typedef struct list_bucket_callback_data { char nextMarker[1024]; int keyCount; int allDetails; - SArray * objectArray; + SArray *objectArray; } list_bucket_callback_data; static S3Status listBucketCallback(int isTruncated, const char *nextMarker, int contentsCount, @@ -693,11 +882,11 @@ static void s3FreeObjectKey(void *pItem) { static SArray *getListByPrefix(const char *prefix) { S3BucketContext bucketContext = {0, tsS3BucketName, protocolG, uriStyleG, tsS3AccessKeyId, tsS3AccessKeySecret, - 0, awsRegionG}; + 0, awsRegionG}; S3ListBucketHandler listBucketHandler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, &listBucketCallback}; - const char * marker = 0, *delimiter = 0; + const char *marker = 0, *delimiter = 0; int maxkeys = 0, allDetails = 0; list_bucket_callback_data data; data.objectArray = taosArrayInit(32, sizeof(void *)); @@ -738,7 +927,7 @@ static SArray *getListByPrefix(const char *prefix) { void s3DeleteObjects(const char *object_name[], int nobject) { S3BucketContext bucketContext = {0, tsS3BucketName, protocolG, uriStyleG, tsS3AccessKeyId, tsS3AccessKeySecret, - 0, awsRegionG}; + 0, awsRegionG}; S3ResponseHandler responseHandler = {0, &responseCompleteCallback}; for (int i = 0; i < nobject; ++i) { @@ -789,7 +978,7 @@ int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t size, const char *ifMatch = 0, *ifNotMatch = 0; S3BucketContext bucketContext = {0, tsS3BucketName, protocolG, uriStyleG, tsS3AccessKeyId, tsS3AccessKeySecret, - 0, awsRegionG}; + 0, awsRegionG}; S3GetConditions getConditions = {ifModifiedSince, ifNotModifiedSince, ifMatch, ifNotMatch}; S3GetObjectHandler getObjectHandler = {{&responsePropertiesCallback, &responseCompleteCallback}, &getObjectDataCallback}; @@ -827,7 +1016,7 @@ int32_t s3GetObjectToFile(const char *object_name, char *fileName) { const char *ifMatch = 0, *ifNotMatch = 0; S3BucketContext bucketContext = {0, tsS3BucketName, protocolG, uriStyleG, tsS3AccessKeyId, tsS3AccessKeySecret, - 0, awsRegionG}; + 0, awsRegionG}; S3GetConditions getConditions = {ifModifiedSince, ifNotModifiedSince, ifMatch, ifNotMatch}; S3GetObjectHandler getObjectHandler = {{&responsePropertiesCallbackNull, &responseCompleteCallback}, &getObjectCallback}; @@ -858,7 +1047,7 @@ int32_t s3GetObjectsByPrefix(const char *prefix, const char *path) { if (objectArray == NULL) return -1; for (size_t i = 0; i < taosArrayGetSize(objectArray); i++) { - char * object = taosArrayGetP(objectArray, i); + char *object = taosArrayGetP(objectArray, i); const char *tmp = strchr(object, '/'); tmp = (tmp == NULL) ? object : tmp + 1; char fileName[PATH_MAX] = {0}; @@ -949,12 +1138,12 @@ static void s3InitRequestOptions(cos_request_options_t *options, int is_cname) { int32_t s3PutObjectFromFile(const char *file_str, const char *object_str) { int32_t code = 0; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; + cos_status_t *s = NULL; cos_request_options_t *options = NULL; cos_string_t bucket, object, file; - cos_table_t * resp_headers; + cos_table_t *resp_headers; // int traffic_limit = 0; cos_pool_create(&p, NULL); @@ -983,18 +1172,19 @@ int32_t s3PutObjectFromFile(const char *file_str, const char *object_str) { return code; } -int32_t s3PutObjectFromFile2(const char *file_str, const char *object_str) { +int32_t s3PutObjectFromFile2(const char *file_str, const char *object_str, int8_t withcp) { int32_t code = 0; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; - cos_request_options_t * options = NULL; + cos_status_t *s = NULL; + cos_request_options_t *options = NULL; cos_string_t bucket, object, file; - cos_table_t * resp_headers; + cos_table_t *resp_headers; int traffic_limit = 0; - cos_table_t * headers = NULL; + cos_table_t *headers = NULL; cos_resumable_clt_params_t *clt_params = NULL; + (void)withcp; cos_pool_create(&p, NULL); options = cos_request_options_create(p); s3InitRequestOptions(options, is_cname); @@ -1025,11 +1215,11 @@ int32_t s3PutObjectFromFile2(const char *file_str, const char *object_str) { } void s3DeleteObjectsByPrefix(const char *prefix_str) { - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; cos_request_options_t *options = NULL; int is_cname = 0; cos_string_t bucket; - cos_status_t * s = NULL; + cos_status_t *s = NULL; cos_string_t prefix; cos_pool_create(&p, NULL); @@ -1044,10 +1234,10 @@ void s3DeleteObjectsByPrefix(const char *prefix_str) { } void s3DeleteObjects(const char *object_name[], int nobject) { - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; cos_string_t bucket; - cos_table_t * resp_headers = NULL; + cos_table_t *resp_headers = NULL; cos_request_options_t *options = NULL; cos_list_t object_list; cos_list_t deleted_object_list; @@ -1081,14 +1271,14 @@ void s3DeleteObjects(const char *object_name[], int nobject) { bool s3Exists(const char *object_name) { bool ret = false; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; - cos_request_options_t * options = NULL; + cos_status_t *s = NULL; + cos_request_options_t *options = NULL; cos_string_t bucket; cos_string_t object; - cos_table_t * resp_headers; - cos_table_t * headers = NULL; + cos_table_t *resp_headers; + cos_table_t *headers = NULL; cos_object_exist_status_e object_exist; cos_pool_create(&p, NULL); @@ -1115,15 +1305,15 @@ bool s3Exists(const char *object_name) { bool s3Get(const char *object_name, const char *path) { bool ret = false; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; + cos_status_t *s = NULL; cos_request_options_t *options = NULL; cos_string_t bucket; cos_string_t object; cos_string_t file; - cos_table_t * resp_headers = NULL; - cos_table_t * headers = NULL; + cos_table_t *resp_headers = NULL; + cos_table_t *headers = NULL; int traffic_limit = 0; //创建内存池 @@ -1159,15 +1349,15 @@ bool s3Get(const char *object_name, const char *path) { int32_t s3GetObjectBlock(const char *object_name, int64_t offset, int64_t block_size, bool check, uint8_t **ppBlock) { (void)check; int32_t code = 0; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; + cos_status_t *s = NULL; cos_request_options_t *options = NULL; cos_string_t bucket; cos_string_t object; - cos_table_t * resp_headers; - cos_table_t * headers = NULL; - cos_buf_t * content = NULL; + cos_table_t *resp_headers; + cos_table_t *headers = NULL; + cos_buf_t *content = NULL; // cos_string_t file; // int traffic_limit = 0; char range_buf[64]; @@ -1261,7 +1451,7 @@ void s3EvictCache(const char *path, long object_size) { terrno = TAOS_SYSTEM_ERROR(errno); vError("failed to open %s since %s", dir_name, terrstr()); } - SArray * evict_files = taosArrayInit(16, sizeof(SEvictFile)); + SArray *evict_files = taosArrayInit(16, sizeof(SEvictFile)); tdbDirEntryPtr pDirEntry; while ((pDirEntry = taosReadDir(pDir)) != NULL) { char *name = taosGetDirEntryName(pDirEntry); @@ -1303,13 +1493,13 @@ void s3EvictCache(const char *path, long object_size) { long s3Size(const char *object_name) { long size = 0; - cos_pool_t * p = NULL; + cos_pool_t *p = NULL; int is_cname = 0; - cos_status_t * s = NULL; + cos_status_t *s = NULL; cos_request_options_t *options = NULL; cos_string_t bucket; cos_string_t object; - cos_table_t * resp_headers = NULL; + cos_table_t *resp_headers = NULL; //创建内存池 cos_pool_create(&p, NULL); @@ -1344,7 +1534,7 @@ long s3Size(const char *object_name) { int32_t s3Init() { return 0; } void s3CleanUp() {} int32_t s3PutObjectFromFile(const char *file, const char *object) { return 0; } -int32_t s3PutObjectFromFile2(const char *file, const char *object) { return 0; } +int32_t s3PutObjectFromFile2(const char *file, const char *object, int8_t withcp) { return 0; } void s3DeleteObjectsByPrefix(const char *prefix) {} void s3DeleteObjects(const char *object_name[], int nobject) {} bool s3Exists(const char *object_name) { return false; } diff --git a/source/common/src/cos_cp.c b/source/common/src/cos_cp.c new file mode 100644 index 0000000000..6d37b4d4dc --- /dev/null +++ b/source/common/src/cos_cp.c @@ -0,0 +1,417 @@ +#define ALLOW_FORBID_FUNC + +#include "cos_cp.h" +#include "cJSON.h" +#include "tutil.h" + +int32_t cos_cp_open(char const* cp_path, SCheckpoint* checkpoint) { + int32_t code = 0; + + TdFilePtr fd = taosOpenFile(cp_path, TD_FILE_WRITE | TD_FILE_CREATE /* | TD_FILE_TRUNC*/ | TD_FILE_WRITE_THROUGH); + if (!fd) { + code = TAOS_SYSTEM_ERROR(errno); + uError("ERROR: %s Failed to open %s", __func__, cp_path); + return code; + } + + checkpoint->thefile = fd; + + return code; +} + +void cos_cp_close(TdFilePtr fd) { taosCloseFile(&fd); } +void cos_cp_remove(char const* filepath) { taosRemoveFile(filepath); } + +static int32_t cos_cp_parse_body(char* cp_body, SCheckpoint* cp) { + int32_t code = 0; + cJSON const* item2 = NULL; + + cJSON* json = cJSON_Parse(cp_body); + if (NULL == json) { + code = TSDB_CODE_FILE_CORRUPTED; + uError("ERROR: %s Failed to parse json", __func__); + goto _exit; + } + + cJSON const* item = cJSON_GetObjectItem(json, "ver"); + if (!cJSON_IsNumber(item) || item->valuedouble != 1) { + code = TSDB_CODE_FILE_CORRUPTED; + uError("ERROR: %s Failed to parse json ver: %f", __func__, item->valuedouble); + goto _exit; + } + + item = cJSON_GetObjectItem(json, "type"); + if (!cJSON_IsNumber(item)) { + code = TSDB_CODE_FILE_CORRUPTED; + uError("ERROR: %s Failed to parse json", __func__); + goto _exit; + } + cp->cp_type = item->valuedouble; + + item = cJSON_GetObjectItem(json, "md5"); + if (cJSON_IsString(item)) { + memcpy(cp->md5, item->valuestring, strlen(item->valuestring)); + } + + item = cJSON_GetObjectItem(json, "upload_id"); + if (cJSON_IsString(item)) { + strncpy(cp->upload_id, item->valuestring, 128); + } + + item2 = cJSON_GetObjectItem(json, "file"); + if (cJSON_IsObject(item2)) { + item = cJSON_GetObjectItem(item2, "size"); + if (cJSON_IsNumber(item)) { + cp->file_size = item->valuedouble; + } + + item = cJSON_GetObjectItem(item2, "lastmodified"); + if (cJSON_IsNumber(item)) { + cp->file_last_modified = item->valuedouble; + } + + item = cJSON_GetObjectItem(item2, "path"); + if (cJSON_IsString(item)) { + strncpy(cp->file_path, item->valuestring, TSDB_FILENAME_LEN); + } + + item = cJSON_GetObjectItem(item2, "file_md5"); + if (cJSON_IsString(item)) { + strncpy(cp->file_md5, item->valuestring, 64); + } + } + + item2 = cJSON_GetObjectItem(json, "object"); + if (cJSON_IsObject(item2)) { + item = cJSON_GetObjectItem(item2, "object_size"); + if (cJSON_IsNumber(item)) { + cp->object_size = item->valuedouble; + } + + item = cJSON_GetObjectItem(item2, "object_name"); + if (cJSON_IsString(item)) { + strncpy(cp->object_name, item->valuestring, 128); + } + + item = cJSON_GetObjectItem(item2, "object_last_modified"); + if (cJSON_IsString(item)) { + strncpy(cp->object_last_modified, item->valuestring, 64); + } + + item = cJSON_GetObjectItem(item2, "object_etag"); + if (cJSON_IsString(item)) { + strncpy(cp->object_etag, item->valuestring, 128); + } + } + + item2 = cJSON_GetObjectItem(json, "cpparts"); + if (cJSON_IsObject(item2)) { + item = cJSON_GetObjectItem(item2, "number"); + if (cJSON_IsNumber(item)) { + cp->part_num = item->valuedouble; + } + + item = cJSON_GetObjectItem(item2, "size"); + if (cJSON_IsNumber(item)) { + cp->part_size = item->valuedouble; + } + + item2 = cJSON_GetObjectItem(item2, "parts"); + if (cJSON_IsArray(item2) && cp->part_num > 0) { + cJSON_ArrayForEach(item, item2) { + cJSON const* item3 = cJSON_GetObjectItem(item, "index"); + int32_t index = 0; + if (cJSON_IsNumber(item3)) { + index = item3->valuedouble; + cp->parts[index].index = index; + } + + item3 = cJSON_GetObjectItem(item, "offset"); + if (cJSON_IsNumber(item3)) { + cp->parts[index].offset = item3->valuedouble; + } + + item3 = cJSON_GetObjectItem(item, "size"); + if (cJSON_IsNumber(item3)) { + cp->parts[index].size = item3->valuedouble; + } + + item3 = cJSON_GetObjectItem(item, "completed"); + if (cJSON_IsNumber(item3)) { + cp->parts[index].completed = item3->valuedouble; + } + + item3 = cJSON_GetObjectItem(item, "crc64"); + if (cJSON_IsNumber(item3)) { + cp->parts[index].crc64 = item3->valuedouble; + } + + item3 = cJSON_GetObjectItem(item, "etag"); + if (cJSON_IsString(item3)) { + strncpy(cp->parts[index].etag, item3->valuestring, 128); + } + } + } + } + +_exit: + if (json) cJSON_Delete(json); + if (cp_body) taosMemoryFree(cp_body); + + return code; +} + +int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint) { + int32_t code = 0; + + TdFilePtr fd = taosOpenFile(filepath, TD_FILE_READ); + if (!fd) { + code = TAOS_SYSTEM_ERROR(errno); + uError("ERROR: %s Failed to open %s", __func__, filepath); + goto _exit; + } + + int64_t size = -1; + code = taosStatFile(filepath, &size, NULL, NULL); + if (code) { + uError("ERROR: %s Failed to stat %s", __func__, filepath); + goto _exit; + } + + char* cp_body = taosMemoryMalloc(size + 1); + + int64_t n = taosReadFile(fd, cp_body, size); + if (n < 0) { + code = TAOS_SYSTEM_ERROR(errno); + uError("ERROR: %s Failed to read %s", __func__, filepath); + goto _exit; + } else if (n != size) { + code = TSDB_CODE_FILE_CORRUPTED; + uError("ERROR: %s Failed to read %s %" PRId64 "/%" PRId64, __func__, filepath, n, size); + goto _exit; + } + taosCloseFile(&fd); + cp_body[size] = '\0'; + + return cos_cp_parse_body(cp_body, checkpoint); + +_exit: + if (fd) { + taosCloseFile(&fd); + } + if (cp_body) { + taosMemoryFree(cp_body); + } + + return code; +} + +static int32_t cos_cp_save_json(cJSON const* json, SCheckpoint* checkpoint) { + int32_t code = 0; + + char* data = cJSON_PrintUnformatted(json); + if (NULL == data) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + TdFilePtr fp = checkpoint->thefile; + if (taosFtruncateFile(fp, 0) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _exit; + } + if (taosLSeekFile(fp, 0, SEEK_SET) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _exit; + } + if (taosWriteFile(fp, data, strlen(data)) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _exit; + } + + if (taosFsyncFile(fp) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _exit; + } + +_exit: + taosMemoryFree(data); + return code; +} + +int32_t cos_cp_dump(SCheckpoint* cp) { + int32_t code = 0; + int32_t lino = 0; + + cJSON* ojson = NULL; + cJSON* json = cJSON_CreateObject(); + if (!json) return TSDB_CODE_OUT_OF_MEMORY; + + if (NULL == cJSON_AddNumberToObject(json, "ver", 1)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (NULL == cJSON_AddNumberToObject(json, "type", cp->cp_type)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (NULL == cJSON_AddStringToObject(json, "md5", cp->md5)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (NULL == cJSON_AddStringToObject(json, "upload_id", cp->upload_id)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (COS_CP_TYPE_UPLOAD == cp->cp_type) { + ojson = cJSON_AddObjectToObject(json, "file"); + if (!ojson) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(ojson, "size", cp->file_size)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(ojson, "lastmodified", cp->file_last_modified)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(ojson, "path", cp->file_path)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(ojson, "file_md5", cp->file_md5)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + } else if (COS_CP_TYPE_DOWNLOAD == cp->cp_type) { + ojson = cJSON_AddObjectToObject(json, "object"); + if (!ojson) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(ojson, "object_size", cp->object_size)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(ojson, "object_name", cp->object_name)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(ojson, "object_last_modified", cp->object_last_modified)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(ojson, "object_etag", cp->object_etag)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + } + + ojson = cJSON_AddObjectToObject(json, "cpparts"); + if (!ojson) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(ojson, "number", cp->part_num)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(ojson, "size", cp->part_size)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + cJSON* ajson = cJSON_AddArrayToObject(ojson, "parts"); + if (!ajson) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + for (int i = 0; i < cp->part_num; ++i) { + cJSON* item = cJSON_CreateObject(); + if (!item) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + cJSON_AddItemToArray(ajson, item); + + if (NULL == cJSON_AddNumberToObject(item, "index", cp->parts[i].index)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(item, "offset", cp->parts[i].offset)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(item, "size", cp->parts[i].size)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(item, "completed", cp->parts[i].completed)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddNumberToObject(item, "crc64", cp->parts[i].crc64)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if (NULL == cJSON_AddStringToObject(item, "etag", cp->parts[i].etag)) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + } + + code = cos_cp_save_json(json, cp); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + uError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + cJSON_Delete(json); + return code; +} + +void cos_cp_get_undo_parts(SCheckpoint* checkpoint, int* part_num, SCheckpointPart* parts, int64_t* consume_bytes) {} + +void cos_cp_update(SCheckpoint* checkpoint, int32_t part_index, char const* etag, uint64_t crc64) { + checkpoint->parts[part_index].completed = 1; + strncpy(checkpoint->parts[part_index].etag, etag, 128); + checkpoint->parts[part_index].crc64 = crc64; +} + +void cos_cp_build_upload(SCheckpoint* checkpoint, char const* filepath, int64_t size, int32_t mtime, + char const* upload_id, int64_t part_size) { + int i = 0; + + checkpoint->cp_type = COS_CP_TYPE_UPLOAD; + strncpy(checkpoint->file_path, filepath, TSDB_FILENAME_LEN); + + checkpoint->file_size = size; + checkpoint->file_last_modified = mtime; + strncpy(checkpoint->upload_id, upload_id, 128); + + checkpoint->part_size = part_size; + for (; i * part_size < size; i++) { + checkpoint->parts[i].index = i; + checkpoint->parts[i].offset = i * part_size; + checkpoint->parts[i].size = TMIN(part_size, (size - i * part_size)); + checkpoint->parts[i].completed = 0; + checkpoint->parts[i].etag[0] = '\0'; + } + checkpoint->part_num = i; +} + +static bool cos_cp_verify_md5(SCheckpoint* cp) { return true; } + +bool cos_cp_is_valid_upload(SCheckpoint* checkpoint, int64_t size, int32_t mtime) { + if (cos_cp_verify_md5(checkpoint) && checkpoint->file_size == size && checkpoint->file_last_modified == mtime) { + return true; + } + + return false; +} diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 1623d9f062..2e52c77080 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -334,6 +334,20 @@ static const SSysDbTableSchema userViewsSchema[] = { // {.name = "column_list", .bytes = 2048 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, }; +static const SSysDbTableSchema userCompactsSchema[] = { + {.name = "compact_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, +}; + +static const SSysDbTableSchema userCompactsDetailSchema[] = { + {.name = "compact_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "number_fileset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, +}; static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true}, @@ -362,6 +376,8 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true}, {TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), true}, {TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false}, + {TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false}, + {TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false}, }; static const SSysDbTableSchema connectionsSchema[] = { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 4f2ae1b11f..6e247a5a27 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -95,8 +95,9 @@ int32_t tsMonitorMaxLogs = 100; bool tsMonitorComp = false; // audit -bool tsEnableAudit = true; -bool tsEnableAuditCreateTable = true; +bool tsEnableAudit = true; +bool tsEnableAuditCreateTable = true; +int32_t tsAuditInterval = 5000; // telem #ifdef TD_ENTERPRISE @@ -247,6 +248,7 @@ int32_t tsTtlBatchDropNum = 10000; // number of tables dropped per batch // internal int32_t tsTransPullupInterval = 2; +int32_t tsCompactPullupInterval = 10; int32_t tsMqRebalanceInterval = 2; int32_t tsStreamCheckpointInterval = 60; float tsSinkDataRate = 2.0; @@ -281,6 +283,8 @@ int32_t tsS3BlockCacheSize = 16; // number of blocks int32_t tsS3PageCacheSize = 4096; // number of pages int32_t tsS3UploadDelaySec = 60 * 60 * 24; +bool tsExperimental = true; + #ifndef _STORAGE int32_t taosSetTfsCfg(SConfig *pCfg) { SConfigItem *pItem = cfgGetItem(pCfg, "dataDir"); @@ -528,6 +532,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { } if (cfgAddInt32(pCfg, "numOfTaskQueueThreads", tsNumOfTaskQueueThreads, 4, 1024, CFG_SCOPE_CLIENT, CFG_DYN_NONE) != 0) return -1; + if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; return 0; } @@ -687,6 +692,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "audit", tsEnableAudit, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddBool(pCfg, "auditCreateTable", tsEnableAuditCreateTable, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; + if (cfgAddInt32(pCfg, "auditInterval", tsAuditInterval, 500, 200000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) + return -1; if (cfgAddBool(pCfg, "crashReporting", tsEnableCrashReport, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; if (cfgAddBool(pCfg, "telemetryReporting", tsEnableTelem, CFG_SCOPE_BOTH, CFG_DYN_ENT_SERVER) != 0) return -1; @@ -705,6 +712,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; + if (cfgAddInt32(pCfg, "compactPullupInterval", tsCompactPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != + 0) + return -1; if (cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; @@ -792,6 +802,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { return -1; if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; + if (cfgAddBool(pCfg, "experimental", tsExperimental, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; + GRANT_CFG_ADD; return 0; } @@ -1077,6 +1089,8 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32; tsKeepAliveIdle = cfgGetItem(pCfg, "keepAliveIdle")->i32; + + tsExperimental = cfgGetItem(pCfg, "experimental")->bval; return 0; } @@ -1140,6 +1154,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsEnableAudit = cfgGetItem(pCfg, "audit")->bval; tsEnableAuditCreateTable = cfgGetItem(pCfg, "auditCreateTable")->bval; + tsAuditInterval = cfgGetItem(pCfg, "auditInterval")->i32; tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; tsEnableCrashReport = cfgGetItem(pCfg, "crashReporting")->bval; @@ -1155,6 +1170,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32; tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; + tsCompactPullupInterval = cfgGetItem(pCfg, "compactPullupInterval")->i32; tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32; tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32; tsTtlPushIntervalSec = cfgGetItem(pCfg, "ttlPushInterval")->i32; @@ -1211,6 +1227,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsS3PageCacheSize = cfgGetItem(pCfg, "s3PageCacheSize")->i32; tsS3UploadDelaySec = cfgGetItem(pCfg, "s3UploadDelaySec")->i32; + tsExperimental = cfgGetItem(pCfg, "experimental")->bval; + GRANT_CFG_GET; return 0; } @@ -1471,6 +1489,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, char *name) { {"timeseriesThreshold", &tsTimeSeriesThreshold}, {"tmqMaxTopicNum", &tmqMaxTopicNum}, {"transPullupInterval", &tsTransPullupInterval}, + {"compactPullupInterval", &tsCompactPullupInterval}, {"trimVDbIntervalSec", &tsTrimVDbIntervalSec}, {"ttlBatchDropNum", &tsTtlBatchDropNum}, {"ttlFlushThreshold", &tsTtlFlushThreshold}, @@ -1480,6 +1499,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, char *name) { {"s3PageCacheSize", &tsS3PageCacheSize}, {"s3UploadDelaySec", &tsS3UploadDelaySec}, {"supportVnodes", &tsNumOfSupportVnodes}, + {"experimental", &tsExperimental} }; if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) { @@ -1703,6 +1723,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { {"shellActivityTimer", &tsShellActivityTimer}, {"slowLogThreshold", &tsSlowLogThreshold}, {"useAdapter", &tsUseAdapter}, + {"experimental", &tsExperimental} }; if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index d69542c98b..918632b7e7 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1827,7 +1827,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) char *tb = taosHashIterate(pRsp->readTbs, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1842,7 +1842,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->writeTbs, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1857,7 +1857,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->alterTbs, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1872,7 +1872,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->readViews, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1887,7 +1887,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->writeViews, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1902,7 +1902,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) tb = taosHashIterate(pRsp->alterViews, NULL); while (tb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(tb, &keyLen); + void *key = taosHashGetKey(tb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -1917,7 +1917,7 @@ int32_t tSerializeSGetUserAuthRspImpl(SEncoder *pEncoder, SGetUserAuthRsp *pRsp) int32_t *useDb = taosHashIterate(pRsp->useDbs, NULL); while (useDb != NULL) { size_t keyLen = 0; - void * key = taosHashGetKey(useDb, &keyLen); + void *key = taosHashGetKey(useDb, &keyLen); if (tEncodeI32(pEncoder, keyLen) < 0) return -1; if (tEncodeCStr(pEncoder, key) < 0) return -1; @@ -3424,6 +3424,66 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq void tFreeSCompactDbReq(SCompactDbReq *pReq) { FREESQL(); } +int32_t tSerializeSCompactDbRsp(void *buf, int32_t bufLen, SCompactDbRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->compactId) < 0) return -1; + if (tEncodeI8(&encoder, pRsp->bAccepted) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSCompactDbRsp(void *buf, int32_t bufLen, SCompactDbRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->compactId) < 0) return -1; + if (tDecodeI8(&decoder, &pRsp->bAccepted) < 0) return -1; + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +int32_t tSerializeSKillCompactReq(void *buf, int32_t bufLen, SKillCompactReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pReq->compactId) < 0) return -1; + ENCODESQL(); + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSKillCompactReq(void *buf, int32_t bufLen, SKillCompactReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; + DECODESQL(); + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSKillCompactReq(SKillCompactReq *pReq) { FREESQL(); } + int32_t tSerializeSUseDbRspImp(SEncoder *pEncoder, const SUseDbRsp *pRsp) { if (tEncodeCStr(pEncoder, pRsp->db) < 0) return -1; if (tEncodeI64(pEncoder, pRsp->uid) < 0) return -1; @@ -4259,6 +4319,7 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq if (tEncodeCStr(&encoder, pReq->tb) < 0) return -1; if (tEncodeCStr(&encoder, pReq->filterTb) < 0) return -1; if (tEncodeCStr(&encoder, pReq->user) < 0) return -1; + if (tEncodeI64(&encoder, pReq->compactId) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -4276,6 +4337,11 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR if (tDecodeCStrTo(&decoder, pReq->tb) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->filterTb) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1; + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI64(&decoder, &pReq->compactId) < 0) return -1; + } else { + pReq->compactId = -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -5051,6 +5117,75 @@ int32_t tFreeSCreateVnodeReq(SCreateVnodeReq *pReq) { return 0; } +int32_t tSerializeSQueryCompactProgressReq(void *buf, int32_t bufLen, SQueryCompactProgressReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pReq->compactId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSQueryCompactProgressReq(void *buf, int32_t bufLen, SQueryCompactProgressReq *pReq) { + int32_t headLen = sizeof(SMsgHead); + + SDecoder decoder = {0}; + tDecoderInit(&decoder, ((uint8_t *)buf) + headLen, bufLen - headLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +int32_t tSerializeSQueryCompactProgressRsp(void *buf, int32_t bufLen, SQueryCompactProgressRsp *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pReq->compactId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->numberFileset) < 0) return -1; + if (tEncodeI32(&encoder, pReq->finished) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} +int32_t tDeserializeSQueryCompactProgressRsp(void *buf, int32_t bufLen, SQueryCompactProgressRsp *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->numberFileset) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->finished) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + int32_t tSerializeSDropVnodeReq(void *buf, int32_t bufLen, SDropVnodeReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -5139,6 +5274,8 @@ int32_t tSerializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq * if (tEncodeI64(&encoder, pReq->tw.skey) < 0) return -1; if (tEncodeI64(&encoder, pReq->tw.ekey) < 0) return -1; + if (tEncodeI32(&encoder, pReq->compactId) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -5165,6 +5302,42 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq if (tDecodeI64(&decoder, &pReq->tw.ekey) < 0) return -1; } + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; + } + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +int32_t tSerializeSVKillCompactReq(void *buf, int32_t bufLen, SVKillCompactReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pReq->compactId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVKillCompactReq(void *buf, int32_t bufLen, SVKillCompactReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pReq->compactId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; @@ -8169,7 +8342,7 @@ int32_t tEncodeMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) { for (int32_t i = 0; i < pRsp->blockNum; i++) { int32_t bLen = *(int32_t *)taosArrayGet(pRsp->blockDataLen, i); - void * data = taosArrayGetP(pRsp->blockData, i); + void *data = taosArrayGetP(pRsp->blockData, i); if (tEncodeBinary(pEncoder, (const uint8_t *)data, bLen) < 0) return -1; if (pRsp->withSchema) { SSchemaWrapper *pSW = (SSchemaWrapper *)taosArrayGetP(pRsp->blockSchema, i); @@ -8202,7 +8375,7 @@ int32_t tDecodeMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { } for (int32_t i = 0; i < pRsp->blockNum; i++) { - void * data; + void *data; uint64_t bLen; if (tDecodeBinaryAlloc(pDecoder, &data, &bLen) < 0) return -1; taosArrayPush(pRsp->blockData, &data); @@ -8248,7 +8421,7 @@ int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) { if (tEncodeI32(pEncoder, pRsp->createTableNum) < 0) return -1; if (pRsp->createTableNum) { for (int32_t i = 0; i < pRsp->createTableNum; i++) { - void * createTableReq = taosArrayGetP(pRsp->createTableReq, i); + void *createTableReq = taosArrayGetP(pRsp->createTableReq, i); int32_t createTableLen = *(int32_t *)taosArrayGet(pRsp->createTableLen, i); if (tEncodeBinary(pEncoder, createTableReq, createTableLen) < 0) return -1; } @@ -8264,7 +8437,7 @@ int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp) { pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t)); pRsp->createTableReq = taosArrayInit(pRsp->createTableNum, sizeof(void *)); for (int32_t i = 0; i < pRsp->createTableNum; i++) { - void * pCreate = NULL; + void *pCreate = NULL; uint64_t len; if (tDecodeBinaryAlloc(pDecoder, &pCreate, &len) < 0) return -1; int32_t l = (int32_t)len; @@ -8566,7 +8739,7 @@ void tDestroySubmitTbData(SSubmitTbData *pTbData, int32_t flag) { taosArrayDestroy(pTbData->aCol); } else { int32_t nRow = TARRAY_SIZE(pTbData->aRowP); - SRow ** rows = (SRow **)TARRAY_DATA(pTbData->aRowP); + SRow **rows = (SRow **)TARRAY_DATA(pTbData->aRowP); for (int32_t i = 0; i < nRow; ++i) { tRowDestroy(rows[i]); diff --git a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h index 9e43c2af47..80502e2662 100644 --- a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h +++ b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h @@ -30,12 +30,14 @@ typedef struct SDnodeMgmt { TdThread statusThread; TdThread notifyThread; TdThread monitorThread; + TdThread auditThread; TdThread crashReportThread; SSingleWorker mgmtWorker; ProcessCreateNodeFp processCreateNodeFp; ProcessAlterNodeTypeFp processAlterNodeTypeFp; ProcessDropNodeFp processDropNodeFp; SendMonitorReportFp sendMonitorReportFp; + SendAuditRecordsFp sendAuditRecordsFp; GetVnodeLoadsFp getVnodeLoadsFp; GetVnodeLoadsFp getVnodeLoadsLiteFp; GetMnodeLoadsFp getMnodeLoadsFp; @@ -62,7 +64,9 @@ void dmStopStatusThread(SDnodeMgmt *pMgmt); int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt); void dmStopNotifyThread(SDnodeMgmt *pMgmt); int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt); +int32_t dmStartAuditThread(SDnodeMgmt *pMgmt); void dmStopMonitorThread(SDnodeMgmt *pMgmt); +void dmStopAuditThread(SDnodeMgmt *pMgmt); int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt); void dmStopCrashReportThread(SDnodeMgmt *pMgmt); int32_t dmStartWorker(SDnodeMgmt *pMgmt); diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c index 4bd32cac20..b9dd45f1c0 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c @@ -29,6 +29,9 @@ static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) { if (dmStartMonitorThread(pMgmt) != 0) { return -1; } + if (dmStartAuditThread(pMgmt) != 0) { + return -1; + } if (dmStartCrashReportThread(pMgmt) != 0) { return -1; } @@ -38,6 +41,7 @@ static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) { static void dmStopMgmt(SDnodeMgmt *pMgmt) { pMgmt->pData->stopped = true; dmStopMonitorThread(pMgmt); + dmStopAuditThread(pMgmt); dmStopStatusThread(pMgmt); #if defined(TD_ENTERPRISE) dmStopNotifyThread(pMgmt); @@ -60,6 +64,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { pMgmt->processAlterNodeTypeFp = pInput->processAlterNodeTypeFp; pMgmt->processDropNodeFp = pInput->processDropNodeFp; pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp; + pMgmt->sendAuditRecordsFp = pInput->sendAuditRecordFp; pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp; pMgmt->getVnodeLoadsLiteFp = pInput->getVnodeLoadsLiteFp; pMgmt->getMnodeLoadsFp = pInput->getMnodeLoadsFp; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index d6bdaf51bc..af43804db4 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -99,6 +99,27 @@ static void *dmMonitorThreadFp(void *param) { return NULL; } +static void *dmAuditThreadFp(void *param) { + SDnodeMgmt *pMgmt = param; + int64_t lastTime = taosGetTimestampMs(); + setThreadName("dnode-audit"); + + while (1) { + taosMsleep(100); + if (pMgmt->pData->dropped || pMgmt->pData->stopped) break; + + int64_t curTime = taosGetTimestampMs(); + if (curTime < lastTime) lastTime = curTime; + float interval = curTime - lastTime; + if (interval >= tsAuditInterval) { + (*pMgmt->sendAuditRecordsFp)(); + lastTime = curTime; + } + } + + return NULL; +} + static void *dmCrashReportThreadFp(void *param) { SDnodeMgmt *pMgmt = param; int64_t lastTime = taosGetTimestampMs(); @@ -218,6 +239,20 @@ int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) { return 0; } +int32_t dmStartAuditThread(SDnodeMgmt *pMgmt) { + TdThreadAttr thAttr; + taosThreadAttrInit(&thAttr); + taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + if (taosThreadCreate(&pMgmt->auditThread, &thAttr, dmAuditThreadFp, pMgmt) != 0) { + dError("failed to create audit thread since %s", strerror(errno)); + return -1; + } + + taosThreadAttrDestroy(&thAttr); + tmsgReportStartup("dnode-audit", "initialized"); + return 0; +} + void dmStopMonitorThread(SDnodeMgmt *pMgmt) { if (taosCheckPthreadValid(pMgmt->monitorThread)) { taosThreadJoin(pMgmt->monitorThread, NULL); @@ -225,6 +260,13 @@ void dmStopMonitorThread(SDnodeMgmt *pMgmt) { } } +void dmStopAuditThread(SDnodeMgmt *pMgmt) { + if (taosCheckPthreadValid(pMgmt->auditThread)) { + taosThreadJoin(pMgmt->auditThread, NULL); + taosThreadClear(&pMgmt->auditThread); + } +} + int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) { if (!tsEnableCrashReport) { return 0; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 737a0338ef..d6de406987 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -192,6 +192,8 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_VIEW, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_VIEW_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_COMPACT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, mmPutMsgToQueryQueue, 1) == NULL) goto _OVER; @@ -221,6 +223,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_KILL_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index a535ab17d7..9438f953a9 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -818,6 +818,8 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_INDEX, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_INDEX, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_COMPACT_PROGRESS, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_KILL_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index 36097438a2..c646bb4bdd 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -70,6 +70,21 @@ typedef struct SUdfdData { int32_t dnodeId; } SUdfdData; +#ifndef TD_MODULE_OPTIMIZE +typedef struct SDnode { + int8_t once; + bool stop; + EDndRunStatus status; + SStartupInfo startup; + SDnodeData data; + SUdfdData udfdData; + TdThreadMutex mutex; + TdFilePtr lockfile; + STfs *pTfs; + SMgmtWrapper wrappers[NODE_END]; + SDnodeTrans trans; +} SDnode; +#else typedef struct SDnode { int8_t once; bool stop; @@ -83,6 +98,7 @@ typedef struct SDnode { STfs *pTfs; SMgmtWrapper wrappers[NODE_END]; } SDnode; +#endif // dmEnv.c SDnode *dmInstance(); @@ -97,8 +113,12 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); int32_t dmInitVars(SDnode *pDnode); void dmClearVars(SDnode *pDnode); -int32_t dmInitModule(SDnode *pDnode, SMgmtWrapper *wrappers); -bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper); +#ifdef TD_MODULE_OPTIMIZE +int32_t dmInitModule(SDnode *pDnode, SMgmtWrapper *wrappers); +bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper); +#else +int32_t dmInitModule(SDnode *pDnode); +#endif SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); @@ -119,11 +139,16 @@ int32_t dmInitStatusClient(SDnode *pDnode); void dmCleanupClient(SDnode *pDnode); void dmCleanupStatusClient(SDnode *pDnode); SMsgCb dmGetMsgcb(SDnode *pDnode); +#ifdef TD_MODULE_OPTIMIZE int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers); +#else +int32_t dmInitMsgHandle(SDnode *pDnode); +#endif int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); // dmMonitor.c void dmSendMonitorReport(); +void dmSendAuditRecords(); void dmGetVnodeLoads(SMonVloadInfo *pInfo); void dmGetVnodeLoadsLite(SMonVloadInfo *pInfo); void dmGetMnodeLoads(SMonMloadInfo *pInfo); diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index e0503c83c6..f9bba19fbb 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -189,6 +189,7 @@ void dmCleanup() { if (dmCheckRepeatCleanup(pDnode) != 0) return; dmCleanupDnode(pDnode); monCleanup(); + auditCleanup(); syncCleanUp(); walCleanUp(); udfcClose(); @@ -396,6 +397,7 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) { .processAlterNodeTypeFp = dmProcessAlterNodeTypeReq, .processDropNodeFp = dmProcessDropNodeReq, .sendMonitorReportFp = dmSendMonitorReport, + .sendAuditRecordFp = auditSendRecordsInBatch, .getVnodeLoadsFp = dmGetVnodeLoads, .getVnodeLoadsLiteFp = dmGetVnodeLoadsLite, .getMnodeLoadsFp = dmGetMnodeLoads, diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 409ee45cd3..84465640c0 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -24,6 +24,22 @@ #include "tglobal.h" #endif +#ifndef TD_MODULE_OPTIMIZE +static bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper) { + SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); + + bool required = false; + int32_t code = (*pWrapper->func.requiredFp)(&input, &required); + if (!required) { + dDebug("node:%s, does not require startup", pWrapper->name); + } else { + dDebug("node:%s, required to startup", pWrapper->name); + } + + return required; +} +#endif + int32_t dmInitDnode(SDnode *pDnode) { dDebug("start to create dnode"); int32_t code = -1; @@ -65,11 +81,15 @@ int32_t dmInitDnode(SDnode *pDnode) { if (pDnode->lockfile == NULL) { goto _OVER; } - +#ifdef TD_MODULE_OPTIMIZE if (dmInitModule(pDnode, pDnode->wrappers) != 0) { goto _OVER; } - +#else + if (dmInitModule(pDnode) != 0) { + goto _OVER; + } +#endif indexInit(tsNumOfCommitThreads); streamMetaInit(); diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index b3db7c3058..c42aa6a1ae 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" #include "dmNodes.h" +#include "audit.h" static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { pInfo->protocol = 1; @@ -108,6 +109,11 @@ void dmSendMonitorReport() { monSendReport(); } +//Todo: put this in seperate file in the future +void dmSendAuditRecords() { + auditSendRecordsInBatch(); +} + void dmGetVnodeLoads(SMonVloadInfo *pInfo) { SDnode *pDnode = dmInstance(); SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE]; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index ad5ca2cecf..1ea61f0e93 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -251,6 +251,7 @@ _OVER: dmReleaseWrapper(pWrapper); } +#ifdef TD_MODULE_OPTIMIZE int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { SDnodeTrans *pTrans = &pDnode->trans; @@ -276,6 +277,33 @@ int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { return 0; } +#else +int32_t dmInitMsgHandle(SDnode *pDnode) { + SDnodeTrans *pTrans = &pDnode->trans; + + for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; + SArray *pArray = (*pWrapper->func.getHandlesFp)(); + if (pArray == NULL) return -1; + + for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { + SMgmtHandle *pMgmt = taosArrayGet(pArray, i); + SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)]; + if (pMgmt->needCheckVgId) { + pHandle->needCheckVgId = pMgmt->needCheckVgId; + } + if (!pMgmt->needCheckVgId) { + pHandle->defaultNtype = ntype; + } + pWrapper->msgFps[TMSG_INDEX(pMgmt->msgType)] = pMgmt->msgFp; + } + + taosArrayDestroy(pArray); + } + + return 0; +} +#endif static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { SDnode *pDnode = dmInstance(); diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 0a52c578a5..4769ef8538 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -86,6 +86,7 @@ typedef enum { typedef int32_t (*ProcessCreateNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg); typedef int32_t (*ProcessDropNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg); typedef void (*SendMonitorReportFp)(); +typedef void (*SendAuditRecordsFp)(); typedef void (*GetVnodeLoadsFp)(SMonVloadInfo *pInfo); typedef void (*GetMnodeLoadsFp)(SMonMloadInfo *pInfo); typedef void (*GetQnodeLoadsFp)(SQnodeLoad *pInfo); @@ -120,6 +121,7 @@ typedef struct { ProcessAlterNodeTypeFp processAlterNodeTypeFp; ProcessDropNodeFp processDropNodeFp; SendMonitorReportFp sendMonitorReportFp; + SendAuditRecordsFp sendAuditRecordFp; GetVnodeLoadsFp getVnodeLoadsFp; GetVnodeLoadsFp getVnodeLoadsLiteFp; GetMnodeLoadsFp getMnodeLoadsFp; diff --git a/source/dnode/mgmt/test/qnode/dqnode.cpp b/source/dnode/mgmt/test/qnode/dqnode.cpp index 3beb57c516..a72d2b42b9 100644 --- a/source/dnode/mgmt/test/qnode/dqnode.cpp +++ b/source/dnode/mgmt/test/qnode/dqnode.cpp @@ -37,6 +37,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION); + rpcFreeCont(pRsp->pCont); } { @@ -50,6 +51,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -63,6 +65,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_ALREADY_DEPLOYED); + rpcFreeCont(pRsp->pCont); } test.Restart(); @@ -78,6 +81,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_ALREADY_DEPLOYED); + rpcFreeCont(pRsp->pCont); } } @@ -94,6 +98,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION); + rpcFreeCont(pRsp->pCont); } #endif @@ -108,6 +113,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -121,6 +127,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_NOT_DEPLOYED); + rpcFreeCont(pRsp->pCont); } test.Restart(); @@ -136,6 +143,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_NOT_DEPLOYED); + rpcFreeCont(pRsp->pCont); } { @@ -149,5 +157,6 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } \ No newline at end of file diff --git a/source/dnode/mgmt/test/snode/dsnode.cpp b/source/dnode/mgmt/test/snode/dsnode.cpp index 30d6a34813..a60ad6f0e4 100644 --- a/source/dnode/mgmt/test/snode/dsnode.cpp +++ b/source/dnode/mgmt/test/snode/dsnode.cpp @@ -37,6 +37,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION); + rpcFreeCont(pRsp->pCont); } { @@ -50,6 +51,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -63,6 +65,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_ALREADY_DEPLOYED); + rpcFreeCont(pRsp->pCont); } test.Restart(); @@ -78,6 +81,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_ALREADY_DEPLOYED); + rpcFreeCont(pRsp->pCont); } } @@ -94,6 +98,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_OPTION); + rpcFreeCont(pRsp->pCont); } #endif @@ -108,6 +113,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -121,6 +127,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_NOT_DEPLOYED); + rpcFreeCont(pRsp->pCont); } test.Restart(); @@ -136,6 +143,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_NOT_DEPLOYED); + rpcFreeCont(pRsp->pCont); } { @@ -149,5 +157,6 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } \ No newline at end of file diff --git a/source/dnode/mnode/impl/inc/mndCompact.h b/source/dnode/mnode/impl/inc/mndCompact.h new file mode 100644 index 0000000000..43cf78a90e --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndCompact.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_COMPACT_H_ +#define _TD_MND_COMPACT_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t mndInitCompact(SMnode *pMnode); +void mndCleanupCompact(SMnode *pMnode); + +void tFreeCompactObj(SCompactObj *pCompact); +int32_t tSerializeSCompactObj(void *buf, int32_t bufLen, const SCompactObj *pObj); +int32_t tDeserializeSCompactObj(void *buf, int32_t bufLen, SCompactObj *pObj); + +SSdbRaw* mndCompactActionEncode(SCompactObj *pCompact); +SSdbRow* mndCompactActionDecode(SSdbRaw *pRaw); + +int32_t mndCompactActionInsert(SSdb *pSdb, SCompactObj *pCompact); +int32_t mndCompactActionDelete(SSdb *pSdb, SCompactObj *pCompact); +int32_t mndCompactActionUpdate(SSdb *pSdb, SCompactObj *pOldCompact, SCompactObj *pNewCompact); + +int32_t mndAddCompactToTran(SMnode *pMnode, STrans *pTrans, SCompactObj* pCompact, SDbObj *pDb, SCompactDbRsp *rsp); + +int32_t mndRetrieveCompact(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); + +int32_t mndProcessKillCompactReq(SRpcMsg *pReq); + +int32_t mndProcessQueryCompactRsp(SRpcMsg *pReq); + +SCompactObj *mndAcquireCompact(SMnode *pMnode, int64_t compactId); +void mndReleaseCompact(SMnode *pMnode, SCompactObj *pCompact); + +void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_COMPACT_H_*/ diff --git a/source/dnode/mnode/impl/inc/mndCompactDetail.h b/source/dnode/mnode/impl/inc/mndCompactDetail.h new file mode 100644 index 0000000000..601af3b64b --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndCompactDetail.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_COMPACT_DETAIL_H_ +#define _TD_MND_COMPACT_DETAIL_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t mndInitCompactDetail(SMnode *pMnode); +void mndCleanupCompactDetail(SMnode *pMnode); + +void tFreeCompactDetailObj(SCompactDetailObj *pCompact); +int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDetailObj *pObj); +int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailObj *pObj); + +SSdbRaw* mndCompactDetailActionEncode(SCompactDetailObj *pCompact); +SSdbRow* mndCompactDetailActionDecode(SSdbRaw *pRaw); + +int32_t mndCompactDetailActionInsert(SSdb *pSdb, SCompactDetailObj *pCompact); +int32_t mndCompactDetailActionDelete(SSdb *pSdb, SCompactDetailObj *pCompact); +int32_t mndCompactDetailActionUpdate(SSdb *pSdb, SCompactDetailObj *pOldCompact, SCompactDetailObj *pNewCompact); + +int32_t mndAddCompactDetailToTran(SMnode *pMnode, STrans *pTrans, SCompactObj* pCompact, SVgObj *pVgroup, + SVnodeGid *pVgid, int32_t index); + +int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_COMPACT_DETAIL_H_*/ diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 08c0aec46a..8dfd03622f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -741,6 +741,25 @@ int32_t tEncodeSViewObj(SEncoder* pEncoder, const SViewObj* pObj); int32_t tDecodeSViewObj(SDecoder* pDecoder, SViewObj* pObj, int32_t sver); void tFreeSViewObj(SViewObj* pObj); +typedef struct { + int32_t compactDetailId; + int32_t compactId; + int32_t vgId; + int32_t dnodeId; + int32_t numberFileset; + int32_t finished; + int64_t startTime; + int32_t newNumberFileset; + int32_t newFinished; +} SCompactDetailObj; + +typedef struct { + int32_t compactId; + char dbname[TSDB_TABLE_FNAME_LEN]; + int64_t startTime; + SArray* compactDetail; +} SCompactObj; + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/inc/mndStream.h b/source/dnode/mnode/impl/inc/mndStream.h index e3ac4fd6fc..b0f6273acc 100644 --- a/source/dnode/mnode/impl/inc/mndStream.h +++ b/source/dnode/mnode/impl/inc/mndStream.h @@ -24,8 +24,9 @@ extern "C" { typedef struct SStreamTransInfo { int64_t startTime; - int32_t transId; + int64_t streamUid; const char *name; + int32_t transId; } SStreamTransInfo; // time to generated the checkpoint, if now() - checkpointTs >= tsCheckpointInterval, this checkpoint will be discard @@ -52,6 +53,14 @@ typedef struct SStreamExecInfo { TdThreadMutex lock; } SStreamExecInfo; +#define MND_STREAM_CREATE_NAME "stream-create" +#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint" +#define MND_STREAM_PAUSE_NAME "stream-pause" +#define MND_STREAM_RESUME_NAME "stream-resume" +#define MND_STREAM_DROP_NAME "stream-drop" +#define MND_STREAM_TASK_RESET_NAME "stream-task-reset" +#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update" + extern SStreamExecInfo execInfo; int32_t mndInitStream(SMnode *pMnode); @@ -61,9 +70,9 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream); int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb); int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream); -int32_t mndStreamRegisterTrans(STrans *pTrans, const char *pName, const char *pSrcDb, const char *pDstDb); +int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pTransName, int64_t streamUid); int32_t mndAddtoCheckpointWaitingList(SStreamObj *pStream, int64_t checkpointId); -bool streamTransConflictOtherTrans(SMnode *pMnode, const char *pSrcDb, const char *pDstDb, bool lock); +bool streamTransConflictOtherTrans(SMnode *pMnode, int64_t streamUid, const char *pTransName, bool lock); // for sma // TODO refactor diff --git a/source/dnode/mnode/impl/src/mndCompact.c b/source/dnode/mnode/impl/src/mndCompact.c new file mode 100644 index 0000000000..9b35343ed2 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndCompact.c @@ -0,0 +1,748 @@ +/* + * 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 "mndCompact.h" +#include "mndTrans.h" +#include "mndShow.h" +#include "mndDb.h" +#include "mndCompactDetail.h" +#include "mndVgroup.h" +#include "tmsgcb.h" +#include "mndDnode.h" +#include "tmisce.h" +#include "audit.h" +#include "mndPrivilege.h" +#include "mndTrans.h" + +#define MND_COMPACT_VER_NUMBER 1 + +static int32_t mndProcessCompactTimer(SRpcMsg *pReq); + +int32_t mndInitCompact(SMnode *pMnode) { + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_COMPACT, mndRetrieveCompact); + mndSetMsgHandle(pMnode, TDMT_MND_KILL_COMPACT, mndProcessKillCompactReq); + mndSetMsgHandle(pMnode, TDMT_VND_QUERY_COMPACT_PROGRESS_RSP, mndProcessQueryCompactRsp); + mndSetMsgHandle(pMnode, TDMT_MND_COMPACT_TIMER, mndProcessCompactTimer); + mndSetMsgHandle(pMnode, TDMT_VND_KILL_COMPACT_RSP, mndTransProcessRsp); + + SSdbTable table = { + .sdbType = SDB_COMPACT, + .keyType = SDB_KEY_INT32, + .encodeFp = (SdbEncodeFp)mndCompactActionEncode, + .decodeFp = (SdbDecodeFp)mndCompactActionDecode, + .insertFp = (SdbInsertFp)mndCompactActionInsert, + .updateFp = (SdbUpdateFp)mndCompactActionUpdate, + .deleteFp = (SdbDeleteFp)mndCompactActionDelete, + }; + + return sdbSetTable(pMnode->pSdb, table); +} + +void mndCleanupCompact(SMnode *pMnode) { + mDebug("mnd compact cleanup"); +} + +void tFreeCompactObj(SCompactObj *pCompact) { +} + +int32_t tSerializeSCompactObj(void *buf, int32_t bufLen, const SCompactObj *pObj) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pObj->compactId) < 0) return -1; + if (tEncodeCStr(&encoder, pObj->dbname) < 0) return -1; + if (tEncodeI64(&encoder, pObj->startTime) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSCompactObj(void *buf, int32_t bufLen, SCompactObj *pObj) { + int8_t ex = 0; + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pObj->compactId) < 0) return -1; + if (tDecodeCStrTo(&decoder, pObj->dbname) < 0) return -1; + if (tDecodeI64(&decoder, &pObj->startTime) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +SSdbRaw *mndCompactActionEncode(SCompactObj *pCompact) { + terrno = TSDB_CODE_SUCCESS; + + void *buf = NULL; + SSdbRaw *pRaw = NULL; + + int32_t tlen = tSerializeSCompactObj(NULL, 0, pCompact); + if (tlen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t size = sizeof(int32_t) + tlen; + pRaw = sdbAllocRaw(SDB_COMPACT, MND_COMPACT_VER_NUMBER, size); + if (pRaw == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + buf = taosMemoryMalloc(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + tlen = tSerializeSCompactObj(buf, tlen, pCompact); + if (tlen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t dataPos = 0; + SDB_SET_INT32(pRaw, dataPos, tlen, OVER); + SDB_SET_BINARY(pRaw, dataPos, buf, tlen, OVER); + SDB_SET_DATALEN(pRaw, dataPos, OVER); + + +OVER: + taosMemoryFreeClear(buf); + if (terrno != TSDB_CODE_SUCCESS) { + mError("compact:%" PRId32 ", failed to encode to raw:%p since %s", pCompact->compactId, pRaw, terrstr()); + sdbFreeRaw(pRaw); + return NULL; + } + + mTrace("compact:%" PRId32 ", encode to raw:%p, row:%p", pCompact->compactId, pRaw, pCompact); + return pRaw; +} + +SSdbRow *mndCompactActionDecode(SSdbRaw *pRaw) { + SSdbRow *pRow = NULL; + SCompactObj *pCompact = NULL; + void *buf = NULL; + terrno = TSDB_CODE_SUCCESS; + + int8_t sver = 0; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) { + goto OVER; + } + + if (sver != MND_COMPACT_VER_NUMBER) { + terrno = TSDB_CODE_SDB_INVALID_DATA_VER; + mError("compact read invalid ver, data ver: %d, curr ver: %d", sver, MND_COMPACT_VER_NUMBER); + goto OVER; + } + + pRow = sdbAllocRow(sizeof(SCompactObj)); + if (pRow == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + pCompact = sdbGetRowObj(pRow); + if (pCompact == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t tlen; + int32_t dataPos = 0; + SDB_GET_INT32(pRaw, dataPos, &tlen, OVER); + buf = taosMemoryMalloc(tlen + 1); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OVER); + + if (tDeserializeSCompactObj(buf, tlen, pCompact) < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + //taosInitRWLatch(&pView->lock); + +OVER: + taosMemoryFreeClear(buf); + if (terrno != TSDB_CODE_SUCCESS) { + mError("compact:%" PRId32 ", failed to decode from raw:%p since %s", pCompact->compactId, pRaw, terrstr()); + taosMemoryFreeClear(pRow); + return NULL; + } + + mTrace("compact:%" PRId32 ", decode from raw:%p, row:%p", pCompact->compactId, pRaw, pCompact); + return pRow; +} + +int32_t mndCompactActionInsert(SSdb *pSdb, SCompactObj *pCompact) { + mTrace("compact:%" PRId32 ", perform insert action", pCompact->compactId); + return 0; +} + +int32_t mndCompactActionDelete(SSdb *pSdb, SCompactObj *pCompact) { + mTrace("compact:%" PRId32 ", perform insert action", pCompact->compactId); + tFreeCompactObj(pCompact); + return 0; +} + +int32_t mndCompactActionUpdate(SSdb *pSdb, SCompactObj *pOldCompact, SCompactObj *pNewCompact) { + mTrace("compact:%" PRId32 ", perform update action, old row:%p new row:%p", + pOldCompact->compactId, pOldCompact, pNewCompact); + + return 0; +} + +SCompactObj *mndAcquireCompact(SMnode *pMnode, int64_t compactId) { + SSdb *pSdb = pMnode->pSdb; + SCompactObj *pCompact = sdbAcquire(pSdb, SDB_COMPACT, &compactId); + if (pCompact == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) { + terrno = TSDB_CODE_SUCCESS; + } + return pCompact; +} + +void mndReleaseCompact(SMnode *pMnode, SCompactObj *pCompact) { + SSdb *pSdb = pMnode->pSdb; + sdbRelease(pSdb, pCompact); +} + +//compact db +int32_t mndAddCompactToTran(SMnode *pMnode, STrans *pTrans, SCompactObj* pCompact, SDbObj *pDb, SCompactDbRsp *rsp){ + pCompact->compactId = tGenIdPI32(); + + strcpy(pCompact->dbname, pDb->name); + + pCompact->startTime = taosGetTimestampMs(); + + SSdbRaw *pVgRaw = mndCompactActionEncode(pCompact); + if (pVgRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + (void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); + + rsp->compactId = pCompact->compactId; + + return 0; +} + +//retrieve compact +int32_t mndRetrieveCompact(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows){ + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + SCompactObj *pCompact = NULL; + char *sep = NULL; + SDbObj *pDb = NULL; + + if (strlen(pShow->db) > 0) { + sep = strchr(pShow->db, '.'); + if (sep && ((0 == strcmp(sep + 1, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcmp(sep + 1, TSDB_PERFORMANCE_SCHEMA_DB))))) { + sep++; + } else { + pDb = mndAcquireDb(pMnode, pShow->db); + if (pDb == NULL) return terrno; + } + } + + while (numOfRows < rows) { + pShow->pIter = sdbFetch(pSdb, SDB_COMPACT, pShow->pIter, (void **)&pCompact); + if (pShow->pIter == NULL) break; + + SColumnInfoData *pColInfo; + SName n; + int32_t cols = 0; + + char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0}; + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->compactId, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + if (pDb != NULL || !IS_SYS_DBNAME(pCompact->dbname)) { + SName name = {0}; + tNameFromString(&name, pCompact->dbname, T_NAME_ACCT | T_NAME_DB); + tNameGetDbName(&name, varDataVal(tmpBuf)); + } else { + strncpy(varDataVal(tmpBuf), pCompact->dbname, strlen(pCompact->dbname) + 1); + } + varDataSetLen(tmpBuf, strlen(varDataVal(tmpBuf))); + colDataSetVal(pColInfo, numOfRows, (const char *)tmpBuf, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompact->startTime, false); + + numOfRows++; + sdbRelease(pSdb, pCompact); + } + + pShow->numOfRows += numOfRows; + mndReleaseDb(pMnode, pDb); + return numOfRows; +} + +//kill compact +static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pContLen, + int32_t compactId, int32_t dnodeid) { + SVKillCompactReq req = {0}; + req.compactId = compactId; + req.vgId = pVgroup->vgId; + req.dnodeId = dnodeid; + + mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId); + int32_t contLen = tSerializeSVKillCompactReq(NULL, 0, &req); + if (contLen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + contLen += sizeof(SMsgHead); + + void *pReq = taosMemoryMalloc(contLen); + if (pReq == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + SMsgHead *pHead = pReq; + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(pVgroup->vgId); + + tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req); + *pContLen = contLen; + return pReq; +} + +static int32_t mndAddKillCompactAction(SMnode *pMnode, STrans *pTrans, SVgObj *pVgroup, + int32_t compactId, int32_t dnodeid) { + STransAction action = {0}; + + SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeid); + if (pDnode == NULL) return -1; + action.epSet = mndGetDnodeEpset(pDnode); + mndReleaseDnode(pMnode, pDnode); + + int32_t contLen = 0; + void *pReq = mndBuildKillCompactReq(pMnode, pVgroup, &contLen, compactId, dnodeid); + if (pReq == NULL) return -1; + + action.pCont = pReq; + action.contLen = contLen; + action.msgType = TDMT_VND_KILL_COMPACT; + + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; + } + + return 0; +} + +static int32_t mndKillCompact(SMnode *pMnode, SRpcMsg *pReq, SCompactObj *pCompact) { + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "kill-compact"); + if (pTrans == NULL) { + mError("compact:%" PRId32 ", failed to drop since %s" , pCompact->compactId, terrstr()); + return -1; + } + mInfo("trans:%d, used to kill compact:%" PRId32, pTrans->id, pCompact->compactId); + + SSdbRaw *pCommitRaw = mndCompactActionEncode(pCompact); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + + void *pIter = NULL; + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == pCompact->compactId) { + SVgObj *pVgroup = mndAcquireVgroup(pMnode, pDetail->vgId); + if(pVgroup == NULL){ + mError("trans:%d, failed to append redo action since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + + if(mndAddKillCompactAction(pMnode, pTrans, pVgroup, pCompact->compactId, pDetail->dnodeId) != 0){ + mError("trans:%d, failed to append redo action since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + + mndReleaseVgroup(pMnode, pVgroup); + + /* + SSdbRaw *pCommitRaw = mndCompactDetailActionEncode(pDetail); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); + */ + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + + mndTransDrop(pTrans); + return 0; +} + +int32_t mndProcessKillCompactReq(SRpcMsg *pReq){ + SKillCompactReq killCompactReq = {0}; + if (tDeserializeSKillCompactReq(pReq->pCont, pReq->contLen, &killCompactReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + mInfo("start to kill compact:%" PRId32, killCompactReq.compactId); + + SMnode *pMnode = pReq->info.node; + int32_t code = -1; + SCompactObj *pCompact = mndAcquireCompact(pMnode, killCompactReq.compactId); + if(pCompact == NULL){ + terrno = TSDB_CODE_MND_INVALID_COMPACT_ID; + tFreeSKillCompactReq(&killCompactReq); + return -1; + } + + if (0 != mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_COMPACT_DB)) { + goto _OVER; + } + + if (mndKillCompact(pMnode, pReq, pCompact) < 0) { + goto _OVER; + } + + code = TSDB_CODE_ACTION_IN_PROGRESS; + + char obj[10] = {0}; + sprintf(obj, "%d", pCompact->compactId); + + auditRecord(pReq, pMnode->clusterId, "killCompact", pCompact->dbname, obj, killCompactReq.sql, killCompactReq.sqlLen); + +_OVER: + if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + mError("failed to kill compact %" PRId32 " since %s", killCompactReq.compactId, terrstr()); + } + + tFreeSKillCompactReq(&killCompactReq); + sdbRelease(pMnode->pSdb, pCompact); + + return code; +} + +//update progress +static int32_t mndUpdateCompactProgress(SMnode *pMnode, SRpcMsg *pReq, int32_t compactId, SQueryCompactProgressRsp* rsp) { + void* pIter = NULL; + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == compactId && pDetail->vgId == rsp->vgId && pDetail->dnodeId == rsp->dnodeId) { + pDetail->newNumberFileset = rsp->numberFileset; + pDetail->newFinished = rsp->finished; + + sdbRelease(pMnode->pSdb, pDetail); + + return 0; + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + return -1; +} + +int32_t mndProcessQueryCompactRsp(SRpcMsg *pReq){ + SQueryCompactProgressRsp req = {0}; + if (tDeserializeSQueryCompactProgressRsp(pReq->pCont, pReq->contLen, &req) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + mDebug("compact:%d, receive query response, vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d", + req.compactId, req.vgId, req.dnodeId, req.numberFileset, req.finished); + + SMnode *pMnode = pReq->info.node; + int32_t code = -1; + + + if(mndUpdateCompactProgress(pMnode, pReq, req.compactId, &req) != 0){ + mError("compact:%d, failed to update progress, vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d", + req.compactId, req.vgId, req.dnodeId, req.numberFileset, req.finished); + return -1; + } + + return 0; +} + +//timer +void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact){ + void *pIter = NULL; + + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == pCompact->compactId) { + SEpSet epSet = {0}; + + SDnodeObj *pDnode = mndAcquireDnode(pMnode, pDetail->dnodeId); + if(pDnode == NULL) break; + addEpIntoEpSet(&epSet, pDnode->fqdn, pDnode->port); + mndReleaseDnode(pMnode, pDnode); + + SQueryCompactProgressReq req; + req.compactId = pDetail->compactId; + req.vgId = pDetail->vgId; + req.dnodeId = pDetail->dnodeId; + + int32_t contLen = tSerializeSQueryCompactProgressReq(NULL, 0, &req); + if (contLen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + continue; + } + + contLen += sizeof(SMsgHead); + + SMsgHead *pHead = rpcMallocCont(contLen); + if (pHead == NULL) { + sdbCancelFetch(pMnode->pSdb, pDetail); + sdbRelease(pMnode->pSdb, pDetail); + continue; + } + + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(pDetail->vgId); + + tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req); + + SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, + .contLen = contLen}; + + //rpcMsg.pCont = rpcMallocCont(contLen); + //if (rpcMsg.pCont == NULL) { + // return; + //} + + //memcpy(rpcMsg.pCont, pHead, contLen); + + rpcMsg.pCont = pHead; + + char detail[1024] = {0}; + int32_t len = snprintf(detail, sizeof(detail), "msgType:%s numOfEps:%d inUse:%d", TMSG_INFO(TDMT_VND_QUERY_COMPACT_PROGRESS), + epSet.numOfEps, epSet.inUse); + for (int32_t i = 0; i < epSet.numOfEps; ++i) { + len += snprintf(detail + len, sizeof(detail) - len, " ep:%d-%s:%u", i, epSet.eps[i].fqdn, + epSet.eps[i].port); + } + + mDebug("compact:%d, send update progress msg to %s", pDetail->compactId, detail); + + tmsgSendReq(&epSet, &rpcMsg); + } + + sdbRelease(pMnode->pSdb, pDetail); + } +} + +static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) { + bool needSave = false; + void* pIter = NULL; + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == compactId) { + mDebug("compact:%d, check save progress, vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d, " + "newNumberFileset:%d, newFinished:%d", + pDetail->compactId, pDetail->vgId, pDetail->dnodeId, pDetail->numberFileset, pDetail->finished, + pDetail->newNumberFileset, pDetail->newFinished); + + if(pDetail->numberFileset < pDetail->newNumberFileset || pDetail->finished < pDetail->newFinished) + needSave = true; + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + if(!needSave) { + mDebug("compact:%" PRId32 ", no need to save" , compactId); + return 0; + } + + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-compact-progress"); + if (pTrans == NULL) { + mError("trans:%" PRId32 ", failed to create since %s" , pTrans->id, terrstr()); + return -1; + } + mInfo("compact:%d, trans:%d, used to update compact progress.", compactId, pTrans->id); + + SCompactObj *pCompact = mndAcquireCompact(pMnode, compactId); + + pIter = NULL; + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == compactId) { + mInfo("compact:%d, trans:%d, check compact progress, vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d, " + "newNumberFileset:%d, newFinished:%d", + pDetail->compactId, pTrans->id, pDetail->vgId, pDetail->dnodeId, pDetail->numberFileset, pDetail->finished, + pDetail->newNumberFileset, pDetail->newFinished); + + pDetail->numberFileset = pDetail->newNumberFileset; + pDetail->finished = pDetail->newFinished; + + SSdbRaw *pCommitRaw = mndCompactDetailActionEncode(pDetail); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("compact:%d, trans:%d, failed to append commit log since %s", pDetail->compactId, pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + bool allFinished = true; + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if(pDetail->compactId == compactId){ + mInfo("compact:%d, trans:%d, check compact finished, vgId:%d, dnodeId:%d, numberFileset:%d, finished:%d", + pDetail->compactId, pTrans->id, pDetail->vgId, pDetail->dnodeId, pDetail->numberFileset, pDetail->finished); + + if(pDetail->numberFileset == -1 && pDetail->finished == -1){ + allFinished = false; + sdbRelease(pMnode->pSdb, pDetail); + break; + } + if (pDetail->numberFileset != -1 && pDetail->finished != -1 && + pDetail->numberFileset != pDetail->finished) { + allFinished = false; + sdbRelease(pMnode->pSdb, pDetail); + break; + } + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + if(allFinished){ + mInfo("compact:%d, all finished", pCompact->compactId); + while (1) { + SCompactDetailObj *pDetail = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT_DETAIL, pIter, (void **)&pDetail); + if (pIter == NULL) break; + + if (pDetail->compactId == pCompact->compactId) { + SSdbRaw *pCommitRaw = mndCompactDetailActionEncode(pDetail); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("compact:%d, trans:%d, failed to append commit log since %s", pDetail->compactId, pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); + } + + sdbRelease(pMnode->pSdb, pDetail); + } + + SSdbRaw *pCommitRaw = mndCompactActionEncode(pCompact); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("compact:%d, trans:%d, failed to append commit log since %s", compactId, pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); + } + + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("compact:%d, trans:%d, failed to prepare since %s", compactId, pTrans->id, terrstr()); + mndTransDrop(pTrans); + sdbRelease(pMnode->pSdb, pCompact); + return -1; + } + + sdbRelease(pMnode->pSdb, pCompact); + mndTransDrop(pTrans); + return 0; +} + +void mndCompactPullup(SMnode *pMnode) { + SSdb *pSdb = pMnode->pSdb; + SArray *pArray = taosArrayInit(sdbGetSize(pSdb, SDB_COMPACT), sizeof(int32_t)); + if (pArray == NULL) return; + + void *pIter = NULL; + while (1) { + SCompactObj *pCompact = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact); + if (pIter == NULL) break; + taosArrayPush(pArray, &pCompact->compactId); + sdbRelease(pSdb, pCompact); + } + + for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { + mInfo("begin to pull up"); + int32_t *pCompactId = taosArrayGet(pArray, i); + SCompactObj *pCompact = mndAcquireCompact(pMnode, *pCompactId); + if (pCompact != NULL) { + mInfo("compact:%d, begin to pull up", pCompact->compactId); + mndCompactSendProgressReq(pMnode, pCompact); + mndSaveCompactProgress(pMnode, pCompact->compactId); + } + mndReleaseCompact(pMnode, pCompact); + } + taosArrayDestroy(pArray); +} + +static int32_t mndProcessCompactTimer(SRpcMsg *pReq) { + mTrace("start to process compact timer"); + mndCompactPullup(pReq->info.node); + return 0; +} diff --git a/source/dnode/mnode/impl/src/mndCompactDetail.c b/source/dnode/mnode/impl/src/mndCompactDetail.c new file mode 100644 index 0000000000..a1c0e95c20 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndCompactDetail.c @@ -0,0 +1,300 @@ +/* + * 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 "mndCompactDetail.h" +#include "mndTrans.h" +#include "mndShow.h" +#include "mndDb.h" + +#define MND_COMPACT_VER_NUMBER 1 + +int32_t mndInitCompactDetail(SMnode *pMnode) { + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_COMPACT_DETAIL, mndRetrieveCompactDetail); + + SSdbTable table = { + .sdbType = SDB_COMPACT_DETAIL, + .keyType = SDB_KEY_INT64, + .encodeFp = (SdbEncodeFp)mndCompactDetailActionEncode, + .decodeFp = (SdbDecodeFp)mndCompactDetailActionDecode, + .insertFp = (SdbInsertFp)mndCompactDetailActionInsert, + .updateFp = (SdbUpdateFp)mndCompactDetailActionUpdate, + .deleteFp = (SdbDeleteFp)mndCompactDetailActionDelete, + }; + + return sdbSetTable(pMnode->pSdb, table); +} + +void mndCleanupCompactDetail(SMnode *pMnode) { + mDebug("mnd compact detail cleanup"); +} + +int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows){ + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + SCompactDetailObj *pCompactDetail = NULL; + char *sep = NULL; + SDbObj *pDb = NULL; + + if (strlen(pShow->db) > 0) { + sep = strchr(pShow->db, '.'); + if (sep && ((0 == strcmp(sep + 1, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcmp(sep + 1, TSDB_PERFORMANCE_SCHEMA_DB))))) { + sep++; + } else { + pDb = mndAcquireDb(pMnode, pShow->db); + if (pDb == NULL) return terrno; + } + } + + while(numOfRows < rows){ + pShow->pIter = sdbFetch(pSdb, SDB_COMPACT_DETAIL, pShow->pIter, (void **)&pCompactDetail); + if (pShow->pIter == NULL) break; + + SColumnInfoData *pColInfo; + SName n; + int32_t cols = 0; + + char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0}; + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->compactId, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->dnodeId, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->finished, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false); + + numOfRows++; + sdbRelease(pSdb, pCompactDetail); + } + + pShow->numOfRows += numOfRows; + mndReleaseDb(pMnode, pDb); + return numOfRows; +} + +void tFreeCompactDetailObj(SCompactDetailObj *pCompact) { +} + +int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDetailObj *pObj) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + + if (tEncodeI32(&encoder, pObj->compactDetailId) < 0) return -1; + if (tEncodeI32(&encoder, pObj->compactId) < 0) return -1; + if (tEncodeI32(&encoder, pObj->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pObj->dnodeId) < 0) return -1; + if (tEncodeI32(&encoder, pObj->numberFileset) < 0) return -1; + if (tEncodeI32(&encoder, pObj->finished) < 0) return -1; + if (tEncodeI64(&encoder, pObj->startTime) < 0) return -1; + if (tEncodeI32(&encoder, pObj->newNumberFileset) < 0) return -1; + if (tEncodeI32(&encoder, pObj->newFinished) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailObj *pObj) { + int8_t ex = 0; + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + + if (tDecodeI32(&decoder, &pObj->compactDetailId) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->compactId) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->vgId) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->dnodeId) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->numberFileset) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->finished) < 0) return -1; + if (tDecodeI64(&decoder, &pObj->startTime) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->newNumberFileset) < 0) return -1; + if (tDecodeI32(&decoder, &pObj->newFinished) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +SSdbRaw *mndCompactDetailActionEncode(SCompactDetailObj *pCompact) { + terrno = TSDB_CODE_SUCCESS; + + void *buf = NULL; + SSdbRaw *pRaw = NULL; + + int32_t tlen = tSerializeSCompactDetailObj(NULL, 0, pCompact); + if (tlen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t size = sizeof(int32_t) + tlen; + pRaw = sdbAllocRaw(SDB_COMPACT_DETAIL, MND_COMPACT_VER_NUMBER, size); + if (pRaw == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + buf = taosMemoryMalloc(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + tlen = tSerializeSCompactDetailObj(buf, tlen, pCompact); + if (tlen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t dataPos = 0; + SDB_SET_INT32(pRaw, dataPos, tlen, OVER); + SDB_SET_BINARY(pRaw, dataPos, buf, tlen, OVER); + SDB_SET_DATALEN(pRaw, dataPos, OVER); + + +OVER: + taosMemoryFreeClear(buf); + if (terrno != TSDB_CODE_SUCCESS) { + mError("compact detail:%" PRId32 ", failed to encode to raw:%p since %s", pCompact->compactId, pRaw, terrstr()); + sdbFreeRaw(pRaw); + return NULL; + } + + mTrace("compact detail:%" PRId32 ", encode to raw:%p, row:%p", pCompact->compactId, pRaw, pCompact); + return pRaw; +} + +SSdbRow *mndCompactDetailActionDecode(SSdbRaw *pRaw) { + SSdbRow *pRow = NULL; + SCompactDetailObj *pCompact = NULL; + void *buf = NULL; + terrno = TSDB_CODE_SUCCESS; + + int8_t sver = 0; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) { + goto OVER; + } + + if (sver != MND_COMPACT_VER_NUMBER) { + terrno = TSDB_CODE_SDB_INVALID_DATA_VER; + mError("compact detail read invalid ver, data ver: %d, curr ver: %d", sver, MND_COMPACT_VER_NUMBER); + goto OVER; + } + + pRow = sdbAllocRow(sizeof(SCompactObj)); + if (pRow == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + pCompact = sdbGetRowObj(pRow); + if (pCompact == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + int32_t tlen; + int32_t dataPos = 0; + SDB_GET_INT32(pRaw, dataPos, &tlen, OVER); + buf = taosMemoryMalloc(tlen + 1); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + SDB_GET_BINARY(pRaw, dataPos, buf, tlen, OVER); + + if (tDeserializeSCompactDetailObj(buf, tlen, pCompact) < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto OVER; + } + + //taosInitRWLatch(&pView->lock); + +OVER: + taosMemoryFreeClear(buf); + if (terrno != TSDB_CODE_SUCCESS) { + mError("compact detail:%" PRId32 ", failed to decode from raw:%p since %s", pCompact->compactId, pRaw, terrstr()); + taosMemoryFreeClear(pRow); + return NULL; + } + + mTrace("compact detail:%" PRId32 ", decode from raw:%p, row:%p", pCompact->compactId, pRaw, pCompact); + return pRow; +} + +int32_t mndCompactDetailActionInsert(SSdb *pSdb, SCompactDetailObj *pCompact) { + mTrace("compact detail:%" PRId32 ", perform insert action", pCompact->compactId); + return 0; +} + +int32_t mndCompactDetailActionDelete(SSdb *pSdb, SCompactDetailObj *pCompact) { + mTrace("compact detail:%" PRId32 ", perform insert action", pCompact->compactId); + tFreeCompactDetailObj(pCompact); + return 0; +} + +int32_t mndCompactDetailActionUpdate(SSdb *pSdb, SCompactDetailObj *pOldCompact, SCompactDetailObj *pNewCompact) { + mTrace("compact detail:%" PRId32 ", perform update action, old row:%p new row:%p", + pOldCompact->compactId, pOldCompact, pNewCompact); + + + pOldCompact->numberFileset = pNewCompact->numberFileset; + pOldCompact->finished = pNewCompact->finished; + + return 0; +} + +int32_t mndAddCompactDetailToTran(SMnode *pMnode, STrans *pTrans, SCompactObj* pCompact, SVgObj *pVgroup, + SVnodeGid *pVgid, int32_t index){ + SCompactDetailObj compactDetail = {0}; + compactDetail.compactDetailId = index; + compactDetail.compactId = pCompact->compactId; + compactDetail.vgId = pVgroup->vgId; + compactDetail.dnodeId = pVgid->dnodeId; + compactDetail.startTime = taosGetTimestampMs(); + compactDetail.numberFileset = -1; + compactDetail.finished = -1; + compactDetail.newNumberFileset = -1; + compactDetail.newFinished = -1; + + mInfo("compact:%d, add compact detail to trans, index:%d, vgId:%d, dnodeId:%d", + compactDetail.compactId, compactDetail.compactDetailId, compactDetail.vgId, compactDetail.dnodeId); + + SSdbRaw *pVgRaw = mndCompactDetailActionEncode(&compactDetail); + if (pVgRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + (void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); + + return 0; +} \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index fdfec610d9..38a92b43e7 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -42,6 +42,8 @@ #include "mndUser.h" #include "mndVgroup.h" #include "mndView.h" +#include "mndCompact.h" +#include "mndCompactDetail.h" static inline int32_t mndAcquireRpc(SMnode *pMnode) { int32_t code = 0; @@ -112,6 +114,16 @@ static void mndPullupTrans(SMnode *pMnode) { } } +static void mndPullupCompacts(SMnode *pMnode) { + mTrace("pullup compact timer msg"); + int32_t contLen = 0; + void *pReq = mndBuildTimerMsg(&contLen); + if (pReq != NULL) { + SRpcMsg rpcMsg = {.msgType = TDMT_MND_COMPACT_TIMER, .pCont = pReq, .contLen = contLen}; + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + } +} + static void mndPullupTtl(SMnode *pMnode) { mTrace("pullup ttl"); int32_t contLen = 0; @@ -287,6 +299,10 @@ static void *mndThreadFp(void *param) { mndPullupTrans(pMnode); } + if (sec % tsCompactPullupInterval == 0) { + mndPullupCompacts(pMnode); + } + if (sec % tsMqRebalanceInterval == 0) { mndCalMqRebalance(pMnode); } @@ -462,6 +478,8 @@ static int32_t mndInitSteps(SMnode *pMnode) { if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; if (mndAllocStep(pMnode, "mnode-view", mndInitView, mndCleanupView) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-compact", mndInitCompact, mndCleanupCompact) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-compact-detail", mndInitCompactDetail, mndCleanupCompactDetail) != 0) return -1; if (mndAllocStep(pMnode, "mnode-sdb", mndOpenSdb, NULL) != 0) return -1; if (mndAllocStep(pMnode, "mnode-profile", mndInitProfile, mndCleanupProfile) != 0) return -1; if (mndAllocStep(pMnode, "mnode-show", mndInitShow, mndCleanupShow) != 0) return -1; @@ -693,7 +711,8 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { _OVER: if (pMsg->msgType == TDMT_MND_TMQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER || pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER || - pMsg->msgType == TDMT_MND_TRIM_DB_TIMER || pMsg->msgType == TDMT_MND_UPTIME_TIMER) { + pMsg->msgType == TDMT_MND_TRIM_DB_TIMER || pMsg->msgType == TDMT_MND_UPTIME_TIMER || + pMsg->msgType == TDMT_MND_COMPACT_TIMER) { mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored, pMnode->stopped, state.restored, syncStr(state.state)); return -1; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index bdf7df25e1..8e7e72aa0e 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -17,6 +17,7 @@ #include "mndShow.h" #include "mndPrivilege.h" #include "systable.h" +#include "mndUser.h" #define SHOW_STEP_SIZE 100 #define SHOW_COLS_STEP_SIZE 4096 @@ -118,6 +119,10 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_PRIVILEGES; } else if (strncasecmp(name, TSDB_INS_TABLE_VIEWS, len) == 0) { type = TSDB_MGMT_TABLE_VIEWS; + } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, len) == 0) { + type = TSDB_MGMT_TABLE_COMPACT; + } else if (strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, len) == 0) { + type = TSDB_MGMT_TABLE_COMPACT_DETAIL; } else { mError("invalid show name:%s len:%d", name, len); } @@ -206,7 +211,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { return -1; } - mDebug("mndProcessRetrieveSysTableReq tb:%s", retrieveReq.tb); + mDebug("process to retrieve systable req db:%s, tb:%s", retrieveReq.db, retrieveReq.tb); if (retrieveReq.showId == 0) { STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb)); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index a495ccd28f..f8fba143f8 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -16,12 +16,9 @@ #include "mndStream.h" #include "audit.h" #include "mndDb.h" -#include "mndDnode.h" -#include "mndMnode.h" #include "mndPrivilege.h" #include "mndScheduler.h" #include "mndShow.h" -#include "mndSnode.h" #include "mndStb.h" #include "mndTrans.h" #include "mndVgroup.h" @@ -34,13 +31,6 @@ #define MND_STREAM_RESERVE_SIZE 64 #define MND_STREAM_MAX_NUM 60 -#define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint" -#define MND_STREAM_PAUSE_NAME "stream-pause" -#define MND_STREAM_RESUME_NAME "stream-resume" -#define MND_STREAM_DROP_NAME "stream-drop" -#define MND_STREAM_TASK_RESET_NAME "stream-task-reset" -#define MND_STREAM_TASK_UPDATE_NAME "stream-task-update" - typedef struct SNodeEntry { int32_t nodeId; bool stageUpdated; // the stage has been updated due to the leader/follower change or node reboot. @@ -705,10 +695,10 @@ static int32_t mndPersistTaskDropReq(SMnode *pMnode, STrans *pTrans, SStreamTask pReq->streamId = pTask->id.streamId; STransAction action = {0}; - SEpSet epset = {0}; - if(pTask->info.nodeId == SNODE_HANDLE){ + SEpSet epset = {0}; + if (pTask->info.nodeId == SNODE_HANDLE) { SSnodeObj *pObj = NULL; - void *pIter = NULL; + void *pIter = NULL; while (1) { pIter = sdbFetch(pMnode->pSdb, SDB_SNODE, pIter, (void **)&pObj); if (pIter == NULL) { @@ -718,10 +708,16 @@ static int32_t mndPersistTaskDropReq(SMnode *pMnode, STrans *pTrans, SStreamTask addEpIntoEpSet(&epset, pObj->pDnode->fqdn, pObj->pDnode->port); sdbRelease(pMnode->pSdb, pObj); } - }else{ + } else { SVgObj *pVgObj = mndAcquireVgroup(pMnode, pTask->info.nodeId); - epset = mndGetVgroupEpset(pMnode, pVgObj); - mndReleaseVgroup(pMnode, pVgObj); + if (pVgObj != NULL) { + epset = mndGetVgroupEpset(pMnode, pVgObj); + mndReleaseVgroup(pMnode, pVgObj); + } else { + mDebug("orphaned task:0x%x need to be dropped, nodeId:%d, no redo action", pTask->id.taskId, pTask->info.nodeId); + taosMemoryFree(pReq); + return 0; + } } // The epset of nodeId of this task may have been expired now, let's use the newest epset from mnode. @@ -834,7 +830,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { goto _OVER; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pReq, "create-stream"); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_CREATE_NAME); if (pTrans == NULL) { mError("stream:%s, failed to create since %s", createStreamReq.name, terrstr()); goto _OVER; @@ -842,11 +838,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name); - mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); + mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { mndTransDrop(pTrans); goto _OVER; } + // create stb for stream if (createStreamReq.createStb == STREAM_CREATE_STABLE_TRUE && mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) { @@ -933,7 +930,8 @@ int64_t mndStreamGenChkpId(SMnode *pMnode) { if (pIter == NULL) break; maxChkpId = TMAX(maxChkpId, pStream->checkpointId); - mDebug("stream %p checkpoint %" PRId64 "", pStream, pStream->checkpointId); + mDebug("stream:%p, %s id:%" PRIx64 "checkpoint %" PRId64 "", pStream, pStream->name, pStream->uid, + pStream->checkpointId); sdbRelease(pSdb, pStream); } @@ -1023,7 +1021,7 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre return -1; } - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); + bool conflict = streamTransConflictOtherTrans(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, true); if (conflict) { mndAddtoCheckpointWaitingList(pStream, checkpointId); mWarn("checkpoint conflict with other trans in %s, ignore the checkpoint for stream:%s %" PRIx64, pStream->sourceDb, @@ -1031,14 +1029,14 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, NULL, MND_STREAM_CHECKPOINT_NAME); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, MND_STREAM_CHECKPOINT_NAME); if (pTrans == NULL) { return -1; } - mndStreamRegisterTrans(pTrans, MND_STREAM_CHECKPOINT_NAME, pStream->sourceDb, pStream->targetDb); + mndStreamRegisterTrans(pTrans, MND_STREAM_CHECKPOINT_NAME, pStream->uid); - mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName); if (mndTrancCheckConflict(pMnode, pTrans) != 0) { mError("failed to checkpoint of stream name%s, checkpointId: %" PRId64 ", reason:%s", pStream->name, checkpointId, tstrerror(TSDB_CODE_MND_TRANS_CONFLICT)); @@ -1375,14 +1373,14 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { } // check if it is conflict with other trans in both sourceDb and targetDb. - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); + bool conflict = streamTransConflictOtherTrans(pMnode, pStream->uid, MND_STREAM_DROP_NAME, true); if (conflict) { sdbRelease(pMnode->pSdb, pStream); tFreeMDropStreamReq(&dropReq); return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, MND_STREAM_DROP_NAME); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_DROP_NAME); if (pTrans == NULL) { mError("stream:%s, failed to drop since %s", dropReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -1392,7 +1390,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { mInfo("trans:%d used to drop stream:%s", pTrans->id, dropReq.name); - mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { sdbRelease(pMnode->pSdb, pStream); mndTransDrop(pTrans); @@ -1400,7 +1398,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } - int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pStream->sourceDb, pStream->targetDb); + int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_DROP_NAME, pStream->uid); // drop all tasks if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { @@ -1658,6 +1656,7 @@ static void setTaskAttrInResBlock(SStreamObj *pStream, SStreamTask *pTask, SSDat STaskStatusEntry *pe = taosHashGet(execInfo.pTaskMap, &id, sizeof(id)); if (pe == NULL) { + mError("task:0x%" PRIx64 " not exists in vnode, no valid status/stage info", id.taskId); return; } @@ -1858,7 +1857,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) { } // check if it is conflict with other trans in both sourceDb and targetDb. - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); + bool conflict = streamTransConflictOtherTrans(pMnode, pStream->uid, MND_STREAM_PAUSE_NAME, true); if (conflict) { sdbRelease(pMnode->pSdb, pStream); return -1; @@ -1870,7 +1869,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) { return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "pause-stream"); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_PAUSE_NAME); if (pTrans == NULL) { mError("stream:%s failed to pause stream since %s", pauseReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -1879,14 +1878,14 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) { mInfo("trans:%d, used to pause stream:%s", pTrans->id, pauseReq.name); - mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { sdbRelease(pMnode->pSdb, pStream); mndTransDrop(pTrans); return -1; } - int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_PAUSE_NAME, pStream->sourceDb, pStream->targetDb); + int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_PAUSE_NAME, pStream->uid); // if nodeUpdate happened, not send pause trans if (mndPauseAllStreamTasks(pMnode, pTrans, pStream) < 0) { @@ -1993,13 +1992,13 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { } // check if it is conflict with other trans in both sourceDb and targetDb. - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); + bool conflict = streamTransConflictOtherTrans(pMnode, pStream->uid, MND_STREAM_RESUME_NAME, true); if (conflict) { sdbRelease(pMnode->pSdb, pStream); return -1; } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, MND_STREAM_RESUME_NAME); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, MND_STREAM_RESUME_NAME); if (pTrans == NULL) { mError("stream:%s, failed to resume stream since %s", pauseReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -2008,14 +2007,14 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { mInfo("trans:%d used to resume stream:%s", pTrans->id, pauseReq.name); - mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { sdbRelease(pMnode->pSdb, pStream); mndTransDrop(pTrans); return -1; } - int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_RESUME_NAME, pStream->sourceDb, pStream->targetDb); + int32_t code = mndStreamRegisterTrans(pTrans, MND_STREAM_RESUME_NAME, pStream->uid); // resume all tasks if (mndResumeAllStreamTasks(pTrans, pMnode, pStream, pauseReq.igUntreated) < 0) { @@ -2652,7 +2651,7 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) { } STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, const char *name, const char *pMsg) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, name); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, name); if (pTrans == NULL) { mError("failed to build trans:%s, reason: %s", name, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -2661,7 +2660,7 @@ STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, const mDebug("s-task:0x%" PRIx64 " start to build trans %s", pStream->uid, pMsg); - mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { terrno = TSDB_CODE_MND_TRANS_CONFLICT; mError("failed to build trans:%s for stream:0x%" PRIx64 " code:%s", name, pStream->uid, tstrerror(terrno)); @@ -2754,7 +2753,10 @@ int32_t killActiveCheckpointTrans(SMnode *pMnode, const char *pDBName, size_t le STrans *pTrans = mndAcquireTrans(pMnode, pTransInfo->transId); if (pTrans != NULL) { - mInfo("kill checkpoint transId:%d in Db:%s", pTransInfo->transId, pDBName); + char* pDupDBName = strndup(pDBName, len); + mInfo("kill checkpoint transId:%d in Db:%s", pTransInfo->transId, pDupDBName); + taosMemoryFree(pDupDBName); + mndKillTrans(pMnode, pTrans); mndReleaseTrans(pMnode, pTrans); } @@ -2780,7 +2782,7 @@ static int32_t mndResetStatusFromCheckpoint(SMnode *pMnode, int32_t transId) { break; } - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, false); + bool conflict = streamTransConflictOtherTrans(pMnode, pStream->uid, MND_STREAM_TASK_RESET_NAME, false); if (conflict) { mError("stream:%s other trans exists in DB:%s & %s failed to start reset-status trans", pStream->name, pStream->sourceDb, pStream->targetDb); diff --git a/source/dnode/mnode/impl/src/mndStreamTrans.c b/source/dnode/mnode/impl/src/mndStreamTrans.c index fa36d69d6e..0db3cb0a8a 100644 --- a/source/dnode/mnode/impl/src/mndStreamTrans.c +++ b/source/dnode/mnode/impl/src/mndStreamTrans.c @@ -23,21 +23,17 @@ typedef struct SKeyInfo { static int32_t clearFinishedTrans(SMnode* pMnode); -int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pName, const char* pSrcDb, const char* pDstDb) { - SStreamTransInfo info = {.transId = pTrans->id, .startTime = taosGetTimestampMs(), .name = pName}; - taosHashPut(execInfo.transMgmt.pDBTrans, pSrcDb, strlen(pSrcDb), &info, sizeof(SStreamTransInfo)); - - if (strcmp(pSrcDb, pDstDb) != 0) { - taosHashPut(execInfo.transMgmt.pDBTrans, pDstDb, strlen(pDstDb), &info, sizeof(SStreamTransInfo)); - } - +int32_t mndStreamRegisterTrans(STrans* pTrans, const char* pTransName, int64_t streamUid) { + SStreamTransInfo info = { + .transId = pTrans->id, .startTime = taosGetTimestampMs(), .name = pTransName, .streamUid = streamUid}; + taosHashPut(execInfo.transMgmt.pDBTrans, &streamUid, sizeof(streamUid), &info, sizeof(SStreamTransInfo)); return 0; } int32_t clearFinishedTrans(SMnode* pMnode) { size_t keyLen = 0; - SArray* pList = taosArrayInit(4, sizeof(SKeyInfo)); void* pIter = NULL; + SArray* pList = taosArrayInit(4, sizeof(SKeyInfo)); while ((pIter = taosHashIterate(execInfo.transMgmt.pDBTrans, pIter)) != NULL) { SStreamTransInfo* pEntry = (SStreamTransInfo*)pIter; @@ -48,8 +44,7 @@ int32_t clearFinishedTrans(SMnode* pMnode) { void* pKey = taosHashGetKey(pEntry, &keyLen); // key is the name of src/dst db name SKeyInfo info = {.pKey = pKey, .keyLen = keyLen}; - - mDebug("transId:%d %s startTs:%" PRId64 "cleared due to finished", pEntry->transId, pEntry->name, + mDebug("transId:%d %s startTs:%" PRId64 " cleared since finished", pEntry->transId, pEntry->name, pEntry->startTime); taosArrayPush(pList, &info); } else { @@ -70,7 +65,7 @@ int32_t clearFinishedTrans(SMnode* pMnode) { return 0; } -bool streamTransConflictOtherTrans(SMnode* pMnode, const char* pSrcDb, const char* pDstDb, bool lock) { +bool streamTransConflictOtherTrans(SMnode* pMnode, int64_t streamUid, const char* pTransName, bool lock) { if (lock) { taosThreadMutexLock(&execInfo.lock); } @@ -85,22 +80,26 @@ bool streamTransConflictOtherTrans(SMnode* pMnode, const char* pSrcDb, const cha clearFinishedTrans(pMnode); - SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, pSrcDb, strlen(pSrcDb)); + SStreamTransInfo *pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, &streamUid, sizeof(streamUid)); if (pEntry != NULL) { - if (lock) { - taosThreadMutexUnlock(&execInfo.lock); - } - mWarn("conflict with other transId:%d in Db:%s, trans:%s", pEntry->transId, pSrcDb, pEntry->name); - return true; - } + SStreamTransInfo tInfo = *pEntry; - pEntry = taosHashGet(execInfo.transMgmt.pDBTrans, pDstDb, strlen(pDstDb)); - if (pEntry != NULL) { if (lock) { taosThreadMutexUnlock(&execInfo.lock); } - mWarn("conflict with other transId:%d in Db:%s, trans:%s", pEntry->transId, pSrcDb, pEntry->name); - return true; + + if (strcmp(tInfo.name, MND_STREAM_CHECKPOINT_NAME) == 0) { + if (strcmp(pTransName, MND_STREAM_DROP_NAME) != 0) { + mWarn("conflict with other transId:%d streamUid:%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamUid, + tInfo.name); + return true; + } + } else if ((strcmp(tInfo.name, MND_STREAM_CREATE_NAME) == 0) || + (strcmp(tInfo.name, MND_STREAM_DROP_NAME) == 0)) { + mWarn("conflict with other transId:%d streamUid:%" PRIx64 ", trans:%s", tInfo.transId, tInfo.streamUid, + tInfo.name); + return true; + } } if (lock) { diff --git a/source/dnode/mnode/impl/test/acct/acct.cpp b/source/dnode/mnode/impl/test/acct/acct.cpp index 1f59a7fcca..a3f9362a4a 100644 --- a/source/dnode/mnode/impl/test/acct/acct.cpp +++ b/source/dnode/mnode/impl/test/acct/acct.cpp @@ -33,6 +33,7 @@ TEST_F(MndTestAcct, 01_Create_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); + rpcFreeCont(pRsp->pCont); } TEST_F(MndTestAcct, 02_Alter_Acct) { @@ -43,6 +44,7 @@ TEST_F(MndTestAcct, 02_Alter_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); + rpcFreeCont(pRsp->pCont); } TEST_F(MndTestAcct, 03_Drop_Acct) { @@ -53,4 +55,5 @@ TEST_F(MndTestAcct, 03_Drop_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); + rpcFreeCont(pRsp->pCont); } diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index 9a2372d904..ed059a2994 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -253,12 +253,14 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildCreateDbReq(dbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { pReq = BuildCreateBSmaStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); } @@ -269,12 +271,14 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildCreateBSmaStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { pReq = BuildDropStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 0); } @@ -283,5 +287,6 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildDropStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } } diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index 1adbb87e19..aa12c107a1 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -155,6 +155,7 @@ void* MndTestStb::BuildAlterStbAddTagReq(const char* stbname, const char* tagnam tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -176,6 +177,7 @@ void* MndTestStb::BuildAlterStbDropTagReq(const char* stbname, const char* tagna tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -204,6 +206,7 @@ void* MndTestStb::BuildAlterStbUpdateTagNameReq(const char* stbname, const char* tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -226,6 +229,7 @@ void* MndTestStb::BuildAlterStbUpdateTagBytesReq(const char* stbname, const char tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -247,6 +251,7 @@ void* MndTestStb::BuildAlterStbAddColumnReq(const char* stbname, const char* col tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -268,6 +273,7 @@ void* MndTestStb::BuildAlterStbDropColumnReq(const char* stbname, const char* co tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -290,6 +296,7 @@ void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const c tSerializeSMAlterStbReq(pHead, contLen, &req); *pContLen = contLen; + taosArrayDestroy(req.pFields); return pHead; } @@ -303,6 +310,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -311,6 +319,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -334,6 +343,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { STableMetaRsp metaRsp = {0}; tDeserializeSTableMetaRsp(pMsg->pCont, pMsg->contLen, &metaRsp); + rpcFreeCont(pMsg->pCont); EXPECT_STREQ(metaRsp.dbFName, dbname); EXPECT_STREQ(metaRsp.tbName, "stb"); @@ -410,6 +420,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pHead, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -423,6 +434,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -436,6 +448,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -443,30 +456,35 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddTagReq("1.d3.stb", "tag4", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DB_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddTagReq("1.d2.stb3", "tag4", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddTagReq(stbname, "tag3", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddTagReq(stbname, "col1", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { @@ -474,6 +492,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); } @@ -483,6 +502,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -495,18 +515,21 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) { void* pReq = BuildCreateDbReq(dbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildCreateStbReq(stbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbDropTagReq(stbname, "tag5", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { @@ -514,6 +537,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -524,6 +548,7 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -536,41 +561,48 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) { void* pReq = BuildCreateDbReq(dbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildCreateStbReq(stbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag5", "tag6", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "col1", "tag6", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "col1", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagNameReq(stbname, "tag3", "tag2", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { @@ -578,6 +610,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -588,6 +621,7 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -600,36 +634,42 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) { void* pReq = BuildCreateDbReq(dbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildCreateStbReq(stbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag5", 12, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag1", 13, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 8, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateTagBytesReq(stbname, "tag3", 20, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -640,6 +680,7 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -653,6 +694,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -660,30 +702,35 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddColumnReq("1.d7.stb", "tag4", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DB_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddColumnReq("1.d6.stb3", "tag4", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_STB_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddColumnReq(stbname, "tag3", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TAG_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbAddColumnReq(stbname, "col1", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_ALREADY_EXIST); + rpcFreeCont(pRsp->pCont); } { @@ -691,6 +738,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -701,6 +749,7 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -713,30 +762,35 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { void* pReq = BuildCreateDbReq(dbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildCreateStbReq(stbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbDropColumnReq(stbname, "col4", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbDropColumnReq(stbname, "col1", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbDropColumnReq(stbname, "ts", &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_ALTER_OPTION); + rpcFreeCont(pRsp->pCont); } { @@ -744,6 +798,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { @@ -751,6 +806,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -761,6 +817,7 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } @@ -773,42 +830,49 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { void* pReq = BuildCreateDbReq(dbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildCreateStbReq(stbname, &contLen); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col5", 12, &contLen, 0); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "ts", 8, &contLen, 0); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_STB_OPTION); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 8, &contLen, 0); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", TSDB_MAX_BYTES_PER_ROW, &contLen, 0); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_ROW_BYTES); + rpcFreeCont(pRsp->pCont); } { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col1", 20, &contLen, 0); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -818,6 +882,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { void* pReq = BuildAlterStbUpdateColumnBytesReq(stbname, "col_not_exist", 20, &contLen, 1); SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_COLUMN_NOT_EXIST); + rpcFreeCont(pRsp->pCont); test.SendShowReq(TSDB_MGMT_TABLE_STB, "ins_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); @@ -828,5 +893,6 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); + rpcFreeCont(pRsp->pCont); } } diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index 0a20dcfd09..e1beaaa910 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -150,7 +150,9 @@ typedef enum { SDB_IDX = 21, SDB_VIEW = 22, SDB_STREAM_SEQ = 23, - SDB_MAX = 24 + SDB_COMPACT = 24, + SDB_COMPACT_DETAIL = 25, + SDB_MAX = 26 } ESdbType; typedef struct SSdbRaw { @@ -170,11 +172,11 @@ typedef struct SSdbRow { } SSdbRow; typedef struct SSdb { - SMnode * pMnode; - SWal * pWal; + SMnode *pMnode; + SWal *pWal; int64_t sync; - char * currDir; - char * tmpDir; + char *currDir; + char *tmpDir; int64_t commitIndex; int64_t commitTerm; int64_t commitConfig; @@ -184,7 +186,7 @@ typedef struct SSdb { int64_t tableVer[SDB_MAX]; int64_t maxId[SDB_MAX]; EKeyType keyTypes[SDB_MAX]; - SHashObj * hashObjs[SDB_MAX]; + SHashObj *hashObjs[SDB_MAX]; TdThreadRwlock locks[SDB_MAX]; SdbInsertFp insertFps[SDB_MAX]; SdbUpdateFp updateFps[SDB_MAX]; @@ -199,7 +201,7 @@ typedef struct SSdb { typedef struct SSdbIter { TdFilePtr file; int64_t total; - char * name; + char *name; } SSdbIter; typedef struct { @@ -216,8 +218,8 @@ typedef struct { typedef struct SSdbOpt { const char *path; - SMnode * pMnode; - SWal * pWal; + SMnode *pMnode; + SWal *pWal; int64_t sync; } SSdbOpt; @@ -394,7 +396,7 @@ int32_t sdbGetRawSoftVer(SSdbRaw *pRaw, int8_t *sver); int32_t sdbGetRawTotalSize(SSdbRaw *pRaw); SSdbRow *sdbAllocRow(int32_t objSize); -void * sdbGetRowObj(SSdbRow *pRow); +void *sdbGetRowObj(SSdbRow *pRow); void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc); int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *term, int64_t *config); diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 5f275f912d..1d2e2de17d 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -64,7 +64,11 @@ const char *sdbTableName(ESdbType type) { return "idx"; case SDB_VIEW: return "view"; - default: + case SDB_COMPACT: + return "compact"; + case SDB_COMPACT_DETAIL: + return "compact_detail"; + default: return "undefine"; } } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 380be1dd38..21d813c7c0 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -66,6 +66,7 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer } else { sndDebug("s-task:%s state:%p", pTask->id.idStr, pTask->pState); } + int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTask->upstreamInfo.pList); SReadHandle handle = { diff --git a/source/dnode/snode/src/snodeInitApi.c b/source/dnode/snode/src/snodeInitApi.c index d1e0aefca0..c605a8373e 100644 --- a/source/dnode/snode/src/snodeInitApi.c +++ b/source/dnode/snode/src/snodeInitApi.c @@ -14,8 +14,8 @@ */ #include "storageapi.h" -#include "tstreamUpdate.h" #include "streamState.h" +#include "tstreamUpdate.h" static void initStateStoreAPI(SStateStore* pStore); static void initFunctionStateStore(SFunctionStateStore* pStore); @@ -100,9 +100,10 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->streamStateClose = streamStateClose; pStore->streamStateBegin = streamStateBegin; pStore->streamStateCommit = streamStateCommit; - pStore->streamStateDestroy= streamStateDestroy; + pStore->streamStateDestroy = streamStateDestroy; pStore->streamStateDeleteCheckPoint = streamStateDeleteCheckPoint; pStore->streamStateReloadInfo = streamStateReloadInfo; + pStore->streamStateCopyBackend = streamStateCopyBackend; } void initFunctionStateStore(SFunctionStateStore* pStore) { diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 114051f02b..2c57eb3cb5 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -93,6 +93,7 @@ IF (TD_VNODE_PLUGINS) vnode PRIVATE ${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompact.c + ${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/tsdbCompactMonitor.c ${TD_ENTERPRISE_DIR}/src/plugins/vnode/src/vnodeCompact.c ) ENDIF () diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 74d62da5c5..9a4e2edf8d 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -154,8 +154,7 @@ typedef struct STsdbReader STsdbReader; #define CACHESCAN_RETRIEVE_LAST 0x8 int32_t tsdbReaderOpen2(void *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables, - SSDataBlock *pResBlock, void **ppReader, const char *idstr, bool countOnly, - SHashObj **pIgnoreTables); + SSDataBlock *pResBlock, void **ppReader, const char *idstr, SHashObj **pIgnoreTables); int32_t tsdbSetTableList2(STsdbReader *pReader, const void *pTableList, int32_t num); void tsdbReaderSetId2(STsdbReader *pReader, const char *idstr); void tsdbReaderClose2(STsdbReader *pReader); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 95982abfbe..d347ce30d8 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -74,6 +74,7 @@ typedef struct SDiskDataBuilder SDiskDataBuilder; typedef struct SBlkInfo SBlkInfo; typedef struct STsdbDataIter2 STsdbDataIter2; typedef struct STsdbFilterInfo STsdbFilterInfo; +typedef struct STFileSystem STFileSystem; #define TSDBROW_ROW_FMT ((int8_t)0x0) #define TSDBROW_COL_FMT ((int8_t)0x1) @@ -392,6 +393,8 @@ struct STsdb { TdThreadMutex pgMutex; struct STFileSystem *pFS; // new SRocksCache rCache; + // compact monitor + struct SCompMonitor *pCompMonitor; }; struct TSDBKEY { @@ -676,8 +679,6 @@ struct SDelFWriter { }; #include "tarray2.h" -// #include "tsdbFS2.h" -// struct STFileSet; typedef struct STFileSet STFileSet; typedef TARRAY2(STFileSet *) TFileSetArray; @@ -786,20 +787,25 @@ typedef struct SBlockDataInfo { int32_t sttBlockIndex; } SBlockDataInfo; -typedef struct SSttBlockLoadInfo { - SBlockDataInfo blockData[2]; // buffered block data - int32_t statisBlockIndex; // buffered statistics block index - void *statisBlock; // buffered statistics block data - void *pSttStatisBlkArray; - SArray *aSttBlk; - int32_t currentLoadBlockIndex; - STSchema *pSchema; - int16_t *colIds; - int32_t numOfCols; - bool checkRemainingRow; // todo: no assign value? - bool isLast; - bool sttBlockLoaded; +// todo: move away +typedef struct { + SArray *pUid; + SArray *pFirstKey; + SArray *pLastKey; + SArray *pCount; +} SSttTableRowsInfo; +typedef struct SSttBlockLoadInfo { + SBlockDataInfo blockData[2]; // buffered block data + SArray *aSttBlk; + int32_t currentLoadBlockIndex; + STSchema *pSchema; + int16_t *colIds; + int32_t numOfCols; + bool checkRemainingRow; // todo: no assign value? + bool isLast; + bool sttBlockLoaded; + SSttTableRowsInfo info; SSttBlockLoadCostInfo cost; } SSttBlockLoadInfo; @@ -888,27 +894,31 @@ typedef struct { _load_tomb_fn loadTombFn; void *pReader; void *idstr; + bool rspRows; // response the rows in stt-file, if possible } SMergeTreeConf; -int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf); +typedef struct SSttDataInfoForTable { + SArray* pTimeWindowList; + int64_t numOfRows; +} SSttDataInfoForTable; -void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter); -bool tMergeTreeNext(SMergeTree *pMTree); -void tMergeTreePinSttBlock(SMergeTree *pMTree); -void tMergeTreeUnpinSttBlock(SMergeTree *pMTree); -bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree); -void tMergeTreeClose(SMergeTree *pMTree); +int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoForTable* pTableInfo); +void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter); +bool tMergeTreeNext(SMergeTree *pMTree); +void tMergeTreePinSttBlock(SMergeTree *pMTree); +void tMergeTreeUnpinSttBlock(SMergeTree *pMTree); +bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree); +void tMergeTreeClose(SMergeTree *pMTree); SSttBlockLoadInfo *tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols); -void getSttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, SSttBlockLoadCostInfo *pLoadCost); void *destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo); void *destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoadCost); // tsdbCache ============================================================================================== typedef enum { - READ_MODE_COUNT_ONLY = 0x1, - READ_MODE_ALL, -} EReadMode; + READER_EXEC_DATA = 0x1, + READER_EXEC_ROWS = 0x2, +} EExecMode; typedef struct { TSKEY ts; diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 50a28357e5..f3b495675d 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -238,10 +238,8 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskResetReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDropHTask(STQ* pTq, SRpcMsg* pMsg); -int32_t tqRestartStreamTasks(STQ* pTq); int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver); int32_t tqScanWal(STQ* pTq); -int32_t tqStartStreamTasks(STQ* pTq); int tqCommit(STQ*); int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index ee76a27414..138c58b45f 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -699,7 +699,23 @@ end: return ret; } -void freePtr(void* ptr) { taosMemoryFree(*(void**)ptr); } +static void freePtr(void* ptr) { taosMemoryFree(*(void**)ptr); } + +static STaskId replaceStreamTaskId(SStreamTask* pTask) { + ASSERT(pTask->info.fillHistory); + STaskId id = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId}; + + pTask->id.streamId = pTask->streamTaskId.streamId; + pTask->id.taskId = pTask->streamTaskId.taskId; + + return id; +} + +static void restoreStreamTaskId(SStreamTask* pTask, STaskId* pId) { + ASSERT(pTask->info.fillHistory); + pTask->id.taskId = pId->taskId; + pTask->id.streamId = pId->streamId; +} int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { int32_t vgId = TD_VID(pTq->pVnode); @@ -713,15 +729,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { streamTaskOpenAllUpstreamInput(pTask); if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - SStreamTask* pStateTask = pTask; - - STaskId taskId = {.streamId = 0, .taskId = 0}; + STaskId taskId = {0}; if (pTask->info.fillHistory) { - taskId.streamId = pTask->id.streamId; - taskId.taskId = pTask->id.taskId; - - pTask->id.streamId = pTask->streamTaskId.streamId; - pTask->id.taskId = pTask->streamTaskId.taskId; + taskId = replaceStreamTaskId(pTask); } pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1); @@ -731,9 +741,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { } else { tqDebug("s-task:%s state:%p", pTask->id.idStr, pTask->pState); } + if (pTask->info.fillHistory) { - pTask->id.streamId = taskId.streamId; - pTask->id.taskId = taskId.taskId; + restoreStreamTaskId(pTask, &taskId); } SReadHandle handle = { @@ -754,15 +764,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { qSetTaskId(pTask->exec.pExecutor, pTask->id.taskId, pTask->id.streamId); } else if (pTask->info.taskLevel == TASK_LEVEL__AGG) { - SStreamTask* pSateTask = pTask; - // SStreamTask task = {0}; - - STaskId taskId = {.streamId = 0, .taskId = 0}; + STaskId taskId = {0}; if (pTask->info.fillHistory) { - taskId.streamId = pTask->id.streamId; - taskId.taskId = pTask->id.taskId; - pTask->id.streamId = pTask->streamTaskId.streamId; - pTask->id.taskId = pTask->streamTaskId.taskId; + taskId = replaceStreamTaskId(pTask); } pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1); @@ -774,15 +778,13 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { } if (pTask->info.fillHistory) { - pTask->id.streamId = taskId.streamId; - pTask->id.taskId = taskId.taskId; + restoreStreamTaskId(pTask, &taskId); } - int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTask->upstreamInfo.pList); SReadHandle handle = { .checkpointId = pTask->chkInfo.checkpointId, .vnode = NULL, - .numOfVgroups = numOfVgroups, + .numOfVgroups = (int32_t)taosArrayGetSize(pTask->upstreamInfo.pList), .pStateBackend = pTask->pState, .fillHistory = pTask->info.fillHistory, .winRange = pTask->dataRange.window, @@ -828,12 +830,6 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { pTask->exec.pWalReader = walOpenReader(pTq->pVnode->pWal, &cond, pTask->id.taskId); } - // // reset the task status from unfinished transaction - // if (pTask->status.taskStatus == TASK_STATUS__PAUSE) { - // tqWarn("s-task:%s reset task status to be normal, status kept in taskMeta: Paused", pTask->id.idStr); - // pTask->status.taskStatus = TASK_STATUS__READY; - // } - streamTaskResetUpstreamStageInfo(pTask); streamSetupScheduleTrigger(pTask); SCheckpointInfo* pChkInfo = &pTask->chkInfo; diff --git a/source/dnode/vnode/src/tq/tqOffset.c b/source/dnode/vnode/src/tq/tqOffset.c index 5e67f3c3ac..f8bf61d4e7 100644 --- a/source/dnode/vnode/src/tq/tqOffset.c +++ b/source/dnode/vnode/src/tq/tqOffset.c @@ -47,6 +47,7 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) { } } + size = htonl(size); void* pMemBuf = taosMemoryCalloc(1, size); if (pMemBuf == NULL) { tqError("vgId:%d failed to restore offset from file, since out of memory, malloc size:%d", vgId, size); @@ -119,6 +120,7 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) { } void tqOffsetClose(STqOffsetStore* pStore) { + if(pStore == NULL) return; tqOffsetCommitFile(pStore); taosHashCleanup(pStore->pHash); taosMemoryFree(pStore); @@ -176,7 +178,7 @@ int32_t tqOffsetCommitFile(STqOffsetStore* pStore) { void* buf = taosMemoryCalloc(1, totLen); void* abuf = POINTER_SHIFT(buf, INT_BYTES); - *(int32_t*)buf = bodyLen; + *(int32_t*)buf = htonl(bodyLen); SEncoder encoder; tEncoderInit(&encoder, abuf, bodyLen); tEncodeSTqOffset(&encoder, pOffset); diff --git a/source/dnode/vnode/src/tq/tqStreamStateSnap.c b/source/dnode/vnode/src/tq/tqStreamStateSnap.c index 2ab710176d..50f413bcc9 100644 --- a/source/dnode/vnode/src/tq/tqStreamStateSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamStateSnap.c @@ -181,5 +181,5 @@ int32_t streamStateRebuildFromSnap(SStreamStateWriter* pWriter, int64_t chkpId) } int32_t streamStateLoadTasks(SStreamStateWriter* pWriter) { - return streamMetaReloadAllTasks(pWriter->pTq->pStreamMeta); + return streamMetaLoadAllTasks(pWriter->pTq->pStreamMeta); } diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index b1d49bf31b..b3c4479efc 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -13,9 +13,9 @@ * along with this program. If not, see . */ -#include "tstream.h" #include "tmsgcb.h" #include "tq.h" +#include "tstream.h" typedef struct STaskUpdateEntry { int64_t streamId; @@ -24,7 +24,7 @@ typedef struct STaskUpdateEntry { } STaskUpdateEntry; int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) { - int32_t vgId = pMeta->vgId; + int32_t vgId = pMeta->vgId; int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); if (numOfTasks == 0) { @@ -42,7 +42,7 @@ int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) { tqDebug("vgId:%d start all %d stream task(s) async", vgId, numOfTasks); pRunReq->head.vgId = vgId; pRunReq->streamId = 0; - pRunReq->taskId = restart? STREAM_EXEC_RESTART_ALL_TASKS_ID:STREAM_EXEC_START_ALL_TASKS_ID; + pRunReq->taskId = restart ? STREAM_EXEC_RESTART_ALL_TASKS_ID : STREAM_EXEC_START_ALL_TASKS_ID; SRpcMsg msg = {.msgType = TDMT_STREAM_TASK_RUN, .pCont = pRunReq, .contLen = sizeof(SStreamTaskRunReq)}; tmsgPutToQueue(cb, STREAM_QUEUE, &msg); @@ -50,10 +50,10 @@ int32_t tqStreamTaskStartAsync(SStreamMeta* pMeta, SMsgCb* cb, bool restart) { } int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pMsg, bool restored) { - int32_t vgId = pMeta->vgId; - char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); - int32_t len = pMsg->contLen - sizeof(SMsgHead); - SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; + int32_t vgId = pMeta->vgId; + char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + int32_t len = pMsg->contLen - sizeof(SMsgHead); + SRpcMsg rsp = {.info = pMsg->info, .code = TSDB_CODE_SUCCESS}; SStreamTaskNodeUpdateMsg req = {0}; @@ -72,7 +72,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM streamMetaWLock(pMeta); // the task epset may be updated again and again, when replaying the WAL, the task may be in stop status. - STaskId id = {.streamId = req.streamId, .taskId = req.taskId}; + STaskId id = {.streamId = req.streamId, .taskId = req.taskId}; SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); if (ppTask == NULL || *ppTask == NULL) { tqError("vgId:%d failed to acquire task:0x%x when handling update, it may have been dropped already", pMeta->vgId, @@ -96,7 +96,7 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM } STaskUpdateEntry entry = {.streamId = req.streamId, .taskId = req.taskId, .transId = req.transId}; - void* exist = taosHashGet(pMeta->updateInfo.pTasks, &entry, sizeof(STaskUpdateEntry)); + void* exist = taosHashGet(pMeta->updateInfo.pTasks, &entry, sizeof(STaskUpdateEntry)); if (exist != NULL) { tqDebug("s-task:%s (vgId:%d) already update in trans:%d, discard the nodeEp update msg", pTask->id.idStr, vgId, req.transId); @@ -166,7 +166,8 @@ int32_t tqStreamTaskProcessUpdateReq(SStreamMeta* pMeta, SMsgCb* cb, SRpcMsg* pM streamMetaWUnLock(pMeta); } else { if (!restored) { - tqDebug("vgId:%d vnode restore not completed, not restart the tasks, clear the start after nodeUpdate flag", vgId); + tqDebug("vgId:%d vnode restore not completed, not restart the tasks, clear the start after nodeUpdate flag", + vgId); pMeta->startInfo.tasksWillRestart = 0; streamMetaWUnLock(pMeta); } else { @@ -238,7 +239,7 @@ int32_t tqStreamTaskProcessDispatchReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { SStreamDispatchReq req = {0}; - SDecoder decoder; + SDecoder decoder; tDecoderInit(&decoder, (uint8_t*)msgBody, msgLen); if (tDecodeStreamDispatchReq(&decoder, &req) < 0) { tDecoderClear(&decoder); @@ -251,7 +252,7 @@ int32_t tqStreamTaskProcessDispatchReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.taskId); if (pTask) { SRpcMsg rsp = {.info = pMsg->info, .code = 0}; - if (streamProcessDispatchMsg(pTask, &req, &rsp) != 0){ + if (streamProcessDispatchMsg(pTask, &req, &rsp) != 0) { return -1; } tDeleteStreamDispatchReq(&req); @@ -355,8 +356,8 @@ int32_t tqStreamTaskProcessScanHistoryFinishReq(SStreamMeta* pMeta, SRpcMsg* pMs SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.downstreamTaskId); if (pTask == NULL) { - tqError("vgId:%d process scan history finish msg, failed to find task:0x%x, it may be destroyed", - pMeta->vgId, req.downstreamTaskId); + tqError("vgId:%d process scan history finish msg, failed to find task:0x%x, it may be destroyed", pMeta->vgId, + req.downstreamTaskId); return -1; } @@ -381,8 +382,8 @@ int32_t tqStreamTaskProcessScanHistoryFinishRsp(SStreamMeta* pMeta, SRpcMsg* pMs SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, req.upstreamTaskId); if (pTask == NULL) { - tqError("vgId:%d process scan history finish rsp, failed to find task:0x%x, it may be destroyed", - pMeta->vgId, req.upstreamTaskId); + tqError("vgId:%d process scan history finish rsp, failed to find task:0x%x, it may be destroyed", pMeta->vgId, + req.upstreamTaskId); return -1; } @@ -428,8 +429,9 @@ int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { // only the leader node handle the check request if (pMeta->role == NODE_ROLE_FOLLOWER) { - tqError("s-task:0x%x invalid check msg from upstream:0x%x(vgId:%d), vgId:%d is follower, not handle check status msg", - taskId, req.upstreamTaskId, req.upstreamNodeId, pMeta->vgId); + tqError( + "s-task:0x%x invalid check msg from upstream:0x%x(vgId:%d), vgId:%d is follower, not handle check status msg", + taskId, req.upstreamTaskId, req.upstreamNodeId, pMeta->vgId); rsp.status = TASK_DOWNSTREAM_NOT_LEADER; } else { SStreamTask* pTask = streamMetaAcquireTask(pMeta, req.streamId, taskId); @@ -439,13 +441,14 @@ int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { char* p = NULL; streamTaskGetStatus(pTask, &p); - tqDebug("s-task:%s status:%s, stage:%"PRId64" recv task check req(reqId:0x%" PRIx64 ") task:0x%x (vgId:%d), check_status:%d", - pTask->id.idStr, p, rsp.oldStage, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); + tqDebug("s-task:%s status:%s, stage:%" PRId64 " recv task check req(reqId:0x%" PRIx64 + ") task:0x%x (vgId:%d), check_status:%d", + pTask->id.idStr, p, rsp.oldStage, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); } else { rsp.status = TASK_DOWNSTREAM_NOT_READY; tqDebug("tq recv task check(taskId:0x%" PRIx64 "-0x%x not built yet) req(reqId:0x%" PRIx64 - ") from task:0x%x (vgId:%d), rsp check_status %d", - req.streamId, taskId, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); + ") from task:0x%x (vgId:%d), rsp check_status %d", + req.streamId, taskId, rsp.reqId, rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.status); } } @@ -472,7 +475,7 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe tDecoderClear(&decoder); tqDebug("tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%" PRIx64 ") from 0x%x (vgId:%d) status %d", - rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status); + rsp.upstreamTaskId, rsp.upstreamNodeId, rsp.reqId, rsp.downstreamTaskId, rsp.downstreamNodeId, rsp.status); if (!isLeader) { streamMetaUpdateTaskDownstreamStatus(pMeta, rsp.streamId, rsp.upstreamTaskId, 0, taosGetTimestampMs(), false); @@ -485,7 +488,7 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe if (pTask == NULL) { streamMetaUpdateTaskDownstreamStatus(pMeta, rsp.streamId, rsp.upstreamTaskId, 0, taosGetTimestampMs(), false); tqError("tq failed to locate the stream task:0x%" PRIx64 "-0x%x (vgId:%d), it may have been destroyed or stopped", - rsp.streamId, rsp.upstreamTaskId, vgId); + rsp.streamId, rsp.upstreamTaskId, vgId); terrno = TSDB_CODE_STREAM_TASK_NOT_EXIST; return -1; } @@ -496,10 +499,10 @@ int32_t tqStreamTaskProcessCheckRsp(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLe } int32_t tqStreamTaskProcessCheckpointReadyMsg(SStreamMeta* pMeta, SRpcMsg* pMsg) { - int32_t vgId = pMeta->vgId; - char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); - int32_t len = pMsg->contLen - sizeof(SMsgHead); - int32_t code = 0; + int32_t vgId = pMeta->vgId; + char* msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + int32_t len = pMsg->contLen - sizeof(SMsgHead); + int32_t code = 0; SStreamCheckpointReadyMsg req = {0}; @@ -526,7 +529,8 @@ int32_t tqStreamTaskProcessCheckpointReadyMsg(SStreamMeta* pMeta, SRpcMsg* pMsg) return code; } -int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, int64_t sversion, char* msg, int32_t msgLen, bool isLeader, bool restored) { +int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, int64_t sversion, char* msg, int32_t msgLen, bool isLeader, + bool restored) { int32_t code = 0; int32_t vgId = pMeta->vgId; @@ -538,7 +542,7 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, int64_t sversion, char* tqDebug("vgId:%d receive new stream task deploy msg, start to build stream task", vgId); // 1.deserialize msg and build task - int32_t size = sizeof(SStreamTask); + int32_t size = sizeof(SStreamTask); SStreamTask* pTask = taosMemoryCalloc(1, size); if (pTask == NULL) { tqError("vgId:%d failed to create stream task due to out of memory, alloc size:%d", vgId, size); @@ -566,7 +570,8 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, int64_t sversion, char* streamMetaWUnLock(pMeta); if (code < 0) { - tqError("failed to add s-task:0x%x into vgId:%d meta, total:%d, code:%s", vgId, taskId, numOfTasks, tstrerror(code)); + tqError("failed to add s-task:0x%x into vgId:%d meta, total:%d, code:%s", vgId, taskId, numOfTasks, + tstrerror(code)); tFreeStreamTask(pTask); return code; } @@ -603,7 +608,7 @@ int32_t tqStreamTaskProcessDeployReq(SStreamMeta* pMeta, int64_t sversion, char* int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen) { SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg; - int32_t vgId = pMeta->vgId; + int32_t vgId = pMeta->vgId; tqDebug("vgId:%d receive msg to drop s-task:0x%x", vgId, pReq->taskId); SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->streamId, pReq->taskId); @@ -628,14 +633,14 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen if (streamMetaCommit(pMeta) < 0) { // persist to disk } - streamMetaWUnLock(pMeta); + streamMetaWUnLock(pMeta); return 0; } int32_t startStreamTasks(SStreamMeta* pMeta) { - int32_t code = TSDB_CODE_SUCCESS; - int32_t vgId = pMeta->vgId; + int32_t code = TSDB_CODE_SUCCESS; + int32_t vgId = pMeta->vgId; int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); tqDebug("vgId:%d start to check all %d stream task(s) downstream status", vgId, numOfTasks); @@ -679,7 +684,7 @@ int32_t startStreamTasks(SStreamMeta* pMeta) { } EStreamTaskEvent event = (HAS_RELATED_FILLHISTORY_TASK(pTask)) ? TASK_EVENT_INIT_STREAM_SCANHIST : TASK_EVENT_INIT; - int32_t ret = streamTaskHandleEvent(pTask->status.pSM, event); + int32_t ret = streamTaskHandleEvent(pTask->status.pSM, event); if (ret != TSDB_CODE_SUCCESS) { code = ret; } @@ -692,8 +697,8 @@ int32_t startStreamTasks(SStreamMeta* pMeta) { } int32_t resetStreamTaskStatus(SStreamMeta* pMeta) { - int32_t vgId = pMeta->vgId; - int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); + int32_t vgId = pMeta->vgId; + int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); tqDebug("vgId:%d reset all %d stream task(s) status to be uninit", vgId, numOfTasks); if (numOfTasks == 0) { @@ -703,7 +708,7 @@ int32_t resetStreamTaskStatus(SStreamMeta* pMeta) { for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pTaskId = taosArrayGet(pMeta->pTaskList, i); - STaskId id = {.streamId = pTaskId->streamId, .taskId = pTaskId->taskId}; + STaskId id = {.streamId = pTaskId->streamId, .taskId = pTaskId->taskId}; SStreamTask** pTask = taosHashGet(pMeta->pTasksMap, &id, sizeof(id)); streamTaskResetStatus(*pTask); } @@ -712,11 +717,11 @@ int32_t resetStreamTaskStatus(SStreamMeta* pMeta) { } static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) { - int32_t vgId = pMeta->vgId; - int32_t code = 0; - int64_t st = taosGetTimestampMs(); + int32_t vgId = pMeta->vgId; + int32_t code = 0; + int64_t st = taosGetTimestampMs(); - while(1) { + while (1) { int32_t startVal = atomic_val_compare_exchange_32(&pMeta->startInfo.taskStarting, 0, 1); if (startVal == 0) { break; @@ -736,18 +741,10 @@ static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) { } streamMetaWLock(pMeta); - code = streamMetaReopen(pMeta); - if (code != TSDB_CODE_SUCCESS) { - tqError("vgId:%d failed to reopen stream meta", vgId); - streamMetaWUnLock(pMeta); - code = terrno; - return code; - } + streamMetaClear(pMeta); - streamMetaInitBackend(pMeta); int64_t el = taosGetTimestampMs() - st; - - tqInfo("vgId:%d close&reload state elapsed time:%.3fs", vgId, el/1000.); + tqInfo("vgId:%d close&reload state elapsed time:%.3fs", vgId, el / 1000.); code = streamMetaLoadAllTasks(pMeta); if (code != TSDB_CODE_SUCCESS) { @@ -758,10 +755,10 @@ static int32_t restartStreamTasks(SStreamMeta* pMeta, bool isLeader) { } if (isLeader && !tsDisableStream) { - tqInfo("vgId:%d restart all stream tasks after all tasks being updated", vgId); resetStreamTaskStatus(pMeta); - streamMetaWUnLock(pMeta); + tqInfo("vgId:%d restart all stream tasks after all tasks being updated", vgId); + startStreamTasks(pMeta); } else { streamMetaResetStartInfo(&pMeta->startInfo); @@ -788,11 +785,11 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead } SStreamTask* pTask = streamMetaAcquireTask(pMeta, pReq->streamId, taskId); - if (pTask != NULL) { // even in halt status, the data in inputQ must be processed + if (pTask != NULL) { // even in halt status, the data in inputQ must be processed char* p = NULL; if (streamTaskReadyToRun(pTask, &p)) { tqDebug("vgId:%d s-task:%s start to process block from inputQ, next checked ver:%" PRId64, vgId, pTask->id.idStr, - pTask->chkInfo.nextProcessVer); + pTask->chkInfo.nextProcessVer); streamExecTask(pTask); } else { int8_t status = streamTaskSetSchedStatusInactive(pTask); @@ -808,5 +805,3 @@ int32_t tqStreamTaskProcessRunReq(SStreamMeta* pMeta, SRpcMsg* pMsg, bool isLead return -1; } } - - diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index b1424c1944..1799823011 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -53,11 +53,10 @@ static void tsdbCloseBICache(STsdb *pTsdb) { } static int32_t tsdbOpenBCache(STsdb *pTsdb) { - int32_t code = 0; - // SLRUCache *pCache = taosLRUCacheInit(10 * 1024 * 1024, 0, .5); - int32_t szPage = pTsdb->pVnode->config.tsdbPageSize; - - SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3BlockCacheSize * tsS3BlockSize * szPage, 0, .5); + int32_t code = 0; + int32_t szPage = pTsdb->pVnode->config.tsdbPageSize; + int64_t szBlock = tsS3BlockSize <= 1024 ? 1024 : tsS3BlockSize; + SLRUCache *pCache = taosLRUCacheInit((int64_t)tsS3BlockCacheSize * szBlock * szPage, 0, .5); if (pCache == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -67,8 +66,9 @@ static int32_t tsdbOpenBCache(STsdb *pTsdb) { taosThreadMutexInit(&pTsdb->bMutex, NULL); -_err: pTsdb->bCache = pCache; + +_err: return code; } @@ -452,9 +452,11 @@ static SLastCol *tsdbCacheLookup(STsdb *pTsdb, tb_uid_t uid, int16_t cid, int8_t static void reallocVarData(SColVal *pColVal) { if (IS_VAR_DATA_TYPE(pColVal->type)) { uint8_t *pVal = pColVal->value.pData; - pColVal->value.pData = taosMemoryMalloc(pColVal->value.nData); - if (pColVal->value.nData) { + if (pColVal->value.nData > 0) { + pColVal->value.pData = taosMemoryMalloc(pColVal->value.nData); memcpy(pColVal->value.pData, pVal, pColVal->value.nData); + } else { + pColVal->value.pData = NULL; } } } @@ -1877,7 +1879,7 @@ static int32_t lastIterOpen(SFSLastIter *iter, STFileSet *pFileSet, STsdb *pTsdb .idstr = pr->idstr, }; - code = tMergeTreeOpen2(&iter->mergeTree, &conf); + code = tMergeTreeOpen2(&iter->mergeTree, &conf, NULL); if (code != TSDB_CODE_SUCCESS) { return -1; } @@ -2755,14 +2757,16 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC *pCol = (SLastCol){.ts = rowTs, .colVal = *pColVal}; if (IS_VAR_DATA_TYPE(pColVal->type) /*&& pColVal->value.nData > 0*/) { - pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); - if (pCol->colVal.value.pData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } if (pColVal->value.nData > 0) { + pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); + if (pCol->colVal.value.pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } memcpy(pCol->colVal.value.pData, pColVal->value.pData, pColVal->value.nData); + } else { + pCol->colVal.value.pData = NULL; } } @@ -2802,17 +2806,21 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal); if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) { SLastCol lastCol = {.ts = rowTs, .colVal = *pColVal}; - if (IS_VAR_DATA_TYPE(pColVal->type) && pColVal->value.nData > 0) { + if (IS_VAR_DATA_TYPE(pColVal->type) /* && pColVal->value.nData > 0 */) { SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol); taosMemoryFree(pLastCol->colVal.value.pData); - lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData); - if (lastCol.colVal.value.pData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + if (pColVal->value.nData > 0) { + lastCol.colVal.value.pData = taosMemoryMalloc(lastCol.colVal.value.nData); + if (lastCol.colVal.value.pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData); + } else { + lastCol.colVal.value.pData = NULL; } - memcpy(lastCol.colVal.value.pData, pColVal->value.pData, pColVal->value.nData); } taosArraySet(pColArray, iCol, &lastCol); @@ -2923,14 +2931,18 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, *pCol = (SLastCol){.ts = rowTs, .colVal = *pColVal}; if (IS_VAR_DATA_TYPE(pColVal->type) /*&& pColVal->value.nData > 0*/) { - pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); - if (pCol->colVal.value.pData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } if (pColVal->value.nData > 0) { - memcpy(pCol->colVal.value.pData, pColVal->value.pData, pColVal->value.nData); + pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData); + if (pCol->colVal.value.pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + if (pColVal->value.nData > 0) { + memcpy(pCol->colVal.value.pData, pColVal->value.pData, pColVal->value.nData); + } + } else { + pCol->colVal.value.pData = NULL; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index a974eb27bf..dc76aa61b2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -435,7 +435,7 @@ _exit: tsdbDebug("vgId:%d %s done, fid:%d minKey:%" PRId64 " maxKey:%" PRId64 " expLevel:%d", TD_VID(tsdb->pVnode), __func__, committer->ctx->fid, committer->ctx->minKey, committer->ctx->maxKey, committer->ctx->expLevel); } - return 0; + return code; } static int32_t tsdbCommitFileSetEnd(SCommitter2 *committer) { diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c index 3f448379c9..d2e3cb08e5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c @@ -115,7 +115,7 @@ static int32_t tsdbDataFileRAWWriterDoClose(SDataFileRAWWriter *writer) { return static int32_t tsdbDataFileRAWWriterCloseCommit(SDataFileRAWWriter *writer, TFileOpArray *opArr) { int32_t code = 0; int32_t lino = 0; - ASSERT(writer->ctx->offset == writer->file.size); + ASSERT(writer->ctx->offset <= writer->file.size); ASSERT(writer->config->fid == writer->file.fid); STFileOp op = (STFileOp){ diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index e933b3a7dc..b2ccc3e859 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -529,7 +529,8 @@ static int32_t tsdbFSDoSanAndFix(STFileSystem *fs) { for (const STfsFile *file = NULL; (file = tfsReaddir(dir)) != NULL;) { if (taosIsDir(file->aname)) continue; - if (tsdbFSGetFileObjHashEntry(&fobjHash, file->aname) == NULL) { + if (tsdbFSGetFileObjHashEntry(&fobjHash, file->aname) == NULL && + strncmp(file->aname + strlen(file->aname) - 3, ".cp", 3)) { int32_t nlevel = tfsGetLevel(fs->tsdb->pVnode->pTfs); remove_file(file->aname, nlevel > 1 && file->did.level == nlevel - 1); } @@ -746,6 +747,7 @@ _exit: } static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block); +extern int32_t tsdbStopAllCompTask(STsdb *tsdb); int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { STFileSystem *fs = pTsdb->pFS; @@ -773,6 +775,10 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { int64_t channel; TARRAY2_FOREACH(&channelArr, channel) { vnodeAChannelDestroy(vnodeAsyncHandle[1], channel, true); } TARRAY2_DESTROY(&channelArr, NULL); + +#ifdef TD_ENTERPRISE + tsdbStopAllCompTask(pTsdb); +#endif return 0; } @@ -1113,7 +1119,7 @@ int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pRa TARRAY2_FOREACH(fs->fSetArr, fset) { int64_t ever = VERSION_MAX; if (pHash) { - int32_t fid = fset->fid; + int32_t fid = fset->fid; STFileSetRange *u = taosHashGet(pHash, &fid, sizeof(fid)); if (u) { ever = u->sver - 1; @@ -1145,10 +1151,10 @@ int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr) { return tsdbFS int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges, TFileSetRangeArray **fsrArr) { - int32_t code = 0; - STFileSet *fset; + int32_t code = 0; + STFileSet *fset; STFileSetRange *fsr1 = NULL; - SHashObj *pHash = NULL; + SHashObj *pHash = NULL; fsrArr[0] = taosMemoryCalloc(1, sizeof(*fsrArr[0])); if (fsrArr[0] == NULL) { @@ -1171,7 +1177,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev int64_t ever1 = ever; if (pHash) { - int32_t fid = fset->fid; + int32_t fid = fset->fid; STFileSetRange *u = taosHashGet(pHash, &fid, sizeof(fid)); if (u) { sver1 = u->sver; diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.h b/source/dnode/vnode/src/tsdb/tsdbFSet2.h index 0951a28f4e..86db3b01c7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.h @@ -27,7 +27,6 @@ typedef struct SSttLvl SSttLvl; typedef TARRAY2(STFileObj *) TFileObjArray; typedef TARRAY2(SSttLvl *) TSttLvlArray; typedef TARRAY2(STFileOp) TFileOpArray; -typedef struct STFileSystem STFileSystem; typedef enum { TSDB_FOP_NONE = 0, diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 8017f1f4d0..0b86cae1be 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -15,6 +15,7 @@ #include "tsdb.h" #include "tsdbFSet2.h" +#include "tsdbUtil2.h" #include "tsdbMerge.h" #include "tsdbReadUtil.h" #include "tsdbSttFileRW.h" @@ -52,15 +53,6 @@ SSttBlockLoadInfo *tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList, return pLoadInfo; } -void getSttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, SSttBlockLoadCostInfo* pLoadCost) { - for (int32_t i = 0; i < 1; ++i) { - pLoadCost->blockElapsedTime += pLoadInfo[i].cost.blockElapsedTime; - pLoadCost->loadBlocks += pLoadInfo[i].cost.loadBlocks; - pLoadCost->loadStatisBlocks += pLoadInfo[i].cost.loadStatisBlocks; - pLoadCost->statisElapsedTime += pLoadInfo[i].cost.statisElapsedTime; - } -} - void *destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { if (pLoadInfo == NULL) { return NULL; @@ -78,9 +70,11 @@ void *destroySttBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) { pInfo->sttBlockIndex = -1; pInfo->pin = false; - if (pLoadInfo->statisBlock != NULL) { - tStatisBlockDestroy(pLoadInfo->statisBlock); - taosMemoryFreeClear(pLoadInfo->statisBlock); + if (pLoadInfo->info.pCount != NULL) { + taosArrayDestroy(pLoadInfo->info.pUid); + taosArrayDestroy(pLoadInfo->info.pFirstKey); + taosArrayDestroy(pLoadInfo->info.pLastKey); + taosArrayDestroy(pLoadInfo->info.pCount); } taosArrayDestroy(pLoadInfo->aSttBlk); @@ -172,7 +166,7 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) { pInfo->cost.blockElapsedTime += el; pInfo->cost.loadBlocks += 1; - tsdbDebug("read last block, total load:%" PRId64 ", trigger by uid:%" PRIu64 ", stt-fileVer:%" PRId64 + tsdbDebug("read stt block, total load:%" PRId64 ", trigger by uid:%" PRIu64 ", stt-fileVer:%" PRId64 ", last block index:%d, entry:%d, rows:%d, uidRange:%" PRId64 "-%" PRId64 " tsRange:%" PRId64 "-%" PRId64 " %p, elapsed time:%.2f ms, %s", pInfo->cost.loadBlocks, pIter->uid, pIter->cid, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock->nRow, @@ -323,95 +317,77 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray return TSDB_CODE_SUCCESS; } -static int32_t suidComparFn(const void *target, const void *p2) { - const uint64_t *targetUid = target; - const uint64_t *uid2 = p2; - if (*uid2 == (*targetUid)) { +static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pBlockLoadInfo, + TStatisBlkArray *pStatisBlkArray, uint64_t suid, const char *id) { + int32_t numOfBlocks = TARRAY2_SIZE(pStatisBlkArray); + if (numOfBlocks <= 0) { return 0; - } else { - return (*targetUid) < (*uid2) ? -1 : 1; - } -} - -static bool existsFromSttBlkStatis(SSttBlockLoadInfo *pBlockLoadInfo, uint64_t suid, uint64_t uid, - SSttFileReader *pReader) { - const TStatisBlkArray *pStatisBlkArray = pBlockLoadInfo->pSttStatisBlkArray; - if (TARRAY2_SIZE(pStatisBlkArray) <= 0) { - return true; } - int32_t i = 0; - for (i = 0; i < TARRAY2_SIZE(pStatisBlkArray); ++i) { - SStatisBlk *p = &pStatisBlkArray->data[i]; - if (p->minTbid.suid <= suid && p->maxTbid.suid >= suid) { - break; - } + int32_t startIndex = 0; + while((startIndex < numOfBlocks) && (pStatisBlkArray->data[startIndex].maxTbid.suid < suid)) { + ++startIndex; } - if (i >= TARRAY2_SIZE(pStatisBlkArray)) { - return false; + if (startIndex >= numOfBlocks || pStatisBlkArray->data[startIndex].minTbid.suid > suid) { + return 0; } - while (i < TARRAY2_SIZE(pStatisBlkArray)) { - SStatisBlk *p = &pStatisBlkArray->data[i]; - if (p->minTbid.suid > suid) { - return false; + int32_t endIndex = startIndex; + while(endIndex < numOfBlocks && pStatisBlkArray->data[endIndex].minTbid.suid <= suid) { + ++endIndex; + } + + int32_t num = endIndex - startIndex; + pBlockLoadInfo->cost.loadStatisBlocks += num; + + STbStatisBlock block; + tStatisBlockInit(&block); + + int64_t st = taosGetTimestampUs(); + + for(int32_t k = startIndex; k < endIndex; ++k) { + tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block); + + int32_t i = 0; + int32_t rows = TARRAY2_SIZE(block.suid); + while (i < rows && block.suid->data[i] != suid) { + ++i; } -// if (pBlockLoadInfo->statisBlock == NULL) { -// pBlockLoadInfo->statisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock)); -// -// int64_t st = taosGetTimestampMs(); -// tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock); -// pBlockLoadInfo->statisBlockIndex = i; -// -// double el = (taosGetTimestampMs() - st) / 1000.0; -// pBlockLoadInfo->cost.loadStatisBlocks += 1; -// pBlockLoadInfo->cost.statisElapsedTime += el; -// } else if (pBlockLoadInfo->statisBlockIndex != i) { -// tStatisBlockDestroy(pBlockLoadInfo->statisBlock); -// -// int64_t st = taosGetTimestampMs(); -// tsdbSttFileReadStatisBlock(pReader, p, pBlockLoadInfo->statisBlock); -// pBlockLoadInfo->statisBlockIndex = i; -// -// double el = (taosGetTimestampMs() - st) / 1000.0; -// pBlockLoadInfo->cost.loadStatisBlocks += 1; -// pBlockLoadInfo->cost.statisElapsedTime += el; -// } - - STbStatisBlock* pBlock = pBlockLoadInfo->statisBlock; - int32_t index = tarray2SearchIdx(pBlock->suid, &suid, sizeof(int64_t), suidComparFn, TD_EQ); - if (index == -1) { - return false; - } - - int32_t j = index; - if (pBlock->uid->data[j] == uid) { - return true; - } else if (pBlock->uid->data[j] > uid) { - while (j >= 0 && pBlock->suid->data[j] == suid) { - if (pBlock->uid->data[j] == uid) { - return true; - } else { - j -= 1; - } + // existed + if (i < rows) { + if (pBlockLoadInfo->info.pUid == NULL) { + pBlockLoadInfo->info.pUid = taosArrayInit(rows, sizeof(int64_t)); + pBlockLoadInfo->info.pFirstKey = taosArrayInit(rows, sizeof(int64_t)); + pBlockLoadInfo->info.pLastKey = taosArrayInit(rows, sizeof(int64_t)); + pBlockLoadInfo->info.pCount = taosArrayInit(rows, sizeof(int64_t)); } - } else { - j = index + 1; - while (j < pBlock->suid->size && pBlock->suid->data[j] == suid) { - if (pBlock->uid->data[j] == uid) { - return true; - } else { - j += 1; + + if (pStatisBlkArray->data[k].maxTbid.suid == suid) { + taosArrayAddBatch(pBlockLoadInfo->info.pUid, &block.uid->data[i], rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pFirstKey, &block.firstKey->data[i], rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pLastKey, &block.lastKey->data[i], rows - i); + taosArrayAddBatch(pBlockLoadInfo->info.pCount, &block.count->data[i], rows - i); + } else { + while (i < rows && block.suid->data[i] == suid) { + taosArrayPush(pBlockLoadInfo->info.pUid, &block.uid->data[i]); + taosArrayPush(pBlockLoadInfo->info.pFirstKey, &block.firstKey->data[i]); + taosArrayPush(pBlockLoadInfo->info.pLastKey, &block.lastKey->data[i]); + taosArrayPush(pBlockLoadInfo->info.pCount, &block.count->data[i]); + i += 1; } } } - - i += 1; } - return false; + tStatisBlockDestroy(&block); + + double el = (taosGetTimestampUs() - st) / 1000.0; + pBlockLoadInfo->cost.statisElapsedTime += el; + + tsdbDebug("%s load %d statis blocks into buf, elapsed time:%.2fms", id, num, el); + return TSDB_CODE_SUCCESS; } static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter *pIter, int64_t suid, @@ -428,19 +404,28 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * return code; } + // load the stt block info for each stt file block code = extractSttBlockInfo(pIter, pSttBlkArray, pBlockLoadInfo, suid); if (code != TSDB_CODE_SUCCESS) { tsdbError("load stt block info failed, code:%s, %s", tstrerror(code), idStr); return code; } - // load stt blocks statis for all stt-blocks, to decide if the data of queried table exists in current stt file - code = tsdbSttFileReadStatisBlk(pIter->pReader, (const TStatisBlkArray **)&pBlockLoadInfo->pSttStatisBlkArray); + // load stt statistics block for all stt-blocks, to decide if the data of queried table exists in current stt file + TStatisBlkArray *pStatisBlkArray = NULL; + code = tsdbSttFileReadStatisBlk(pIter->pReader, (const TStatisBlkArray **)&pStatisBlkArray); if (code != TSDB_CODE_SUCCESS) { tsdbError("failed to load stt block statistics, code:%s, %s", tstrerror(code), idStr); return code; } + // load statistics block for all tables in current stt file + code = loadSttStatisticsBlockData(pIter->pReader, pIter->pBlockLoadInfo, pStatisBlkArray, suid, idStr); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("failed to load stt statistics block data, code:%s, %s", tstrerror(code), idStr); + return code; + } + code = loadTombFn(pReader1, pIter->pReader, pIter->pBlockLoadInfo); double el = (taosGetTimestampUs() - st) / 1000.0; @@ -448,19 +433,44 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * return code; } +static int32_t uidComparFn(const void* p1, const void* p2) { + const uint64_t *pFirst = p1; + const uint64_t *pVal = p2; + + if (*pFirst == *pVal) { + return 0; + } else { + return *pFirst < *pVal? -1:1; + } +} + +static void setSttInfoForCurrentTable(SSttBlockLoadInfo *pLoadInfo, uint64_t uid, STimeWindow *pTimeWindow, + int64_t *numOfRows) { + if (pTimeWindow == NULL || taosArrayGetSize(pLoadInfo->info.pUid) == 0) { + return; + } + + int32_t index = taosArraySearchIdx(pLoadInfo->info.pUid, &uid, uidComparFn, TD_EQ); + if (index >= 0) { + pTimeWindow->skey = *(int64_t *)taosArrayGet(pLoadInfo->info.pFirstKey, index); + pTimeWindow->ekey = *(int64_t *)taosArrayGet(pLoadInfo->info.pLastKey, index); + + *numOfRows += *(int64_t*) taosArrayGet(pLoadInfo->info.pCount, index); + } +} + int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32_t cid, int8_t backward, - uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, - SSttBlockLoadInfo *pBlockLoadInfo, const char *idStr, bool strictTimeRange, - _load_tomb_fn loadTombFn, void *pReader1) { + SMergeTreeConf *pConf, SSttBlockLoadInfo *pBlockLoadInfo, STimeWindow *pTimeWindow, + int64_t *numOfRows, const char *idStr) { int32_t code = TSDB_CODE_SUCCESS; - pIter->uid = uid; + pIter->uid = pConf->uid; pIter->cid = cid; pIter->backward = backward; - pIter->verRange.minVer = pRange->minVer; - pIter->verRange.maxVer = pRange->maxVer; - pIter->timeWindow.skey = pTimeWindow->skey; - pIter->timeWindow.ekey = pTimeWindow->ekey; + pIter->verRange.minVer = pConf->verRange.minVer; + pIter->verRange.maxVer = pConf->verRange.maxVer; + pIter->timeWindow.skey = pConf->timewindow.skey; + pIter->timeWindow.ekey = pConf->timewindow.ekey; pIter->pReader = pSttFileReader; pIter->pBlockLoadInfo = pBlockLoadInfo; @@ -473,34 +483,29 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32 } if (!pBlockLoadInfo->sttBlockLoaded) { - code = doLoadSttFilesBlk(pBlockLoadInfo, pIter, suid, loadTombFn, pReader1, idStr); + code = doLoadSttFilesBlk(pBlockLoadInfo, pIter, pConf->suid, pConf->loadTombFn, pConf->pReader, idStr); if (code != TSDB_CODE_SUCCESS) { return code; } } -// bool exists = existsFromSttBlkStatis(pBlockLoadInfo, suid, uid, pIter->pReader); -// if (!exists) { -// pIter->iSttBlk = -1; -// pIter->pSttBlk = NULL; -// return TSDB_CODE_SUCCESS; -// } + setSttInfoForCurrentTable(pBlockLoadInfo, pConf->uid, pTimeWindow, numOfRows); // find the start block, actually we could load the position to avoid repeatly searching for the start position when // the skey is updated. size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk); - pIter->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, uid, backward); + pIter->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, pConf->uid, backward); if (pIter->iSttBlk != -1) { pIter->pSttBlk = taosArrayGet(pBlockLoadInfo->aSttBlk, pIter->iSttBlk); pIter->iRow = (pIter->backward) ? pIter->pSttBlk->nRow : -1; - if ((!backward) && ((strictTimeRange && pIter->pSttBlk->minKey >= pIter->timeWindow.ekey) || - (!strictTimeRange && pIter->pSttBlk->minKey > pIter->timeWindow.ekey))) { + if ((!backward) && ((pConf->strictTimeRange && pIter->pSttBlk->minKey >= pIter->timeWindow.ekey) || + (!pConf->strictTimeRange && pIter->pSttBlk->minKey > pIter->timeWindow.ekey))) { pIter->pSttBlk = NULL; } - if (backward && ((strictTimeRange && pIter->pSttBlk->maxKey <= pIter->timeWindow.skey) || - (!strictTimeRange && pIter->pSttBlk->maxKey < pIter->timeWindow.skey))) { + if (backward && ((pConf->strictTimeRange && pIter->pSttBlk->maxKey <= pIter->timeWindow.skey) || + (!pConf->strictTimeRange && pIter->pSttBlk->maxKey < pIter->timeWindow.skey))) { pIter->pSttBlk = NULL; pIter->ignoreEarlierTs = true; } @@ -708,8 +713,6 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL) && (pBlockData != NULL); } -SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; } - // SMergeTree ================================================= static FORCE_INLINE int32_t tLDataIterCmprFn(const SRBTreeNode *p1, const SRBTreeNode *p2) { SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - offsetof(SLDataIter, node)); @@ -737,7 +740,7 @@ static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SR return -1 * tLDataIterCmprFn(p1, p2); } -int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf) { +int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoForTable* pSttDataInfo) { int32_t code = TSDB_CODE_SUCCESS; pMTree->pIter = NULL; @@ -758,17 +761,16 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf) { goto _end; } - // add the list/iter placeholder - adjustLDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset); + adjustSttDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset); for (int32_t j = 0; j < numOfLevels; ++j) { SSttLvl *pSttLevel = ((STFileSet *)pConf->pCurrentFileset)->lvlArr->data[j]; - SArray *pList = taosArrayGetP(pConf->pSttFileBlockIterArray, j); + SArray * pList = taosArrayGetP(pConf->pSttFileBlockIterArray, j); for (int32_t i = 0; i < TARRAY2_SIZE(pSttLevel->fobjArr); ++i) { // open all last file SLDataIter *pIter = taosArrayGetP(pList, i); - SSttFileReader *pSttFileReader = pIter->pReader; + SSttFileReader * pSttFileReader = pIter->pReader; SSttBlockLoadInfo *pLoadInfo = pIter->pBlockLoadInfo; // open stt file reader if not opened yet @@ -790,10 +792,11 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf) { memset(pIter, 0, sizeof(SLDataIter)); + STimeWindow w = {0}; + int64_t numOfRows = 0; + int64_t cid = pSttLevel->fobjArr->data[i]->f->cid; - code = tLDataIterOpen2(pIter, pSttFileReader, cid, pMTree->backward, pConf->suid, pConf->uid, &pConf->timewindow, - &pConf->verRange, pLoadInfo, pMTree->idStr, pConf->strictTimeRange, pConf->loadTombFn, - pConf->pReader); + code = tLDataIterOpen2(pIter, pSttFileReader, cid, pMTree->backward, pConf, pLoadInfo, &w, &numOfRows, pMTree->idStr); if (code != TSDB_CODE_SUCCESS) { goto _end; } @@ -801,6 +804,12 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf) { bool hasVal = tLDataIterNextRow(pIter, pMTree->idStr); if (hasVal) { tMergeTreeAddIter(pMTree, pIter); + + // let's record the time window for current table of uid in the stt files + if (pSttDataInfo != NULL) { + taosArrayPush(pSttDataInfo->pTimeWindowList, &w); + pSttDataInfo->numOfRows += numOfRows; + } } else { if (!pMTree->ignoreEarlierTs) { pMTree->ignoreEarlierTs = pIter->ignoreEarlierTs; diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index a1f864814f..ea3d285880 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -16,6 +16,9 @@ #include "tsdb.h" #include "tsdbFS2.h" +extern int32_t tsdbOpenCompMonitor(STsdb *tsdb); +extern int32_t tsdbCloseCompMonitor(STsdb *tsdb); + int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) { STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg; pKeepCfg->precision = pCfg->precision; @@ -81,6 +84,12 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee goto _err; } +#ifdef TD_ENTERPRISE + if (tsdbOpenCompMonitor(pTsdb) < 0) { + goto _err; + } +#endif + tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d, keepTimeoffset:%d", TD_VID(pVnode), pTsdb->path, pTsdb->keepCfg.days, pTsdb->keepCfg.keep0, pTsdb->keepCfg.keep1, pTsdb->keepCfg.keep2, pTsdb->keepCfg.keepTimeOffset); @@ -108,6 +117,9 @@ int tsdbClose(STsdb **pTsdb) { tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); +#ifdef TD_ENTERPRISE + tsdbCloseCompMonitor(*pTsdb); +#endif taosThreadMutexDestroy(&(*pTsdb)->mutex); taosMemoryFreeClear(*pTsdb); } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 6bb5b51a30..427d5dd5d7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -25,6 +25,16 @@ #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) #define getCurrentKeyInSttBlock(_r) ((_r)->currentKey) +typedef struct { + bool overlapWithNeighborBlock; + bool hasDupTs; + bool overlapWithDelInfo; + bool overlapWithSttBlock; + bool overlapWithKeyInBuf; + bool partiallyRequired; + bool moreThanCapcity; +} SDataBlockToLoadInfo; + static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); static int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader); @@ -57,7 +67,7 @@ static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond static int32_t doBuildDataBlock(STsdbReader* pReader); static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader); static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo); -static bool hasDataInSttBlock(SSttBlockReader* pSttBlockReader); +static bool hasDataInSttBlock(STableBlockScanInfo *pInfo); static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter); static int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order); static void resetTableListIndex(SReaderStatus* pStatus); @@ -66,6 +76,8 @@ static void updateComposedBlockInfo(STsdbReader* pReader, double el, ST static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); } +static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus); + static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, int32_t numOfCols) { pSupInfo->smaValid = true; @@ -596,6 +608,13 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN return TSDB_CODE_OUT_OF_MEMORY; } + if (pScanInfo->filesetWindow.skey > pRecord->firstKey) { + pScanInfo->filesetWindow.skey = pRecord->firstKey; + } + if (pScanInfo->filesetWindow.ekey < pRecord->lastKey) { + pScanInfo->filesetWindow.ekey = pRecord->lastKey; + } + pBlockNum->numOfBlocks += 1; if (taosArrayGetSize(pTableScanInfoList) == 0) { taosArrayPush(pTableScanInfoList, &pScanInfo); @@ -614,7 +633,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug( - "load block of %d tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed " + "load block of %d tables completed, blocks:%d in %d tables, stt-files:%d, block-info-size:%.2f Kb, elapsed " "time:%.2f ms %s", numOfTables, pBlockNum->numOfBlocks, (int32_t)taosArrayGetSize(pTableScanInfoList), pBlockNum->numOfSttFiles, sizeInDisk / 1000.0, el, pReader->idStr); @@ -1226,78 +1245,6 @@ static bool keyOverlapFileBlock(TSDBKEY key, SFileDataBlockInfo* pBlock, SVersio (pBlock->record.maxVer >= pVerRange->minVer) && (pBlock->record.minVer <= pVerRange->maxVer); } -static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, - int32_t startIndex) { - size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline); - - for (int32_t i = startIndex; i < num; i += 1) { - TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); - if (p->ts >= pRecord->firstKey && p->ts <= pRecord->lastKey) { - if (p->version >= pRecord->minVer) { - return true; - } - } else if (p->ts < pRecord->firstKey) { // p->ts < pBlock->minKey.ts - if (p->version >= pRecord->minVer) { - if (i < num - 1) { - TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); - if (pnext->ts >= pRecord->firstKey) { - return true; - } - } else { // it must be the last point - ASSERT(p->version == 0); - } - } - } else { // (p->ts > pBlock->maxKey.ts) { - return false; - } - } - - return false; -} - -static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order) { - if (pBlockScanInfo->delSkyline == NULL || (taosArrayGetSize(pBlockScanInfo->delSkyline) == 0)) { - return false; - } - - // ts is not overlap - TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); - TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); - if (pRecord->firstKey > pLast->ts || pRecord->lastKey < pFirst->ts) { - return false; - } - - // version is not overlap - if (ASCENDING_TRAVERSE(order)) { - return doCheckforDatablockOverlap(pBlockScanInfo, pRecord, pBlockScanInfo->fileDelIndex); - } else { - int32_t index = pBlockScanInfo->fileDelIndex; - while (1) { - TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index); - if (p->ts > pRecord->firstKey && index > 0) { - index -= 1; - } else { // find the first point that is smaller than the minKey.ts of dataBlock. - if (p->ts == pRecord->firstKey && p->version < pRecord->maxVer && index > 0) { - index -= 1; - } - break; - } - } - - return doCheckforDatablockOverlap(pBlockScanInfo, pRecord, index); - } -} - -typedef struct { - bool overlapWithNeighborBlock; - bool hasDupTs; - bool overlapWithDelInfo; - bool overlapWithLastBlock; - bool overlapWithKeyInBuf; - bool partiallyRequired; - bool moreThanCapcity; -} SDataBlockToLoadInfo; - static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pScanInfo, TSDBKEY keyInBuf, STsdbReader* pReader) { SBrinRecord rec = {0}; @@ -1318,7 +1265,7 @@ static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* ASSERT(pScanInfo->sttKeyInfo.status != STT_FILE_READER_UNINIT); if (pScanInfo->sttKeyInfo.status == STT_FILE_HAS_DATA) { int64_t nextProcKeyInStt = pScanInfo->sttKeyInfo.nextProcKey; - pInfo->overlapWithLastBlock = + pInfo->overlapWithSttBlock = !(pBlockInfo->record.lastKey < nextProcKeyInStt || pBlockInfo->record.firstKey > nextProcKeyInStt); } @@ -1340,15 +1287,15 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pBlock bool loadDataBlock = (info.overlapWithNeighborBlock || info.hasDupTs || info.partiallyRequired || info.overlapWithKeyInBuf || - info.moreThanCapcity || info.overlapWithDelInfo || info.overlapWithLastBlock); + info.moreThanCapcity || info.overlapWithDelInfo || info.overlapWithSttBlock); // log the reason why load the datablock for profile if (loadDataBlock) { tsdbDebug("%p uid:%" PRIu64 " need to load the datablock, overlapneighbor:%d, hasDup:%d, partiallyRequired:%d, " - "overlapWithKey:%d, greaterThanBuf:%d, overlapWithDel:%d, overlapWithlastBlock:%d, %s", + "overlapWithKey:%d, greaterThanBuf:%d, overlapWithDel:%d, overlapWithSttBlock:%d, %s", pReader, pBlockInfo->uid, info.overlapWithNeighborBlock, info.hasDupTs, info.partiallyRequired, - info.overlapWithKeyInBuf, info.moreThanCapcity, info.overlapWithDelInfo, info.overlapWithLastBlock, + info.overlapWithKeyInBuf, info.moreThanCapcity, info.overlapWithDelInfo, info.overlapWithSttBlock, pReader->idStr); } @@ -1360,7 +1307,7 @@ static bool isCleanFileDataBlock(STsdbReader* pReader, SFileDataBlockInfo* pBloc SDataBlockToLoadInfo info = {0}; getBlockToLoadInfo(&info, pBlockInfo, pScanInfo, keyInBuf, pReader); bool isCleanFileBlock = !(info.overlapWithNeighborBlock || info.hasDupTs || info.overlapWithKeyInBuf || - info.overlapWithDelInfo || info.overlapWithLastBlock); + info.overlapWithDelInfo || info.overlapWithSttBlock); return isCleanFileBlock; } @@ -1521,7 +1468,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; int64_t tsLast = INT64_MIN; - if (hasDataInSttBlock(pSttBlockReader)) { + if (hasDataInSttBlock(pBlockScanInfo)) { tsLast = getCurrentKeyInSttBlock(pSttBlockReader); } @@ -1540,7 +1487,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* int64_t minKey = 0; if (pReader->info.order == TSDB_ORDER_ASC) { minKey = INT64_MAX; // chosen the minimum value - if (minKey > tsLast && hasDataInSttBlock(pSttBlockReader)) { + if (minKey > tsLast && hasDataInSttBlock(pBlockScanInfo)) { minKey = tsLast; } @@ -1553,7 +1500,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } } else { minKey = INT64_MIN; - if (minKey < tsLast && hasDataInSttBlock(pSttBlockReader)) { + if (minKey < tsLast && hasDataInSttBlock(pBlockScanInfo)) { minKey = tsLast; } @@ -1760,7 +1707,7 @@ static int32_t mergeFileBlockAndSttBlock(STsdbReader* pReader, SSttBlockReader* } bool dataInDataFile = hasDataInFileBlock(pBlockData, pDumpInfo); - bool dataInSttFile = hasDataInSttBlock(pSttBlockReader); + bool dataInSttFile = hasDataInSttBlock(pBlockScanInfo); if (dataInDataFile && (!dataInSttFile)) { // no stt file block available, only data block exists return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); @@ -1846,7 +1793,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader); int64_t tsLast = INT64_MIN; - if (hasDataInSttBlock(pSttBlockReader)) { + if (hasDataInSttBlock(pBlockScanInfo)) { tsLast = getCurrentKeyInSttBlock(pSttBlockReader); } @@ -1895,7 +1842,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = key; } - if (minKey > tsLast && hasDataInSttBlock(pSttBlockReader)) { + if (minKey > tsLast && hasDataInSttBlock(pBlockScanInfo)) { minKey = tsLast; } } else { @@ -1912,7 +1859,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = key; } - if (minKey < tsLast && hasDataInSttBlock(pSttBlockReader)) { + if (minKey < tsLast && hasDataInSttBlock(pBlockScanInfo)) { minKey = tsLast; } } @@ -2115,27 +2062,34 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum return true; } -static bool initSttBlockReader(SSttBlockReader* pLBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) { - // the last block reader has been initialized for this table. - if (pLBlockReader->uid == pScanInfo->uid) { - return hasDataInSttBlock(pLBlockReader); +static bool initSttBlockReader(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) { + bool hasData = true; + + // the stt block reader has been initialized for this table. + if (pSttBlockReader->uid == pScanInfo->uid) { + return hasDataInSttBlock(pScanInfo); } - if (pLBlockReader->uid != 0) { - tMergeTreeClose(&pLBlockReader->mergeTree); + if (pSttBlockReader->uid != 0) { + tMergeTreeClose(&pSttBlockReader->mergeTree); } - pLBlockReader->uid = pScanInfo->uid; + pSttBlockReader->uid = pScanInfo->uid; - STimeWindow w = pLBlockReader->window; - if (ASCENDING_TRAVERSE(pLBlockReader->order)) { + // second time init stt block reader + if (pScanInfo->cleanSttBlocks && pReader->info.execMode == READER_EXEC_ROWS) { + return !pScanInfo->sttBlockReturned; + } + + STimeWindow w = pSttBlockReader->window; + if (ASCENDING_TRAVERSE(pSttBlockReader->order)) { w.skey = pScanInfo->sttKeyInfo.nextProcKey; } else { w.ekey = pScanInfo->sttKeyInfo.nextProcKey; } int64_t st = taosGetTimestampUs(); - tsdbDebug("init last block reader, window:%" PRId64 "-%" PRId64 ", uid:%" PRIu64 ", %s", w.skey, w.ekey, + tsdbDebug("init stt block reader, window:%" PRId64 "-%" PRId64 ", uid:%" PRIu64 ", %s", w.skey, w.ekey, pScanInfo->uid, pReader->idStr); SMergeTreeConf conf = { @@ -2143,20 +2097,22 @@ static bool initSttBlockReader(SSttBlockReader* pLBlockReader, STableBlockScanIn .suid = pReader->info.suid, .pTsdb = pReader->pTsdb, .timewindow = w, - .verRange = pLBlockReader->verRange, + .verRange = pSttBlockReader->verRange, .strictTimeRange = false, .pSchema = pReader->info.pSchema, .pCurrentFileset = pReader->status.pCurrentFileset, - .backward = (pLBlockReader->order == TSDB_ORDER_DESC), + .backward = (pSttBlockReader->order == TSDB_ORDER_DESC), .pSttFileBlockIterArray = pReader->status.pLDataIterArray, .pCols = pReader->suppInfo.colId, .numOfCols = pReader->suppInfo.numOfCols, .loadTombFn = loadSttTombDataForAll, .pReader = pReader, .idstr = pReader->idStr, + .rspRows = (pReader->info.execMode == READER_EXEC_ROWS), }; - int32_t code = tMergeTreeOpen2(&pLBlockReader->mergeTree, &conf); + SSttDataInfoForTable info = {.pTimeWindowList = taosArrayInit(4, sizeof(STimeWindow))}; + int32_t code = tMergeTreeOpen2(&pSttBlockReader->mergeTree, &conf, &info); if (code != TSDB_CODE_SUCCESS) { return false; } @@ -2164,16 +2120,49 @@ static bool initSttBlockReader(SSttBlockReader* pLBlockReader, STableBlockScanIn initMemDataIterator(pScanInfo, pReader); initDelSkylineIterator(pScanInfo, pReader->info.order, &pReader->cost); - code = nextRowFromSttBlocks(pLBlockReader, pScanInfo, &pReader->info.verRange); + if (conf.rspRows) { + pScanInfo->cleanSttBlocks = + isCleanSttBlock(info.pTimeWindowList, &pReader->info.window, pScanInfo, pReader->info.order); + + if (pScanInfo->cleanSttBlocks) { + pScanInfo->numOfRowsInStt = info.numOfRows; + pScanInfo->sttWindow.skey = INT64_MAX; + pScanInfo->sttWindow.ekey = INT64_MIN; + + // calculate the time window for data in stt files + for(int32_t i = 0; i < taosArrayGetSize(info.pTimeWindowList); ++i) { + STimeWindow* pWindow = taosArrayGet(info.pTimeWindowList, i); + if (pScanInfo->sttWindow.skey > pWindow->skey) { + pScanInfo->sttWindow.skey = pWindow->skey; + } + + if (pScanInfo->sttWindow.ekey < pWindow->ekey) { + pScanInfo->sttWindow.ekey = pWindow->ekey; + } + } + + pScanInfo->sttKeyInfo.status = taosArrayGetSize(info.pTimeWindowList)? STT_FILE_HAS_DATA:STT_FILE_NO_DATA; + pScanInfo->sttKeyInfo.nextProcKey = ASCENDING_TRAVERSE(pReader->info.order)? pScanInfo->sttWindow.skey:pScanInfo->sttWindow.ekey; + hasData = true; + } else { + hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); + } + } else { + hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); + } + + taosArrayDestroy(info.pTimeWindowList); int64_t el = taosGetTimestampUs() - st; pReader->cost.initSttBlockReader += (el / 1000.0); - tsdbDebug("init last block reader completed, elapsed time:%" PRId64 "us %s", el, pReader->idStr); - return code; + tsdbDebug("init stt block reader completed, elapsed time:%" PRId64 "us %s", el, pReader->idStr); + return hasData; } -static bool hasDataInSttBlock(SSttBlockReader* pSttBlockReader) { return pSttBlockReader->mergeTree.pIter != NULL; } +static bool hasDataInSttBlock(STableBlockScanInfo *pInfo) { + return pInfo->sttKeyInfo.status == STT_FILE_HAS_DATA; +} bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) { if ((pBlockData->nRow > 0) && (pBlockData->nRow != pDumpInfo->totalRows)) { @@ -2360,56 +2349,50 @@ void updateComposedBlockInfo(STsdbReader* pReader, double el, STableBlockScanInf } static int32_t buildComposedDataBlock(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; - - SSDataBlock* pResBlock = pReader->resBlockInfo.pResBlock; - + int32_t code = TSDB_CODE_SUCCESS; + bool asc = ASCENDING_TRAVERSE(pReader->info.order); + int64_t st = taosGetTimestampUs(); + int32_t step = asc ? 1 : -1; + double el = 0; + SSDataBlock* pResBlock = pReader->resBlockInfo.pResBlock; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); - SSttBlockReader* pSttBlockReader = pReader->status.fileIter.pSttBlockReader; - - bool asc = ASCENDING_TRAVERSE(pReader->info.order); - int64_t st = taosGetTimestampUs(); - int32_t step = asc ? 1 : -1; - double el = 0; - SBrinRecord* pRecord = &pBlockInfo->record; - + SSttBlockReader* pSttBlockReader = pReader->status.fileIter.pSttBlockReader; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; + SBrinRecord* pRecord = NULL; STableBlockScanInfo* pBlockScanInfo = NULL; - if (pBlockInfo != NULL) { - if (pReader->pIgnoreTables && taosHashGet(*pReader->pIgnoreTables, &pBlockInfo->uid, sizeof(pBlockInfo->uid))) { - setBlockAllDumped(pDumpInfo, pRecord->lastKey, pReader->info.order); - return code; - } + if (pBlockInfo == NULL) { + return 0; + } - pBlockScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); - if (pBlockScanInfo == NULL) { - goto _end; - } + pRecord = &pBlockInfo->record; - pRecord = &pBlockInfo->record; - TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader); + if (pReader->pIgnoreTables && taosHashGet(*pReader->pIgnoreTables, &pBlockInfo->uid, sizeof(pBlockInfo->uid))) { + setBlockAllDumped(pDumpInfo, pRecord->lastKey, pReader->info.order); + return code; + } - // it is a clean block, load it directly - int64_t cap = pReader->resBlockInfo.capacity; - if (isCleanFileDataBlock(pReader, pBlockInfo, pBlockScanInfo, keyInBuf) && (pRecord->numRow <= cap)) { - if (asc || (pBlockScanInfo->sttKeyInfo.status == STT_FILE_NO_DATA)) { - code = copyBlockDataToSDataBlock(pReader); - if (code) { - goto _end; - } + pBlockScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); + if (pBlockScanInfo == NULL) { + goto _end; + } - // record the last key value - pBlockScanInfo->lastProcKey = asc ? pRecord->lastKey : pRecord->firstKey; + pRecord = &pBlockInfo->record; + TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader); + + // it is a clean block, load it directly + int64_t cap = pReader->resBlockInfo.capacity; + if (isCleanFileDataBlock(pReader, pBlockInfo, pBlockScanInfo, keyInBuf) && (pRecord->numRow <= cap)) { + if (((asc && (pRecord->firstKey < keyInBuf.ts)) || (!asc && (pRecord->lastKey > keyInBuf.ts))) && + (pBlockScanInfo->sttKeyInfo.status == STT_FILE_NO_DATA)) { + code = copyBlockDataToSDataBlock(pReader); + if (code) { goto _end; } - } - } else { // file blocks not exist - ASSERT(0); - pBlockScanInfo = *pReader->status.pTableIter; - if (pReader->pIgnoreTables && - taosHashGet(*pReader->pIgnoreTables, &pBlockScanInfo->uid, sizeof(pBlockScanInfo->uid))) { - return code; + + // record the last key value + pBlockScanInfo->lastProcKey = asc ? pRecord->lastKey : pRecord->firstKey; + goto _end; } } @@ -2573,15 +2556,17 @@ static void prepareDurationForNextFileSet(STsdbReader* pReader) { tsdbFidKeyRange(fid, pReader->pTsdb->keepCfg.days, pReader->pTsdb->keepCfg.precision, &winFid.skey, &winFid.ekey); if (ASCENDING_TRAVERSE(pReader->info.order)) { - pReader->status.bProcMemPreFileset = !(pReader->status.memTableMaxKey < pReader->status.prevFilesetStartKey || + pReader->status.bProcMemPreFileset = !(pReader->status.memTableMaxKey < pReader->status.prevFilesetStartKey || (winFid.skey-1) < pReader->status.memTableMinKey); } else { - pReader->status.bProcMemPreFileset = !( pReader->status.memTableMaxKey < (winFid.ekey+1) || + pReader->status.bProcMemPreFileset = !( pReader->status.memTableMaxKey < (winFid.ekey+1) || pReader->status.prevFilesetEndKey < pReader->status.memTableMinKey); } - + if (pReader->status.bProcMemPreFileset) { - resetTableListIndex(&pReader->status); + tsdbDebug("will start pre-fileset %d buffer processing. %s", fid, pReader->idStr); + pReader->status.procMemUidList.tableUidList = pReader->status.uidList.tableUidList; + resetPreFilesetMemTableListIndex(&pReader->status); } if (!pReader->status.bProcMemPreFileset) { @@ -2589,9 +2574,10 @@ static void prepareDurationForNextFileSet(STsdbReader* pReader) { STsdReaderNotifyInfo info = {0}; info.duration.filesetId = fid; pReader->notifyFn(TSD_READER_NOTIFY_DURATION_START, &info, pReader->notifyParam); - } + tsdbDebug("new duration %d start notification when no buffer preceeding fileset, %s", fid, pReader->idStr); + } } - + pReader->status.prevFilesetStartKey = winFid.skey; pReader->status.prevFilesetEndKey = winFid.ekey; } @@ -2659,6 +2645,14 @@ static void resetTableListIndex(SReaderStatus* pStatus) { pStatus->pTableIter = tSimpleHashGet(pStatus->pTableMap, &uid, sizeof(uid)); } +static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus) { + STableUidList* pList = &pStatus->procMemUidList; + + pList->currentIndex = 0; + uint64_t uid = pList->tableUidList[0]; + pStatus->pProcMemTableIter = tSimpleHashGet(pStatus->pTableMap, &uid, sizeof(uid)); +} + static bool moveToNextTable(STableUidList* pOrderedCheckInfo, SReaderStatus* pStatus) { pOrderedCheckInfo->currentIndex += 1; if (pOrderedCheckInfo->currentIndex >= tSimpleHashGetSize(pStatus->pTableMap)) { @@ -2671,11 +2665,24 @@ static bool moveToNextTable(STableUidList* pOrderedCheckInfo, SReaderStatus* pSt return (pStatus->pTableIter != NULL); } +static bool moveToNextTableForPreFileSetMem(SReaderStatus* pStatus) { + STableUidList* pUidList = &pStatus->procMemUidList; + pUidList->currentIndex += 1; + if (pUidList->currentIndex >= tSimpleHashGetSize(pStatus->pTableMap)) { + pStatus->pProcMemTableIter = NULL; + return false; + } + + uint64_t uid = pUidList->tableUidList[pUidList->currentIndex]; + pStatus->pProcMemTableIter = tSimpleHashGet(pStatus->pTableMap, &uid, sizeof(uid)); + return (pStatus->pProcMemTableIter != NULL); +} + static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) { - SReaderStatus* pStatus = &pReader->status; + SReaderStatus* pStatus = &pReader->status; SSttBlockReader* pSttBlockReader = pStatus->fileIter.pSttBlockReader; - STableUidList* pUidList = &pStatus->uidList; - int32_t code = TSDB_CODE_SUCCESS; + STableUidList* pUidList = &pStatus->uidList; + int32_t code = TSDB_CODE_SUCCESS; if (tSimpleHashGetSize(pStatus->pTableMap) == 0) { return TSDB_CODE_SUCCESS; @@ -2711,8 +2718,8 @@ static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) { continue; } - bool hasDataInLastFile = initSttBlockReader(pSttBlockReader, pScanInfo, pReader); - if (!hasDataInLastFile) { + bool hasDataInSttFile = initSttBlockReader(pSttBlockReader, pScanInfo, pReader); + if (!hasDataInSttFile) { bool hasNexTable = moveToNextTable(pUidList, pStatus); if (!hasNexTable) { return TSDB_CODE_SUCCESS; @@ -2721,12 +2728,37 @@ static int32_t doLoadSttBlockSequentially(STsdbReader* pReader) { continue; } + // if only require the total rows, no need to load data from stt file if it is clean stt blocks + if (pReader->info.execMode == READER_EXEC_ROWS && pScanInfo->cleanSttBlocks) { + bool asc = ASCENDING_TRAVERSE(pReader->info.order); + + SDataBlockInfo* pInfo = &pResBlock->info; + blockDataEnsureCapacity(pResBlock, pScanInfo->numOfRowsInStt); + + pInfo->rows = pScanInfo->numOfRowsInStt; + pInfo->id.uid = pScanInfo->uid; + pInfo->dataLoad = 1; + pInfo->window = pScanInfo->sttWindow; + + setComposedBlockFlag(pReader, true); + + pScanInfo->sttKeyInfo.nextProcKey = asc ? pScanInfo->sttWindow.ekey + 1 : pScanInfo->sttWindow.skey - 1; + pScanInfo->sttKeyInfo.status = STT_FILE_NO_DATA; + pScanInfo->lastProcKey = asc ? pScanInfo->sttWindow.ekey : pScanInfo->sttWindow.skey; + pScanInfo->sttBlockReturned = true; + + pSttBlockReader->mergeTree.pIter = NULL; + + tsdbDebug("%p uid:%" PRId64 " return clean stt block as one, brange:%" PRId64 "-%" PRId64 " rows:%" PRId64 " %s", + pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, + pResBlock->info.rows, pReader->idStr); + return TSDB_CODE_SUCCESS; + } + int64_t st = taosGetTimestampUs(); while (1) { - bool hasBlockLData = hasDataInSttBlock(pSttBlockReader); - - // no data in last block and block, no need to proceed. - if (hasBlockLData == false) { + // no data in stt block and block, no need to proceed. + if (!hasDataInSttBlock(pScanInfo)) { break; } @@ -2771,14 +2803,13 @@ static bool notOverlapWithSttFiles(SFileDataBlockInfo* pBlockInfo, STableBlockSc } static int32_t doBuildDataBlock(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; - SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; STableBlockScanInfo* pScanInfo = NULL; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); - SSttBlockReader* pSttBlockReader = pReader->status.fileIter.pSttBlockReader; + SSttBlockReader* pSttBlockReader = pReader->status.fileIter.pSttBlockReader; bool asc = ASCENDING_TRAVERSE(pReader->info.order); + int32_t code = TSDB_CODE_SUCCESS; if (pReader->pIgnoreTables && taosHashGet(*pReader->pIgnoreTables, &pBlockInfo->uid, sizeof(pBlockInfo->uid))) { setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlockInfo->record.lastKey, pReader->info.order); @@ -2836,14 +2867,15 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { SSDataBlock* pResBlock = pReader->resBlockInfo.pResBlock; - tsdbDebug("load data in last block firstly %s", pReader->idStr); + tsdbDebug("load data in stt block firstly %s", pReader->idStr); int64_t st = taosGetTimestampUs(); - // let's load data from stt files + // let's load data from stt files, make sure clear the cleanStt block flag before load the data from stt files + pScanInfo->cleanSttBlocks = false; initSttBlockReader(pSttBlockReader, pScanInfo, pReader); - // no data in last block, no need to proceed. - while (hasDataInSttBlock(pSttBlockReader)) { + // no data in stt block, no need to proceed. + while (hasDataInSttBlock(pScanInfo)) { ASSERT(pScanInfo->sttKeyInfo.status == STT_FILE_HAS_DATA); code = buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pSttBlockReader); @@ -2880,145 +2912,45 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { return (pReader->code != TSDB_CODE_SUCCESS) ? pReader->code : code; } -static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReader) { - int64_t st = taosGetTimestampUs(); - LRUHandle* handle = NULL; - int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle); - if (code != TSDB_CODE_SUCCESS || handle == NULL) { - goto _end; - } +static int32_t buildBlockFromBufferSeqForPreFileset(STsdbReader* pReader, int64_t endKey) { + SReaderStatus* pStatus = &pReader->status; -#if 0 - int32_t numOfTables = tSimpleHashGetSize(pReader->status.pTableMap); - - SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle); - size_t num = taosArrayGetSize(aBlockIdx); - if (num == 0) { - tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); - return TSDB_CODE_SUCCESS; - } - - SBlockIdx* pBlockIdx = NULL; - for (int32_t i = 0; i < num; ++i) { - pBlockIdx = (SBlockIdx*)taosArrayGet(aBlockIdx, i); - if (pBlockIdx->suid != pReader->info.suid) { - continue; - } - - STableBlockScanInfo** p = tSimpleHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(pBlockIdx->uid)); - if (p == NULL) { - continue; - } - - STableBlockScanInfo* pScanInfo = *p; - SDataBlk block = {0}; - // for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) { - // tGetDataBlk(pScanInfo->mapData.pData + pScanInfo->mapData.aOffset[j], &block); - // pReader->rowsNum += block.nRow; - // } - } -#endif - -_end: - tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); - return code; -} - -static int32_t doSumSttBlockRows(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; - SSttBlockReader* pSttBlockReader = pReader->status.fileIter.pSttBlockReader; - SSttBlockLoadInfo* pBlockLoadInfo = NULL; -#if 0 - for (int32_t i = 0; i < pReader->pFileReader->pSet->nSttF; ++i) { // open all last file - pBlockLoadInfo = &pSttBlockReader->pInfo[i]; - - code = tsdbReadSttBlk(pReader->pFileReader, i, pBlockLoadInfo->aSttBlk); - if (code) { - return code; - } - - size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk); - if (size >= 1) { - SSttBlk* pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0); - SSttBlk* pEnd = taosArrayGet(pBlockLoadInfo->aSttBlk, size - 1); - - // all identical - if (pStart->suid == pEnd->suid) { - if (pStart->suid != pReader->info.suid) { - // no qualified stt block existed - taosArrayClear(pBlockLoadInfo->aSttBlk); - continue; - } - for (int32_t j = 0; j < size; ++j) { - SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, j); - pReader->rowsNum += p->nRow; - } - } else { - for (int32_t j = 0; j < size; ++j) { - SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, j); - uint64_t s = p->suid; - if (s < pReader->info.suid) { - continue; - } - - if (s == pReader->info.suid) { - pReader->rowsNum += p->nRow; - } else if (s > pReader->info.suid) { - break; - } - } - } - } - } -#endif - - return code; -} - -static int32_t readRowsCountFromFiles(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; + tsdbDebug("seq load data blocks from cache that preceeds fileset %d, %s", pReader->status.pCurrentFileset->fid, pReader->idStr); while (1) { - bool hasNext = false; - code = filesetIteratorNext(&pReader->status.fileIter, pReader, &hasNext); - if (code) { - return code; + if (pReader->code != TSDB_CODE_SUCCESS) { + tsdbWarn("tsdb reader is stopped ASAP, code:%s, %s", strerror(pReader->code), pReader->idStr); + return pReader->code; } - if (!hasNext) { // no data files on disk - break; + STableBlockScanInfo** pBlockScanInfo = pStatus->pProcMemTableIter; + if (pReader->pIgnoreTables && + taosHashGet(*pReader->pIgnoreTables, &(*pBlockScanInfo)->uid, sizeof((*pBlockScanInfo)->uid))) { + bool hasNexTable = moveToNextTableForPreFileSetMem(pStatus); + if (!hasNexTable) { + return TSDB_CODE_SUCCESS; + } + continue; } - // code = doSumFileBlockRows(pReader, pReader->pFileReader); + initMemDataIterator(*pBlockScanInfo, pReader); + initDelSkylineIterator(*pBlockScanInfo, pReader->info.order, &pReader->cost); + + int32_t code = buildDataBlockFromBuf(pReader, *pBlockScanInfo, endKey); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doSumSttBlockRows(pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; + if (pReader->resBlockInfo.pResBlock->info.rows > 0) { + return TSDB_CODE_SUCCESS; + } + + // current table is exhausted, let's try next table + bool hasNexTable = moveToNextTableForPreFileSetMem(pStatus); + if (!hasNexTable) { + return TSDB_CODE_SUCCESS; } } - - pReader->status.loadFromFile = false; - - return code; -} - -static int32_t readRowsCountFromMem(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; - int64_t memNum = 0, imemNum = 0; - if (pReader->pReadSnap->pMem != NULL) { - tsdbMemTableCountRows(pReader->pReadSnap->pMem, pReader->status.pTableMap, &memNum); - } - - if (pReader->pReadSnap->pIMem != NULL) { - tsdbMemTableCountRows(pReader->pReadSnap->pIMem, pReader->status.pTableMap, &imemNum); - } - - pReader->rowsNum += memNum + imemNum; - - return code; } static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader, int64_t endKey) { @@ -3149,7 +3081,7 @@ static ERetrieveType doReadDataFromSttFiles(STsdbReader* pReader) { return TSDB_READ_RETURN; } - // all data blocks are checked in this last block file, now let's try the next file + // all data blocks are checked in this stt file, now let's try the next file set ASSERT(pReader->status.pTableIter == NULL); code = initForFirstBlockInFile(pReader, pBlockIter); @@ -3875,7 +3807,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e } if (row.type == TSDBROW_ROW_FMT) { - int64_t ts = row.pTSRow->ts;; + int64_t ts = row.pTSRow->ts; code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); if (freeTSRow) { @@ -3986,14 +3918,14 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { getMemTableTimeRange(pReader, &pReader->status.memTableMaxKey, &pReader->status.memTableMinKey); pReader->status.bProcMemFirstFileset = true; } - + initFilesetIterator(&pStatus->fileIter, pReader->pReadSnap->pfSetArray, pReader); resetDataBlockIterator(&pStatus->blockIter, pReader->info.order); int32_t code = TSDB_CODE_SUCCESS; if (pStatus->fileIter.numOfFiles == 0) { pStatus->loadFromFile = false; - } else if (READ_MODE_COUNT_ONLY == pReader->info.readMode) { +// } else if (READER_EXEC_DATA == pReader->info.readMode) { // DO NOTHING } else { code = initForFirstBlockInFile(pReader, pBlockIter); @@ -4034,8 +3966,7 @@ static void setSharedPtr(STsdbReader* pDst, const STsdbReader* pSrc) { // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen2(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables, - SSDataBlock* pResBlock, void** ppReader, const char* idstr, bool countOnly, - SHashObj** pIgnoreTables) { + SSDataBlock* pResBlock, void** ppReader, const char* idstr, SHashObj** pIgnoreTables) { STimeWindow window = pCond->twindows; SVnodeCfg* pConf = &(((SVnode*)pVnode)->config); @@ -4141,13 +4072,9 @@ int32_t tsdbReaderOpen2(void* pVnode, SQueryTableDataCond* pCond, void* pTableLi } pReader->flag = READER_STATUS_SUSPEND; - - if (countOnly) { - pReader->info.readMode = READ_MODE_COUNT_ONLY; - } + pReader->info.execMode = pCond->notLoadData? READER_EXEC_ROWS : READER_EXEC_DATA; pReader->pIgnoreTables = pIgnoreTables; - tsdbDebug("%p total numOfTable:%d, window:%" PRId64 " - %" PRId64 ", verRange:%" PRId64 " - %" PRId64 " in this query %s", pReader, numOfTables, pReader->info.window.skey, pReader->info.window.ekey, pReader->info.verRange.minVer, @@ -4257,8 +4184,6 @@ int32_t tsdbReaderSuspend2(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; STableBlockScanInfo* pBlockScanInfo = NULL; - pReader->status.suspendInvoked = true; // record the suspend status - if (pStatus->loadFromFile) { SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); if (pBlockInfo != NULL) { @@ -4383,30 +4308,31 @@ _err: return code; } -static bool tsdbReadRowsCountOnly(STsdbReader* pReader) { - int32_t code = TSDB_CODE_SUCCESS; +static int32_t buildFromPreFilesetBuffer(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SReaderStatus* pStatus = &pReader->status; + SSDataBlock* pBlock = pReader->resBlockInfo.pResBlock; - if (pReader->status.loadFromFile == false) { - return false; + int32_t fid = pReader->status.pCurrentFileset->fid; + STimeWindow win = {0}; + tsdbFidKeyRange(fid, pReader->pTsdb->keepCfg.days, pReader->pTsdb->keepCfg.precision, &win.skey, &win.ekey); + + int64_t endKey = (ASCENDING_TRAVERSE(pReader->info.order)) ? win.skey : win.ekey; + code = buildBlockFromBufferSeqForPreFileset(pReader, endKey); + if (code != TSDB_CODE_SUCCESS || pBlock->info.rows > 0) { + return code; + } else { + tsdbDebug("finished pre-fileset %d buffer processing. %s", fid, pReader->idStr); + pStatus->bProcMemPreFileset = false; + if (pReader->notifyFn) { + STsdReaderNotifyInfo info = {0}; + info.duration.filesetId = fid; + pReader->notifyFn(TSD_READER_NOTIFY_DURATION_START, &info, pReader->notifyParam); + tsdbDebug("new duration %d start notification when buffer pre-fileset, %s", fid, pReader->idStr); + } } - - code = readRowsCountFromFiles(pReader); - if (code != TSDB_CODE_SUCCESS) { - return false; - } - - code = readRowsCountFromMem(pReader); - if (code != TSDB_CODE_SUCCESS) { - return false; - } - - pBlock->info.rows = pReader->rowsNum; - pBlock->info.id.uid = 0; - pBlock->info.dataLoad = 0; - pReader->rowsNum = 0; - - return pBlock->info.rows > 0; + return code; } static int32_t doTsdbNextDataBlockFilesetDelimited(STsdbReader* pReader) { @@ -4416,22 +4342,9 @@ static int32_t doTsdbNextDataBlockFilesetDelimited(STsdbReader* pReader) { if (pStatus->loadFromFile) { if (pStatus->bProcMemPreFileset) { - int32_t fid = pReader->status.pCurrentFileset->fid; - STimeWindow win = {0}; - tsdbFidKeyRange(fid, pReader->pTsdb->keepCfg.days, pReader->pTsdb->keepCfg.precision, &win.skey, &win.ekey); - - int64_t endKey = (ASCENDING_TRAVERSE(pReader->info.order)) ? win.skey : win.ekey; - code = buildBlockFromBufferSequentially(pReader, endKey); + code = buildFromPreFilesetBuffer(pReader); if (code != TSDB_CODE_SUCCESS || pBlock->info.rows > 0) { return code; - } else { - pStatus->bProcMemPreFileset = false; - if (pReader->notifyFn) { - STsdReaderNotifyInfo info = {0}; - info.duration.filesetId = fid; - pReader->notifyFn(TSD_READER_NOTIFY_DURATION_START, &info, pReader->notifyParam); - } - resetTableListIndex(pStatus); } } @@ -4440,6 +4353,21 @@ static int32_t doTsdbNextDataBlockFilesetDelimited(STsdbReader* pReader) { return code; } + tsdbTrace("block from file rows: %"PRId64", will process pre-file set buffer: %d. %s", + pBlock->info.rows, pStatus->bProcMemFirstFileset, pReader->idStr); + if (pStatus->bProcMemPreFileset) { + if (pBlock->info.rows > 0) { + if (pReader->notifyFn) { + int32_t fid = pReader->status.pCurrentFileset->fid; + STsdReaderNotifyInfo info = {0}; + info.duration.filesetId = fid; + pReader->notifyFn(TSD_READER_NOTIFY_NEXT_DURATION_BLOCK, &info, pReader->notifyParam); + } + } else { + pStatus->bProcMemPreFileset = false; + } + } + if (pBlock->info.rows <= 0) { resetTableListIndex(&pReader->status); int64_t endKey = (ASCENDING_TRAVERSE(pReader->info.order)) ? INT64_MAX : INT64_MIN; @@ -4489,9 +4417,6 @@ static int32_t doTsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) { return code; } - if (READ_MODE_COUNT_ONLY == pReader->info.readMode) { - return tsdbReadRowsCountOnly(pReader); - } if (!pReader->bFilesetDelimited) { code = doTsdbNextDataBlockFilesFirst(pReader); } else { @@ -4793,7 +4718,7 @@ SSDataBlock* tsdbRetrieveDataBlock2(STsdbReader* pReader, SArray* pIdList) { } SReaderStatus* pStatus = &pTReader->status; - if (pStatus->composedDataBlock) { + if (pStatus->composedDataBlock || pReader->info.execMode == READER_EXEC_ROWS) { return pTReader->resBlockInfo.pResBlock; } @@ -4830,9 +4755,9 @@ int32_t tsdbReaderReset2(STsdbReader* pReader, SQueryTableDataCond* pCond) { pReader->info.order = pCond->order; pReader->type = TIMEWINDOW_RANGE_CONTAINED; + pReader->info.window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); pStatus->loadFromFile = true; pStatus->pTableIter = NULL; - pReader->info.window = updateQueryTimeWindow(pReader->pTsdb, &pCond->twindows); // allocate buffer in order to load data blocks from file memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg)); @@ -4888,14 +4813,13 @@ static int32_t getBucketIndex(int32_t startRow, int32_t bucketRange, int32_t num } int32_t tsdbGetFileBlocksDistInfo2(STsdbReader* pReader, STableBlockDistInfo* pTableBlockInfo) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; + const int32_t numOfBuckets = 20.0; + pTableBlockInfo->totalSize = 0; pTableBlockInfo->totalRows = 0; pTableBlockInfo->numOfVgroups = 1; - const int32_t numOfBuckets = 20.0; - const int32_t defaultRows = 4096; - // find the start data block in file tsdbAcquireReader(pReader); if (pReader->flag == READER_STATUS_SUSPEND) { diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c index a058c0173d..a223a2dc2d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c @@ -22,15 +22,9 @@ #include "tsdbUtil2.h" #include "tsimplehash.h" -int32_t uidComparFunc(const void* p1, const void* p2) { - uint64_t pu1 = *(uint64_t*)p1; - uint64_t pu2 = *(uint64_t*)p2; - if (pu1 == pu2) { - return 0; - } else { - return (pu1 < pu2) ? -1 : 1; - } -} +#define INIT_TIMEWINDOW(_w) do { (_w)->skey = INT64_MAX; (_w)->ekey = INT64_MIN;} while(0); + +static bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order); static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { int32_t num = numOfTables / pBuf->numPerBucket; @@ -61,6 +55,16 @@ static int32_t initBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { return TSDB_CODE_SUCCESS; } +int32_t uidComparFunc(const void* p1, const void* p2) { + uint64_t pu1 = *(uint64_t*)p1; + uint64_t pu2 = *(uint64_t*)p2; + if (pu1 == pu2) { + return 0; + } else { + return (pu1 < pu2) ? -1 : 1; + } +} + int32_t ensureBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) { if (numOfTables <= pBuf->numOfTables) { return TSDB_CODE_SUCCESS; @@ -153,6 +157,9 @@ SSHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(pBuf, j); pScanInfo->uid = idList[j].uid; + INIT_TIMEWINDOW(&pScanInfo->sttWindow); + INIT_TIMEWINDOW(&pScanInfo->filesetWindow); + pUidList->tableUidList[j] = idList[j].uid; if (ASCENDING_TRAVERSE(pTsdbReader->info.order)) { @@ -243,6 +250,11 @@ static void doCleanupInfoForNextFileset(STableBlockScanInfo* pScanInfo) { taosArrayClear(pScanInfo->pBlockList); taosArrayClear(pScanInfo->pBlockIdxList); taosArrayClear(pScanInfo->pFileDelData); // del data from each file set + pScanInfo->cleanSttBlocks = false; + pScanInfo->numOfRowsInStt = 0; + pScanInfo->sttBlockReturned = false; + INIT_TIMEWINDOW(&pScanInfo->sttWindow); + INIT_TIMEWINDOW(&pScanInfo->filesetWindow); pScanInfo->sttKeyInfo.status = STT_FILE_READER_UNINIT; } @@ -403,12 +415,10 @@ int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int3 blockInfo.record = *(SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[0][i].pInfo->pBlockList, i); taosArrayPush(pBlockIter->blockList, &blockInfo); - STableDataBlockIdx tableDataBlockIdx = {.globalIndex = i}; taosArrayPush(pTableScanInfo->pBlockIdxList, &tableDataBlockIdx); } - taosArrayDestroy(pTableScanInfo->pBlockList); - pTableScanInfo->pBlockList = NULL; + pTableScanInfo->pBlockList = taosArrayDestroy(pTableScanInfo->pBlockList); int64_t et = taosGetTimestampUs(); tsdbDebug("%p create blocks info struct completed for one table, %d blocks not sorted, elapsed time:%.2f ms %s", @@ -457,8 +467,7 @@ int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int3 for (int32_t i = 0; i < numOfTables; ++i) { STableBlockScanInfo* pTableScanInfo = taosArrayGetP(pTableList, i); - taosArrayDestroy(pTableScanInfo->pBlockList); - pTableScanInfo->pBlockList = NULL; + pTableScanInfo->pBlockList = taosArrayDestroy(pTableScanInfo->pBlockList); } int64_t et = taosGetTimestampUs(); @@ -488,7 +497,7 @@ typedef enum { BLK_CHECK_QUIT = 0x2, } ETombBlkCheckEnum; -static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, const SSttBlockLoadInfo* pBlockLoadInfo, +static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock, const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i, int32_t* j); static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_t numOfTables, int32_t* j, ETombBlkCheckEnum* pRet) { @@ -662,17 +671,17 @@ void loadMemTombData(SArray** ppMemDelData, STbData* pMemTbData, STbData* piMemT } } -int32_t getNumOfRowsInSttBlock(SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pBlockLoadInfo, uint64_t suid, - const uint64_t* pUidList, int32_t numOfTables) { +int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pBlockLoadInfo, + TStatisBlkArray* pStatisBlkArray, uint64_t suid, const uint64_t* pUidList, + int32_t numOfTables) { int32_t num = 0; - const TStatisBlkArray *pStatisBlkArray = pBlockLoadInfo->pSttStatisBlkArray; if (TARRAY2_SIZE(pStatisBlkArray) <= 0) { return 0; } int32_t i = 0; - while((i < TARRAY2_SIZE(pStatisBlkArray)) && (pStatisBlkArray->data[i].minTbid.suid < suid)) { + while((i < TARRAY2_SIZE(pStatisBlkArray)) && (pStatisBlkArray->data[i].maxTbid.suid < suid)) { ++i; } @@ -681,64 +690,65 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader *pSttFileReader, SSttBlockLoadInfo } SStatisBlk *p = &pStatisBlkArray->data[i]; - if (pBlockLoadInfo->statisBlock == NULL) { - pBlockLoadInfo->statisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock)); - tStatisBlockInit(pBlockLoadInfo->statisBlock); - } + STbStatisBlock* pStatisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock)); + tStatisBlockInit(pStatisBlock); int64_t st = taosGetTimestampMs(); - tsdbSttFileReadStatisBlock(pSttFileReader, p, pBlockLoadInfo->statisBlock); - pBlockLoadInfo->statisBlockIndex = i; + tsdbSttFileReadStatisBlock(pSttFileReader, p, pStatisBlock); double el = (taosGetTimestampMs() - st) / 1000.0; pBlockLoadInfo->cost.loadStatisBlocks += 1; pBlockLoadInfo->cost.statisElapsedTime += el; - STbStatisBlock *pBlock = pBlockLoadInfo->statisBlock; - int32_t index = 0; - while (index < TARRAY2_SIZE(pBlock->suid) && pBlock->suid->data[index] < suid) { + while (index < TARRAY2_SIZE(pStatisBlock->suid) && pStatisBlock->suid->data[index] < suid) { ++index; } - if (index >= TARRAY2_SIZE(pBlock->suid)) { + if (index >= TARRAY2_SIZE(pStatisBlock->suid)) { + tStatisBlockDestroy(pStatisBlock); + taosMemoryFreeClear(pStatisBlock); return num; } int32_t j = index; int32_t uidIndex = 0; - while (i < TARRAY2_SIZE(pStatisBlkArray) && uidIndex <= numOfTables) { + while (i < TARRAY2_SIZE(pStatisBlkArray) && uidIndex < numOfTables) { p = &pStatisBlkArray->data[i]; if (p->minTbid.suid > suid) { + tStatisBlockDestroy(pStatisBlock); + taosMemoryFreeClear(pStatisBlock); return num; } uint64_t uid = pUidList[uidIndex]; - if (pBlock->uid->data[j] == uid) { - num += pBlock->count->data[j]; + if (pStatisBlock->uid->data[j] == uid) { + num += pStatisBlock->count->data[j]; uidIndex += 1; j += 1; - loadNextStatisticsBlock(pSttFileReader, pBlockLoadInfo, pStatisBlkArray, pBlock->suid->size, &i, &j); - } else if (pBlock->uid->data[j] < uid) { + loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->suid->size, &i, &j); + } else if (pStatisBlock->uid->data[j] < uid) { j += 1; - loadNextStatisticsBlock(pSttFileReader, pBlockLoadInfo, pStatisBlkArray, pBlock->suid->size, &i, &j); + loadNextStatisticsBlock(pSttFileReader, pStatisBlock, pStatisBlkArray, pStatisBlock->suid->size, &i, &j); } else { uidIndex += 1; } } + tStatisBlockDestroy(pStatisBlock); + taosMemoryFreeClear(pStatisBlock); return num; } // load next stt statistics block -static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, const SSttBlockLoadInfo* pBlockLoadInfo, +static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlock* pStatisBlock, const TStatisBlkArray* pStatisBlkArray, int32_t numOfRows, int32_t* i, int32_t* j) { if ((*j) >= numOfRows) { (*i) += 1; (*j) = 0; if ((*i) < TARRAY2_SIZE(pStatisBlkArray)) { - tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pBlockLoadInfo->statisBlock); + tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pStatisBlock); } } } @@ -762,7 +772,7 @@ void doAdjustValidDataIters(SArray* pLDIterList, int32_t numOfFileObj) { } } -int32_t adjustLDataIters(SArray* pSttFileBlockIterArray, STFileSet* pFileSet) { +int32_t adjustSttDataIters(SArray* pSttFileBlockIterArray, STFileSet* pFileSet) { int32_t numOfLevels = pFileSet->lvlArr->size; // add the list/iter placeholder @@ -791,7 +801,7 @@ int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArra } // add the list/iter placeholder - adjustLDataIters(pSttFileBlockIterArray, pFileSet); + adjustSttDataIters(pSttFileBlockIterArray, pFileSet); for (int32_t j = 0; j < numOfLevels; ++j) { SSttLvl* pSttLevel = pFileSet->lvlArr->data[j]; @@ -819,7 +829,8 @@ int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArra } // load stt blocks statis for all stt-blocks, to decide if the data of queried table exists in current stt file - int32_t code = tsdbSttFileReadStatisBlk(pIter->pReader, (const TStatisBlkArray **)&pIter->pBlockLoadInfo->pSttStatisBlkArray); + TStatisBlkArray *pStatisBlkArray = NULL; + int32_t code = tsdbSttFileReadStatisBlk(pIter->pReader, (const TStatisBlkArray **)&pStatisBlkArray); if (code != TSDB_CODE_SUCCESS) { tsdbError("failed to load stt block statistics, code:%s, %s", tstrerror(code), pstr); continue; @@ -829,9 +840,214 @@ int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArra STsdbReader* pReader = pConf->pReader; int32_t numOfTables = tSimpleHashGetSize(pReader->status.pTableMap); uint64_t* pUidList = pReader->status.uidList.tableUidList; - numOfRows += getNumOfRowsInSttBlock(pIter->pReader, pIter->pBlockLoadInfo, pConf->suid, pUidList, numOfTables); + numOfRows += getNumOfRowsInSttBlock(pIter->pReader, pIter->pBlockLoadInfo, pStatisBlkArray, pConf->suid, pUidList, + numOfTables); } } return numOfRows; +} + +static bool overlapHelper(const STimeWindow* pLeft, TSKEY minKey, TSKEY maxKey) { + return (pLeft->ekey >= minKey) && (pLeft->skey <= maxKey); +} + +static bool overlapWithTimeWindow(STimeWindow* p1, STimeWindow* pQueryWindow, STableBlockScanInfo* pBlockScanInfo, + int32_t order) { + // overlap with query window + if (!(p1->skey >= pQueryWindow->skey && p1->ekey <= pQueryWindow->ekey)) { + return true; + } + + SIterInfo* pMemIter = &pBlockScanInfo->iter; + SIterInfo* pIMemIter = &pBlockScanInfo->iiter; + + // overlap with mem data + if (pMemIter->hasVal) { + STbData* pTbData = pMemIter->iter->pTbData; + if (overlapHelper(p1, pTbData->minKey, pTbData->maxKey)) { + return true; + } + } + + // overlap with imem data + if (pIMemIter->hasVal) { + STbData* pITbData = pIMemIter->iter->pTbData; + if (overlapHelper(p1, pITbData->minKey, pITbData->maxKey)) { + return true; + } + } + + // overlap with data file block + STimeWindow* pFileWin = &pBlockScanInfo->filesetWindow; + if ((taosArrayGetSize(pBlockScanInfo->pBlockIdxList) > 0) && overlapHelper(p1, pFileWin->skey, pFileWin->ekey)) { + return true; + } + + // overlap with deletion skyline + SBrinRecord record = {.firstKey = p1->skey, .lastKey = p1->ekey}; + if (overlapWithDelSkylineWithoutVer(pBlockScanInfo, &record, order)) { + return true; + } + + return false; +} + +static int32_t sortUidComparFn(const void* p1, const void* p2) { + const STimeWindow* px1 = p1; + const STimeWindow* px2 = p2; + if (px1->skey == px2->skey) { + return 0; + } else { + return px1->skey < px2->skey? -1:1; + } +} + +bool isCleanSttBlock(SArray* pTimewindowList, STimeWindow* pQueryWindow, STableBlockScanInfo *pScanInfo, int32_t order) { + // check if it overlap with del skyline + taosArraySort(pTimewindowList, sortUidComparFn); + + int32_t num = taosArrayGetSize(pTimewindowList); + if (num == 0) { + return false; + } + + STimeWindow* p = taosArrayGet(pTimewindowList, 0); + if (overlapWithTimeWindow(p, pQueryWindow, pScanInfo, order)) { + return false; + } + + for (int32_t i = 0; i < num - 1; ++i) { + STimeWindow* p1 = taosArrayGet(pTimewindowList, i); + STimeWindow* p2 = taosArrayGet(pTimewindowList, i + 1); + + if (p1->ekey >= p2->skey) { + return false; + } + + bool overlap = overlapWithTimeWindow(p2, pQueryWindow, pScanInfo, order); + if (overlap) { + return false; + } + } + + return true; +} + +static bool doCheckDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, + int32_t startIndex) { + size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline); + + for (int32_t i = startIndex; i < num; i += 1) { + TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); + if (p->ts >= pRecord->firstKey && p->ts <= pRecord->lastKey) { + if (p->version >= pRecord->minVer) { + return true; + } + } else if (p->ts < pRecord->firstKey) { // p->ts < pBlock->minKey.ts + if (p->version >= pRecord->minVer) { + if (i < num - 1) { + TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); + if (pnext->ts >= pRecord->firstKey) { + return true; + } + } else { // it must be the last point + ASSERT(p->version == 0); + } + } + } else { // (p->ts > pBlock->maxKey.ts) { + return false; + } + } + + return false; +} + +static bool doCheckDatablockOverlapWithoutVersion(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, + int32_t startIndex) { + size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline); + + for (int32_t i = startIndex; i < num; i += 1) { + TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, i); + if (p->ts >= pRecord->firstKey && p->ts <= pRecord->lastKey) { + return true; + } else if (p->ts < pRecord->firstKey) { // p->ts < pBlock->minKey.ts + if (i < num - 1) { + TSDBKEY* pnext = taosArrayGet(pBlockScanInfo->delSkyline, i + 1); + if (pnext->ts >= pRecord->firstKey) { + return true; + } + } + } else { // (p->ts > pBlock->maxKey.ts) { + return false; + } + } + + return false; +} + +bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order) { + if (pBlockScanInfo->delSkyline == NULL || (taosArrayGetSize(pBlockScanInfo->delSkyline) == 0)) { + return false; + } + + // ts is not overlap + TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); + TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); + if (pRecord->firstKey > pLast->ts || pRecord->lastKey < pFirst->ts) { + return false; + } + + // version is not overlap + if (ASCENDING_TRAVERSE(order)) { + return doCheckDatablockOverlap(pBlockScanInfo, pRecord, pBlockScanInfo->fileDelIndex); + } else { + int32_t index = pBlockScanInfo->fileDelIndex; + while (1) { + TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index); + if (p->ts > pRecord->firstKey && index > 0) { + index -= 1; + } else { // find the first point that is smaller than the minKey.ts of dataBlock. + if (p->ts == pRecord->firstKey && p->version < pRecord->maxVer && index > 0) { + index -= 1; + } + break; + } + } + + return doCheckDatablockOverlap(pBlockScanInfo, pRecord, index); + } +} + +bool overlapWithDelSkylineWithoutVer(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order) { + if (pBlockScanInfo->delSkyline == NULL || (taosArrayGetSize(pBlockScanInfo->delSkyline) == 0)) { + return false; + } + + // ts is not overlap + TSDBKEY* pFirst = taosArrayGet(pBlockScanInfo->delSkyline, 0); + TSDBKEY* pLast = taosArrayGetLast(pBlockScanInfo->delSkyline); + if (pRecord->firstKey > pLast->ts || pRecord->lastKey < pFirst->ts) { + return false; + } + + // version is not overlap + if (ASCENDING_TRAVERSE(order)) { + return doCheckDatablockOverlapWithoutVersion(pBlockScanInfo, pRecord, pBlockScanInfo->fileDelIndex); + } else { + int32_t index = pBlockScanInfo->fileDelIndex; + while (1) { + TSDBKEY* p = taosArrayGet(pBlockScanInfo->delSkyline, index); + if (p->ts > pRecord->firstKey && index > 0) { + index -= 1; + } else { // find the first point that is smaller than the minKey.ts of dataBlock. + if (p->ts == pRecord->firstKey && index > 0) { + index -= 1; + } + break; + } + } + + return doCheckDatablockOverlapWithoutVersion(pBlockScanInfo, pRecord, index); + } } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h index f4fa7bc2c8..3679015e9c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h @@ -40,8 +40,7 @@ typedef enum { typedef struct STsdbReaderInfo { uint64_t suid; STSchema* pSchema; - EReadMode readMode; - uint64_t rowsNum; + EExecMode execMode; STimeWindow window; SVersionRange verRange; int16_t order; @@ -75,6 +74,11 @@ typedef struct SSttKeyInfo { int64_t nextProcKey; } SSttKeyInfo; +// clean stt file blocks: +// 1. not overlap with stt blocks in other stt files of the same fileset +// 2. not overlap with delete skyline +// 3. not overlap with in-memory data (mem/imem) +// 4. not overlap with data file blocks typedef struct STableBlockScanInfo { uint64_t uid; TSKEY lastProcKey; @@ -89,6 +93,11 @@ typedef struct STableBlockScanInfo { int32_t fileDelIndex; // file block delete index int32_t sttBlockDelIndex; // delete index for last block bool iterInit; // whether to initialize the in-memory skip list iterator or not + bool cleanSttBlocks; // stt block is clean in current fileset + bool sttBlockReturned; // result block returned alreay + int64_t numOfRowsInStt; + STimeWindow sttWindow; // timestamp window for current stt files + STimeWindow filesetWindow; // timestamp window for current file set } STableBlockScanInfo; typedef struct SResultBlockInfo { @@ -146,6 +155,7 @@ typedef struct SBlockLoadSuppInfo { bool smaValid; // the sma on all queried columns are activated } SBlockLoadSuppInfo; +// each blocks in stt file not overlaps with in-memory/data-file/tomb-files, and not overlap with any other blocks in stt-file typedef struct SSttBlockReader { STimeWindow window; SVersionRange verRange; @@ -187,7 +197,6 @@ typedef struct SFileBlockDumpInfo { } SFileBlockDumpInfo; typedef struct SReaderStatus { - bool suspendInvoked; bool loadFromFile; // check file stage bool composedDataBlock; // the returned data block is a composed block or not SSHashObj* pTableMap; // SHash @@ -201,12 +210,16 @@ typedef struct SReaderStatus { SArray* pLDataIterArray; SRowMerger merger; SColumnInfoData* pPrimaryTsCol; // primary time stamp output col info data + // the following for preceeds fileset memory processing + // TODO: refactor into seperate struct bool bProcMemPreFileset; int64_t memTableMaxKey; int64_t memTableMinKey; int64_t prevFilesetStartKey; int64_t prevFilesetEndKey; bool bProcMemFirstFileset; + STableUidList procMemUidList; + STableBlockScanInfo** pProcMemTableIter; } SReaderStatus; struct STsdbReader { @@ -272,12 +285,17 @@ bool blockIteratorNext(SDataBlockIter* pBlockIter, const char* idStr); void loadMemTombData(SArray** ppMemDelData, STbData* pMemTbData, STbData* piMemTbData, int64_t ver); int32_t loadDataFileTombDataForAll(STsdbReader* pReader); int32_t loadSttTombDataForAll(STsdbReader* pReader, SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pLoadInfo); -int32_t getNumOfRowsInSttBlock(SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pBlockLoadInfo, uint64_t suid, - const uint64_t* pUidList, int32_t numOfTables); +int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo* pBlockLoadInfo, + TStatisBlkArray* pStatisBlkArray, uint64_t suid, const uint64_t* pUidList, + int32_t numOfTables); + void destroyLDataIter(SLDataIter* pIter); -int32_t adjustLDataIters(SArray* pSttFileBlockIterArray, STFileSet* pFileSet); +int32_t adjustSttDataIters(SArray* pSttFileBlockIterArray, STFileSet* pFileSet); int32_t tsdbGetRowsInSttFiles(STFileSet* pFileSet, SArray* pSttFileBlockIterArray, STsdb* pTsdb, SMergeTreeConf* pConf, const char* pstr); +bool isCleanSttBlock(SArray* pTimewindowList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo, int32_t order); +bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBrinRecord* pRecord, int32_t order); + typedef struct { SArray* pTombData; } STableLoadInfo; diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index dc98f46ac5..9ecb2fd5ba 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -112,7 +112,7 @@ static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile TSDB_CHECK_CODE(code, lino, _exit); char *object_name = taosDirEntryBaseName(fname); - code = s3PutObjectFromFile2(from->fname, object_name); + code = s3PutObjectFromFile2(from->fname, object_name, 1); TSDB_CHECK_CODE(code, lino, _exit); taosCloseFile(&fdFrom); diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index c95d2324aa..66668b60df 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -177,12 +177,15 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { } static int32_t vnodeAsyncCancelAllTasks(SVAsync *async) { - for (int32_t i = 0; i < EVA_PRIORITY_MAX; i++) { - while (async->queue[i].next != &async->queue[i]) { - SVATask *task = async->queue[i].next; - task->prev->next = task->next; - task->next->prev = task->prev; - vnodeAsyncTaskDone(async, task); + while (async->queue[0].next != &async->queue[0] || async->queue[1].next != &async->queue[1] || + async->queue[2].next != &async->queue[2]) { + for (int32_t i = 0; i < EVA_PRIORITY_MAX; i++) { + while (async->queue[i].next != &async->queue[i]) { + SVATask *task = async->queue[i].next; + task->prev->next = task->next; + task->next->prev = task->prev; + vnodeAsyncTaskDone(async, task); + } } } return 0; @@ -588,7 +591,7 @@ int32_t vnodeACancel(SVAsync *async, int64_t taskId) { task->prev->next = task->next; vnodeAsyncTaskDone(async, task); } else { - ret = 0; // task is running, should return code TSDB_CODE_BUSY ?? + ret = TSDB_CODE_FAILED; } } diff --git a/source/dnode/vnode/src/vnd/vnodeHash.c b/source/dnode/vnode/src/vnd/vnodeHash.c index 33602f6581..093b5056ed 100644 --- a/source/dnode/vnode/src/vnd/vnodeHash.c +++ b/source/dnode/vnode/src/vnd/vnodeHash.c @@ -24,14 +24,6 @@ struct SVHashEntry { void* obj; }; -struct SVHashTable { - uint32_t (*hash)(const void*); - int32_t (*compare)(const void*, const void*); - int32_t numEntries; - uint32_t numBuckets; - SVHashEntry** buckets; -}; - static int32_t vHashRehash(SVHashTable* ht, uint32_t newNumBuckets) { SVHashEntry** newBuckets = (SVHashEntry**)taosMemoryCalloc(newNumBuckets, sizeof(SVHashEntry*)); if (newBuckets == NULL) { diff --git a/source/dnode/vnode/src/vnd/vnodeHash.h b/source/dnode/vnode/src/vnd/vnodeHash.h index 86f6f9ac87..0181ca748d 100644 --- a/source/dnode/vnode/src/vnd/vnodeHash.h +++ b/source/dnode/vnode/src/vnd/vnodeHash.h @@ -24,6 +24,15 @@ extern "C" { typedef struct SVHashTable SVHashTable; +struct SVHashTable { + uint32_t (*hash)(const void*); + int32_t (*compare)(const void*, const void*); + int32_t numEntries; + uint32_t numBuckets; + struct SVHashEntry** buckets; +}; + +#define vHashNumEntries(ht) ((ht)->numEntries) int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*)); int32_t vHashDestroy(SVHashTable** ht); int32_t vHashPut(SVHashTable* ht, void* obj); diff --git a/source/dnode/vnode/src/vnd/vnodeInitApi.c b/source/dnode/vnode/src/vnd/vnodeInitApi.c index 6b7b778cd5..c323a81093 100644 --- a/source/dnode/vnode/src/vnd/vnodeInitApi.c +++ b/source/dnode/vnode/src/vnd/vnodeInitApi.c @@ -42,7 +42,7 @@ void initStorageAPI(SStorageAPI* pAPI) { void initTsdbReaderAPI(TsdReader* pReader) { pReader->tsdReaderOpen = (int32_t(*)(void*, SQueryTableDataCond*, void*, int32_t, SSDataBlock*, void**, const char*, - bool, SHashObj**))tsdbReaderOpen2; + SHashObj**))tsdbReaderOpen2; pReader->tsdReaderClose = tsdbReaderClose2; pReader->tsdNextDataBlock = tsdbNextDataBlock2; @@ -215,6 +215,7 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->streamStateDestroy = streamStateDestroy; pStore->streamStateDeleteCheckPoint = streamStateDeleteCheckPoint; pStore->streamStateReloadInfo = streamStateReloadInfo; + pStore->streamStateCopyBackend = streamStateCopyBackend; } void initMetaReaderAPI(SStoreMetaReader* pMetaReader) { diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index e9dbc5e659..b6a9360afd 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -423,9 +423,9 @@ void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { "nBatchInsertSuccess"); } -void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t* numOfTables, int64_t* numOfNormalTables) { - SVnode* pVnodeObj = pVnode; - SVnodeCfg* pConf = &pVnodeObj->config; +void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t *numOfTables, int64_t *numOfNormalTables) { + SVnode *pVnodeObj = pVnode; + SVnodeCfg *pConf = &pVnodeObj->config; if (dbname) { *dbname = pConf->dbname; @@ -444,7 +444,7 @@ void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t* num } } -int32_t vnodeGetTableList(void* pVnode, int8_t type, SArray* pList) { +int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList) { if (type == TSDB_SUPER_TABLE) { return vnodeGetStbIdList(pVnode, 0, pList); } else { @@ -694,12 +694,12 @@ void *vnodeGetIdx(void *pVnode) { return NULL; } - return metaGetIdx(((SVnode*)pVnode)->pMeta); + return metaGetIdx(((SVnode *)pVnode)->pMeta); } void *vnodeGetIvtIdx(void *pVnode) { if (pVnode == NULL) { return NULL; } - return metaGetIvtIdx(((SVnode*)pVnode)->pMeta); + return metaGetIvtIdx(((SVnode *)pVnode)->pMeta); } diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 1f951097a4..afb8f962b3 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -14,24 +14,22 @@ */ #include "audit.h" +#include "cos.h" #include "tencode.h" #include "tmsg.h" #include "tstrbuild.h" #include "vnd.h" -#include "cos.h" #include "vnode.h" #include "vnodeInt.h" -#include "audit.h" -#include "tstrbuild.h" static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessAlterStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); -static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, - SRpcMsg *pOriginRpc); +static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, + SRpcMsg *pOriginRpc); static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); -static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, - SRpcMsg *pOriginRpc); +static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, + SRpcMsg *pOriginRpc); static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); @@ -45,6 +43,9 @@ static int32_t vnodeProcessDropIndexReq(SVnode *pVnode, int64_t ver, void *pReq, static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); +extern int32_t vnodeProcessKillCompactReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); +extern int32_t vnodeQueryCompactProgress(SVnode *pVnode, SRpcMsg *pMsg); + static int32_t vnodePreprocessCreateTableReq(SVnode *pVnode, SDecoder *pCoder, int64_t btime, int64_t *pUid) { int32_t code = 0; int32_t lino = 0; @@ -629,6 +630,11 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg case TDMT_SYNC_CONFIG_CHANGE: vnodeProcessConfigChangeReq(pVnode, ver, pReq, len, pRsp); break; +#ifdef TD_ENTERPRISE + case TDMT_VND_KILL_COMPACT: + vnodeProcessKillCompactReq(pVnode, ver, pReq, len, pRsp); + break; +#endif default: vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType); return -1; @@ -738,6 +744,10 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { return vnodeGetTableCfg(pVnode, pMsg, true); case TDMT_VND_BATCH_META: return vnodeGetBatchMeta(pVnode, pMsg); +#ifdef TD_ENTERPRISE + case TDMT_VND_QUERY_COMPACT_PROGRESS: + return vnodeQueryCompactProgress(pVnode, pMsg); +#endif // case TDMT_VND_TMQ_CONSUME: // return tqProcessPollReq(pVnode->pTq, pMsg); case TDMT_VND_TMQ_VG_WALINFO: @@ -886,8 +896,8 @@ _err: return -1; } -static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, - SRpcMsg *pOriginRpc) { +static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, + SRpcMsg *pOriginRpc) { SDecoder decoder = {0}; SEncoder encoder = {0}; int32_t rcode = 0; @@ -937,8 +947,8 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, goto _exit; } - if(tsEnableAudit && tsEnableAuditCreateTable){ - char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); + if (tsEnableAudit && tsEnableAuditCreateTable) { + char *str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); if (str == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; rcode = -1; @@ -992,27 +1002,27 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncodeSVCreateTbBatchRsp(&encoder, &rsp); - if(tsEnableAudit && tsEnableAuditCreateTable){ + if (tsEnableAudit && tsEnableAuditCreateTable) { int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; SName name = {0}; tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); SStringBuilder sb = {0}; - for(int32_t i = 0; i < tbNames->size; i++){ - char** key = (char**)taosArrayGet(tbNames, i); + for (int32_t i = 0; i < tbNames->size; i++) { + char **key = (char **)taosArrayGet(tbNames, i); taosStringBuilderAppendStringLen(&sb, *key, strlen(*key)); - if(i < tbNames->size - 1){ + if (i < tbNames->size - 1) { taosStringBuilderAppendChar(&sb, ','); } taosMemoryFreeClear(*key); } - size_t len = 0; - char* keyJoined = taosStringBuilderGetResult(&sb, &len); + size_t len = 0; + char *keyJoined = taosStringBuilderGetResult(&sb, &len); - if(pOriginRpc->info.conn.user != NULL && strlen(pOriginRpc->info.conn.user) > 0){ - auditRecord(pOriginRpc, clusterId, "createTable", name.dbname, "", keyJoined, len); + if (pOriginRpc->info.conn.user != NULL && strlen(pOriginRpc->info.conn.user) > 0) { + auditAddRecord(pOriginRpc, clusterId, "createTable", name.dbname, "", keyJoined, len); } taosStringBuilderDestroy(&sb); @@ -1023,7 +1033,7 @@ _exit: pCreateReq = req.pReqs + iReq; taosMemoryFree(pCreateReq->sql); taosMemoryFree(pCreateReq->comment); - taosArrayDestroy(pCreateReq->ctb.tagName); + taosArrayDestroy(pCreateReq->ctb.tagName); } taosArrayDestroyEx(rsp.pArray, tFreeSVCreateTbRsp); taosArrayDestroy(tbUids); @@ -1156,7 +1166,7 @@ _exit: } static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, - SRpcMsg *pOriginRpc) { + SRpcMsg *pOriginRpc) { SVDropTbBatchReq req = {0}; SVDropTbBatchRsp rsp = {0}; SDecoder decoder = {0}; @@ -1235,13 +1245,13 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in size_t len = 0; char *keyJoined = taosStringBuilderGetResult(&sb, &len); - if(pOriginRpc->info.conn.user != NULL && strlen(pOriginRpc->info.conn.user) > 0){ - auditRecord(pOriginRpc, clusterId, "dropTable", name.dbname, "", keyJoined, len); + if (pOriginRpc->info.conn.user != NULL && strlen(pOriginRpc->info.conn.user) > 0) { + auditAddRecord(pOriginRpc, clusterId, "dropTable", name.dbname, "", keyJoined, len); } taosStringBuilderDestroy(&sb); } - + _exit: taosArrayDestroy(tbUids); tdUidStoreFree(pStore); diff --git a/source/libs/audit/inc/auditInt.h b/source/libs/audit/inc/auditInt.h index b6c6ec87e8..e5fed2e473 100644 --- a/source/libs/audit/inc/auditInt.h +++ b/source/libs/audit/inc/auditInt.h @@ -17,9 +17,12 @@ #define _TD_AUDIT_INT_H_ #include "audit.h" +#include "tarray.h" typedef struct { SAuditCfg cfg; + SArray *records; + TdThreadMutex lock; } SAudit; #endif /*_TD_AUDIT_INT_H_*/ diff --git a/source/libs/audit/src/auditMain.c b/source/libs/audit/src/auditMain.c index c408f0d87b..19dc771c56 100644 --- a/source/libs/audit/src/auditMain.c +++ b/source/libs/audit/src/auditMain.c @@ -14,6 +14,8 @@ */ #define _DEFAULT_SOURCE + +#include "tarray.h" #include "auditInt.h" #include "taoserror.h" #include "thttp.h" @@ -21,25 +23,66 @@ #include "tjson.h" #include "tglobal.h" #include "mnode.h" +#include "audit.h" +#include "osMemory.h" SAudit tsAudit = {0}; char* tsAuditUri = "/audit"; +char* tsAuditBatchUri = "/audit-batch"; int32_t auditInit(const SAuditCfg *pCfg) { tsAudit.cfg = *pCfg; + tsAudit.records = taosArrayInit(0, sizeof(SAuditRecord *)); + taosThreadMutexInit(&tsAudit.lock, NULL); return 0; } +static FORCE_INLINE void auditDeleteRecord(SAuditRecord * record) { + if (record) { + taosMemoryFree(record->detail); + taosMemoryFree(record); + } +} + +void auditCleanup() { + tsLogFp = NULL; + taosThreadMutexLock(&tsAudit.lock); + taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord); + taosThreadMutexUnlock(&tsAudit.lock); + tsAudit.records = NULL; + taosThreadMutexDestroy(&tsAudit.lock); +} + extern void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail, int32_t len); +extern void auditAddRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, + char *detail, int32_t len); +extern void auditSendRecordsInBatchImp(); void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail, int32_t len) { auditRecordImp(pReq, clusterId, operation, target1, target2, detail, len); } +void auditAddRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, + char *detail, int32_t len) { + auditAddRecordImp(pReq, clusterId, operation, target1, target2, detail, len); +} + +void auditSendRecordsInBatch(){ + auditSendRecordsInBatchImp(); +} + #ifndef TD_ENTERPRISE void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, char *detail, int32_t len) { } + +void auditAddRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, + char *detail, int32_t len) { +} + +void auditSendRecordsInBatchImp(){ + +} #endif diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index cba26c46b5..e3e504cdbc 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -298,9 +298,14 @@ typedef struct STableMergeScanInfo { SHashObj* mSkipTables; int64_t mergeLimit; SSortExecInfo sortExecInfo; - bool bNewFileset; - bool bOnlyRetrieveBlock; + bool filesetDelimited; + bool bNewFilesetEvent; + bool bNextDurationBlockEvent; + int32_t numNextDurationBlocks; + SSDataBlock* nextDurationBlocks[2]; + bool rtnNextDurationBlocks; + int32_t nextDurationBlocksIdx; } STableMergeScanInfo; typedef struct STagScanFilterContext { @@ -636,6 +641,7 @@ typedef struct SStreamEventAggOperatorInfo { bool isHistoryOp; SArray* historyWins; bool reCkBlock; + bool recvGetAll; SSDataBlock* pCheckpointRes; SFilterInfo* pStartCondInfo; SFilterInfo* pEndCondInfo; @@ -748,7 +754,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput); SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData, - int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, + int32_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup); int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, @@ -837,6 +843,8 @@ void compactTimeWindow(SExprSupp* pSup, SStreamAggSupporter* pAggSup, STimeW int32_t releaseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI); void resetWinRange(STimeWindow* winRange); bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts); +int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval); +void resetUnCloseSessionWinInfo(SSHashObj* winMap); int32_t encodeSSessionKey(void** buf, SSessionKey* key); void* decodeSSessionKey(void* buf, SSessionKey* key); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index e5d5aee7b3..6674dd731b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1734,6 +1734,11 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi pCond->endVersion = -1; pCond->skipRollup = readHandle->skipRollup; + // allowed read stt file optimization mode + pCond->notLoadData = (pTableScanNode->dataRequired == FUNC_DATA_REQUIRED_NOT_LOAD) && + (pTableScanNode->scan.node.pConditions == NULL) && + (pTableScanNode->interval == 0); + int32_t j = 0; for (int32_t i = 0; i < pCond->numOfCols; ++i) { STargetNode* pNode = (STargetNode*)nodesListGetNode(pTableScanNode->scan.pScanCols, i); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index c445da6e30..8ebde1aea0 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -984,6 +984,21 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) { qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); + pSup->calTriggerSaved = pSup->calTrigger; + pSup->deleteMarkSaved = pSup->deleteMark; + pSup->calTrigger = STREAM_TRIGGER_AT_ONCE; + pSup->deleteMark = INT64_MAX; + pInfo->ignoreExpiredDataSaved = pInfo->ignoreExpiredData; + pInfo->ignoreExpiredData = false; + } else if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT) { + SStreamEventAggOperatorInfo* pInfo = pOperator->info; + STimeWindowAggSupp* pSup = &pInfo->twAggSup; + + ASSERT(pSup->calTrigger == STREAM_TRIGGER_AT_ONCE || pSup->calTrigger == STREAM_TRIGGER_WINDOW_CLOSE); + ASSERT(pSup->calTriggerSaved == 0 && pSup->deleteMarkSaved == 0); + + qInfo("save stream param for state: %d, %" PRId64, pSup->calTrigger, pSup->deleteMark); + pSup->calTriggerSaved = pSup->calTrigger; pSup->deleteMarkSaved = pSup->deleteMark; pSup->calTrigger = STREAM_TRIGGER_AT_ONCE; @@ -1232,7 +1247,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT if (pScanBaseInfo->dataReader == NULL) { int32_t code = pTaskInfo->storageAPI.tsdReader.tsdReaderOpen( pScanBaseInfo->readHandle.vnode, &pScanBaseInfo->cond, &keyInfo, 1, pScanInfo->pResBlock, - (void**)&pScanBaseInfo->dataReader, id, false, NULL); + (void**)&pScanBaseInfo->dataReader, id, NULL); if (code != TSDB_CODE_SUCCESS) { qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id); terrno = code; @@ -1291,7 +1306,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT int32_t size = tableListGetSize(pTableListInfo); pTaskInfo->storageAPI.tsdReader.tsdReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, - (void**)&pInfo->dataReader, NULL, false, NULL); + (void**)&pInfo->dataReader, NULL, NULL); cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index 138da16324..95d26fdd0e 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -137,7 +137,7 @@ SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, i * +----------+---------------+ */ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData, - int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, + int32_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup) { SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId); if (!keepGroup) { diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index eb18278870..1e9771edd6 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -65,7 +65,7 @@ typedef struct SPartitionOperatorInfo { static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInfo** pGroupInfo, int32_t len); static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity); static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, - int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup); + int32_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup); static SArray* extractColumnInfo(SNodeList* pNodeList); static void freeGroupKey(void* param) { @@ -1016,7 +1016,7 @@ _error: } int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, - int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) { + int32_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SResultRowInfo* pResultRowInfo = &binfo->resultRowInfo; SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 4fb6e26cc5..0ef8c4b81a 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -889,7 +889,7 @@ static SSDataBlock* groupSeqTableScan(SOperatorInfo* pOperator) { ASSERT(pInfo->base.dataReader == NULL); int32_t code = pAPI->tsdReader.tsdReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock, - (void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), pInfo->countOnly, &pInfo->pIgnoreTables); + (void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), &pInfo->pIgnoreTables); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -1061,7 +1061,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->base.readerAPI = pTaskInfo->storageAPI.tsdReader; initResultSizeInfo(&pOperator->resultInfo, 4096); pInfo->pResBlock = createDataBlockFromDescNode(pDescNode); - // blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity); code = filterInitFromNode((SNode*)pTableScanNode->scan.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); if (code != TSDB_CODE_SUCCESS) { @@ -1184,7 +1183,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU SSDataBlock* pBlock = pTableScanInfo->pResBlock; STsdbReader* pReader = NULL; int32_t code = pAPI->tsdReader.tsdReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, - (void**)&pReader, GET_TASKID(pTaskInfo), false, NULL); + (void**)&pReader, GET_TASKID(pTaskInfo), NULL); if (code != TSDB_CODE_SUCCESS) { terrno = code; T_LONG_JMP(pTaskInfo->env, code); @@ -3242,6 +3241,52 @@ static int32_t tableMergeScanDoSkipTable(STableMergeScanInfo* pInfo, SSDataBlock return TSDB_CODE_SUCCESS; } +static void doGetBlockForTableMergeScan(SOperatorInfo* pOperator, bool* pFinished, bool* pSkipped) { + STableMergeScanInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStorageAPI* pAPI = &pTaskInfo->storageAPI; + + SSDataBlock* pBlock = pInfo->pReaderBlock; + int32_t code = 0; + bool hasNext = false; + STsdbReader* reader = pInfo->base.dataReader; + + code = pAPI->tsdReader.tsdNextDataBlock(reader, &hasNext); + if (code != 0) { + pAPI->tsdReader.tsdReaderReleaseDataBlock(reader); + qError("table merge scan fetch next data block error code: %d, %s", code, GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, code); + } + + if (!hasNext || isTaskKilled(pTaskInfo)) { + if (isTaskKilled(pTaskInfo)) { + qInfo("table merge scan fetch next data block found task killed. %s", GET_TASKID(pTaskInfo)); + pAPI->tsdReader.tsdReaderReleaseDataBlock(reader); + } + *pFinished = true; + return; + } + + uint32_t status = 0; + code = loadDataBlock(pOperator, &pInfo->base, pBlock, &status); + if (code != TSDB_CODE_SUCCESS) { + qInfo("table merge scan load datablock code %d, %s", code, GET_TASKID(pTaskInfo)); + T_LONG_JMP(pTaskInfo->env, code); + } + + if (status == FUNC_DATA_REQUIRED_ALL_FILTEROUT) { + *pFinished = true; + return; + } + + // current block is filter out according to filter condition, continue load the next block + if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) { + *pSkipped = true; + return; + } + return; +} + static SSDataBlock* getBlockForTableMergeScan(void* param) { STableMergeScanSortSourceParam* source = param; SOperatorInfo* pOperator = source->pOperator; @@ -3249,7 +3294,7 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStorageAPI* pAPI = &pTaskInfo->storageAPI; - SSDataBlock* pBlock = pInfo->pReaderBlock; + SSDataBlock* pBlock = NULL; int32_t code = 0; int64_t st = taosGetTimestampUs(); @@ -3257,53 +3302,56 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { STsdbReader* reader = pInfo->base.dataReader; while (true) { - if (!pInfo->bOnlyRetrieveBlock) { - code = pAPI->tsdReader.tsdNextDataBlock(reader, &hasNext); - if (code != 0) { - pAPI->tsdReader.tsdReaderReleaseDataBlock(reader); - qError("table merge scan fetch next data block error code: %d, %s", code, GET_TASKID(pTaskInfo)); - T_LONG_JMP(pTaskInfo->env, code); - } - - if (!hasNext || isTaskKilled(pTaskInfo)) { - pInfo->bNewFileset = false; - if (isTaskKilled(pTaskInfo)) { - qInfo("table merge scan fetch next data block found task killed. %s", GET_TASKID(pTaskInfo)); - pAPI->tsdReader.tsdReaderReleaseDataBlock(reader); + if (pInfo->rtnNextDurationBlocks) { + qDebug("%s table merge scan return already fetched new duration blocks. index %d num of blocks %d", + GET_TASKID(pTaskInfo), pInfo->nextDurationBlocksIdx, pInfo->numNextDurationBlocks); + if (pInfo->nextDurationBlocksIdx < pInfo->numNextDurationBlocks) { + pBlock = pInfo->nextDurationBlocks[pInfo->nextDurationBlocksIdx]; + ++pInfo->nextDurationBlocksIdx; + } else { + for (int32_t i = 0; i < pInfo->numNextDurationBlocks; ++i) { + blockDataDestroy(pInfo->nextDurationBlocks[i]); + pInfo->nextDurationBlocks[i] = NULL; } + pInfo->rtnNextDurationBlocks = false; + pInfo->nextDurationBlocksIdx = 0; + pInfo->numNextDurationBlocks = 0; + continue; + } + } else { + + bool bFinished = false; + bool bSkipped = false; + doGetBlockForTableMergeScan(pOperator, &bFinished, &bSkipped); + pBlock = pInfo->pReaderBlock; + qDebug("%s table merge scan fetch block. finished %d skipped %d next-duration-block %d new-fileset %d", + GET_TASKID(pTaskInfo), bFinished, bSkipped, pInfo->bNextDurationBlockEvent, pInfo->bNewFilesetEvent); + if (bFinished) { + pInfo->bNewFilesetEvent = false; break; } - if (pInfo->bNewFileset) { - pInfo->bOnlyRetrieveBlock = true; - return NULL; + if (pInfo->bNextDurationBlockEvent || pInfo->bNewFilesetEvent) { + if (!bSkipped) { + pInfo->nextDurationBlocks[pInfo->numNextDurationBlocks] = createOneDataBlock(pBlock, true); + ++pInfo->numNextDurationBlocks; + if (pInfo->numNextDurationBlocks > 2) { + qError("%s table merge scan prefetch %d next duration blocks. end early.", GET_TASKID(pTaskInfo), pInfo->numNextDurationBlocks); + pInfo->bNewFilesetEvent = false; + break; + } + } + if (pInfo->bNewFilesetEvent) { + pInfo->rtnNextDurationBlocks = true; + return NULL; + } + if (pInfo->bNextDurationBlockEvent) { + pInfo->bNextDurationBlockEvent = false; + continue; + } } + if (bSkipped) continue; } - // process this data block based on the probabilities - bool processThisBlock = processBlockWithProbability(&pInfo->sample); - if (!processThisBlock) { - continue; - } - - uint32_t status = 0; - code = loadDataBlock(pOperator, &pInfo->base, pBlock, &status); - if (pInfo->bOnlyRetrieveBlock) { - pInfo->bOnlyRetrieveBlock = false; - } - if (code != TSDB_CODE_SUCCESS) { - qInfo("table merge scan load datablock code %d, %s", code, GET_TASKID(pTaskInfo)); - T_LONG_JMP(pTaskInfo->env, code); - } - - if (status == FUNC_DATA_REQUIRED_ALL_FILTEROUT) { - break; - } - - // current block is filter out according to filter condition, continue load the next block - if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) { - continue; - } - pBlock->info.id.groupId = tableListGetTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); if (pInfo->mergeLimit != -1) { @@ -3312,13 +3360,13 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { pOperator->resultInfo.totalRows += pBlock->info.rows; pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; - return pBlock; } return NULL; } + SArray* generateSortByTsInfo(SArray* colMatchInfo, int32_t order) { int32_t tsTargetSlotId = 0; for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) { @@ -3350,7 +3398,13 @@ int32_t dumpQueryTableCond(const SQueryTableDataCond* src, SQueryTableDataCond* void tableMergeScanTsdbNotifyCb(ETsdReaderNotifyType type, STsdReaderNotifyInfo* info, void* param) { STableMergeScanInfo* pTmsInfo = param; - pTmsInfo->bNewFileset = true; + if (type == TSD_READER_NOTIFY_DURATION_START) { + pTmsInfo->bNewFilesetEvent = true; + } else if (type == TSD_READER_NOTIFY_NEXT_DURATION_BLOCK) { + pTmsInfo->bNextDurationBlockEvent = true; + } + qDebug("table merge scan receive notification. type %d, fileset %d", type, info->duration.filesetId); + return; } @@ -3360,7 +3414,9 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { int32_t code = TSDB_CODE_SUCCESS; int32_t numOfTable = pInfo->tableEndIndex - pInfo->tableStartIndex + 1; - pInfo->bNewFileset = false; + qDebug("%s table merge scan start duration ", GET_TASKID(pTaskInfo)); + pInfo->bNewFilesetEvent = false; + pInfo->bNextDurationBlockEvent = false; pInfo->sortBufSize = 2048 * pInfo->bufPageSize; int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; @@ -3390,6 +3446,8 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { void stopDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { STableMergeScanInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + qDebug("%s table merge scan stop duration ", GET_TASKID(pTaskInfo)); SSortExecInfo sortExecInfo = tsortGetSortExecInfo(pInfo->pSortHandle); pInfo->sortExecInfo.sortMethod = sortExecInfo.sortMethod; @@ -3407,6 +3465,7 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SReadHandle* pHandle = &pInfo->base.readHandle; SStorageAPI* pAPI = &pTaskInfo->storageAPI; + qDebug("%s table merge scan start group %"PRIu64, GET_TASKID(pTaskInfo), pInfo->groupId); { size_t numOfTables = tableListGetSize(pInfo->base.pTableListInfo); @@ -3428,7 +3487,7 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { int32_t numOfTable = tableEndIdx - tableStartIdx + 1; STableKeyInfo* startKeyInfo = tableListGetInfo(pInfo->base.pTableListInfo, tableStartIdx); pAPI->tsdReader.tsdReaderOpen(pHandle->vnode, &pInfo->base.cond, startKeyInfo, numOfTable, pInfo->pReaderBlock, - (void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), false, &pInfo->mSkipTables); + (void**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), &pInfo->mSkipTables); if (pInfo->filesetDelimited) { pAPI->tsdReader.tsdSetFilesetDelimited(pInfo->base.dataReader); } @@ -3454,10 +3513,19 @@ int32_t stopGroupTableMergeScan(SOperatorInfo* pOperator) { pAPI->tsdReader.tsdReaderClose(pInfo->base.dataReader); pInfo->base.dataReader = NULL; } - + for (int32_t i = 0; i < pInfo->numNextDurationBlocks; ++i) { + if (pInfo->nextDurationBlocks[i]) { + blockDataDestroy(pInfo->nextDurationBlocks[i]); + pInfo->nextDurationBlocks[i] = NULL; + } + pInfo->numNextDurationBlocks = 0; + pInfo->nextDurationBlocksIdx = 0; + } resetLimitInfoForNextGroup(&pInfo->limitInfo); taosHashCleanup(pInfo->mSkipTables); pInfo->mSkipTables = NULL; + qDebug("%s table merge scan stop group %"PRIu64, GET_TASKID(pTaskInfo), pInfo->groupId); + return TSDB_CODE_SUCCESS; } @@ -3537,7 +3605,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { pOperator->resultInfo.totalRows += pBlock->info.rows; return pBlock; } else { - if (pInfo->bNewFileset) { + if (pInfo->bNewFilesetEvent) { stopDurationForGroupTableMergeScan(pOperator); startDurationForGroupTableMergeScan(pOperator); } else { @@ -3568,6 +3636,13 @@ void destroyTableMergeScanOperatorInfo(void* param) { pTableScanInfo->base.readerAPI.tsdReaderClose(pTableScanInfo->base.dataReader); pTableScanInfo->base.dataReader = NULL; + for (int32_t i = 0; i < pTableScanInfo->numNextDurationBlocks; ++i) { + if (pTableScanInfo->nextDurationBlocks[i] != NULL) { + blockDataDestroy(pTableScanInfo->nextDurationBlocks[i]); + pTableScanInfo->nextDurationBlocks[i] = NULL; + } + } + taosArrayDestroy(pTableScanInfo->sortSourceParams); tsortDestroySortHandle(pTableScanInfo->pSortHandle); pTableScanInfo->pSortHandle = NULL; @@ -3677,8 +3752,11 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN int32_t rowSize = pInfo->pResBlock->info.rowSize; uint32_t nCols = taosArrayGetSize(pInfo->pResBlock->pDataBlock); pInfo->bufPageSize = getProperSortPageSize(rowSize, nCols); - - pInfo->filesetDelimited = pTableScanNode->filesetDelimited; + if (!tsExperimental) { + pInfo->filesetDelimited = false; + } else { + pInfo->filesetDelimited = pTableScanNode->filesetDelimited; + } setOperatorInfo(pOperator, "TableMergeScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->exprSupp.numOfExprs = numOfCols; diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 914b95ba83..6adab74344 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -176,7 +176,7 @@ int32_t updateEventWindowInfo(SStreamAggSupporter* pAggSup, SEventWindowInfo* pW for (int32_t i = start; i < rows; ++i) { if (pTsData[i] >= maxTs) { - return i - 1 - start; + return i - start; } if (pWin->skey > pTsData[i]) { @@ -486,6 +486,11 @@ static SSDataBlock* doStreamEventAgg(SOperatorInfo* pOperator) { return pInfo->pCheckpointRes; } + if (pInfo->recvGetAll) { + pInfo->recvGetAll = false; + resetUnCloseSessionWinInfo(pInfo->streamAggSup.pResultRows); + } + setOperatorCompleted(pOperator); return NULL; } @@ -510,6 +515,7 @@ static SSDataBlock* doStreamEventAgg(SOperatorInfo* pOperator) { deleteSessionWinState(&pInfo->streamAggSup, pBlock, pInfo->pSeUpdated, pInfo->pSeDeleted); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { + pInfo->recvGetAll = true; getAllSessionWindow(pInfo->streamAggSup.pResultRows, pInfo->pSeUpdated); continue; } else if (pBlock->info.type == STREAM_CREATE_CHILD_TABLE) { @@ -610,6 +616,10 @@ void streamEventReloadState(SOperatorInfo* pOperator) { qDebug("===stream=== reload state. try process result %" PRId64 ", %" PRIu64 ", index:%d", pSeKeyBuf[i].win.skey, pSeKeyBuf[i].groupId, i); getSessionWindowInfoByKey(pAggSup, pSeKeyBuf + i, &curInfo.winInfo); + //event window has been deleted + if (!IS_VALID_SESSION_WIN(curInfo.winInfo)) { + continue; + } setEventWindowFlag(pAggSup, &curInfo); if (!curInfo.pWinFlag->startFlag || curInfo.pWinFlag->endFlag) { continue; @@ -672,6 +682,7 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys .calTrigger = pEventNode->window.triggerType, .maxTs = INT64_MIN, .minTs = INT64_MAX, + .deleteMark = getDeleteMark(&pEventNode->window, 0), }; initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); @@ -720,6 +731,7 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT); pInfo->reCkBlock = false; + pInfo->recvGetAll = false; // for stream void* buff = NULL; diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index fe19700cc9..fde3fec7d4 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -408,6 +408,11 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { taosArrayDestroy(pInfo->pDelWins); blockDataDestroy(pInfo->pDelRes); pInfo->stateStore.streamFileStateDestroy(pInfo->pState->pFileState); + + if (pInfo->pState->dump == 1) { + taosMemoryFreeClear(pInfo->pState->pTdbState->pOwner); + taosMemoryFreeClear(pInfo->pState->pTdbState); + } taosMemoryFreeClear(pInfo->pState); nodesDestroyNode((SNode*)pInfo->pPhyNode); @@ -431,6 +436,18 @@ static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) { return true; } +void reloadFromDownStream(SOperatorInfo* downstream, SStreamIntervalOperatorInfo* pInfo) { + SStateStore* pAPI = &downstream->pTaskInfo->storageAPI.stateStore; + + if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + reloadFromDownStream(downstream->pDownstream[0], pInfo); + return; + } + + SStreamScanInfo* pScanInfo = downstream->info; + pInfo->pUpdateInfo = pScanInfo->pUpdateInfo; +} + void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SStreamIntervalOperatorInfo* pInfo) { SStateStore* pAPI = &downstream->pTaskInfo->storageAPI.stateStore; @@ -634,9 +651,6 @@ static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo, i for (int32_t i = 0; i < size; i++) { SWinKey* winKey = taosArrayGet(wins, i); STimeWindow nextWin = getFinalTimeWindow(winKey->ts, &pInfo->interval); - if (isOverdue(nextWin.ekey, &pInfo->twAggSup) && pInfo->ignoreExpiredData) { - continue; - } void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey)); if (!chIds) { SPullWindowInfo pull = { @@ -801,7 +815,7 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDat } while (1) { bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup); - if ((!IS_FINAL_INTERVAL_OP(pOperator) && pInfo->ignoreExpiredData && + if ((!IS_FINAL_INTERVAL_OP(pOperator) && pInfo->ignoreExpiredData && pSDataBlock->info.type != STREAM_PULL_DATA && checkExpiredData(&pInfo->stateStore, pInfo->pUpdateInfo, &pInfo->twAggSup, pSDataBlock->info.id.uid, nextWin.ekey)) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { @@ -1345,12 +1359,12 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return buildIntervalResult(pOperator); } -static int64_t getDeleteMark(SIntervalPhysiNode* pIntervalPhyNode) { - if (pIntervalPhyNode->window.deleteMark <= 0) { +int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval) { + if (pWinPhyNode->deleteMark <= 0) { return DEAULT_DELETE_MARK; } - int64_t deleteMark = TMAX(pIntervalPhyNode->window.deleteMark, pIntervalPhyNode->window.watermark); - deleteMark = TMAX(deleteMark, pIntervalPhyNode->interval); + int64_t deleteMark = TMAX(pWinPhyNode->deleteMark, pWinPhyNode->watermark); + deleteMark = TMAX(deleteMark, interval); return deleteMark; } @@ -1400,9 +1414,9 @@ static void streamIntervalReleaseState(SOperatorInfo* pOperator) { } void streamIntervalReloadState(SOperatorInfo* pOperator) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL && pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { - SStreamIntervalOperatorInfo* pInfo = pOperator->info; int32_t size = 0; void* pBuf = NULL; int32_t code = pInfo->stateStore.streamStateGetInfo(pInfo->pState, STREAM_INTERVAL_OP_STATE_NAME, @@ -1418,6 +1432,7 @@ void streamIntervalReloadState(SOperatorInfo* pOperator) { if (downstream->fpSet.reloadStreamStateFn) { downstream->fpSet.reloadStreamStateFn(downstream); } + reloadFromDownStream(downstream, pInfo); } SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, @@ -1444,7 +1459,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, .minTs = INT64_MAX, - .deleteMark = getDeleteMark(pIntervalPhyNode), + .deleteMark = getDeleteMark(&pIntervalPhyNode->window, pIntervalPhyNode->interval), .deleteMarkSaved = 0, .calTriggerSaved = 0, }; @@ -1467,7 +1482,11 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, initBasicInfo(&pInfo->binfo, pResBlock); pInfo->pState = taosMemoryCalloc(1, sizeof(SStreamState)); - *(pInfo->pState) = *(pTaskInfo->streamInfo.pState); + qInfo("open state %p", pInfo->pState); + pAPI->stateStore.streamStateCopyBackend(pTaskInfo->streamInfo.pState, pInfo->pState); + //*(pInfo->pState) = *(pTaskInfo->streamInfo.pState); + + qInfo("copy state %p to %p", pTaskInfo->streamInfo.pState, pInfo->pState); pAPI->stateStore.streamStateSetNumber(pInfo->pState, -1); int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, @@ -2568,7 +2587,7 @@ void doStreamSessionSaveCheckpoint(SOperatorInfo* pOperator) { taosMemoryFree(buf); } -static void resetUnCloseSessionWinInfo(SSHashObj* winMap) { +void resetUnCloseSessionWinInfo(SSHashObj* winMap) { void* pIte = NULL; int32_t iter = 0; while ((pIte = tSimpleHashIterate(winMap, pIte, &iter)) != NULL) { @@ -3344,7 +3363,8 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); for (int32_t i = 0; i < rows; i += winRows) { if (pInfo->ignoreExpiredData && checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, - &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i]) || colDataIsNull_s(pKeyColInfo, i)) { + &pInfo->twAggSup, pSDataBlock->info.id.uid, tsCols[i]) || + colDataIsNull_s(pKeyColInfo, i)) { i++; continue; } @@ -3966,7 +3986,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys .calTrigger = pIntervalPhyNode->window.triggerType, .maxTs = INT64_MIN, .minTs = INT64_MAX, - .deleteMark = getDeleteMark(pIntervalPhyNode)}; + .deleteMark = getDeleteMark(&pIntervalPhyNode->window, pIntervalPhyNode->interval)}; ASSERTS(pInfo->twAggSup.calTrigger != STREAM_TRIGGER_MAX_DELAY, "trigger type should not be max delay"); diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 6bdbefc5c0..76de204cab 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1610,7 +1610,10 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) { const char* name = tNameGetTableName(&pInfo->name); if (pInfo->showRewrite) { getDBNameFromCondition(pInfo->pCondition, dbName); - sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName); + if (strncasecmp(name, TSDB_INS_TABLE_COMPACTS, TSDB_TABLE_FNAME_LEN) != 0 && + strncasecmp(name, TSDB_INS_TABLE_COMPACT_DETAILS, TSDB_TABLE_FNAME_LEN) != 0) { + sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName); + } } else if (strncasecmp(name, TSDB_INS_TABLE_COLS, TSDB_TABLE_FNAME_LEN) == 0) { getDBNameFromCondition(pInfo->pCondition, dbName); if (dbName[0]) sprintf(pInfo->req.db, "%d.%s", pInfo->accountId, dbName); @@ -2304,7 +2307,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi void* pList = tableListGetInfo(pTableListInfo, 0); code = readHandle->api.tsdReader.tsdReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, - (void**)&pInfo->pHandle, pTaskInfo->id.str, false, NULL); + (void**)&pInfo->pHandle, pTaskInfo->id.str, NULL); cleanupQueryTableDataCond(&cond); if (code != 0) { goto _error; diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 25a3c509a7..8a2e118fe7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5466,13 +5466,12 @@ bool blockDistSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { } int32_t blockDistFunction(SqlFunctionCtx* pCtx) { - const int32_t BLOCK_DIST_RESULT_ROWS = 24; + const int32_t BLOCK_DIST_RESULT_ROWS = 25; SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pInputCol = pInput->pData[0]; - - SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - STableBlockDistInfo* pDistInfo = GET_ROWCELL_INTERBUF(pResInfo); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + STableBlockDistInfo* pDistInfo = GET_ROWCELL_INTERBUF(pResInfo); STableBlockDistInfo p1 = {0}; tDeserializeBlockDistInfo(varDataVal(pInputCol->pData), varDataLen(pInputCol->pData), &p1); @@ -5635,7 +5634,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { double factor = pData->numOfBlocks / 80.0; int32_t numOfBuckets = sizeof(pData->blockRowsHisto) / sizeof(pData->blockRowsHisto[0]); - int32_t bucketRange = (pData->defMaxRows - pData->defMinRows) / numOfBuckets; + int32_t bucketRange = ceil(((double) (pData->defMaxRows - pData->defMinRows)) / numOfBuckets); for (int32_t i = 0; i < tListLen(pData->blockRowsHisto); ++i) { len = sprintf(st + VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * (i + 1)); @@ -5650,7 +5649,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { len += x; } - if (num > 0) { + if (pData->blockRowsHisto[i] > 0) { double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks; len += sprintf(st + VARSTR_HEADER_SIZE + len, " %d (%.2f%c)", pData->blockRowsHisto[i], v, '%'); } diff --git a/source/libs/index/test/CMakeLists.txt b/source/libs/index/test/CMakeLists.txt index 2bc7353aa5..1ee835573b 100644 --- a/source/libs/index/test/CMakeLists.txt +++ b/source/libs/index/test/CMakeLists.txt @@ -164,7 +164,7 @@ IF(NOT TD_DARWIN) ) add_test( - NAME idxtest + NAME idxTest COMMAND idxTest ) add_test( diff --git a/source/libs/index/test/jsonUT.cc b/source/libs/index/test/jsonUT.cc index 0e76980799..bee8e0dd85 100644 --- a/source/libs/index/test/jsonUT.cc +++ b/source/libs/index/test/jsonUT.cc @@ -60,6 +60,7 @@ class JsonEnv : public ::testing::Test { } virtual void TearDown() { indexJsonClose(index); + indexOptsDestroy(opts); printf("destory\n"); taosMsleep(1000); } @@ -152,6 +153,7 @@ TEST_F(JsonEnv, testWrite) { indexMultiTermQueryAdd(mq, q, QUERY_TERM); indexJsonSearch(index, mq, result); EXPECT_EQ(100, taosArrayGetSize(result)); + taosArrayDestroy(result); indexMultiTermQueryDestroy(mq); } } @@ -211,6 +213,7 @@ TEST_F(JsonEnv, testWriteMillonData) { indexJsonSearch(index, mq, result); EXPECT_EQ(10, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { { @@ -226,6 +229,7 @@ TEST_F(JsonEnv, testWriteMillonData) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { { @@ -241,6 +245,7 @@ TEST_F(JsonEnv, testWriteMillonData) { indexJsonSearch(index, mq, result); EXPECT_EQ(10, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } } } @@ -311,6 +316,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test"); @@ -325,6 +331,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test"); @@ -340,6 +347,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test"); @@ -355,6 +363,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test"); @@ -370,6 +379,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } } @@ -413,6 +423,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test1"); @@ -427,6 +438,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test1"); @@ -442,6 +454,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test1"); @@ -456,6 +469,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test1"); @@ -470,6 +484,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(1000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("other_column"); @@ -499,6 +514,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } { std::string colName("test1"); @@ -527,6 +543,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) { indexJsonSearch(index, mq, result); EXPECT_EQ(2000, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); + taosArrayDestroy(result); } } TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT2) { @@ -553,6 +570,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT2) { int val = 9; Search(index, colName, TSDB_DATA_TYPE_INT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; @@ -560,6 +578,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT2) { std::string colVal("xxxxxxxxxxxxxxx"); Search(index, colName, TSDB_DATA_TYPE_BINARY, (void*)(colVal.c_str()), colVal.size(), QUERY_TERM, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } } TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) { @@ -583,6 +602,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) { float val = 1.9; Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(2000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; @@ -590,6 +610,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) { float val = 2.1; Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { std::string colName("test1"); @@ -597,6 +618,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_FLOAT) { float val = 2.1; Search(index, colName, TSDB_DATA_TYPE_FLOAT, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } } TEST_F(JsonEnv, testWriteJsonTfileAndCache_DOUBLE) { @@ -618,29 +640,34 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_DOUBLE) { double val = 1.9; Search(index, "test1", TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(2000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; double val = 2.1; Search(index, "test1", TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; double val = 2.1; Search(index, "test1", TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_GREATER_EQUAL, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; double val = 10.0; Search(index, "test1", TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_LESS_EQUAL, &res); EXPECT_EQ(2000, taosArrayGetSize(res)); + taosArrayDestroy(res); } { SArray* res = NULL; double val = 10.0; Search(index, "test1", TSDB_DATA_TYPE_DOUBLE, &val, sizeof(val), QUERY_LESS_THAN, &res); EXPECT_EQ(1000, taosArrayGetSize(res)); + taosArrayDestroy(res); } } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 0041cd4fa0..e066797100 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -259,6 +259,10 @@ const char* nodesNodeName(ENodeType type) { return "ShowLocalVariablesStmt"; case QUERY_NODE_SHOW_TABLE_TAGS_STMT: return "ShowTableTagsStmt"; + case QUERY_NODE_SHOW_COMPACTS_STMT: + return "ShowCompactsStmt"; + case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: + return "ShowCompactDetailsStmt"; case QUERY_NODE_DELETE_STMT: return "DeleteStmt"; case QUERY_NODE_INSERT_STMT: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index f70cb3866e..222539ec36 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -456,10 +456,15 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowCreateViewStmt)); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return makeNode(type, sizeof(SShowTableDistributedStmt)); + case QUERY_NODE_SHOW_COMPACTS_STMT: + return makeNode(type, sizeof(SShowCompactsStmt)); + case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: + return makeNode(type, sizeof(SShowCompactDetailsStmt)); case QUERY_NODE_KILL_QUERY_STMT: return makeNode(type, sizeof(SKillQueryStmt)); case QUERY_NODE_KILL_TRANSACTION_STMT: case QUERY_NODE_KILL_CONNECTION_STMT: + case QUERY_NODE_KILL_COMPACT_STMT: return makeNode(type, sizeof(SKillStmt)); case QUERY_NODE_DELETE_STMT: return makeNode(type, sizeof(SDeleteStmt)); @@ -1087,6 +1092,13 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pDnodeId); nodesDestroyNode(((SShowDnodeVariablesStmt*)pNode)->pLikePattern); break; + case QUERY_NODE_SHOW_COMPACTS_STMT: + break; + case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: { + SShowCompactDetailsStmt* pStmt = (SShowCompactDetailsStmt*)pNode; + nodesDestroyNode(pStmt->pCompactId); + break; + } case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: taosMemoryFreeClear(((SShowCreateDatabaseStmt*)pNode)->pCfg); break; @@ -1100,6 +1112,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field case QUERY_NODE_KILL_QUERY_STMT: // no pointer field case QUERY_NODE_KILL_TRANSACTION_STMT: // no pointer field + case QUERY_NODE_KILL_COMPACT_STMT: // no pointer field break; case QUERY_NODE_DELETE_STMT: { SDeleteStmt* pStmt = (SDeleteStmt*)pNode; diff --git a/source/libs/nodes/test/nodesTestMain.cpp b/source/libs/nodes/test/nodesTestMain.cpp index a7f9a06611..356b13f4a7 100644 --- a/source/libs/nodes/test/nodesTestMain.cpp +++ b/source/libs/nodes/test/nodesTestMain.cpp @@ -53,6 +53,7 @@ TEST(NodesTest, traverseTest) { EXPECT_EQ(res, DEAL_RES_CONTINUE); EXPECT_EQ(nodeType(pRoot), QUERY_NODE_VALUE); EXPECT_EQ(string(((SValueNode*)pRoot)->literal), "18"); + nodesDestroyNode(pRoot); } int main(int argc, char* argv[]) { diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index c863c1e0ee..c3f2a53f7b 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -260,7 +260,8 @@ SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere); SNode* createInsertStmt(SAstCreateContext* pCxt, SNode* pTable, SNodeList* pCols, SNode* pQuery); SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pView, const SToken* pAs, SNode* pQuery); SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pView); - +SNode* createShowCompactDetailsStmt(SAstCreateContext* pCxt, SNode* pCompactIdNode); +SNode* createShowCompactsStmt(SAstCreateContext* pCxt, ENodeType type); #ifdef __cplusplus } #endif diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 9bcf65dbbe..0479fce255 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -511,6 +511,8 @@ cmd ::= SHOW db_name_cond_opt(A) ALIVE. cmd ::= SHOW CLUSTER ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } cmd ::= SHOW db_name_cond_opt(A) VIEWS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, A, NULL, OP_TYPE_LIKE); } cmd ::= SHOW CREATE VIEW full_table_name(A). { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, A); } +cmd ::= SHOW COMPACTS. { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } +cmd ::= SHOW COMPACT NK_INTEGER(A). { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A)); } %type table_kind_db_name_cond_opt { SShowTablesOption } %destructor table_kind_db_name_cond_opt { } @@ -700,6 +702,7 @@ ignore_opt(A) ::= IGNORE UNTREATED. cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } cmd ::= KILL QUERY NK_STRING(A). { pCxt->pRootNode = createKillQueryStmt(pCxt, &A); } cmd ::= KILL TRANSACTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &A); } +cmd ::= KILL COMPACT NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &A); } /************************************************ merge/redistribute/ vgroup ******************************************/ cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 3ae82c3615..eb866c99aa 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1638,6 +1638,13 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { return (SNode*)pStmt; } +SNode* createShowCompactsStmt(SAstCreateContext* pCxt, ENodeType type) { + CHECK_PARSER_STATUS(pCxt); + SShowCompactsStmt* pStmt = (SShowCompactsStmt*)nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + return (SNode*)pStmt; +} + SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind) { if (pStmt == NULL) { return NULL; @@ -1783,6 +1790,13 @@ SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* p return (SNode*)pStmt; } +SNode* createShowCompactDetailsStmt(SAstCreateContext* pCxt, SNode* pCompactId) { + CHECK_PARSER_STATUS(pCxt); + SShowCompactDetailsStmt* pStmt = (SShowCompactDetailsStmt*)nodesMakeNode(QUERY_NODE_SHOW_COMPACT_DETAILS_STMT); + pStmt->pCompactId = pCompactId; + return (SNode*)pStmt; +} + static int32_t getIpV4RangeFromWhitelistItem(char* ipRange, SIpV4Range* pIpRange) { int32_t code = TSDB_CODE_SUCCESS; char* ipCopy = taosStrdup(ipRange); diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 91625defd0..be272228fe 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -607,6 +607,17 @@ static int32_t collectMetaKeyFromShowViews(SCollectMetaKeyCxt* pCxt, SShowStmt* return code; } +static int32_t collectMetaKeyFromShowCompacts(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_COMPACTS, + pCxt->pMetaCache); + return code; +} + +static int32_t collectMetaKeyFromShowCompactDetails(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_COMPACT_DETAILS, + pCxt->pMetaCache); + return code; +} static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) { return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); @@ -824,6 +835,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowUserPrivileges(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_VIEWS_STMT: return collectMetaKeyFromShowViews(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_COMPACTS_STMT: + return collectMetaKeyFromShowCompacts(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: + return collectMetaKeyFromShowCompactDetails(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 5988c68e17..03a5317cd3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -64,6 +64,7 @@ static SKeyword keywordTable[] = { {"COMMENT", TK_COMMENT}, {"COMP", TK_COMP}, {"COMPACT", TK_COMPACT}, + {"COMPACTS", TK_COMPACTS}, {"CONNECTION", TK_CONNECTION}, {"CONNECTIONS", TK_CONNECTIONS}, {"CONNS", TK_CONNS}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c5ac8a3dd6..3bb24566c2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -257,6 +257,18 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { .numOfShowCols = 1, .pShowCols = {"*"} }, + { .showType = QUERY_NODE_SHOW_COMPACTS_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_COMPACTS, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, + { .showType = QUERY_NODE_SHOW_COMPACT_DETAILS_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_COMPACT_DETAILS, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, }; // clang-format on @@ -7118,6 +7130,12 @@ static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt return buildCmdMsg(pCxt, TDMT_MND_KILL_CONN, (FSerializeFunc)tSerializeSKillConnReq, &killReq); } +static int32_t translateKillCompact(STranslateContext* pCxt, SKillStmt* pStmt) { + SKillCompactReq killReq = {0}; + killReq.compactId = pStmt->targetId; + return buildCmdMsg(pCxt, TDMT_MND_KILL_COMPACT, (FSerializeFunc)tSerializeSKillCompactReq, &killReq); +} + static int32_t translateKillQuery(STranslateContext* pCxt, SKillQueryStmt* pStmt) { SKillQueryReq killReq = {0}; strcpy(killReq.queryStrId, pStmt->queryId); @@ -8511,6 +8529,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_KILL_CONNECTION_STMT: code = translateKillConnection(pCxt, (SKillStmt*)pNode); break; + case QUERY_NODE_KILL_COMPACT_STMT: + code = translateKillCompact(pCxt, (SKillStmt*)pNode); + break; case QUERY_NODE_KILL_QUERY_STMT: code = translateKillQuery(pCxt, (SKillQueryStmt*)pNode); break; @@ -8761,6 +8782,28 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS return TSDB_CODE_SUCCESS; } +static int32_t extractCompactDbResultSchema(int32_t* numOfCols, SSchema** pSchema) { + *numOfCols = COMPACT_DB_RESULT_COLS; + *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); + if (NULL == (*pSchema)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[0].bytes = COMPACT_DB_RESULT_FIELD1_LEN; + strcpy((*pSchema)[0].name, "name"); + + (*pSchema)[1].type = TSDB_DATA_TYPE_INT; + (*pSchema)[1].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + strcpy((*pSchema)[1].name, "id"); + + (*pSchema)[2].type = TSDB_DATA_TYPE_BINARY; + (*pSchema)[2].bytes = COMPACT_DB_RESULT_FIELD3_LEN; + strcpy((*pSchema)[2].name, "reason"); + + return TSDB_CODE_SUCCESS; +} + int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { if (NULL == pRoot) { return TSDB_CODE_SUCCESS; @@ -8787,6 +8830,8 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: return extractShowVariablesResultSchema(numOfCols, pSchema); + case QUERY_NODE_COMPACT_DATABASE_STMT: + return extractCompactDbResultSchema(numOfCols, pSchema); default: break; } @@ -10268,6 +10313,37 @@ static int32_t rewriteFlushDatabase(STranslateContext* pCxt, SQuery* pQuery) { return code; } +static int32_t rewriteShowCompacts(STranslateContext* pCxt, SQuery* pQuery) { + SShowCompactsStmt* pShow = (SShowCompactsStmt*)(pQuery->pRoot); + SSelectStmt* pStmt = NULL; + int32_t code = createSelectStmtForShow(QUERY_NODE_SHOW_COMPACTS_STMT, &pStmt); + if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; + pQuery->showRewrite = true; + nodesDestroyNode(pQuery->pRoot); + pQuery->pRoot = (SNode*)pStmt; + } + return code; +} + +static int32_t rewriteShowCompactDetailsStmt(STranslateContext* pCxt, SQuery* pQuery) { + SShowCompactDetailsStmt* pShow = (SShowCompactDetailsStmt*)(pQuery->pRoot); + SSelectStmt* pStmt = NULL; + int32_t code = createSelectStmtForShow(QUERY_NODE_SHOW_COMPACT_DETAILS_STMT, &pStmt); + if (TSDB_CODE_SUCCESS == code) { + if (NULL != pShow->pCompactId) { + code = createOperatorNode(OP_TYPE_EQUAL, "compact_id", pShow->pCompactId, &pStmt->pWhere); + } + } + if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; + pQuery->showRewrite = true; + nodesDestroyNode(pQuery->pRoot); + pQuery->pRoot = (SNode*)pStmt; + } + return code; +} + static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pQuery->pRoot)) { @@ -10330,6 +10406,12 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_FLUSH_DATABASE_STMT: code = rewriteFlushDatabase(pCxt, pQuery); break; + case QUERY_NODE_SHOW_COMPACTS_STMT: + code = rewriteShowCompacts(pCxt, pQuery); + break; + case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: + code = rewriteShowCompactDetailsStmt(pCxt, pQuery); + break; default: break; } @@ -10435,6 +10517,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { pQuery->execMode = QUERY_EXEC_MODE_LOCAL; break; case QUERY_NODE_SHOW_VARIABLES_STMT: + case QUERY_NODE_COMPACT_DATABASE_STMT: pQuery->haveResultSet = true; pQuery->execMode = QUERY_EXEC_MODE_RPC; if (NULL != pCxt->pCmdMsg) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index f012b90941..66258ba3a9 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,3 +1,5 @@ +/* This file is automatically generated by Lemon from input grammar +** source file "sql.y". */ /* ** 2000-05-29 ** @@ -22,9 +24,8 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ +#line 11 "sql.y" #include #include @@ -41,12 +42,359 @@ #include "parAst.h" #define YYSTACKDEPTH 0 +#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ -/**************** End makeheaders token definitions ***************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +#ifndef TK_OR +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_USER 35 +#define TK_ENABLE 36 +#define TK_NK_INTEGER 37 +#define TK_SYSINFO 38 +#define TK_ADD 39 +#define TK_DROP 40 +#define TK_GRANT 41 +#define TK_ON 42 +#define TK_TO 43 +#define TK_REVOKE 44 +#define TK_FROM 45 +#define TK_SUBSCRIBE 46 +#define TK_READ 47 +#define TK_WRITE 48 +#define TK_NK_DOT 49 +#define TK_WITH 50 +#define TK_DNODE 51 +#define TK_PORT 52 +#define TK_DNODES 53 +#define TK_RESTORE 54 +#define TK_NK_IPTOKEN 55 +#define TK_FORCE 56 +#define TK_UNSAFE 57 +#define TK_LOCAL 58 +#define TK_QNODE 59 +#define TK_BNODE 60 +#define TK_SNODE 61 +#define TK_MNODE 62 +#define TK_VNODE 63 +#define TK_DATABASE 64 +#define TK_USE 65 +#define TK_FLUSH 66 +#define TK_TRIM 67 +#define TK_COMPACT 68 +#define TK_IF 69 +#define TK_NOT 70 +#define TK_EXISTS 71 +#define TK_BUFFER 72 +#define TK_CACHEMODEL 73 +#define TK_CACHESIZE 74 +#define TK_COMP 75 +#define TK_DURATION 76 +#define TK_NK_VARIABLE 77 +#define TK_MAXROWS 78 +#define TK_MINROWS 79 +#define TK_KEEP 80 +#define TK_PAGES 81 +#define TK_PAGESIZE 82 +#define TK_TSDB_PAGESIZE 83 +#define TK_PRECISION 84 +#define TK_REPLICA 85 +#define TK_VGROUPS 86 +#define TK_SINGLE_STABLE 87 +#define TK_RETENTIONS 88 +#define TK_SCHEMALESS 89 +#define TK_WAL_LEVEL 90 +#define TK_WAL_FSYNC_PERIOD 91 +#define TK_WAL_RETENTION_PERIOD 92 +#define TK_WAL_RETENTION_SIZE 93 +#define TK_WAL_ROLL_PERIOD 94 +#define TK_WAL_SEGMENT_SIZE 95 +#define TK_STT_TRIGGER 96 +#define TK_TABLE_PREFIX 97 +#define TK_TABLE_SUFFIX 98 +#define TK_KEEP_TIME_OFFSET 99 +#define TK_NK_COLON 100 +#define TK_BWLIMIT 101 +#define TK_START 102 +#define TK_TIMESTAMP 103 +#define TK_END 104 +#define TK_TABLE 105 +#define TK_NK_LP 106 +#define TK_NK_RP 107 +#define TK_STABLE 108 +#define TK_COLUMN 109 +#define TK_MODIFY 110 +#define TK_RENAME 111 +#define TK_TAG 112 +#define TK_SET 113 +#define TK_NK_EQ 114 +#define TK_USING 115 +#define TK_TAGS 116 +#define TK_BOOL 117 +#define TK_TINYINT 118 +#define TK_SMALLINT 119 +#define TK_INT 120 +#define TK_INTEGER 121 +#define TK_BIGINT 122 +#define TK_FLOAT 123 +#define TK_DOUBLE 124 +#define TK_BINARY 125 +#define TK_NCHAR 126 +#define TK_UNSIGNED 127 +#define TK_JSON 128 +#define TK_VARCHAR 129 +#define TK_MEDIUMBLOB 130 +#define TK_BLOB 131 +#define TK_VARBINARY 132 +#define TK_GEOMETRY 133 +#define TK_DECIMAL 134 +#define TK_COMMENT 135 +#define TK_MAX_DELAY 136 +#define TK_WATERMARK 137 +#define TK_ROLLUP 138 +#define TK_TTL 139 +#define TK_SMA 140 +#define TK_DELETE_MARK 141 +#define TK_FIRST 142 +#define TK_LAST 143 +#define TK_SHOW 144 +#define TK_PRIVILEGES 145 +#define TK_DATABASES 146 +#define TK_TABLES 147 +#define TK_STABLES 148 +#define TK_MNODES 149 +#define TK_QNODES 150 +#define TK_FUNCTIONS 151 +#define TK_INDEXES 152 +#define TK_ACCOUNTS 153 +#define TK_APPS 154 +#define TK_CONNECTIONS 155 +#define TK_LICENCES 156 +#define TK_GRANTS 157 +#define TK_QUERIES 158 +#define TK_SCORES 159 +#define TK_TOPICS 160 +#define TK_VARIABLES 161 +#define TK_CLUSTER 162 +#define TK_BNODES 163 +#define TK_SNODES 164 +#define TK_TRANSACTIONS 165 +#define TK_DISTRIBUTED 166 +#define TK_CONSUMERS 167 +#define TK_SUBSCRIPTIONS 168 +#define TK_VNODES 169 +#define TK_ALIVE 170 +#define TK_VIEWS 171 +#define TK_VIEW 172 +#define TK_COMPACTS 173 +#define TK_NORMAL 174 +#define TK_CHILD 175 +#define TK_LIKE 176 +#define TK_TBNAME 177 +#define TK_QTAGS 178 +#define TK_AS 179 +#define TK_SYSTEM 180 +#define TK_INDEX 181 +#define TK_FUNCTION 182 +#define TK_INTERVAL 183 +#define TK_COUNT 184 +#define TK_LAST_ROW 185 +#define TK_META 186 +#define TK_ONLY 187 +#define TK_TOPIC 188 +#define TK_CONSUMER 189 +#define TK_GROUP 190 +#define TK_DESC 191 +#define TK_DESCRIBE 192 +#define TK_RESET 193 +#define TK_QUERY 194 +#define TK_CACHE 195 +#define TK_EXPLAIN 196 +#define TK_ANALYZE 197 +#define TK_VERBOSE 198 +#define TK_NK_BOOL 199 +#define TK_RATIO 200 +#define TK_NK_FLOAT 201 +#define TK_OUTPUTTYPE 202 +#define TK_AGGREGATE 203 +#define TK_BUFSIZE 204 +#define TK_LANGUAGE 205 +#define TK_REPLACE 206 +#define TK_STREAM 207 +#define TK_INTO 208 +#define TK_PAUSE 209 +#define TK_RESUME 210 +#define TK_TRIGGER 211 +#define TK_AT_ONCE 212 +#define TK_WINDOW_CLOSE 213 +#define TK_IGNORE 214 +#define TK_EXPIRED 215 +#define TK_FILL_HISTORY 216 +#define TK_UPDATE 217 +#define TK_SUBTABLE 218 +#define TK_UNTREATED 219 +#define TK_KILL 220 +#define TK_CONNECTION 221 +#define TK_TRANSACTION 222 +#define TK_BALANCE 223 +#define TK_VGROUP 224 +#define TK_LEADER 225 +#define TK_MERGE 226 +#define TK_REDISTRIBUTE 227 +#define TK_SPLIT 228 +#define TK_DELETE 229 +#define TK_INSERT 230 +#define TK_NULL 231 +#define TK_NK_QUESTION 232 +#define TK_NK_ALIAS 233 +#define TK_NK_ARROW 234 +#define TK_ROWTS 235 +#define TK_QSTART 236 +#define TK_QEND 237 +#define TK_QDURATION 238 +#define TK_WSTART 239 +#define TK_WEND 240 +#define TK_WDURATION 241 +#define TK_IROWTS 242 +#define TK_ISFILLED 243 +#define TK_CAST 244 +#define TK_NOW 245 +#define TK_TODAY 246 +#define TK_TIMEZONE 247 +#define TK_CLIENT_VERSION 248 +#define TK_SERVER_VERSION 249 +#define TK_SERVER_STATUS 250 +#define TK_CURRENT_USER 251 +#define TK_CASE 252 +#define TK_WHEN 253 +#define TK_THEN 254 +#define TK_ELSE 255 +#define TK_BETWEEN 256 +#define TK_IS 257 +#define TK_NK_LT 258 +#define TK_NK_GT 259 +#define TK_NK_LE 260 +#define TK_NK_GE 261 +#define TK_NK_NE 262 +#define TK_MATCH 263 +#define TK_NMATCH 264 +#define TK_CONTAINS 265 +#define TK_IN 266 +#define TK_JOIN 267 +#define TK_INNER 268 +#define TK_SELECT 269 +#define TK_NK_HINT 270 +#define TK_DISTINCT 271 +#define TK_WHERE 272 +#define TK_PARTITION 273 +#define TK_BY 274 +#define TK_SESSION 275 +#define TK_STATE_WINDOW 276 +#define TK_EVENT_WINDOW 277 +#define TK_SLIDING 278 +#define TK_FILL 279 +#define TK_VALUE 280 +#define TK_VALUE_F 281 +#define TK_NONE 282 +#define TK_PREV 283 +#define TK_NULL_F 284 +#define TK_LINEAR 285 +#define TK_NEXT 286 +#define TK_HAVING 287 +#define TK_RANGE 288 +#define TK_EVERY 289 +#define TK_ORDER 290 +#define TK_SLIMIT 291 +#define TK_SOFFSET 292 +#define TK_LIMIT 293 +#define TK_OFFSET 294 +#define TK_ASC 295 +#define TK_NULLS 296 +#define TK_ABORT 297 +#define TK_AFTER 298 +#define TK_ATTACH 299 +#define TK_BEFORE 300 +#define TK_BEGIN 301 +#define TK_BITAND 302 +#define TK_BITNOT 303 +#define TK_BITOR 304 +#define TK_BLOCKS 305 +#define TK_CHANGE 306 +#define TK_COMMA 307 +#define TK_CONCAT 308 +#define TK_CONFLICT 309 +#define TK_COPY 310 +#define TK_DEFERRED 311 +#define TK_DELIMITERS 312 +#define TK_DETACH 313 +#define TK_DIVIDE 314 +#define TK_DOT 315 +#define TK_EACH 316 +#define TK_FAIL 317 +#define TK_FILE 318 +#define TK_FOR 319 +#define TK_GLOB 320 +#define TK_ID 321 +#define TK_IMMEDIATE 322 +#define TK_IMPORT 323 +#define TK_INITIALLY 324 +#define TK_INSTEAD 325 +#define TK_ISNULL 326 +#define TK_KEY 327 +#define TK_MODULES 328 +#define TK_NK_BITNOT 329 +#define TK_NK_SEMI 330 +#define TK_NOTNULL 331 +#define TK_OF 332 +#define TK_PLUS 333 +#define TK_PRIVILEGE 334 +#define TK_RAISE 335 +#define TK_RESTRICT 336 +#define TK_ROW 337 +#define TK_SEMI 338 +#define TK_STAR 339 +#define TK_STATEMENT 340 +#define TK_STRICT 341 +#define TK_STRING 342 +#define TK_TIMES 343 +#define TK_VALUES 344 +#define TK_VARIABLE 345 +#define TK_WAL 346 +#endif +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -104,29 +452,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 507 +#define YYNOCODE 508 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EFillMode yy36; - SNode* yy80; - SNodeList* yy106; - SDataType yy292; - EOperatorType yy428; - int8_t yy431; - SAlterOption yy455; - EShowKind yy459; - STokenPair yy573; - SShowTablesOption yy709; - ENullOrder yy763; - SToken yy785; - EOrder yy812; - EJoinType yy828; - bool yy923; - int32_t yy982; - int64_t yy987; + SNodeList* yy88; + int32_t yy92; + SAlterOption yy117; + SShowTablesOption yy133; + ENullOrder yy153; + int64_t yy221; + SNode* yy232; + STokenPair yy241; + EFillMode yy246; + int8_t yy279; + EShowKind yy281; + SDataType yy400; + EJoinType yy436; + EOperatorType yy708; + EOrder yy834; + bool yy985; + SToken yy993; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -142,18 +490,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 835 -#define YYNRULE 639 -#define YYNRULE_WITH_ACTION 639 -#define YYNTOKEN 346 -#define YY_MAX_SHIFT 834 -#define YY_MIN_SHIFTREDUCE 1237 -#define YY_MAX_SHIFTREDUCE 1875 -#define YY_ERROR_ACTION 1876 -#define YY_ACCEPT_ACTION 1877 -#define YY_NO_ACTION 1878 -#define YY_MIN_REDUCE 1879 -#define YY_MAX_REDUCE 2517 +#define YYNSTATE 840 +#define YYNRULE 642 +#define YYNRULE_WITH_ACTION 642 +#define YYNTOKEN 347 +#define YY_MAX_SHIFT 839 +#define YY_MIN_SHIFTREDUCE 1242 +#define YY_MAX_SHIFTREDUCE 1883 +#define YY_ERROR_ACTION 1884 +#define YY_ACCEPT_ACTION 1885 +#define YY_NO_ACTION 1886 +#define YY_MIN_REDUCE 1887 +#define YY_MAX_REDUCE 2528 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -220,895 +568,874 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3178) +#define YY_ACTTAB_COUNT (3071) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 173, 409, 462, 418, 2278, 720, 2067, 461, 2006, 171, - /* 10 */ 2007, 168, 48, 46, 1799, 424, 423, 2069, 397, 2069, - /* 20 */ 415, 1669, 1640, 41, 40, 137, 2118, 47, 45, 44, - /* 30 */ 43, 42, 599, 475, 2176, 1725, 1963, 1638, 41, 40, - /* 40 */ 1647, 694, 47, 45, 44, 43, 42, 2319, 1665, 720, - /* 50 */ 2067, 2120, 662, 469, 662, 2488, 681, 2488, 381, 789, - /* 60 */ 702, 184, 2028, 30, 1720, 1880, 2118, 719, 556, 208, - /* 70 */ 19, 557, 1922, 2494, 203, 2494, 203, 1646, 2489, 688, - /* 80 */ 2489, 688, 219, 383, 2337, 2180, 127, 719, 2337, 126, - /* 90 */ 125, 124, 123, 122, 121, 120, 119, 118, 523, 521, - /* 100 */ 2285, 364, 736, 831, 786, 217, 15, 1665, 806, 805, - /* 110 */ 804, 803, 427, 719, 802, 801, 151, 796, 795, 794, - /* 120 */ 793, 792, 791, 790, 150, 784, 783, 782, 426, 425, - /* 130 */ 779, 778, 777, 183, 182, 776, 687, 1842, 573, 2488, - /* 140 */ 561, 2318, 1727, 1728, 2356, 680, 558, 114, 2320, 740, - /* 150 */ 2322, 2323, 735, 51, 730, 2424, 2200, 686, 203, 186, - /* 160 */ 2200, 2409, 2489, 688, 687, 411, 2405, 2488, 788, 720, - /* 170 */ 2067, 408, 699, 146, 2197, 707, 1700, 1710, 2198, 707, - /* 180 */ 205, 2421, 1665, 1726, 1729, 686, 203, 1382, 2439, 137, - /* 190 */ 2489, 688, 1439, 682, 574, 2193, 604, 1877, 1641, 51, - /* 200 */ 1639, 677, 2295, 1650, 2306, 1872, 1430, 765, 764, 763, - /* 210 */ 1434, 762, 1436, 1437, 761, 758, 2303, 1445, 755, 1447, - /* 220 */ 1448, 752, 749, 746, 481, 2176, 2299, 1384, 389, 388, - /* 230 */ 1644, 1645, 1697, 1670, 1699, 1702, 1703, 1704, 1705, 1706, - /* 240 */ 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, 1723, - /* 250 */ 1724, 2, 48, 46, 509, 2176, 576, 363, 63, 1663, - /* 260 */ 415, 2308, 1640, 1540, 1541, 2319, 507, 184, 63, 526, - /* 270 */ 2301, 412, 95, 221, 525, 1725, 430, 1638, 734, 95, - /* 280 */ 730, 429, 300, 2417, 698, 68, 138, 697, 1668, 2488, - /* 290 */ 489, 2181, 527, 683, 678, 671, 385, 491, 2063, 387, - /* 300 */ 386, 695, 601, 226, 1720, 2062, 2337, 686, 203, 1871, - /* 310 */ 19, 1666, 2489, 688, 618, 617, 616, 1646, 2285, 2424, - /* 320 */ 736, 608, 143, 612, 603, 1822, 662, 611, 602, 2488, - /* 330 */ 720, 2067, 610, 615, 391, 390, 1803, 645, 609, 634, - /* 340 */ 1823, 605, 1665, 831, 384, 2420, 15, 2494, 203, 460, - /* 350 */ 56, 459, 2489, 688, 632, 477, 630, 269, 268, 2318, - /* 360 */ 564, 304, 2356, 557, 1922, 356, 2320, 740, 2322, 2323, - /* 370 */ 735, 733, 730, 721, 2374, 47, 45, 44, 43, 42, - /* 380 */ 1821, 458, 1727, 1728, 63, 2187, 2166, 63, 514, 513, - /* 390 */ 512, 511, 506, 505, 504, 503, 502, 497, 496, 495, - /* 400 */ 494, 367, 486, 485, 484, 1697, 479, 478, 382, 172, - /* 410 */ 38, 320, 1528, 1529, 341, 34, 1700, 1710, 1547, 223, - /* 420 */ 304, 41, 40, 1726, 1729, 47, 45, 44, 43, 42, - /* 430 */ 304, 338, 74, 1474, 1475, 73, 646, 775, 1641, 420, - /* 440 */ 1639, 1966, 2113, 2115, 517, 365, 302, 41, 40, 52, - /* 450 */ 691, 47, 45, 44, 43, 42, 235, 538, 536, 533, - /* 460 */ 90, 41, 40, 89, 1902, 47, 45, 44, 43, 42, - /* 470 */ 1644, 1645, 1697, 1669, 1699, 1702, 1703, 1704, 1705, 1706, - /* 480 */ 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, 1723, - /* 490 */ 1724, 2, 12, 48, 46, 159, 553, 63, 1701, 720, - /* 500 */ 2067, 415, 2248, 1640, 551, 644, 227, 547, 543, 375, - /* 510 */ 566, 2239, 572, 618, 617, 616, 1725, 2285, 1638, 466, - /* 520 */ 608, 143, 612, 834, 699, 146, 611, 88, 516, 515, - /* 530 */ 1735, 610, 615, 391, 390, 64, 1665, 609, 237, 327, - /* 540 */ 605, 284, 559, 1830, 1930, 1720, 304, 1669, 2319, 304, - /* 550 */ 196, 19, 661, 1754, 1698, 193, 274, 1756, 1646, 720, - /* 560 */ 2067, 702, 2107, 822, 818, 814, 810, 127, 324, 55, - /* 570 */ 126, 125, 124, 123, 122, 121, 120, 119, 118, 467, - /* 580 */ 9, 84, 83, 465, 831, 100, 216, 15, 12, 2337, - /* 590 */ 10, 1640, 674, 673, 1828, 1829, 1831, 1832, 1833, 457, - /* 600 */ 455, 2285, 643, 736, 112, 2493, 1638, 720, 2067, 113, - /* 610 */ 366, 304, 318, 446, 1755, 1666, 443, 439, 435, 432, - /* 620 */ 458, 147, 1668, 1727, 1728, 2044, 1303, 483, 1302, 2059, - /* 630 */ 174, 199, 1891, 701, 201, 2417, 2418, 35, 144, 2422, - /* 640 */ 699, 146, 2318, 142, 716, 2356, 1646, 1761, 114, 2320, - /* 650 */ 740, 2322, 2323, 735, 1901, 730, 2120, 1700, 1710, 304, - /* 660 */ 186, 1304, 2409, 36, 1726, 1729, 411, 2405, 106, 41, - /* 670 */ 40, 706, 831, 47, 45, 44, 43, 42, 2043, 1641, - /* 680 */ 61, 1639, 699, 146, 307, 1670, 720, 2067, 659, 2440, - /* 690 */ 606, 306, 1701, 2060, 37, 413, 1749, 1750, 1751, 1752, - /* 700 */ 1753, 1757, 1758, 1759, 1760, 194, 498, 2285, 692, 1865, - /* 710 */ 277, 1644, 1645, 1697, 1379, 1699, 1702, 1703, 1704, 1705, - /* 720 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, - /* 730 */ 1723, 1724, 2, 48, 46, 1730, 2319, 1560, 1561, 1286, - /* 740 */ 239, 415, 1900, 1640, 559, 1664, 1930, 775, 1698, 737, - /* 750 */ 202, 2417, 2418, 603, 144, 2422, 1725, 602, 1638, 1670, - /* 760 */ 773, 161, 160, 770, 769, 768, 158, 1641, 2319, 1639, - /* 770 */ 773, 161, 160, 770, 769, 768, 158, 2337, 1559, 1562, - /* 780 */ 302, 737, 1899, 1932, 727, 1720, 1879, 720, 2067, 2285, - /* 790 */ 1669, 736, 204, 2417, 2418, 2285, 144, 2422, 1646, 1644, - /* 800 */ 1645, 2114, 2115, 1898, 646, 1788, 2319, 499, 2424, 2337, - /* 810 */ 136, 135, 134, 133, 132, 131, 130, 129, 128, 737, - /* 820 */ 1665, 2285, 99, 736, 831, 720, 2067, 49, 1665, 623, - /* 830 */ 2318, 720, 2067, 2356, 2419, 2285, 114, 2320, 740, 2322, - /* 840 */ 2323, 735, 1897, 730, 635, 500, 149, 2337, 156, 2380, - /* 850 */ 2409, 575, 1588, 272, 411, 2405, 2285, 271, 418, 2285, - /* 860 */ 270, 736, 2318, 1727, 1728, 2356, 171, 2151, 114, 2320, - /* 870 */ 740, 2322, 2323, 735, 2069, 730, 626, 2042, 648, 2239, - /* 880 */ 2508, 2120, 2409, 620, 2120, 12, 411, 2405, 396, 267, - /* 890 */ 1646, 405, 720, 2067, 1896, 2285, 2118, 1700, 1710, 2118, - /* 900 */ 2318, 595, 594, 2356, 1726, 1729, 114, 2320, 740, 2322, - /* 910 */ 2323, 735, 2064, 730, 2295, 722, 255, 2381, 2384, 1641, - /* 920 */ 2409, 1639, 1895, 98, 411, 2405, 370, 1894, 2058, 395, - /* 930 */ 72, 636, 178, 71, 2120, 1277, 614, 613, 2299, 766, - /* 940 */ 593, 589, 585, 581, 1746, 254, 1893, 2285, 198, 715, - /* 950 */ 2279, 1644, 1645, 1697, 1284, 1699, 1702, 1703, 1704, 1705, - /* 960 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, - /* 970 */ 1723, 1724, 2, 48, 46, 2285, 1701, 1279, 1282, 1283, - /* 980 */ 2285, 415, 2301, 1640, 720, 2067, 96, 720, 2067, 252, - /* 990 */ 2120, 2492, 730, 325, 2120, 2319, 1725, 410, 1638, 2285, - /* 1000 */ 662, 419, 1670, 2488, 275, 2118, 1284, 283, 737, 2118, - /* 1010 */ 2447, 2056, 773, 161, 160, 770, 769, 768, 158, 720, - /* 1020 */ 2067, 2494, 203, 720, 2067, 1720, 2489, 688, 493, 2319, - /* 1030 */ 1282, 1283, 1698, 421, 720, 2067, 2337, 492, 1646, 705, - /* 1040 */ 1698, 171, 737, 315, 2460, 720, 2067, 2052, 2285, 2069, - /* 1050 */ 736, 41, 40, 242, 717, 47, 45, 44, 43, 42, - /* 1060 */ 1796, 251, 244, 450, 831, 718, 2161, 49, 249, 570, - /* 1070 */ 2337, 41, 40, 720, 2067, 47, 45, 44, 43, 42, - /* 1080 */ 1306, 1307, 2285, 1933, 736, 720, 2067, 241, 1337, 2318, - /* 1090 */ 452, 448, 2356, 321, 2054, 114, 2320, 740, 2322, 2323, - /* 1100 */ 735, 641, 730, 1727, 1728, 422, 2266, 2508, 473, 2409, - /* 1110 */ 647, 41, 40, 411, 2405, 47, 45, 44, 43, 42, - /* 1120 */ 1303, 1890, 1302, 2318, 800, 798, 2356, 1889, 1338, 114, - /* 1130 */ 2320, 740, 2322, 2323, 735, 824, 730, 1700, 1710, 597, - /* 1140 */ 596, 2508, 273, 2409, 1726, 1729, 2050, 411, 2405, 2493, - /* 1150 */ 1841, 662, 2488, 148, 2488, 1304, 2380, 311, 312, 1641, - /* 1160 */ 662, 1639, 310, 2488, 724, 2295, 2381, 1888, 1394, 703, - /* 1170 */ 1815, 2492, 2494, 203, 2285, 2489, 2491, 2489, 688, 2304, - /* 1180 */ 2285, 2494, 203, 1393, 14, 13, 2489, 688, 638, 2299, - /* 1190 */ 637, 1644, 1645, 1697, 1887, 1699, 1702, 1703, 1704, 1705, - /* 1200 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, - /* 1210 */ 1723, 1724, 2, 48, 46, 2319, 197, 1609, 1610, 662, - /* 1220 */ 2285, 415, 2488, 1640, 1398, 44, 43, 42, 737, 1886, - /* 1230 */ 669, 2493, 767, 2301, 2488, 2111, 1725, 2120, 1638, 1397, - /* 1240 */ 2494, 203, 1885, 730, 1884, 2489, 688, 2285, 2319, 528, - /* 1250 */ 1649, 171, 2119, 2492, 2071, 1883, 2337, 2489, 2490, 2070, - /* 1260 */ 1882, 737, 1648, 2481, 771, 1720, 334, 2111, 2285, 2097, - /* 1270 */ 736, 772, 1907, 826, 2111, 2429, 1788, 690, 1646, 41, - /* 1280 */ 40, 170, 2285, 47, 45, 44, 43, 42, 2269, 2337, - /* 1290 */ 1768, 2045, 1950, 280, 3, 2285, 76, 2285, 139, 260, - /* 1300 */ 159, 2285, 258, 736, 831, 530, 54, 15, 2285, 2318, - /* 1310 */ 86, 2453, 2356, 2285, 619, 114, 2320, 740, 2322, 2323, - /* 1320 */ 735, 731, 730, 607, 152, 262, 1795, 2508, 261, 2409, - /* 1330 */ 210, 424, 423, 411, 2405, 264, 1941, 266, 263, 437, - /* 1340 */ 265, 1654, 2318, 1727, 1728, 2356, 87, 1377, 114, 2320, - /* 1350 */ 740, 2322, 2323, 735, 1725, 730, 1647, 1939, 621, 297, - /* 1360 */ 2508, 1892, 2409, 1874, 1875, 675, 411, 2405, 14, 13, - /* 1370 */ 141, 291, 2338, 2004, 1604, 2319, 780, 1700, 1710, 624, - /* 1380 */ 159, 50, 50, 1720, 1726, 1729, 187, 159, 737, 50, - /* 1390 */ 2428, 309, 75, 111, 157, 781, 1646, 159, 2003, 1641, - /* 1400 */ 1356, 1639, 108, 672, 2185, 1923, 2443, 401, 679, 398, - /* 1410 */ 709, 66, 50, 1652, 50, 428, 2337, 744, 157, 1354, - /* 1420 */ 1929, 159, 726, 140, 157, 1651, 2108, 2186, 2285, 655, - /* 1430 */ 736, 1644, 1645, 1697, 2444, 1699, 1702, 1703, 1704, 1705, - /* 1440 */ 1706, 1707, 1708, 1709, 732, 728, 1718, 1719, 1721, 1722, - /* 1450 */ 1723, 1724, 2, 2454, 1607, 1827, 1826, 700, 299, 296, - /* 1460 */ 289, 704, 2029, 1557, 303, 313, 712, 5, 317, 2318, - /* 1470 */ 431, 1424, 2356, 436, 379, 114, 2320, 740, 2322, 2323, - /* 1480 */ 735, 444, 730, 2319, 445, 1762, 1711, 2508, 333, 2409, - /* 1490 */ 1673, 1452, 1456, 411, 2405, 1463, 737, 1461, 162, 454, - /* 1500 */ 212, 211, 453, 214, 456, 1581, 328, 1663, 470, 1664, - /* 1510 */ 474, 225, 476, 480, 519, 482, 487, 1655, 501, 1650, - /* 1520 */ 508, 2178, 510, 518, 2337, 520, 532, 531, 529, 229, - /* 1530 */ 230, 534, 232, 535, 537, 539, 2285, 1671, 736, 554, - /* 1540 */ 4, 2319, 555, 562, 563, 240, 565, 92, 1666, 1658, - /* 1550 */ 1660, 243, 1672, 567, 737, 1674, 568, 246, 569, 1675, - /* 1560 */ 571, 248, 2194, 728, 1718, 1719, 1721, 1722, 1723, 1724, - /* 1570 */ 93, 577, 598, 94, 253, 97, 642, 2318, 2319, 627, - /* 1580 */ 2356, 2257, 2337, 114, 2320, 740, 2322, 2323, 735, 600, - /* 1590 */ 730, 737, 116, 628, 2285, 2382, 736, 2409, 2057, 257, - /* 1600 */ 360, 411, 2405, 640, 2053, 259, 153, 164, 2254, 165, - /* 1610 */ 2055, 2319, 2051, 166, 167, 329, 276, 1667, 2240, 2337, - /* 1620 */ 650, 649, 651, 281, 737, 657, 2459, 279, 676, 710, - /* 1630 */ 8, 2285, 2253, 736, 2431, 2318, 654, 685, 2356, 666, - /* 1640 */ 2458, 114, 2320, 740, 2322, 2323, 735, 290, 730, 179, - /* 1650 */ 667, 292, 2337, 723, 2319, 2409, 286, 665, 288, 411, - /* 1660 */ 2405, 656, 2487, 402, 2285, 664, 736, 737, 295, 696, - /* 1670 */ 2511, 298, 2318, 693, 1788, 2356, 145, 1668, 115, 2320, - /* 1680 */ 740, 2322, 2323, 735, 1793, 730, 190, 2425, 1791, 293, - /* 1690 */ 294, 2319, 2409, 1, 305, 2337, 2408, 2405, 154, 330, - /* 1700 */ 708, 2208, 2207, 2206, 737, 2318, 331, 2285, 2356, 736, - /* 1710 */ 407, 115, 2320, 740, 2322, 2323, 735, 713, 730, 206, - /* 1720 */ 714, 332, 62, 155, 2390, 2409, 107, 2068, 105, 725, - /* 1730 */ 2405, 742, 2337, 2112, 335, 1261, 825, 323, 828, 371, - /* 1740 */ 53, 359, 372, 830, 2285, 339, 736, 163, 738, 2319, - /* 1750 */ 344, 2356, 2277, 2276, 115, 2320, 740, 2322, 2323, 735, - /* 1760 */ 358, 730, 737, 337, 348, 2275, 2319, 81, 2409, 2270, - /* 1770 */ 433, 434, 374, 2405, 1631, 1632, 209, 438, 2268, 737, - /* 1780 */ 440, 441, 442, 1630, 2267, 2318, 380, 2319, 2356, 2265, - /* 1790 */ 2337, 175, 2320, 740, 2322, 2323, 735, 447, 730, 2264, - /* 1800 */ 737, 449, 2285, 451, 736, 2263, 1620, 2337, 2244, 213, - /* 1810 */ 2243, 215, 1584, 82, 2221, 1583, 2220, 2219, 463, 2285, - /* 1820 */ 464, 736, 2218, 2217, 2168, 468, 1527, 2160, 2337, 471, - /* 1830 */ 2157, 472, 218, 663, 2450, 2156, 85, 2155, 2154, 2159, - /* 1840 */ 2285, 2158, 736, 2318, 220, 2153, 2356, 2152, 2150, 176, - /* 1850 */ 2320, 740, 2322, 2323, 735, 2149, 730, 2148, 222, 2147, - /* 1860 */ 2318, 488, 490, 2356, 2163, 2146, 115, 2320, 740, 2322, - /* 1870 */ 2323, 735, 2145, 730, 2144, 2143, 2142, 2165, 2141, 2140, - /* 1880 */ 2409, 2318, 2139, 2138, 2356, 2406, 2319, 175, 2320, 740, - /* 1890 */ 2322, 2323, 735, 2137, 730, 2136, 2135, 2134, 2133, 737, - /* 1900 */ 2132, 224, 2131, 689, 2509, 91, 2130, 2129, 2128, 2164, - /* 1910 */ 2162, 2127, 2126, 2319, 1533, 2125, 2124, 228, 522, 2123, - /* 1920 */ 524, 2122, 2121, 1395, 1969, 1399, 737, 2337, 1391, 1968, - /* 1930 */ 2451, 368, 399, 231, 369, 233, 1967, 234, 1965, 2285, - /* 1940 */ 1962, 736, 540, 1961, 2319, 541, 542, 1954, 1943, 1918, - /* 1950 */ 544, 1285, 1917, 2242, 2337, 2238, 185, 737, 2228, 400, - /* 1960 */ 546, 2216, 548, 552, 2215, 545, 2285, 2192, 736, 550, - /* 1970 */ 247, 549, 78, 236, 238, 2046, 79, 1964, 1960, 578, - /* 1980 */ 2318, 2319, 2305, 2356, 195, 2337, 357, 2320, 740, 2322, - /* 1990 */ 2323, 735, 245, 730, 737, 560, 579, 2285, 580, 736, - /* 2000 */ 250, 1958, 582, 1330, 584, 583, 1956, 2318, 586, 1953, - /* 2010 */ 2356, 587, 588, 357, 2320, 740, 2322, 2323, 735, 590, - /* 2020 */ 730, 592, 2337, 591, 1938, 1936, 1937, 1935, 1914, 2048, - /* 2030 */ 1468, 65, 1467, 2047, 2285, 1951, 736, 1381, 2318, 1380, - /* 2040 */ 1378, 2356, 1376, 1942, 350, 2320, 740, 2322, 2323, 735, - /* 2050 */ 1375, 730, 1374, 256, 2319, 1373, 1372, 1369, 1368, 1367, - /* 2060 */ 1366, 392, 393, 797, 799, 622, 1940, 737, 394, 625, - /* 2070 */ 1913, 1912, 1911, 629, 1910, 2318, 1909, 633, 2356, 2319, - /* 2080 */ 117, 176, 2320, 740, 2322, 2323, 735, 631, 730, 1614, - /* 2090 */ 684, 1616, 734, 1613, 1618, 2337, 29, 2241, 69, 2237, - /* 2100 */ 406, 1590, 278, 1592, 1594, 2227, 652, 2285, 2214, 736, - /* 2110 */ 2493, 20, 6, 17, 31, 668, 21, 57, 2213, 7, - /* 2120 */ 2337, 22, 2319, 1844, 287, 189, 200, 33, 285, 2306, - /* 2130 */ 67, 23, 2285, 24, 736, 737, 2510, 2319, 282, 18, - /* 2140 */ 670, 58, 301, 1859, 653, 169, 1569, 1568, 2318, 1825, - /* 2150 */ 737, 2356, 2319, 177, 357, 2320, 740, 2322, 2323, 735, - /* 2160 */ 1858, 730, 403, 2337, 188, 737, 1814, 32, 414, 658, - /* 2170 */ 660, 80, 1863, 2318, 1864, 2285, 2356, 736, 2337, 356, - /* 2180 */ 2320, 740, 2322, 2323, 735, 1862, 730, 404, 2375, 1865, - /* 2190 */ 2285, 60, 736, 2337, 1785, 180, 1784, 2212, 416, 2191, - /* 2200 */ 2190, 101, 102, 308, 25, 2285, 103, 736, 1820, 191, - /* 2210 */ 314, 319, 26, 13, 316, 70, 2318, 2319, 104, 2356, - /* 2220 */ 1737, 1736, 357, 2320, 740, 2322, 2323, 735, 108, 730, - /* 2230 */ 737, 639, 1656, 711, 2356, 2319, 11, 352, 2320, 740, - /* 2240 */ 2322, 2323, 735, 2359, 730, 1715, 2318, 729, 737, 2356, - /* 2250 */ 1713, 39, 357, 2320, 740, 2322, 2323, 735, 2337, 730, - /* 2260 */ 59, 1712, 181, 16, 192, 27, 1690, 741, 1682, 28, - /* 2270 */ 2285, 1747, 736, 1453, 743, 417, 2337, 739, 745, 747, - /* 2280 */ 1450, 748, 750, 1449, 751, 753, 756, 1446, 2285, 754, - /* 2290 */ 736, 1440, 757, 759, 1438, 760, 1444, 1443, 1442, 109, - /* 2300 */ 322, 1441, 110, 1462, 77, 1458, 1363, 1328, 1360, 774, - /* 2310 */ 1389, 2318, 1359, 1358, 2356, 1357, 1355, 342, 2320, 740, - /* 2320 */ 2322, 2323, 735, 1353, 730, 1352, 1351, 785, 1388, 2318, - /* 2330 */ 2319, 787, 2356, 207, 1349, 340, 2320, 740, 2322, 2323, - /* 2340 */ 735, 1348, 730, 737, 1347, 1346, 1345, 2319, 1344, 1343, - /* 2350 */ 1383, 1385, 1340, 1339, 1336, 1335, 1334, 1333, 1959, 807, - /* 2360 */ 737, 808, 1957, 2319, 811, 812, 809, 813, 1955, 815, - /* 2370 */ 816, 2337, 1952, 817, 819, 821, 737, 820, 1934, 823, - /* 2380 */ 1274, 1908, 1262, 2285, 827, 736, 326, 829, 2337, 1642, - /* 2390 */ 833, 336, 832, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2400 */ 2285, 1878, 736, 1878, 2337, 1878, 1878, 1878, 1878, 1878, - /* 2410 */ 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 1878, - /* 2420 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 1878, - /* 2430 */ 343, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, - /* 2440 */ 2319, 2318, 1878, 1878, 2356, 1878, 1878, 349, 2320, 740, - /* 2450 */ 2322, 2323, 735, 737, 730, 1878, 1878, 2318, 1878, 2319, - /* 2460 */ 2356, 1878, 1878, 353, 2320, 740, 2322, 2323, 735, 1878, - /* 2470 */ 730, 1878, 737, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2480 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2490 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, - /* 2500 */ 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2510 */ 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, 1878, - /* 2520 */ 1878, 1878, 1878, 1878, 1878, 1878, 2319, 1878, 1878, 1878, - /* 2530 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 737, - /* 2540 */ 345, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, - /* 2550 */ 1878, 1878, 1878, 2318, 1878, 2319, 2356, 1878, 1878, 354, - /* 2560 */ 2320, 740, 2322, 2323, 735, 1878, 730, 2337, 737, 1878, - /* 2570 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, - /* 2580 */ 1878, 736, 1878, 1878, 2319, 1878, 1878, 1878, 1878, 1878, - /* 2590 */ 1878, 1878, 1878, 1878, 1878, 1878, 2337, 737, 1878, 1878, - /* 2600 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, - /* 2610 */ 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2620 */ 2318, 1878, 2319, 2356, 1878, 2337, 346, 2320, 740, 2322, - /* 2630 */ 2323, 735, 1878, 730, 1878, 737, 1878, 2285, 1878, 736, - /* 2640 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2318, - /* 2650 */ 1878, 1878, 2356, 1878, 1878, 355, 2320, 740, 2322, 2323, - /* 2660 */ 735, 1878, 730, 2337, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2670 */ 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 2318, 2319, - /* 2680 */ 1878, 2356, 1878, 1878, 347, 2320, 740, 2322, 2323, 735, - /* 2690 */ 1878, 730, 737, 1878, 1878, 1878, 1878, 2319, 1878, 1878, - /* 2700 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2710 */ 737, 1878, 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, - /* 2720 */ 2337, 1878, 361, 2320, 740, 2322, 2323, 735, 1878, 730, - /* 2730 */ 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 2337, 1878, - /* 2740 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2750 */ 2285, 1878, 736, 1878, 2319, 1878, 1878, 1878, 1878, 1878, - /* 2760 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 737, 1878, 1878, - /* 2770 */ 1878, 1878, 1878, 2318, 2319, 1878, 2356, 1878, 1878, 362, - /* 2780 */ 2320, 740, 2322, 2323, 735, 1878, 730, 737, 1878, 1878, - /* 2790 */ 2319, 2318, 1878, 1878, 2356, 2337, 1878, 2331, 2320, 740, - /* 2800 */ 2322, 2323, 735, 737, 730, 1878, 1878, 2285, 1878, 736, - /* 2810 */ 1878, 1878, 1878, 1878, 1878, 2337, 1878, 1878, 1878, 1878, - /* 2820 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, - /* 2830 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2840 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 2318, 1878, - /* 2850 */ 1878, 2356, 1878, 1878, 2330, 2320, 740, 2322, 2323, 735, - /* 2860 */ 1878, 730, 1878, 1878, 1878, 1878, 1878, 1878, 2318, 1878, - /* 2870 */ 1878, 2356, 1878, 1878, 2329, 2320, 740, 2322, 2323, 735, - /* 2880 */ 1878, 730, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 2319, - /* 2890 */ 376, 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, - /* 2900 */ 1878, 1878, 737, 1878, 1878, 2319, 1878, 1878, 1878, 1878, - /* 2910 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 737, 1878, - /* 2920 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2930 */ 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2940 */ 1878, 1878, 2285, 1878, 736, 1878, 2337, 1878, 1878, 1878, - /* 2950 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 2285, 1878, - /* 2960 */ 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2970 */ 1878, 1878, 2319, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 2980 */ 1878, 1878, 1878, 2318, 1878, 737, 2356, 2319, 1878, 377, - /* 2990 */ 2320, 740, 2322, 2323, 735, 1878, 730, 1878, 1878, 2318, - /* 3000 */ 737, 1878, 2356, 1878, 1878, 373, 2320, 740, 2322, 2323, - /* 3010 */ 735, 1878, 730, 2337, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3020 */ 1878, 1878, 1878, 1878, 1878, 2285, 1878, 736, 2337, 1878, - /* 3030 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3040 */ 2285, 1878, 736, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3050 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3060 */ 1878, 1878, 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, - /* 3070 */ 2319, 1878, 378, 2320, 740, 2322, 2323, 735, 1878, 730, - /* 3080 */ 1878, 738, 1878, 737, 2356, 1878, 1878, 352, 2320, 740, - /* 3090 */ 2322, 2323, 735, 1878, 730, 1878, 1878, 1878, 1878, 1878, - /* 3100 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3110 */ 1878, 2337, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3120 */ 1878, 1878, 1878, 2285, 1878, 736, 1878, 1878, 1878, 1878, - /* 3130 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3140 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3150 */ 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, - /* 3160 */ 1878, 1878, 1878, 1878, 2318, 1878, 1878, 2356, 1878, 1878, - /* 3170 */ 351, 2320, 740, 2322, 2323, 735, 1878, 730, + /* 0 */ 409, 561, 197, 418, 562, 1930, 569, 2064, 171, 562, + /* 10 */ 1930, 168, 48, 46, 1807, 2210, 2077, 34, 397, 2077, + /* 20 */ 415, 471, 1648, 41, 40, 1673, 2126, 47, 45, 44, + /* 30 */ 43, 42, 36, 2208, 712, 1733, 1971, 1646, 41, 40, + /* 40 */ 38, 320, 47, 45, 44, 43, 42, 2330, 41, 40, + /* 50 */ 480, 2186, 47, 45, 44, 43, 42, 704, 146, 1674, + /* 60 */ 707, 184, 2122, 2123, 1728, 1888, 528, 526, 420, 365, + /* 70 */ 19, 2121, 2123, 217, 41, 40, 173, 1654, 47, 45, + /* 80 */ 44, 43, 42, 383, 2014, 2190, 127, 95, 2348, 126, + /* 90 */ 125, 124, 123, 122, 121, 120, 119, 118, 1673, 219, + /* 100 */ 2296, 237, 741, 836, 385, 564, 15, 1938, 811, 810, + /* 110 */ 809, 808, 427, 2070, 807, 806, 151, 801, 800, 799, + /* 120 */ 798, 797, 796, 795, 150, 789, 788, 787, 426, 425, + /* 130 */ 784, 783, 782, 183, 182, 781, 692, 486, 2186, 2499, + /* 140 */ 1648, 2329, 1735, 1736, 2367, 686, 184, 114, 2331, 745, + /* 150 */ 2333, 2334, 740, 148, 735, 1646, 2391, 691, 203, 186, + /* 160 */ 581, 2420, 2500, 693, 1282, 411, 2416, 300, 2428, 703, + /* 170 */ 2191, 138, 702, 2348, 2499, 704, 146, 1708, 1718, 2435, + /* 180 */ 205, 1479, 1480, 1289, 1734, 1737, 221, 724, 2450, 2128, + /* 190 */ 1674, 724, 691, 203, 2210, 1654, 381, 2500, 693, 1649, + /* 200 */ 174, 1647, 1899, 2504, 2126, 2432, 1284, 1287, 1288, 408, + /* 210 */ 41, 40, 2207, 712, 47, 45, 44, 43, 42, 127, + /* 220 */ 1676, 836, 126, 125, 124, 123, 122, 121, 120, 119, + /* 230 */ 118, 1652, 1653, 1705, 685, 1707, 1710, 1711, 1712, 1713, + /* 240 */ 1714, 1715, 1716, 1717, 737, 733, 1726, 1727, 1729, 1730, + /* 250 */ 1731, 1732, 2, 48, 46, 1547, 1548, 1880, 364, 682, + /* 260 */ 1671, 415, 1308, 1648, 1307, 514, 2186, 512, 1830, 2330, + /* 270 */ 531, 724, 375, 51, 692, 530, 1733, 2499, 1646, 142, + /* 280 */ 2306, 650, 742, 1831, 706, 201, 2428, 2429, 272, 144, + /* 290 */ 2433, 494, 271, 532, 2066, 691, 203, 1309, 496, 2504, + /* 300 */ 2500, 693, 2499, 112, 2310, 1728, 1887, 1873, 474, 566, + /* 310 */ 2348, 19, 1567, 1568, 226, 563, 1762, 1649, 1654, 1647, + /* 320 */ 147, 2503, 2296, 1829, 741, 2500, 2502, 2330, 2067, 196, + /* 330 */ 136, 135, 134, 133, 132, 131, 130, 129, 128, 608, + /* 340 */ 742, 2115, 1940, 607, 836, 384, 687, 15, 2312, 1652, + /* 350 */ 1653, 688, 683, 676, 1566, 1569, 482, 51, 735, 98, + /* 360 */ 578, 1879, 370, 2329, 2051, 395, 2367, 641, 2348, 175, + /* 370 */ 2331, 745, 2333, 2334, 740, 577, 735, 666, 1763, 302, + /* 380 */ 2296, 106, 741, 1735, 1736, 1910, 2197, 2176, 1958, 519, + /* 390 */ 518, 517, 516, 511, 510, 509, 508, 507, 502, 501, + /* 400 */ 500, 499, 367, 491, 490, 489, 2068, 484, 483, 382, + /* 410 */ 624, 668, 2461, 475, 1535, 1536, 579, 2203, 1708, 1718, + /* 420 */ 1554, 2329, 1673, 648, 2367, 1734, 1737, 114, 2331, 745, + /* 430 */ 2333, 2334, 740, 780, 735, 1676, 304, 639, 2296, 2519, + /* 440 */ 1649, 2420, 1647, 41, 40, 411, 2416, 47, 45, 44, + /* 450 */ 43, 42, 637, 1654, 635, 269, 268, 2289, 37, 413, + /* 460 */ 1757, 1758, 1759, 1760, 1761, 1765, 1766, 1767, 1768, 780, + /* 470 */ 311, 312, 1652, 1653, 1705, 310, 1707, 1710, 1711, 1712, + /* 480 */ 1713, 1714, 1715, 1716, 1717, 737, 733, 1726, 1727, 1729, + /* 490 */ 1730, 1731, 1732, 2, 12, 48, 46, 255, 239, 2330, + /* 500 */ 1673, 1399, 564, 415, 1938, 1648, 61, 667, 63, 1909, + /* 510 */ 2499, 63, 742, 178, 664, 12, 1398, 68, 1733, 558, + /* 520 */ 1646, 598, 594, 590, 586, 223, 254, 556, 2505, 203, + /* 530 */ 552, 548, 1908, 2500, 693, 2330, 159, 623, 622, 621, + /* 540 */ 2348, 651, 1849, 522, 613, 143, 617, 1728, 707, 651, + /* 550 */ 616, 2052, 2296, 19, 741, 615, 620, 391, 390, 1705, + /* 560 */ 1654, 614, 2296, 3, 610, 2504, 90, 96, 2499, 89, + /* 570 */ 252, 1311, 1312, 41, 40, 54, 2348, 47, 45, 44, + /* 580 */ 43, 42, 533, 424, 423, 2296, 836, 2503, 2296, 15, + /* 590 */ 741, 2500, 2501, 2329, 302, 1308, 2367, 1307, 30, 114, + /* 600 */ 2331, 745, 2333, 2334, 740, 227, 735, 2306, 1655, 149, + /* 610 */ 55, 156, 2391, 2420, 1811, 571, 2249, 411, 2416, 63, + /* 620 */ 1673, 2315, 771, 653, 2249, 1735, 1736, 521, 520, 2329, + /* 630 */ 1309, 2310, 2367, 88, 242, 114, 2331, 745, 2333, 2334, + /* 640 */ 740, 2128, 735, 251, 244, 600, 599, 186, 396, 2420, + /* 650 */ 249, 575, 325, 411, 2416, 2435, 2126, 1709, 41, 40, + /* 660 */ 1708, 1718, 47, 45, 44, 43, 42, 1734, 1737, 241, + /* 670 */ 699, 304, 1850, 1743, 304, 2312, 2451, 1974, 2159, 1673, + /* 680 */ 1444, 2431, 1649, 2060, 1647, 735, 778, 161, 160, 775, + /* 690 */ 774, 773, 158, 52, 1435, 770, 769, 768, 1439, 767, + /* 700 */ 1441, 1442, 766, 763, 171, 1450, 760, 1452, 1453, 757, + /* 710 */ 754, 751, 2078, 1706, 1652, 1653, 1705, 99, 1707, 1710, + /* 720 */ 1711, 1712, 1713, 1714, 1715, 1716, 1717, 737, 733, 1726, + /* 730 */ 1727, 1729, 1730, 1731, 1732, 2, 48, 46, 1738, 2062, + /* 740 */ 2330, 44, 43, 42, 415, 2128, 1648, 1907, 1595, 623, + /* 750 */ 622, 621, 405, 742, 1838, 2458, 613, 143, 617, 1733, + /* 760 */ 2126, 1646, 616, 725, 2075, 725, 2075, 615, 620, 391, + /* 770 */ 390, 2330, 1658, 614, 725, 2075, 610, 1709, 1885, 2050, + /* 780 */ 9, 2348, 304, 137, 742, 137, 2471, 2058, 1728, 12, + /* 790 */ 604, 10, 609, 2296, 208, 741, 602, 601, 448, 2435, + /* 800 */ 2296, 1654, 1906, 679, 678, 1836, 1837, 1839, 1840, 1841, + /* 810 */ 464, 2079, 2348, 41, 40, 463, 2128, 47, 45, 44, + /* 820 */ 43, 42, 1291, 410, 2296, 2430, 741, 836, 1672, 170, + /* 830 */ 49, 2126, 280, 1706, 2329, 1905, 1709, 2367, 2330, 498, + /* 840 */ 114, 2331, 745, 2333, 2334, 740, 2128, 735, 497, 725, + /* 850 */ 2075, 739, 2519, 419, 2420, 2296, 304, 430, 411, 2416, + /* 860 */ 667, 2126, 429, 2499, 2503, 2329, 1735, 1736, 2367, 56, + /* 870 */ 736, 114, 2331, 745, 2333, 2334, 740, 2290, 735, 2348, + /* 880 */ 95, 2505, 203, 2519, 1904, 2420, 2500, 693, 2296, 411, + /* 890 */ 2416, 2296, 1706, 741, 778, 161, 160, 775, 774, 773, + /* 900 */ 158, 1708, 1718, 704, 146, 418, 2071, 667, 1734, 1737, + /* 910 */ 2499, 2128, 1823, 171, 778, 161, 160, 775, 774, 773, + /* 920 */ 158, 2077, 2317, 1649, 452, 1647, 711, 667, 2505, 203, + /* 930 */ 2499, 700, 2329, 2500, 693, 2367, 1949, 2296, 356, 2331, + /* 940 */ 745, 2333, 2334, 740, 738, 735, 726, 2385, 2505, 203, + /* 950 */ 1764, 454, 450, 2500, 693, 1652, 1653, 1705, 626, 1707, + /* 960 */ 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 737, 733, + /* 970 */ 1726, 1727, 1729, 1730, 1731, 1732, 2, 48, 46, 2319, + /* 980 */ 2330, 725, 2075, 1403, 646, 415, 1387, 1648, 1903, 649, + /* 990 */ 725, 2075, 727, 742, 2392, 674, 725, 2075, 1402, 273, + /* 1000 */ 1733, 468, 1646, 421, 725, 2075, 1796, 839, 619, 618, + /* 1010 */ 469, 171, 2330, 202, 2428, 2429, 488, 144, 2433, 2077, + /* 1020 */ 2169, 2348, 2306, 327, 275, 742, 1389, 2492, 1657, 1728, + /* 1030 */ 35, 725, 2075, 2296, 667, 741, 2314, 2499, 1804, 193, + /* 1040 */ 1769, 2296, 1654, 725, 2075, 284, 2310, 827, 823, 819, + /* 1050 */ 815, 503, 324, 2348, 791, 2505, 203, 2258, 725, 2075, + /* 1060 */ 2500, 693, 478, 504, 535, 2296, 2015, 741, 836, 704, + /* 1070 */ 146, 49, 1902, 628, 2329, 1616, 1617, 2367, 505, 1677, + /* 1080 */ 114, 2331, 745, 2333, 2334, 740, 652, 735, 640, 100, + /* 1090 */ 2312, 412, 2519, 113, 2420, 1677, 318, 1673, 411, 2416, + /* 1100 */ 735, 725, 2075, 2277, 270, 1900, 2329, 1735, 1736, 2367, + /* 1110 */ 1289, 274, 114, 2331, 745, 2333, 2334, 740, 793, 735, + /* 1120 */ 631, 580, 1677, 696, 2519, 2296, 2420, 625, 721, 794, + /* 1130 */ 411, 2416, 2036, 267, 1287, 1288, 667, 805, 803, 2499, + /* 1140 */ 41, 40, 1708, 1718, 47, 45, 44, 43, 42, 1734, + /* 1150 */ 1737, 695, 1677, 389, 388, 725, 2075, 2505, 203, 729, + /* 1160 */ 159, 2392, 2500, 693, 1649, 772, 1647, 2128, 2119, 307, + /* 1170 */ 1901, 725, 2075, 2128, 72, 2072, 306, 71, 111, 204, + /* 1180 */ 2428, 2429, 720, 144, 2433, 14, 13, 108, 2127, 708, + /* 1190 */ 63, 283, 1660, 1898, 1897, 277, 1652, 1653, 1705, 1896, + /* 1200 */ 1707, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 737, + /* 1210 */ 733, 1726, 1727, 1729, 1730, 1731, 1732, 2, 48, 46, + /* 1220 */ 725, 2075, 2330, 2296, 387, 386, 415, 606, 1648, 47, + /* 1230 */ 45, 44, 43, 42, 1611, 742, 1895, 2439, 194, 667, + /* 1240 */ 710, 1733, 2499, 1646, 725, 2075, 2296, 2296, 1894, 608, + /* 1250 */ 1893, 1892, 2296, 607, 725, 2075, 725, 2075, 725, 2075, + /* 1260 */ 2505, 203, 2280, 2348, 315, 2500, 693, 725, 2075, 776, + /* 1270 */ 1728, 76, 2119, 732, 722, 2296, 723, 741, 321, 1891, + /* 1280 */ 1890, 198, 462, 1654, 461, 777, 2464, 422, 2119, 2296, + /* 1290 */ 334, 1776, 1678, 2105, 1915, 831, 260, 2440, 1796, 258, + /* 1300 */ 643, 2296, 642, 2296, 2296, 1803, 139, 50, 1678, 836, + /* 1310 */ 1706, 199, 15, 437, 460, 1656, 2329, 2330, 86, 2367, + /* 1320 */ 611, 87, 114, 2331, 745, 2333, 2334, 740, 210, 735, + /* 1330 */ 742, 2053, 2296, 2296, 2519, 1678, 2420, 424, 423, 262, + /* 1340 */ 411, 2416, 261, 264, 1384, 612, 263, 1662, 1735, 1736, + /* 1350 */ 680, 266, 1947, 304, 265, 785, 159, 1342, 2348, 50, + /* 1360 */ 1733, 786, 1655, 297, 152, 1678, 50, 1882, 1883, 1382, + /* 1370 */ 2296, 141, 741, 2349, 629, 291, 14, 13, 2012, 1361, + /* 1380 */ 1941, 1719, 697, 1708, 1718, 1359, 2011, 187, 159, 1728, + /* 1390 */ 1734, 1737, 50, 309, 75, 2195, 157, 1343, 159, 66, + /* 1400 */ 50, 749, 1654, 157, 159, 1649, 140, 1647, 1931, 2454, + /* 1410 */ 157, 2329, 677, 401, 2367, 684, 714, 114, 2331, 745, + /* 1420 */ 2333, 2334, 740, 398, 735, 2196, 428, 1937, 731, 2395, + /* 1430 */ 1614, 2420, 829, 1835, 1754, 411, 2416, 1652, 1653, 1705, + /* 1440 */ 1834, 1707, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, + /* 1450 */ 737, 733, 1726, 1727, 1729, 1730, 1731, 1732, 2, 2116, + /* 1460 */ 172, 289, 709, 705, 660, 341, 1564, 313, 717, 2455, + /* 1470 */ 317, 2465, 1429, 1770, 333, 1457, 299, 1461, 1468, 1659, + /* 1480 */ 1466, 296, 338, 74, 162, 303, 73, 2037, 5, 431, + /* 1490 */ 436, 379, 444, 445, 1681, 455, 366, 211, 1588, 456, + /* 1500 */ 2330, 212, 214, 458, 1671, 328, 472, 235, 543, 541, + /* 1510 */ 538, 1672, 479, 742, 225, 485, 481, 487, 492, 524, + /* 1520 */ 506, 523, 513, 2188, 1663, 515, 1658, 525, 536, 537, + /* 1530 */ 534, 229, 230, 539, 232, 540, 542, 544, 1679, 4, + /* 1540 */ 559, 2348, 560, 567, 240, 568, 570, 92, 63, 1674, + /* 1550 */ 572, 243, 1680, 2296, 573, 741, 1666, 1668, 1682, 576, + /* 1560 */ 246, 574, 248, 1683, 93, 2204, 582, 94, 253, 603, + /* 1570 */ 733, 1726, 1727, 1729, 1730, 1731, 1732, 632, 360, 633, + /* 1580 */ 116, 2267, 2264, 605, 2263, 2065, 64, 645, 97, 257, + /* 1590 */ 2061, 259, 164, 165, 2329, 647, 2063, 2367, 2059, 166, + /* 1600 */ 114, 2331, 745, 2333, 2334, 740, 167, 735, 153, 329, + /* 1610 */ 276, 1675, 2393, 655, 2420, 654, 659, 656, 411, 2416, + /* 1620 */ 281, 662, 671, 681, 2470, 715, 2330, 2469, 8, 2442, + /* 1630 */ 690, 290, 293, 84, 83, 467, 402, 292, 216, 742, + /* 1640 */ 661, 286, 288, 179, 279, 672, 2250, 669, 294, 295, + /* 1650 */ 670, 459, 457, 1796, 145, 2522, 1676, 701, 1801, 1, + /* 1660 */ 2330, 2498, 363, 698, 1799, 446, 298, 2348, 443, 439, + /* 1670 */ 435, 432, 460, 742, 305, 190, 2436, 154, 330, 2296, + /* 1680 */ 713, 741, 2218, 2217, 331, 2216, 407, 718, 719, 332, + /* 1690 */ 155, 105, 206, 2076, 62, 2401, 107, 2120, 747, 335, + /* 1700 */ 1266, 2348, 833, 323, 830, 163, 835, 359, 371, 372, + /* 1710 */ 2288, 304, 344, 2296, 53, 741, 337, 2287, 2286, 81, + /* 1720 */ 2329, 358, 2281, 2367, 348, 433, 114, 2331, 745, 2333, + /* 1730 */ 2334, 740, 434, 735, 2330, 339, 1639, 1640, 728, 209, + /* 1740 */ 2420, 438, 2279, 440, 411, 2416, 441, 742, 442, 1638, + /* 1750 */ 2278, 2276, 380, 447, 2329, 2275, 449, 2367, 2274, 451, + /* 1760 */ 115, 2331, 745, 2333, 2334, 740, 2273, 735, 2330, 453, + /* 1770 */ 1627, 2254, 213, 2253, 2420, 2348, 215, 1591, 2419, 2416, + /* 1780 */ 82, 742, 1590, 2231, 2230, 2229, 466, 2296, 465, 741, + /* 1790 */ 2228, 2227, 2178, 470, 1534, 2175, 473, 2174, 2168, 476, + /* 1800 */ 477, 2330, 2165, 218, 2164, 85, 2163, 2162, 2167, 2348, + /* 1810 */ 220, 2166, 2161, 2160, 742, 2158, 2157, 2156, 222, 493, + /* 1820 */ 2155, 2296, 495, 741, 2171, 2154, 2153, 2152, 2329, 224, + /* 1830 */ 2139, 2367, 2151, 2150, 115, 2331, 745, 2333, 2334, 740, + /* 1840 */ 2173, 735, 2348, 2149, 2148, 2147, 2146, 2145, 2420, 527, + /* 1850 */ 91, 2138, 730, 2416, 2296, 2144, 741, 2143, 2142, 2141, + /* 1860 */ 2140, 2137, 743, 2136, 2172, 2367, 2170, 2135, 115, 2331, + /* 1870 */ 745, 2333, 2334, 740, 2134, 735, 1540, 2330, 2133, 2132, + /* 1880 */ 228, 2131, 2420, 529, 2130, 2129, 374, 2416, 368, 369, + /* 1890 */ 742, 1400, 1404, 1977, 1976, 2329, 1975, 1973, 2367, 231, + /* 1900 */ 233, 176, 2331, 745, 2333, 2334, 740, 2330, 735, 1970, + /* 1910 */ 1396, 1969, 234, 545, 549, 1962, 546, 547, 2348, 550, + /* 1920 */ 742, 1951, 551, 553, 1926, 555, 557, 1290, 185, 1925, + /* 1930 */ 2296, 2252, 741, 554, 78, 236, 2248, 2316, 2238, 2226, + /* 1940 */ 195, 2225, 238, 79, 245, 2202, 247, 565, 2348, 250, + /* 1950 */ 2054, 1972, 1968, 583, 584, 694, 2520, 1966, 588, 585, + /* 1960 */ 2296, 589, 741, 587, 1964, 591, 1961, 593, 1946, 592, + /* 1970 */ 595, 2329, 597, 596, 2367, 1335, 1944, 115, 2331, 745, + /* 1980 */ 2333, 2334, 740, 1945, 735, 2330, 1943, 1922, 2056, 1472, + /* 1990 */ 1473, 2420, 2055, 1386, 802, 1385, 2417, 1383, 742, 1381, + /* 2000 */ 1380, 2329, 2330, 804, 2367, 1959, 1379, 175, 2331, 745, + /* 2010 */ 2333, 2334, 740, 1372, 735, 742, 1378, 256, 1377, 2330, + /* 2020 */ 392, 1374, 65, 1950, 393, 627, 2348, 1373, 1948, 394, + /* 2030 */ 1371, 399, 742, 630, 1921, 1920, 1919, 634, 2296, 1918, + /* 2040 */ 741, 636, 1917, 2348, 638, 117, 1621, 1623, 400, 1620, + /* 2050 */ 2462, 1625, 29, 2251, 69, 2296, 1601, 741, 2247, 1599, + /* 2060 */ 2348, 1597, 278, 2237, 169, 657, 2224, 2223, 2504, 6, + /* 2070 */ 17, 20, 2296, 21, 741, 23, 7, 31, 673, 2329, + /* 2080 */ 1852, 285, 2367, 22, 2330, 357, 2331, 745, 2333, 2334, + /* 2090 */ 740, 57, 735, 58, 189, 177, 2329, 742, 200, 2367, + /* 2100 */ 2317, 287, 357, 2331, 745, 2333, 2334, 740, 675, 735, + /* 2110 */ 1833, 658, 33, 2329, 2330, 1822, 2367, 282, 1872, 350, + /* 2120 */ 2331, 745, 2333, 2334, 740, 2348, 735, 742, 1576, 663, + /* 2130 */ 67, 24, 1867, 1575, 1873, 188, 32, 2296, 80, 741, + /* 2140 */ 1866, 665, 403, 1871, 1870, 18, 404, 60, 1793, 301, + /* 2150 */ 180, 1792, 2222, 2201, 101, 2348, 2200, 102, 25, 103, + /* 2160 */ 406, 308, 1828, 191, 26, 689, 314, 2296, 716, 741, + /* 2170 */ 70, 108, 319, 1745, 104, 1744, 316, 59, 2329, 2330, + /* 2180 */ 13, 2367, 1664, 2370, 176, 2331, 745, 2333, 2334, 740, + /* 2190 */ 1755, 735, 739, 1723, 11, 734, 181, 1721, 39, 2330, + /* 2200 */ 1720, 1690, 16, 192, 1698, 27, 748, 746, 2329, 1458, + /* 2210 */ 28, 2367, 742, 417, 357, 2331, 745, 2333, 2334, 740, + /* 2220 */ 2348, 735, 2330, 1455, 750, 752, 753, 755, 1454, 1451, + /* 2230 */ 756, 744, 2296, 758, 741, 742, 759, 2330, 761, 2521, + /* 2240 */ 2348, 1445, 762, 764, 1443, 414, 1449, 765, 109, 322, + /* 2250 */ 742, 110, 2296, 1448, 741, 1447, 2330, 1467, 1463, 1446, + /* 2260 */ 1333, 77, 779, 2348, 1368, 1365, 1364, 1363, 416, 742, + /* 2270 */ 1394, 1362, 1360, 2329, 1358, 2296, 2367, 741, 2348, 356, + /* 2280 */ 2331, 745, 2333, 2334, 740, 1357, 735, 1356, 2386, 1393, + /* 2290 */ 2296, 790, 741, 2329, 792, 207, 2367, 2348, 1354, 357, + /* 2300 */ 2331, 745, 2333, 2334, 740, 1353, 735, 1352, 1351, 2296, + /* 2310 */ 1350, 741, 1349, 1967, 1348, 1390, 2329, 1388, 1345, 2367, + /* 2320 */ 1344, 1341, 357, 2331, 745, 2333, 2334, 740, 1339, 735, + /* 2330 */ 2330, 644, 1340, 1338, 2367, 812, 813, 352, 2331, 745, + /* 2340 */ 2333, 2334, 740, 742, 735, 814, 1965, 816, 817, 2330, + /* 2350 */ 2329, 818, 1963, 2367, 820, 821, 342, 2331, 745, 2333, + /* 2360 */ 2334, 740, 742, 735, 822, 2330, 1960, 824, 826, 825, + /* 2370 */ 1942, 2348, 828, 1279, 1916, 1267, 832, 326, 742, 834, + /* 2380 */ 1886, 1650, 336, 2296, 837, 741, 1886, 838, 1886, 1886, + /* 2390 */ 2348, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2400 */ 1886, 1886, 2296, 1886, 741, 1886, 2348, 1886, 1886, 1886, + /* 2410 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 2296, 1886, + /* 2420 */ 741, 1886, 1886, 2330, 2329, 1886, 1886, 2367, 1886, 1886, + /* 2430 */ 340, 2331, 745, 2333, 2334, 740, 742, 735, 1886, 1886, + /* 2440 */ 1886, 1886, 1886, 2329, 1886, 1886, 2367, 2330, 1886, 343, + /* 2450 */ 2331, 745, 2333, 2334, 740, 1886, 735, 1886, 1886, 2329, + /* 2460 */ 742, 1886, 2367, 1886, 2348, 349, 2331, 745, 2333, 2334, + /* 2470 */ 740, 1886, 735, 1886, 1886, 1886, 2296, 1886, 741, 1886, + /* 2480 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 2348, 1886, + /* 2490 */ 2330, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2500 */ 2296, 1886, 741, 742, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2510 */ 1886, 1886, 1886, 1886, 1886, 1886, 2330, 2329, 1886, 1886, + /* 2520 */ 2367, 1886, 1886, 353, 2331, 745, 2333, 2334, 740, 742, + /* 2530 */ 735, 2348, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2540 */ 1886, 2329, 1886, 2296, 2367, 741, 1886, 345, 2331, 745, + /* 2550 */ 2333, 2334, 740, 1886, 735, 1886, 1886, 2348, 1886, 2330, + /* 2560 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 2296, + /* 2570 */ 1886, 741, 742, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2580 */ 1886, 1886, 1886, 2330, 2329, 1886, 1886, 2367, 1886, 1886, + /* 2590 */ 354, 2331, 745, 2333, 2334, 740, 742, 735, 1886, 1886, + /* 2600 */ 2348, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2610 */ 2329, 1886, 2296, 2367, 741, 1886, 346, 2331, 745, 2333, + /* 2620 */ 2334, 740, 1886, 735, 2348, 1886, 2330, 1886, 1886, 1886, + /* 2630 */ 1886, 1886, 1886, 1886, 1886, 1886, 2296, 1886, 741, 742, + /* 2640 */ 1886, 2330, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2650 */ 1886, 1886, 1886, 2329, 742, 1886, 2367, 2330, 1886, 355, + /* 2660 */ 2331, 745, 2333, 2334, 740, 1886, 735, 2348, 1886, 1886, + /* 2670 */ 742, 1886, 1886, 1886, 1886, 1886, 1886, 2329, 1886, 2296, + /* 2680 */ 2367, 741, 2348, 347, 2331, 745, 2333, 2334, 740, 1886, + /* 2690 */ 735, 1886, 1886, 1886, 2296, 1886, 741, 1886, 2348, 1886, + /* 2700 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2710 */ 2296, 1886, 741, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2720 */ 2329, 1886, 1886, 2367, 1886, 1886, 361, 2331, 745, 2333, + /* 2730 */ 2334, 740, 1886, 735, 2330, 2329, 1886, 1886, 2367, 1886, + /* 2740 */ 1886, 362, 2331, 745, 2333, 2334, 740, 742, 735, 1886, + /* 2750 */ 1886, 2329, 1886, 2330, 2367, 1886, 1886, 2342, 2331, 745, + /* 2760 */ 2333, 2334, 740, 1886, 735, 1886, 742, 1886, 1886, 2330, + /* 2770 */ 1886, 1886, 1886, 1886, 1886, 2348, 1886, 1886, 1886, 1886, + /* 2780 */ 1886, 1886, 742, 1886, 1886, 1886, 1886, 2296, 1886, 741, + /* 2790 */ 1886, 1886, 1886, 1886, 2348, 1886, 1886, 1886, 1886, 1886, + /* 2800 */ 1886, 1886, 1886, 1886, 1886, 1886, 2296, 1886, 741, 1886, + /* 2810 */ 2348, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2820 */ 1886, 1886, 2296, 1886, 741, 1886, 1886, 2330, 2329, 1886, + /* 2830 */ 1886, 2367, 1886, 1886, 2341, 2331, 745, 2333, 2334, 740, + /* 2840 */ 742, 735, 1886, 1886, 1886, 1886, 1886, 2329, 1886, 1886, + /* 2850 */ 2367, 2330, 1886, 2340, 2331, 745, 2333, 2334, 740, 1886, + /* 2860 */ 735, 1886, 1886, 2329, 742, 1886, 2367, 1886, 2348, 376, + /* 2870 */ 2331, 745, 2333, 2334, 740, 1886, 735, 1886, 1886, 1886, + /* 2880 */ 2296, 1886, 741, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2890 */ 1886, 1886, 2348, 1886, 2330, 1886, 1886, 1886, 1886, 1886, + /* 2900 */ 1886, 1886, 1886, 1886, 2296, 1886, 741, 742, 1886, 1886, + /* 2910 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2920 */ 2330, 2329, 1886, 1886, 2367, 1886, 1886, 377, 2331, 745, + /* 2930 */ 2333, 2334, 740, 742, 735, 2348, 1886, 1886, 1886, 1886, + /* 2940 */ 1886, 1886, 1886, 1886, 1886, 2329, 1886, 2296, 2367, 741, + /* 2950 */ 1886, 373, 2331, 745, 2333, 2334, 740, 1886, 735, 1886, + /* 2960 */ 1886, 2348, 1886, 2330, 1886, 1886, 1886, 1886, 1886, 1886, + /* 2970 */ 1886, 1886, 1886, 2296, 1886, 741, 742, 1886, 1886, 1886, + /* 2980 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 2329, 1886, + /* 2990 */ 1886, 2367, 1886, 1886, 378, 2331, 745, 2333, 2334, 740, + /* 3000 */ 1886, 735, 1886, 1886, 2348, 1886, 1886, 1886, 1886, 1886, + /* 3010 */ 1886, 1886, 1886, 1886, 743, 1886, 2296, 2367, 741, 1886, + /* 3020 */ 352, 2331, 745, 2333, 2334, 740, 1886, 735, 1886, 1886, + /* 3030 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 3040 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, 1886, + /* 3050 */ 1886, 1886, 1886, 1886, 1886, 1886, 1886, 2329, 1886, 1886, + /* 3060 */ 2367, 1886, 1886, 351, 2331, 745, 2333, 2334, 740, 1886, + /* 3070 */ 735, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 371, 382, 425, 382, 425, 361, 362, 430, 379, 390, - /* 10 */ 379, 390, 12, 13, 14, 12, 13, 398, 397, 398, - /* 20 */ 20, 20, 22, 8, 9, 381, 405, 12, 13, 14, - /* 30 */ 15, 16, 388, 361, 362, 35, 0, 37, 8, 9, - /* 40 */ 37, 33, 12, 13, 14, 15, 16, 349, 20, 361, - /* 50 */ 362, 390, 475, 361, 475, 478, 362, 478, 397, 377, - /* 60 */ 362, 390, 380, 33, 64, 0, 405, 20, 356, 381, - /* 70 */ 70, 359, 360, 496, 497, 496, 497, 77, 501, 502, - /* 80 */ 501, 502, 410, 412, 390, 414, 21, 20, 390, 24, - /* 90 */ 25, 26, 27, 28, 29, 30, 31, 32, 406, 407, - /* 100 */ 402, 409, 404, 103, 13, 413, 106, 20, 72, 73, - /* 110 */ 74, 75, 76, 20, 78, 79, 80, 81, 82, 83, + /* 0 */ 383, 357, 432, 383, 360, 361, 357, 392, 391, 360, + /* 10 */ 361, 391, 12, 13, 14, 405, 399, 2, 398, 399, + /* 20 */ 20, 362, 22, 8, 9, 20, 406, 12, 13, 14, + /* 30 */ 15, 16, 2, 423, 424, 35, 0, 37, 8, 9, + /* 40 */ 465, 466, 12, 13, 14, 15, 16, 350, 8, 9, + /* 50 */ 362, 363, 12, 13, 14, 15, 16, 362, 363, 20, + /* 60 */ 363, 391, 404, 405, 64, 0, 407, 408, 401, 410, + /* 70 */ 70, 404, 405, 414, 8, 9, 372, 77, 12, 13, + /* 80 */ 14, 15, 16, 413, 380, 415, 21, 371, 391, 24, + /* 90 */ 25, 26, 27, 28, 29, 30, 31, 32, 20, 411, + /* 100 */ 403, 358, 405, 103, 388, 362, 106, 364, 72, 73, + /* 110 */ 74, 75, 76, 397, 78, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 475, 107, 361, 478, - /* 140 */ 14, 443, 142, 143, 446, 451, 20, 449, 450, 451, - /* 150 */ 452, 453, 454, 106, 456, 448, 404, 496, 497, 461, - /* 160 */ 404, 463, 501, 502, 475, 467, 468, 478, 77, 361, - /* 170 */ 362, 419, 361, 362, 422, 423, 176, 177, 422, 423, - /* 180 */ 482, 474, 20, 183, 184, 496, 497, 37, 490, 381, - /* 190 */ 501, 502, 103, 20, 417, 418, 388, 346, 198, 106, - /* 200 */ 200, 182, 378, 200, 49, 190, 117, 118, 119, 120, - /* 210 */ 121, 122, 123, 124, 125, 126, 392, 128, 129, 130, - /* 220 */ 131, 132, 133, 134, 361, 362, 402, 77, 39, 40, - /* 230 */ 230, 231, 232, 232, 234, 235, 236, 237, 238, 239, + /* 130 */ 94, 95, 96, 97, 98, 99, 476, 362, 363, 479, + /* 140 */ 22, 444, 142, 143, 447, 363, 391, 450, 451, 452, + /* 150 */ 453, 454, 455, 460, 457, 37, 463, 497, 498, 462, + /* 160 */ 69, 464, 502, 503, 4, 468, 469, 472, 473, 474, + /* 170 */ 415, 476, 477, 391, 479, 362, 363, 177, 178, 449, + /* 180 */ 483, 142, 143, 23, 184, 185, 411, 20, 491, 391, + /* 190 */ 20, 20, 497, 498, 405, 77, 398, 502, 503, 199, + /* 200 */ 349, 201, 351, 3, 406, 475, 46, 47, 48, 420, + /* 210 */ 8, 9, 423, 424, 12, 13, 14, 15, 16, 21, + /* 220 */ 20, 103, 24, 25, 26, 27, 28, 29, 30, 31, + /* 230 */ 32, 231, 232, 233, 452, 235, 236, 237, 238, 239, /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 250, 251, 12, 13, 361, 362, 69, 18, 106, 20, - /* 260 */ 20, 106, 22, 176, 177, 349, 27, 390, 106, 30, - /* 270 */ 446, 447, 370, 410, 35, 35, 425, 37, 362, 370, - /* 280 */ 456, 430, 471, 472, 473, 4, 475, 476, 20, 478, - /* 290 */ 51, 414, 53, 274, 275, 276, 387, 58, 396, 110, - /* 300 */ 111, 293, 113, 410, 64, 396, 390, 496, 497, 294, - /* 310 */ 70, 20, 501, 502, 72, 73, 74, 77, 402, 448, - /* 320 */ 404, 79, 80, 81, 135, 22, 475, 85, 139, 478, - /* 330 */ 361, 362, 90, 91, 92, 93, 14, 20, 96, 21, - /* 340 */ 37, 99, 20, 103, 105, 474, 106, 496, 497, 197, - /* 350 */ 381, 199, 501, 502, 36, 116, 38, 39, 40, 443, - /* 360 */ 356, 268, 446, 359, 360, 449, 450, 451, 452, 453, - /* 370 */ 454, 455, 456, 457, 458, 12, 13, 14, 15, 16, - /* 380 */ 77, 229, 142, 143, 106, 146, 147, 106, 149, 150, - /* 390 */ 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, - /* 400 */ 161, 162, 163, 164, 165, 232, 167, 168, 169, 18, - /* 410 */ 464, 465, 173, 174, 23, 2, 176, 177, 179, 64, - /* 420 */ 268, 8, 9, 183, 184, 12, 13, 14, 15, 16, - /* 430 */ 268, 40, 41, 142, 143, 44, 361, 69, 198, 400, - /* 440 */ 200, 0, 403, 404, 86, 54, 178, 8, 9, 106, - /* 450 */ 33, 12, 13, 14, 15, 16, 65, 66, 67, 68, - /* 460 */ 105, 8, 9, 108, 349, 12, 13, 14, 15, 16, - /* 470 */ 230, 231, 232, 20, 234, 235, 236, 237, 238, 239, - /* 480 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 490 */ 250, 251, 252, 12, 13, 33, 51, 106, 176, 361, - /* 500 */ 362, 20, 386, 22, 59, 1, 148, 62, 63, 70, - /* 510 */ 435, 436, 20, 72, 73, 74, 35, 402, 37, 381, - /* 520 */ 79, 80, 81, 19, 361, 362, 85, 172, 170, 171, - /* 530 */ 14, 90, 91, 92, 93, 144, 20, 96, 357, 35, - /* 540 */ 99, 64, 361, 230, 363, 64, 268, 20, 349, 268, - /* 550 */ 389, 70, 50, 114, 232, 51, 440, 175, 77, 361, - /* 560 */ 362, 362, 401, 59, 60, 61, 62, 21, 64, 107, - /* 570 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 381, - /* 580 */ 42, 190, 191, 192, 103, 108, 195, 106, 252, 390, - /* 590 */ 254, 22, 279, 280, 281, 282, 283, 284, 285, 208, - /* 600 */ 209, 402, 116, 404, 368, 3, 37, 361, 362, 105, - /* 610 */ 219, 268, 108, 222, 175, 20, 225, 226, 227, 228, - /* 620 */ 229, 385, 20, 142, 143, 0, 20, 381, 22, 393, - /* 630 */ 348, 178, 350, 470, 471, 472, 473, 255, 475, 476, - /* 640 */ 361, 362, 443, 37, 140, 446, 77, 265, 449, 450, - /* 650 */ 451, 452, 453, 454, 349, 456, 390, 176, 177, 268, - /* 660 */ 461, 55, 463, 2, 183, 184, 467, 468, 368, 8, - /* 670 */ 9, 405, 103, 12, 13, 14, 15, 16, 0, 198, - /* 680 */ 178, 200, 361, 362, 180, 232, 361, 362, 186, 490, - /* 690 */ 13, 187, 176, 393, 255, 256, 257, 258, 259, 260, - /* 700 */ 261, 262, 263, 264, 265, 178, 381, 402, 291, 107, - /* 710 */ 206, 230, 231, 232, 37, 234, 235, 236, 237, 238, - /* 720 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 730 */ 249, 250, 251, 12, 13, 14, 349, 142, 143, 14, - /* 740 */ 357, 20, 349, 22, 361, 20, 363, 69, 232, 362, - /* 750 */ 471, 472, 473, 135, 475, 476, 35, 139, 37, 232, - /* 760 */ 135, 136, 137, 138, 139, 140, 141, 198, 349, 200, - /* 770 */ 135, 136, 137, 138, 139, 140, 141, 390, 183, 184, - /* 780 */ 178, 362, 349, 364, 70, 64, 0, 361, 362, 402, - /* 790 */ 20, 404, 471, 472, 473, 402, 475, 476, 77, 230, - /* 800 */ 231, 403, 404, 349, 361, 267, 349, 381, 448, 390, - /* 810 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 362, - /* 820 */ 20, 402, 172, 404, 103, 361, 362, 106, 20, 4, - /* 830 */ 443, 361, 362, 446, 474, 402, 449, 450, 451, 452, - /* 840 */ 453, 454, 349, 456, 19, 381, 459, 390, 461, 462, - /* 850 */ 463, 381, 202, 137, 467, 468, 402, 141, 382, 402, - /* 860 */ 35, 404, 443, 142, 143, 446, 390, 0, 449, 450, - /* 870 */ 451, 452, 453, 454, 398, 456, 51, 0, 435, 436, - /* 880 */ 461, 390, 463, 58, 390, 252, 467, 468, 397, 64, - /* 890 */ 77, 397, 361, 362, 349, 402, 405, 176, 177, 405, - /* 900 */ 443, 366, 367, 446, 183, 184, 449, 450, 451, 452, - /* 910 */ 453, 454, 381, 456, 378, 460, 35, 462, 461, 198, - /* 920 */ 463, 200, 349, 207, 467, 468, 210, 349, 392, 213, - /* 930 */ 105, 215, 51, 108, 390, 4, 375, 376, 402, 116, - /* 940 */ 59, 60, 61, 62, 230, 64, 349, 402, 178, 405, - /* 950 */ 425, 230, 231, 232, 23, 234, 235, 236, 237, 238, - /* 960 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 970 */ 249, 250, 251, 12, 13, 402, 176, 46, 47, 48, - /* 980 */ 402, 20, 446, 22, 361, 362, 105, 361, 362, 108, - /* 990 */ 390, 3, 456, 34, 390, 349, 35, 397, 37, 402, - /* 1000 */ 475, 397, 232, 478, 381, 405, 23, 381, 362, 405, - /* 1010 */ 364, 391, 135, 136, 137, 138, 139, 140, 141, 361, - /* 1020 */ 362, 496, 497, 361, 362, 64, 501, 502, 161, 349, - /* 1030 */ 47, 48, 232, 382, 361, 362, 390, 170, 77, 381, - /* 1040 */ 232, 390, 362, 381, 364, 361, 362, 391, 402, 398, - /* 1050 */ 404, 8, 9, 172, 381, 12, 13, 14, 15, 16, - /* 1060 */ 4, 180, 181, 193, 103, 381, 0, 106, 187, 188, - /* 1070 */ 390, 8, 9, 361, 362, 12, 13, 14, 15, 16, - /* 1080 */ 56, 57, 402, 0, 404, 361, 362, 206, 37, 443, - /* 1090 */ 220, 221, 446, 381, 391, 449, 450, 451, 452, 453, - /* 1100 */ 454, 425, 456, 142, 143, 381, 0, 461, 42, 463, - /* 1110 */ 425, 8, 9, 467, 468, 12, 13, 14, 15, 16, - /* 1120 */ 20, 349, 22, 443, 375, 376, 446, 349, 77, 449, - /* 1130 */ 450, 451, 452, 453, 454, 52, 456, 176, 177, 366, - /* 1140 */ 367, 461, 136, 463, 183, 184, 391, 467, 468, 475, - /* 1150 */ 107, 475, 478, 459, 478, 55, 462, 136, 137, 198, - /* 1160 */ 475, 200, 141, 478, 460, 378, 462, 349, 22, 425, - /* 1170 */ 107, 497, 496, 497, 402, 501, 502, 501, 502, 392, - /* 1180 */ 402, 496, 497, 37, 1, 2, 501, 502, 214, 402, - /* 1190 */ 216, 230, 231, 232, 349, 234, 235, 236, 237, 238, - /* 1200 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1210 */ 249, 250, 251, 12, 13, 349, 431, 211, 212, 475, - /* 1220 */ 402, 20, 478, 22, 22, 14, 15, 16, 362, 349, - /* 1230 */ 364, 475, 399, 446, 478, 402, 35, 390, 37, 37, - /* 1240 */ 496, 497, 349, 456, 349, 501, 502, 402, 349, 103, - /* 1250 */ 37, 390, 405, 497, 391, 349, 390, 501, 502, 398, - /* 1260 */ 349, 362, 37, 364, 399, 64, 383, 402, 402, 386, - /* 1270 */ 404, 399, 352, 353, 402, 266, 267, 289, 77, 8, - /* 1280 */ 9, 178, 402, 12, 13, 14, 15, 16, 0, 390, - /* 1290 */ 107, 0, 0, 391, 33, 402, 116, 402, 33, 109, - /* 1300 */ 33, 402, 112, 404, 103, 103, 45, 106, 402, 443, - /* 1310 */ 45, 415, 446, 402, 22, 449, 450, 451, 452, 453, - /* 1320 */ 454, 391, 456, 13, 33, 109, 270, 461, 112, 463, - /* 1330 */ 224, 12, 13, 467, 468, 109, 0, 109, 112, 51, - /* 1340 */ 112, 22, 443, 142, 143, 446, 166, 37, 449, 450, - /* 1350 */ 451, 452, 453, 454, 35, 456, 37, 0, 22, 505, - /* 1360 */ 461, 350, 463, 142, 143, 494, 467, 468, 1, 2, - /* 1370 */ 365, 487, 390, 378, 107, 349, 13, 176, 177, 22, - /* 1380 */ 33, 33, 33, 64, 183, 184, 33, 33, 362, 33, - /* 1390 */ 364, 33, 33, 106, 33, 13, 77, 33, 378, 198, - /* 1400 */ 37, 200, 115, 493, 415, 360, 415, 493, 493, 424, - /* 1410 */ 493, 33, 33, 200, 33, 365, 390, 33, 33, 37, - /* 1420 */ 362, 33, 103, 33, 33, 200, 401, 415, 402, 432, - /* 1430 */ 404, 230, 231, 232, 415, 234, 235, 236, 237, 238, - /* 1440 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1450 */ 249, 250, 251, 415, 107, 107, 107, 477, 498, 469, - /* 1460 */ 107, 107, 380, 107, 480, 107, 107, 271, 107, 443, - /* 1470 */ 426, 107, 446, 51, 445, 449, 450, 451, 452, 453, - /* 1480 */ 454, 42, 456, 349, 444, 107, 107, 461, 107, 463, - /* 1490 */ 20, 107, 107, 467, 468, 107, 362, 107, 107, 437, - /* 1500 */ 370, 442, 213, 370, 437, 196, 428, 20, 361, 20, - /* 1510 */ 362, 45, 411, 362, 175, 411, 408, 198, 361, 200, - /* 1520 */ 362, 361, 411, 408, 390, 408, 374, 104, 102, 373, - /* 1530 */ 361, 101, 361, 372, 361, 361, 402, 20, 404, 354, - /* 1540 */ 50, 349, 358, 354, 358, 370, 437, 370, 20, 230, - /* 1550 */ 231, 370, 20, 404, 362, 20, 363, 370, 427, 20, - /* 1560 */ 363, 370, 418, 244, 245, 246, 247, 248, 249, 250, - /* 1570 */ 370, 361, 354, 370, 370, 106, 441, 443, 349, 352, - /* 1580 */ 446, 402, 390, 449, 450, 451, 452, 453, 454, 390, - /* 1590 */ 456, 362, 361, 352, 402, 461, 404, 463, 390, 390, - /* 1600 */ 354, 467, 468, 217, 390, 390, 439, 390, 402, 390, - /* 1610 */ 390, 349, 390, 390, 390, 437, 368, 20, 436, 390, - /* 1620 */ 204, 203, 434, 368, 362, 361, 486, 433, 278, 277, - /* 1630 */ 286, 402, 402, 404, 489, 443, 404, 189, 446, 402, - /* 1640 */ 486, 449, 450, 451, 452, 453, 454, 488, 456, 486, - /* 1650 */ 288, 485, 390, 461, 349, 463, 420, 287, 420, 467, - /* 1660 */ 468, 426, 500, 295, 402, 272, 404, 362, 426, 292, - /* 1670 */ 506, 499, 443, 290, 267, 446, 362, 20, 449, 450, - /* 1680 */ 451, 452, 453, 454, 116, 456, 363, 448, 269, 484, - /* 1690 */ 483, 349, 463, 481, 368, 390, 467, 468, 368, 420, - /* 1700 */ 402, 402, 402, 402, 362, 443, 420, 402, 446, 404, - /* 1710 */ 402, 449, 450, 451, 452, 453, 454, 181, 456, 479, - /* 1720 */ 416, 386, 106, 368, 466, 463, 106, 362, 368, 467, - /* 1730 */ 468, 394, 390, 402, 361, 22, 38, 368, 351, 421, - /* 1740 */ 429, 438, 421, 354, 402, 347, 404, 355, 443, 349, - /* 1750 */ 384, 446, 0, 0, 449, 450, 451, 452, 453, 454, - /* 1760 */ 384, 456, 362, 369, 384, 0, 349, 45, 463, 0, - /* 1770 */ 37, 223, 467, 468, 37, 37, 37, 223, 0, 362, - /* 1780 */ 37, 37, 223, 37, 0, 443, 223, 349, 446, 0, - /* 1790 */ 390, 449, 450, 451, 452, 453, 454, 37, 456, 0, - /* 1800 */ 362, 22, 402, 37, 404, 0, 218, 390, 0, 206, - /* 1810 */ 0, 206, 200, 207, 0, 198, 0, 0, 194, 402, - /* 1820 */ 193, 404, 0, 0, 147, 49, 49, 0, 390, 37, - /* 1830 */ 0, 51, 49, 491, 492, 0, 45, 0, 0, 0, - /* 1840 */ 402, 0, 404, 443, 49, 0, 446, 0, 0, 449, - /* 1850 */ 450, 451, 452, 453, 454, 0, 456, 0, 161, 0, - /* 1860 */ 443, 37, 161, 446, 0, 0, 449, 450, 451, 452, - /* 1870 */ 453, 454, 0, 456, 0, 0, 0, 0, 0, 0, - /* 1880 */ 463, 443, 0, 0, 446, 468, 349, 449, 450, 451, - /* 1890 */ 452, 453, 454, 0, 456, 0, 0, 0, 0, 362, - /* 1900 */ 0, 49, 0, 503, 504, 45, 0, 0, 0, 0, - /* 1910 */ 0, 0, 0, 349, 22, 0, 0, 147, 146, 0, - /* 1920 */ 145, 0, 0, 22, 0, 22, 362, 390, 37, 0, - /* 1930 */ 492, 50, 395, 64, 50, 64, 0, 64, 0, 402, - /* 1940 */ 0, 404, 37, 0, 349, 51, 42, 0, 0, 0, - /* 1950 */ 37, 14, 0, 0, 390, 0, 33, 362, 0, 395, - /* 1960 */ 42, 0, 37, 37, 0, 51, 402, 0, 404, 42, - /* 1970 */ 189, 51, 42, 45, 43, 0, 42, 0, 0, 37, - /* 1980 */ 443, 349, 49, 446, 49, 390, 449, 450, 451, 452, - /* 1990 */ 453, 454, 42, 456, 362, 49, 51, 402, 42, 404, - /* 2000 */ 49, 0, 37, 71, 42, 51, 0, 443, 37, 0, - /* 2010 */ 446, 51, 42, 449, 450, 451, 452, 453, 454, 37, - /* 2020 */ 456, 42, 390, 51, 0, 0, 0, 0, 0, 0, - /* 2030 */ 37, 114, 22, 0, 402, 0, 404, 37, 443, 37, - /* 2040 */ 37, 446, 37, 0, 449, 450, 451, 452, 453, 454, - /* 2050 */ 37, 456, 37, 112, 349, 37, 37, 37, 37, 22, - /* 2060 */ 37, 22, 22, 33, 33, 53, 0, 362, 22, 37, - /* 2070 */ 0, 0, 0, 37, 0, 443, 0, 22, 446, 349, - /* 2080 */ 20, 449, 450, 451, 452, 453, 454, 37, 456, 37, - /* 2090 */ 495, 37, 362, 37, 107, 390, 106, 0, 106, 0, - /* 2100 */ 395, 37, 49, 22, 205, 0, 22, 402, 0, 404, - /* 2110 */ 3, 33, 50, 273, 106, 104, 33, 178, 0, 50, - /* 2120 */ 390, 33, 349, 107, 107, 33, 49, 33, 106, 49, - /* 2130 */ 3, 273, 402, 33, 404, 362, 504, 349, 181, 273, - /* 2140 */ 102, 178, 49, 37, 178, 201, 178, 178, 443, 107, - /* 2150 */ 362, 446, 349, 106, 449, 450, 451, 452, 453, 454, - /* 2160 */ 37, 456, 37, 390, 106, 362, 107, 106, 395, 185, - /* 2170 */ 185, 106, 37, 443, 107, 402, 446, 404, 390, 449, - /* 2180 */ 450, 451, 452, 453, 454, 37, 456, 37, 458, 107, - /* 2190 */ 402, 33, 404, 390, 107, 49, 107, 0, 395, 0, - /* 2200 */ 0, 106, 42, 107, 106, 402, 42, 404, 107, 106, - /* 2210 */ 106, 49, 33, 2, 180, 106, 443, 349, 106, 446, - /* 2220 */ 104, 104, 449, 450, 451, 452, 453, 454, 115, 456, - /* 2230 */ 362, 443, 22, 182, 446, 349, 253, 449, 450, 451, - /* 2240 */ 452, 453, 454, 106, 456, 107, 443, 106, 362, 446, - /* 2250 */ 107, 106, 449, 450, 451, 452, 453, 454, 390, 456, - /* 2260 */ 266, 107, 49, 106, 49, 106, 22, 116, 107, 106, - /* 2270 */ 402, 230, 404, 107, 37, 37, 390, 233, 106, 37, - /* 2280 */ 107, 106, 37, 107, 106, 37, 37, 107, 402, 106, - /* 2290 */ 404, 107, 106, 37, 107, 106, 127, 127, 127, 106, - /* 2300 */ 33, 127, 106, 37, 106, 22, 37, 71, 37, 70, - /* 2310 */ 77, 443, 37, 37, 446, 37, 37, 449, 450, 451, - /* 2320 */ 452, 453, 454, 37, 456, 37, 37, 100, 77, 443, - /* 2330 */ 349, 100, 446, 33, 37, 449, 450, 451, 452, 453, - /* 2340 */ 454, 37, 456, 362, 37, 22, 37, 349, 37, 37, - /* 2350 */ 37, 77, 37, 37, 37, 37, 22, 37, 0, 37, - /* 2360 */ 362, 51, 0, 349, 37, 51, 42, 42, 0, 37, - /* 2370 */ 51, 390, 0, 42, 37, 42, 362, 51, 0, 37, - /* 2380 */ 37, 0, 22, 402, 33, 404, 22, 21, 390, 22, - /* 2390 */ 20, 22, 21, 507, 507, 507, 507, 507, 507, 507, - /* 2400 */ 402, 507, 404, 507, 390, 507, 507, 507, 507, 507, - /* 2410 */ 507, 507, 507, 507, 507, 507, 402, 507, 404, 507, - /* 2420 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 507, - /* 2430 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, - /* 2440 */ 349, 443, 507, 507, 446, 507, 507, 449, 450, 451, - /* 2450 */ 452, 453, 454, 362, 456, 507, 507, 443, 507, 349, - /* 2460 */ 446, 507, 507, 449, 450, 451, 452, 453, 454, 507, - /* 2470 */ 456, 507, 362, 507, 507, 507, 507, 507, 507, 507, - /* 2480 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2490 */ 507, 507, 507, 402, 507, 404, 507, 507, 507, 507, - /* 2500 */ 390, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2510 */ 507, 507, 402, 507, 404, 507, 507, 507, 507, 507, - /* 2520 */ 507, 507, 507, 507, 507, 507, 349, 507, 507, 507, - /* 2530 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 362, - /* 2540 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, - /* 2550 */ 507, 507, 507, 443, 507, 349, 446, 507, 507, 449, - /* 2560 */ 450, 451, 452, 453, 454, 507, 456, 390, 362, 507, - /* 2570 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 402, - /* 2580 */ 507, 404, 507, 507, 349, 507, 507, 507, 507, 507, - /* 2590 */ 507, 507, 507, 507, 507, 507, 390, 362, 507, 507, - /* 2600 */ 507, 507, 507, 507, 507, 507, 507, 507, 402, 507, - /* 2610 */ 404, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2620 */ 443, 507, 349, 446, 507, 390, 449, 450, 451, 452, - /* 2630 */ 453, 454, 507, 456, 507, 362, 507, 402, 507, 404, - /* 2640 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 443, - /* 2650 */ 507, 507, 446, 507, 507, 449, 450, 451, 452, 453, - /* 2660 */ 454, 507, 456, 390, 507, 507, 507, 507, 507, 507, - /* 2670 */ 507, 507, 507, 507, 507, 402, 507, 404, 443, 349, - /* 2680 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, - /* 2690 */ 507, 456, 362, 507, 507, 507, 507, 349, 507, 507, - /* 2700 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2710 */ 362, 507, 507, 507, 507, 507, 443, 507, 507, 446, - /* 2720 */ 390, 507, 449, 450, 451, 452, 453, 454, 507, 456, - /* 2730 */ 507, 507, 402, 507, 404, 507, 507, 507, 390, 507, - /* 2740 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2750 */ 402, 507, 404, 507, 349, 507, 507, 507, 507, 507, - /* 2760 */ 507, 507, 507, 507, 507, 507, 507, 362, 507, 507, - /* 2770 */ 507, 507, 507, 443, 349, 507, 446, 507, 507, 449, - /* 2780 */ 450, 451, 452, 453, 454, 507, 456, 362, 507, 507, - /* 2790 */ 349, 443, 507, 507, 446, 390, 507, 449, 450, 451, - /* 2800 */ 452, 453, 454, 362, 456, 507, 507, 402, 507, 404, - /* 2810 */ 507, 507, 507, 507, 507, 390, 507, 507, 507, 507, - /* 2820 */ 507, 507, 507, 507, 507, 507, 507, 402, 507, 404, - /* 2830 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2840 */ 507, 507, 507, 402, 507, 404, 507, 507, 443, 507, - /* 2850 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, - /* 2860 */ 507, 456, 507, 507, 507, 507, 507, 507, 443, 507, - /* 2870 */ 507, 446, 507, 507, 449, 450, 451, 452, 453, 454, - /* 2880 */ 507, 456, 507, 507, 443, 507, 507, 446, 507, 349, - /* 2890 */ 449, 450, 451, 452, 453, 454, 507, 456, 507, 507, - /* 2900 */ 507, 507, 362, 507, 507, 349, 507, 507, 507, 507, - /* 2910 */ 507, 507, 507, 507, 507, 507, 507, 507, 362, 507, - /* 2920 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2930 */ 390, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2940 */ 507, 507, 402, 507, 404, 507, 390, 507, 507, 507, - /* 2950 */ 507, 507, 507, 507, 507, 507, 507, 507, 402, 507, - /* 2960 */ 404, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 2970 */ 507, 507, 349, 507, 507, 507, 507, 507, 507, 507, - /* 2980 */ 507, 507, 507, 443, 507, 362, 446, 349, 507, 449, - /* 2990 */ 450, 451, 452, 453, 454, 507, 456, 507, 507, 443, - /* 3000 */ 362, 507, 446, 507, 507, 449, 450, 451, 452, 453, - /* 3010 */ 454, 507, 456, 390, 507, 507, 507, 507, 507, 507, - /* 3020 */ 507, 507, 507, 507, 507, 402, 507, 404, 390, 507, - /* 3030 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3040 */ 402, 507, 404, 507, 507, 507, 507, 507, 507, 507, - /* 3050 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3060 */ 507, 507, 507, 507, 507, 507, 443, 507, 507, 446, - /* 3070 */ 349, 507, 449, 450, 451, 452, 453, 454, 507, 456, - /* 3080 */ 507, 443, 507, 362, 446, 507, 507, 449, 450, 451, - /* 3090 */ 452, 453, 454, 507, 456, 507, 507, 507, 507, 507, - /* 3100 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3110 */ 507, 390, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3120 */ 507, 507, 507, 402, 507, 404, 507, 507, 507, 507, - /* 3130 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3140 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3150 */ 507, 507, 507, 507, 507, 507, 507, 507, 507, 507, - /* 3160 */ 507, 507, 507, 507, 443, 507, 507, 446, 507, 507, - /* 3170 */ 449, 450, 451, 452, 453, 454, 507, 456, 346, 346, - /* 3180 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3190 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3200 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3210 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3220 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3230 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3240 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3250 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3260 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3270 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3280 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3290 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3300 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3310 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3320 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3330 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3340 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3350 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3360 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3370 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3380 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3390 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3400 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3410 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3420 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3430 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3440 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3450 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3460 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3470 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3480 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3490 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3500 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3510 */ 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, - /* 3520 */ 346, 346, 346, 346, + /* 250 */ 250, 251, 252, 12, 13, 177, 178, 191, 18, 183, + /* 260 */ 20, 20, 20, 22, 22, 362, 363, 27, 22, 350, + /* 270 */ 30, 20, 70, 106, 476, 35, 35, 479, 37, 37, + /* 280 */ 379, 20, 363, 37, 471, 472, 473, 474, 137, 476, + /* 290 */ 477, 51, 141, 53, 393, 497, 498, 55, 58, 476, + /* 300 */ 502, 503, 479, 369, 403, 64, 0, 107, 68, 14, + /* 310 */ 391, 70, 142, 143, 411, 20, 114, 199, 77, 201, + /* 320 */ 386, 498, 403, 77, 405, 502, 503, 350, 394, 390, + /* 330 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 135, + /* 340 */ 363, 402, 365, 139, 103, 105, 20, 106, 447, 231, + /* 350 */ 232, 275, 276, 277, 184, 185, 116, 106, 457, 208, + /* 360 */ 362, 295, 211, 444, 0, 214, 447, 216, 391, 450, + /* 370 */ 451, 452, 453, 454, 455, 20, 457, 50, 176, 179, + /* 380 */ 403, 369, 405, 142, 143, 350, 146, 147, 0, 149, + /* 390 */ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + /* 400 */ 160, 161, 162, 163, 164, 165, 394, 167, 168, 169, + /* 410 */ 22, 492, 493, 173, 174, 175, 418, 419, 177, 178, + /* 420 */ 180, 444, 20, 116, 447, 184, 185, 450, 451, 452, + /* 430 */ 453, 454, 455, 69, 457, 20, 269, 21, 403, 462, + /* 440 */ 199, 464, 201, 8, 9, 468, 469, 12, 13, 14, + /* 450 */ 15, 16, 36, 77, 38, 39, 40, 426, 256, 257, + /* 460 */ 258, 259, 260, 261, 262, 263, 264, 265, 266, 69, + /* 470 */ 136, 137, 231, 232, 233, 141, 235, 236, 237, 238, + /* 480 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, + /* 490 */ 249, 250, 251, 252, 253, 12, 13, 35, 358, 350, + /* 500 */ 20, 22, 362, 20, 364, 22, 179, 476, 106, 350, + /* 510 */ 479, 106, 363, 51, 187, 253, 37, 4, 35, 51, + /* 520 */ 37, 59, 60, 61, 62, 64, 64, 59, 497, 498, + /* 530 */ 62, 63, 350, 502, 503, 350, 33, 72, 73, 74, + /* 540 */ 391, 362, 107, 86, 79, 80, 81, 64, 363, 362, + /* 550 */ 85, 0, 403, 70, 405, 90, 91, 92, 93, 233, + /* 560 */ 77, 96, 403, 33, 99, 476, 105, 105, 479, 108, + /* 570 */ 108, 56, 57, 8, 9, 45, 391, 12, 13, 14, + /* 580 */ 15, 16, 103, 12, 13, 403, 103, 498, 403, 106, + /* 590 */ 405, 502, 503, 444, 179, 20, 447, 22, 33, 450, + /* 600 */ 451, 452, 453, 454, 455, 148, 457, 379, 37, 460, + /* 610 */ 107, 462, 463, 464, 14, 436, 437, 468, 469, 106, + /* 620 */ 20, 393, 116, 436, 437, 142, 143, 170, 171, 444, + /* 630 */ 55, 403, 447, 172, 172, 450, 451, 452, 453, 454, + /* 640 */ 455, 391, 457, 181, 182, 367, 368, 462, 398, 464, + /* 650 */ 188, 189, 34, 468, 469, 449, 406, 177, 8, 9, + /* 660 */ 177, 178, 12, 13, 14, 15, 16, 184, 185, 207, + /* 670 */ 33, 269, 107, 14, 269, 447, 491, 0, 0, 20, + /* 680 */ 103, 475, 199, 392, 201, 457, 135, 136, 137, 138, + /* 690 */ 139, 140, 141, 106, 117, 118, 119, 120, 121, 122, + /* 700 */ 123, 124, 125, 126, 391, 128, 129, 130, 131, 132, + /* 710 */ 133, 134, 399, 233, 231, 232, 233, 172, 235, 236, + /* 720 */ 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, + /* 730 */ 247, 248, 249, 250, 251, 252, 12, 13, 14, 392, + /* 740 */ 350, 14, 15, 16, 20, 391, 22, 350, 203, 72, + /* 750 */ 73, 74, 398, 363, 231, 365, 79, 80, 81, 35, + /* 760 */ 406, 37, 85, 362, 363, 362, 363, 90, 91, 92, + /* 770 */ 93, 350, 201, 96, 362, 363, 99, 177, 347, 0, + /* 780 */ 42, 391, 269, 382, 363, 382, 365, 392, 64, 253, + /* 790 */ 389, 255, 389, 403, 382, 405, 367, 368, 68, 449, + /* 800 */ 403, 77, 350, 280, 281, 282, 283, 284, 285, 286, + /* 810 */ 426, 392, 391, 8, 9, 431, 391, 12, 13, 14, + /* 820 */ 15, 16, 14, 398, 403, 475, 405, 103, 20, 179, + /* 830 */ 106, 406, 392, 233, 444, 350, 177, 447, 350, 161, + /* 840 */ 450, 451, 452, 453, 454, 455, 391, 457, 170, 362, + /* 850 */ 363, 363, 462, 398, 464, 403, 269, 426, 468, 469, + /* 860 */ 476, 406, 431, 479, 3, 444, 142, 143, 447, 382, + /* 870 */ 392, 450, 451, 452, 453, 454, 455, 426, 457, 391, + /* 880 */ 371, 497, 498, 462, 350, 464, 502, 503, 403, 468, + /* 890 */ 469, 403, 233, 405, 135, 136, 137, 138, 139, 140, + /* 900 */ 141, 177, 178, 362, 363, 383, 397, 476, 184, 185, + /* 910 */ 479, 391, 107, 391, 135, 136, 137, 138, 139, 140, + /* 920 */ 141, 399, 49, 199, 194, 201, 406, 476, 497, 498, + /* 930 */ 479, 294, 444, 502, 503, 447, 0, 403, 450, 451, + /* 940 */ 452, 453, 454, 455, 456, 457, 458, 459, 497, 498, + /* 950 */ 176, 221, 222, 502, 503, 231, 232, 233, 22, 235, + /* 960 */ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, + /* 970 */ 246, 247, 248, 249, 250, 251, 252, 12, 13, 106, + /* 980 */ 350, 362, 363, 22, 426, 20, 37, 22, 350, 1, + /* 990 */ 362, 363, 461, 363, 463, 365, 362, 363, 37, 136, + /* 1000 */ 35, 382, 37, 383, 362, 363, 268, 19, 376, 377, + /* 1010 */ 382, 391, 350, 472, 473, 474, 382, 476, 477, 399, + /* 1020 */ 0, 391, 379, 35, 382, 363, 77, 365, 37, 64, + /* 1030 */ 256, 362, 363, 403, 476, 405, 393, 479, 4, 51, + /* 1040 */ 266, 403, 77, 362, 363, 64, 403, 59, 60, 61, + /* 1050 */ 62, 382, 64, 391, 13, 497, 498, 387, 362, 363, + /* 1060 */ 502, 503, 42, 382, 103, 403, 380, 405, 103, 362, + /* 1070 */ 363, 106, 350, 4, 444, 212, 213, 447, 382, 20, + /* 1080 */ 450, 451, 452, 453, 454, 455, 426, 457, 19, 108, + /* 1090 */ 447, 448, 462, 105, 464, 20, 108, 20, 468, 469, + /* 1100 */ 457, 362, 363, 0, 35, 351, 444, 142, 143, 447, + /* 1110 */ 23, 441, 450, 451, 452, 453, 454, 455, 77, 457, + /* 1120 */ 51, 382, 20, 33, 462, 403, 464, 58, 140, 378, + /* 1130 */ 468, 469, 381, 64, 47, 48, 476, 376, 377, 479, + /* 1140 */ 8, 9, 177, 178, 12, 13, 14, 15, 16, 184, + /* 1150 */ 185, 290, 20, 39, 40, 362, 363, 497, 498, 461, + /* 1160 */ 33, 463, 502, 503, 199, 400, 201, 391, 403, 181, + /* 1170 */ 350, 362, 363, 391, 105, 382, 188, 108, 106, 472, + /* 1180 */ 473, 474, 406, 476, 477, 1, 2, 115, 406, 426, + /* 1190 */ 106, 382, 201, 350, 350, 207, 231, 232, 233, 350, + /* 1200 */ 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, + /* 1210 */ 245, 246, 247, 248, 249, 250, 251, 252, 12, 13, + /* 1220 */ 362, 363, 350, 403, 110, 111, 20, 113, 22, 12, + /* 1230 */ 13, 14, 15, 16, 107, 363, 350, 365, 179, 476, + /* 1240 */ 382, 35, 479, 37, 362, 363, 403, 403, 350, 135, + /* 1250 */ 350, 350, 403, 139, 362, 363, 362, 363, 362, 363, + /* 1260 */ 497, 498, 0, 391, 382, 502, 503, 362, 363, 400, + /* 1270 */ 64, 116, 403, 70, 382, 403, 382, 405, 382, 350, + /* 1280 */ 350, 179, 198, 77, 200, 400, 416, 382, 403, 403, + /* 1290 */ 384, 107, 233, 387, 353, 354, 109, 267, 268, 112, + /* 1300 */ 215, 403, 217, 403, 403, 271, 33, 33, 233, 103, + /* 1310 */ 233, 179, 106, 51, 230, 37, 444, 350, 45, 447, + /* 1320 */ 13, 166, 450, 451, 452, 453, 454, 455, 225, 457, + /* 1330 */ 363, 0, 403, 403, 462, 233, 464, 12, 13, 109, + /* 1340 */ 468, 469, 112, 109, 37, 13, 112, 22, 142, 143, + /* 1350 */ 495, 109, 0, 269, 112, 13, 33, 37, 391, 33, + /* 1360 */ 35, 13, 37, 506, 33, 233, 33, 142, 143, 37, + /* 1370 */ 403, 366, 405, 391, 22, 488, 1, 2, 379, 37, + /* 1380 */ 0, 107, 292, 177, 178, 37, 379, 33, 33, 64, + /* 1390 */ 184, 185, 33, 33, 33, 416, 33, 77, 33, 33, + /* 1400 */ 33, 33, 77, 33, 33, 199, 33, 201, 361, 416, + /* 1410 */ 33, 444, 494, 494, 447, 494, 494, 450, 451, 452, + /* 1420 */ 453, 454, 455, 425, 457, 416, 366, 363, 103, 462, + /* 1430 */ 107, 464, 52, 107, 231, 468, 469, 231, 232, 233, + /* 1440 */ 107, 235, 236, 237, 238, 239, 240, 241, 242, 243, + /* 1450 */ 244, 245, 246, 247, 248, 249, 250, 251, 252, 402, + /* 1460 */ 18, 107, 107, 478, 433, 23, 107, 107, 107, 416, + /* 1470 */ 107, 416, 107, 107, 107, 107, 499, 107, 107, 201, + /* 1480 */ 107, 470, 40, 41, 107, 481, 44, 381, 272, 427, + /* 1490 */ 51, 446, 42, 445, 20, 214, 54, 443, 197, 438, + /* 1500 */ 350, 371, 371, 438, 20, 429, 362, 65, 66, 67, + /* 1510 */ 68, 20, 363, 363, 45, 363, 412, 412, 409, 176, + /* 1520 */ 362, 409, 363, 362, 199, 412, 201, 409, 104, 375, + /* 1530 */ 102, 374, 362, 101, 362, 373, 362, 362, 20, 50, + /* 1540 */ 355, 391, 359, 355, 371, 359, 438, 371, 106, 20, + /* 1550 */ 405, 371, 20, 403, 364, 405, 231, 232, 20, 364, + /* 1560 */ 371, 428, 371, 20, 371, 419, 362, 371, 371, 355, + /* 1570 */ 245, 246, 247, 248, 249, 250, 251, 353, 355, 353, + /* 1580 */ 362, 403, 403, 391, 403, 391, 144, 218, 106, 391, + /* 1590 */ 391, 391, 391, 391, 444, 442, 391, 447, 391, 391, + /* 1600 */ 450, 451, 452, 453, 454, 455, 391, 457, 440, 438, + /* 1610 */ 369, 20, 462, 205, 464, 204, 405, 435, 468, 469, + /* 1620 */ 369, 362, 403, 279, 487, 278, 350, 487, 287, 490, + /* 1630 */ 190, 489, 485, 191, 192, 193, 296, 486, 196, 363, + /* 1640 */ 427, 421, 421, 487, 434, 289, 437, 273, 484, 427, + /* 1650 */ 288, 209, 210, 268, 363, 507, 20, 293, 116, 482, + /* 1660 */ 350, 501, 220, 291, 270, 223, 500, 391, 226, 227, + /* 1670 */ 228, 229, 230, 363, 369, 364, 449, 369, 421, 403, + /* 1680 */ 403, 405, 403, 403, 421, 403, 403, 182, 417, 387, + /* 1690 */ 369, 369, 480, 363, 106, 467, 106, 403, 395, 362, + /* 1700 */ 22, 391, 352, 369, 38, 356, 355, 439, 422, 422, + /* 1710 */ 0, 269, 385, 403, 430, 405, 370, 0, 0, 45, + /* 1720 */ 444, 385, 0, 447, 385, 37, 450, 451, 452, 453, + /* 1730 */ 454, 455, 224, 457, 350, 348, 37, 37, 462, 37, + /* 1740 */ 464, 224, 0, 37, 468, 469, 37, 363, 224, 37, + /* 1750 */ 0, 0, 224, 37, 444, 0, 37, 447, 0, 22, + /* 1760 */ 450, 451, 452, 453, 454, 455, 0, 457, 350, 37, + /* 1770 */ 219, 0, 207, 0, 464, 391, 207, 201, 468, 469, + /* 1780 */ 208, 363, 199, 0, 0, 0, 194, 403, 195, 405, + /* 1790 */ 0, 0, 147, 49, 49, 0, 37, 0, 0, 37, + /* 1800 */ 51, 350, 0, 49, 0, 45, 0, 0, 0, 391, + /* 1810 */ 49, 0, 0, 0, 363, 0, 0, 0, 161, 37, + /* 1820 */ 0, 403, 161, 405, 0, 0, 0, 0, 444, 49, + /* 1830 */ 0, 447, 0, 0, 450, 451, 452, 453, 454, 455, + /* 1840 */ 0, 457, 391, 0, 0, 0, 0, 0, 464, 146, + /* 1850 */ 45, 0, 468, 469, 403, 0, 405, 0, 0, 0, + /* 1860 */ 0, 0, 444, 0, 0, 447, 0, 0, 450, 451, + /* 1870 */ 452, 453, 454, 455, 0, 457, 22, 350, 0, 0, + /* 1880 */ 147, 0, 464, 145, 0, 0, 468, 469, 50, 50, + /* 1890 */ 363, 22, 22, 0, 0, 444, 0, 0, 447, 64, + /* 1900 */ 64, 450, 451, 452, 453, 454, 455, 350, 457, 0, + /* 1910 */ 37, 0, 64, 37, 37, 0, 51, 42, 391, 51, + /* 1920 */ 363, 0, 42, 37, 0, 42, 37, 14, 33, 0, + /* 1930 */ 403, 0, 405, 51, 42, 45, 0, 49, 0, 0, + /* 1940 */ 49, 0, 43, 42, 42, 0, 190, 49, 391, 49, + /* 1950 */ 0, 0, 0, 37, 51, 504, 505, 0, 51, 42, + /* 1960 */ 403, 42, 405, 37, 0, 37, 0, 42, 0, 51, + /* 1970 */ 37, 444, 42, 51, 447, 71, 0, 450, 451, 452, + /* 1980 */ 453, 454, 455, 0, 457, 350, 0, 0, 0, 22, + /* 1990 */ 37, 464, 0, 37, 33, 37, 469, 37, 363, 37, + /* 2000 */ 37, 444, 350, 33, 447, 0, 37, 450, 451, 452, + /* 2010 */ 453, 454, 455, 22, 457, 363, 37, 112, 37, 350, + /* 2020 */ 22, 37, 114, 0, 22, 53, 391, 37, 0, 22, + /* 2030 */ 37, 396, 363, 37, 0, 0, 0, 37, 403, 0, + /* 2040 */ 405, 37, 0, 391, 22, 20, 37, 37, 396, 37, + /* 2050 */ 493, 107, 106, 0, 106, 403, 206, 405, 0, 22, + /* 2060 */ 391, 37, 49, 0, 202, 22, 0, 0, 3, 50, + /* 2070 */ 274, 33, 403, 33, 405, 274, 50, 106, 104, 444, + /* 2080 */ 107, 106, 447, 33, 350, 450, 451, 452, 453, 454, + /* 2090 */ 455, 179, 457, 179, 33, 106, 444, 363, 49, 447, + /* 2100 */ 49, 107, 450, 451, 452, 453, 454, 455, 102, 457, + /* 2110 */ 107, 179, 33, 444, 350, 107, 447, 182, 107, 450, + /* 2120 */ 451, 452, 453, 454, 455, 391, 457, 363, 179, 186, + /* 2130 */ 3, 33, 37, 179, 107, 106, 106, 403, 106, 405, + /* 2140 */ 37, 186, 37, 37, 37, 274, 37, 33, 107, 49, + /* 2150 */ 49, 107, 0, 0, 106, 391, 0, 42, 106, 42, + /* 2160 */ 396, 107, 107, 106, 33, 496, 106, 403, 183, 405, + /* 2170 */ 106, 115, 49, 104, 106, 104, 181, 267, 444, 350, + /* 2180 */ 2, 447, 22, 106, 450, 451, 452, 453, 454, 455, + /* 2190 */ 231, 457, 363, 107, 254, 106, 49, 107, 106, 350, + /* 2200 */ 107, 107, 106, 49, 22, 106, 37, 116, 444, 107, + /* 2210 */ 106, 447, 363, 37, 450, 451, 452, 453, 454, 455, + /* 2220 */ 391, 457, 350, 107, 106, 37, 106, 37, 107, 107, + /* 2230 */ 106, 234, 403, 37, 405, 363, 106, 350, 37, 505, + /* 2240 */ 391, 107, 106, 37, 107, 396, 127, 106, 106, 33, + /* 2250 */ 363, 106, 403, 127, 405, 127, 350, 37, 22, 127, + /* 2260 */ 71, 106, 70, 391, 37, 37, 37, 37, 396, 363, + /* 2270 */ 77, 37, 37, 444, 37, 403, 447, 405, 391, 450, + /* 2280 */ 451, 452, 453, 454, 455, 37, 457, 37, 459, 77, + /* 2290 */ 403, 100, 405, 444, 100, 33, 447, 391, 37, 450, + /* 2300 */ 451, 452, 453, 454, 455, 37, 457, 37, 22, 403, + /* 2310 */ 37, 405, 37, 0, 37, 77, 444, 37, 37, 447, + /* 2320 */ 37, 37, 450, 451, 452, 453, 454, 455, 22, 457, + /* 2330 */ 350, 444, 37, 37, 447, 37, 51, 450, 451, 452, + /* 2340 */ 453, 454, 455, 363, 457, 42, 0, 37, 51, 350, + /* 2350 */ 444, 42, 0, 447, 37, 51, 450, 451, 452, 453, + /* 2360 */ 454, 455, 363, 457, 42, 350, 0, 37, 42, 51, + /* 2370 */ 0, 391, 37, 37, 0, 22, 33, 22, 363, 21, + /* 2380 */ 508, 22, 22, 403, 21, 405, 508, 20, 508, 508, + /* 2390 */ 391, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2400 */ 508, 508, 403, 508, 405, 508, 391, 508, 508, 508, + /* 2410 */ 508, 508, 508, 508, 508, 508, 508, 508, 403, 508, + /* 2420 */ 405, 508, 508, 350, 444, 508, 508, 447, 508, 508, + /* 2430 */ 450, 451, 452, 453, 454, 455, 363, 457, 508, 508, + /* 2440 */ 508, 508, 508, 444, 508, 508, 447, 350, 508, 450, + /* 2450 */ 451, 452, 453, 454, 455, 508, 457, 508, 508, 444, + /* 2460 */ 363, 508, 447, 508, 391, 450, 451, 452, 453, 454, + /* 2470 */ 455, 508, 457, 508, 508, 508, 403, 508, 405, 508, + /* 2480 */ 508, 508, 508, 508, 508, 508, 508, 508, 391, 508, + /* 2490 */ 350, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2500 */ 403, 508, 405, 363, 508, 508, 508, 508, 508, 508, + /* 2510 */ 508, 508, 508, 508, 508, 508, 350, 444, 508, 508, + /* 2520 */ 447, 508, 508, 450, 451, 452, 453, 454, 455, 363, + /* 2530 */ 457, 391, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2540 */ 508, 444, 508, 403, 447, 405, 508, 450, 451, 452, + /* 2550 */ 453, 454, 455, 508, 457, 508, 508, 391, 508, 350, + /* 2560 */ 508, 508, 508, 508, 508, 508, 508, 508, 508, 403, + /* 2570 */ 508, 405, 363, 508, 508, 508, 508, 508, 508, 508, + /* 2580 */ 508, 508, 508, 350, 444, 508, 508, 447, 508, 508, + /* 2590 */ 450, 451, 452, 453, 454, 455, 363, 457, 508, 508, + /* 2600 */ 391, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2610 */ 444, 508, 403, 447, 405, 508, 450, 451, 452, 453, + /* 2620 */ 454, 455, 508, 457, 391, 508, 350, 508, 508, 508, + /* 2630 */ 508, 508, 508, 508, 508, 508, 403, 508, 405, 363, + /* 2640 */ 508, 350, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2650 */ 508, 508, 508, 444, 363, 508, 447, 350, 508, 450, + /* 2660 */ 451, 452, 453, 454, 455, 508, 457, 391, 508, 508, + /* 2670 */ 363, 508, 508, 508, 508, 508, 508, 444, 508, 403, + /* 2680 */ 447, 405, 391, 450, 451, 452, 453, 454, 455, 508, + /* 2690 */ 457, 508, 508, 508, 403, 508, 405, 508, 391, 508, + /* 2700 */ 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2710 */ 403, 508, 405, 508, 508, 508, 508, 508, 508, 508, + /* 2720 */ 444, 508, 508, 447, 508, 508, 450, 451, 452, 453, + /* 2730 */ 454, 455, 508, 457, 350, 444, 508, 508, 447, 508, + /* 2740 */ 508, 450, 451, 452, 453, 454, 455, 363, 457, 508, + /* 2750 */ 508, 444, 508, 350, 447, 508, 508, 450, 451, 452, + /* 2760 */ 453, 454, 455, 508, 457, 508, 363, 508, 508, 350, + /* 2770 */ 508, 508, 508, 508, 508, 391, 508, 508, 508, 508, + /* 2780 */ 508, 508, 363, 508, 508, 508, 508, 403, 508, 405, + /* 2790 */ 508, 508, 508, 508, 391, 508, 508, 508, 508, 508, + /* 2800 */ 508, 508, 508, 508, 508, 508, 403, 508, 405, 508, + /* 2810 */ 391, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2820 */ 508, 508, 403, 508, 405, 508, 508, 350, 444, 508, + /* 2830 */ 508, 447, 508, 508, 450, 451, 452, 453, 454, 455, + /* 2840 */ 363, 457, 508, 508, 508, 508, 508, 444, 508, 508, + /* 2850 */ 447, 350, 508, 450, 451, 452, 453, 454, 455, 508, + /* 2860 */ 457, 508, 508, 444, 363, 508, 447, 508, 391, 450, + /* 2870 */ 451, 452, 453, 454, 455, 508, 457, 508, 508, 508, + /* 2880 */ 403, 508, 405, 508, 508, 508, 508, 508, 508, 508, + /* 2890 */ 508, 508, 391, 508, 350, 508, 508, 508, 508, 508, + /* 2900 */ 508, 508, 508, 508, 403, 508, 405, 363, 508, 508, + /* 2910 */ 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 2920 */ 350, 444, 508, 508, 447, 508, 508, 450, 451, 452, + /* 2930 */ 453, 454, 455, 363, 457, 391, 508, 508, 508, 508, + /* 2940 */ 508, 508, 508, 508, 508, 444, 508, 403, 447, 405, + /* 2950 */ 508, 450, 451, 452, 453, 454, 455, 508, 457, 508, + /* 2960 */ 508, 391, 508, 350, 508, 508, 508, 508, 508, 508, + /* 2970 */ 508, 508, 508, 403, 508, 405, 363, 508, 508, 508, + /* 2980 */ 508, 508, 508, 508, 508, 508, 508, 508, 444, 508, + /* 2990 */ 508, 447, 508, 508, 450, 451, 452, 453, 454, 455, + /* 3000 */ 508, 457, 508, 508, 391, 508, 508, 508, 508, 508, + /* 3010 */ 508, 508, 508, 508, 444, 508, 403, 447, 405, 508, + /* 3020 */ 450, 451, 452, 453, 454, 455, 508, 457, 508, 508, + /* 3030 */ 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 3040 */ 508, 508, 508, 508, 508, 508, 508, 508, 508, 508, + /* 3050 */ 508, 508, 508, 508, 508, 508, 508, 444, 508, 508, + /* 3060 */ 447, 508, 508, 450, 451, 452, 453, 454, 455, 508, + /* 3070 */ 457, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3080 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3090 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3100 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3110 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3120 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3130 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3140 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3150 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3160 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3170 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3180 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3190 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3200 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3210 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3220 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3230 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3240 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3250 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3260 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3270 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3280 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3290 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3300 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3310 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3320 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3330 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3340 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3350 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3360 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3370 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3380 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3390 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3400 */ 347, 347, 347, 347, 347, 347, 347, 347, 347, 347, + /* 3410 */ 347, 347, 347, 347, 347, 347, 347, 347, }; -#define YY_SHIFT_COUNT (834) +#define YY_SHIFT_COUNT (839) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2381) +#define YY_SHIFT_MAX (2374) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 391, 0, 240, 0, 481, 481, 481, 481, 481, 481, - /* 10 */ 481, 481, 481, 481, 481, 481, 721, 961, 961, 1201, - /* 20 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, - /* 30 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, - /* 40 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961, - /* 50 */ 961, 93, 162, 152, 47, 278, 343, 278, 278, 47, - /* 60 */ 47, 278, 1319, 278, 239, 1319, 1319, 281, 278, 28, - /* 70 */ 595, 67, 67, 931, 931, 595, 87, 291, 126, 126, - /* 80 */ 173, 67, 67, 67, 67, 67, 67, 67, 67, 67, - /* 90 */ 67, 67, 317, 492, 67, 67, 187, 28, 67, 317, - /* 100 */ 67, 28, 67, 67, 28, 67, 67, 28, 67, 28, - /* 110 */ 28, 28, 67, 368, 439, 439, 242, 546, 569, 569, - /* 120 */ 569, 569, 569, 569, 569, 569, 569, 569, 569, 569, - /* 130 */ 569, 569, 569, 569, 569, 569, 569, 189, 602, 87, - /* 140 */ 291, 1024, 1024, 150, 268, 268, 268, 678, 336, 336, - /* 150 */ 91, 150, 187, 486, 28, 28, 633, 28, 813, 28, - /* 160 */ 813, 813, 823, 959, 89, 89, 89, 89, 89, 89, - /* 170 */ 89, 89, 504, 441, 65, 453, 15, 313, 606, 19, - /* 180 */ 322, 516, 3, 3, 527, 983, 770, 303, 303, 303, - /* 190 */ 502, 303, 800, 1100, 1, 725, 618, 650, 1, 1, - /* 200 */ 808, 1009, 538, 988, 1009, 1261, 1056, 91, 1196, 1422, - /* 210 */ 1439, 1470, 1289, 187, 1470, 187, 1309, 1487, 1489, 1466, - /* 220 */ 1489, 1466, 1339, 1487, 1489, 1487, 1466, 1339, 1339, 1423, - /* 230 */ 1426, 1487, 1430, 1487, 1487, 1487, 1517, 1490, 1517, 1490, - /* 240 */ 1470, 187, 187, 1528, 187, 1532, 1535, 187, 1532, 187, - /* 250 */ 1539, 187, 187, 1487, 187, 1517, 28, 28, 28, 28, - /* 260 */ 28, 28, 28, 28, 28, 28, 28, 1487, 959, 959, - /* 270 */ 1517, 813, 813, 813, 1386, 1469, 1470, 368, 1597, 1416, - /* 280 */ 1418, 1528, 368, 1196, 1487, 813, 1350, 1352, 1350, 1352, - /* 290 */ 1344, 1448, 1350, 1362, 1370, 1393, 1196, 1368, 1377, 1383, - /* 300 */ 1407, 1489, 1657, 1568, 1419, 1532, 368, 368, 1352, 813, - /* 310 */ 813, 813, 813, 1352, 813, 1536, 368, 823, 368, 1489, - /* 320 */ 1616, 1620, 813, 1487, 368, 1713, 1698, 1517, 3178, 3178, - /* 330 */ 3178, 3178, 3178, 3178, 3178, 3178, 3178, 36, 881, 786, - /* 340 */ 30, 825, 1043, 1063, 625, 413, 661, 1103, 877, 1271, - /* 350 */ 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1271, 635, 716, - /* 360 */ 318, 363, 363, 355, 358, 445, 870, 867, 1146, 1202, - /* 370 */ 1006, 1021, 1021, 1211, 1183, 382, 1211, 1211, 1211, 1288, - /* 380 */ 1106, 462, 1066, 1265, 1180, 1291, 1190, 1216, 1226, 1228, - /* 390 */ 677, 1310, 1292, 1336, 1357, 974, 1267, 1347, 477, 1348, - /* 400 */ 1349, 1353, 1221, 417, 8, 1354, 1356, 1358, 1359, 1361, - /* 410 */ 1364, 1367, 1378, 714, 1379, 155, 1381, 1384, 1385, 1388, - /* 420 */ 1390, 1391, 1287, 1213, 1225, 1363, 1382, 1051, 1083, 1752, - /* 430 */ 1753, 1765, 1722, 1769, 1733, 1548, 1737, 1738, 1739, 1554, - /* 440 */ 1778, 1743, 1744, 1559, 1746, 1784, 1563, 1789, 1760, 1799, - /* 450 */ 1779, 1805, 1766, 1588, 1808, 1603, 1810, 1605, 1606, 1612, - /* 460 */ 1617, 1814, 1816, 1817, 1624, 1627, 1822, 1823, 1677, 1776, - /* 470 */ 1777, 1827, 1792, 1780, 1830, 1783, 1835, 1791, 1837, 1838, - /* 480 */ 1839, 1795, 1841, 1845, 1847, 1848, 1855, 1857, 1697, 1824, - /* 490 */ 1859, 1701, 1864, 1865, 1872, 1874, 1875, 1876, 1877, 1878, - /* 500 */ 1879, 1882, 1883, 1893, 1895, 1896, 1897, 1898, 1900, 1852, - /* 510 */ 1902, 1860, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1892, - /* 520 */ 1915, 1770, 1916, 1772, 1919, 1775, 1921, 1922, 1901, 1881, - /* 530 */ 1903, 1884, 1924, 1869, 1891, 1929, 1871, 1936, 1873, 1938, - /* 540 */ 1940, 1905, 1894, 1904, 1943, 1913, 1914, 1918, 1947, 1925, - /* 550 */ 1920, 1927, 1948, 1926, 1949, 1928, 1930, 1923, 1933, 1935, - /* 560 */ 1937, 1946, 1952, 1931, 1934, 1953, 1955, 1958, 1961, 1950, - /* 570 */ 1781, 1964, 1933, 1951, 1967, 1975, 1932, 1977, 1978, 1942, - /* 580 */ 1945, 1956, 2001, 1965, 1954, 1962, 2006, 1971, 1960, 1970, - /* 590 */ 2009, 1982, 1972, 1979, 2024, 2025, 2026, 2027, 2028, 2029, - /* 600 */ 1917, 1941, 1993, 2010, 2033, 2000, 2002, 2003, 2005, 2013, - /* 610 */ 2015, 2018, 2019, 2030, 2031, 2020, 2021, 2037, 2023, 2035, - /* 620 */ 2039, 2043, 2040, 2012, 2066, 2046, 2032, 2070, 2071, 2072, - /* 630 */ 2036, 2074, 2050, 2076, 2055, 2060, 2052, 2054, 2056, 1987, - /* 640 */ 1990, 2097, 1939, 1992, 1899, 1933, 2053, 2099, 1963, 2064, - /* 650 */ 2081, 2105, 1944, 2084, 1966, 1957, 2108, 2118, 1968, 1984, - /* 660 */ 1969, 1985, 2107, 2078, 1840, 2008, 2016, 2022, 2062, 2011, - /* 670 */ 2069, 2038, 2017, 2083, 2088, 2042, 2047, 2058, 2061, 2059, - /* 680 */ 2092, 2077, 2080, 2065, 2094, 1858, 2067, 2082, 2127, 2100, - /* 690 */ 1866, 2106, 2123, 2125, 2135, 2148, 2150, 2087, 2089, 2093, - /* 700 */ 1994, 2158, 2146, 2197, 2199, 2095, 2160, 2098, 2096, 2101, - /* 710 */ 2103, 2104, 2051, 2109, 2200, 2164, 2034, 2112, 2113, 1933, - /* 720 */ 2162, 2179, 2116, 1983, 2117, 2211, 2210, 2041, 2137, 2138, - /* 730 */ 2141, 2143, 2145, 2154, 2213, 2157, 2159, 2215, 2161, 2244, - /* 740 */ 2044, 2163, 2151, 2166, 2237, 2238, 2172, 2173, 2242, 2175, - /* 750 */ 2176, 2245, 2178, 2180, 2248, 2183, 2184, 2249, 2186, 2187, - /* 760 */ 2256, 2189, 2169, 2170, 2171, 2174, 2193, 2267, 2196, 2266, - /* 770 */ 2198, 2267, 2267, 2283, 2236, 2239, 2269, 2271, 2275, 2276, - /* 780 */ 2278, 2279, 2286, 2288, 2289, 2233, 2227, 2251, 2231, 2300, - /* 790 */ 2297, 2304, 2307, 2323, 2309, 2311, 2312, 2274, 2030, 2313, - /* 800 */ 2031, 2315, 2316, 2317, 2318, 2334, 2320, 2358, 2322, 2310, - /* 810 */ 2324, 2362, 2327, 2314, 2325, 2368, 2332, 2319, 2331, 2372, - /* 820 */ 2337, 2326, 2333, 2378, 2342, 2343, 2381, 2360, 2351, 2364, - /* 830 */ 2366, 2367, 2369, 2371, 2370, + /* 0 */ 1442, 0, 241, 0, 483, 483, 483, 483, 483, 483, + /* 10 */ 483, 483, 483, 483, 483, 483, 724, 965, 965, 1206, + /* 20 */ 965, 965, 965, 965, 965, 965, 965, 965, 965, 965, + /* 30 */ 965, 965, 965, 965, 965, 965, 965, 965, 965, 965, + /* 40 */ 965, 965, 965, 965, 965, 965, 965, 965, 965, 965, + /* 50 */ 965, 167, 402, 1084, 251, 405, 587, 405, 405, 251, + /* 60 */ 251, 405, 1325, 405, 240, 1325, 1325, 513, 405, 5, + /* 70 */ 170, 171, 171, 160, 160, 170, 78, 39, 295, 295, + /* 80 */ 326, 171, 171, 171, 171, 171, 171, 171, 171, 171, + /* 90 */ 171, 171, 261, 355, 171, 171, 91, 5, 171, 261, + /* 100 */ 171, 5, 171, 171, 5, 171, 171, 5, 171, 5, + /* 110 */ 5, 5, 171, 400, 202, 202, 465, 198, 118, 118, + /* 120 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + /* 130 */ 118, 118, 118, 118, 118, 118, 118, 1114, 200, 78, + /* 140 */ 39, 515, 515, 949, 415, 415, 415, 364, 536, 536, + /* 150 */ 1041, 949, 91, 307, 5, 5, 262, 5, 376, 5, + /* 160 */ 376, 376, 506, 618, 577, 577, 577, 577, 577, 577, + /* 170 */ 577, 577, 988, 677, 65, 1132, 66, 523, 242, 76, + /* 180 */ 600, 659, 571, 571, 1059, 1087, 1102, 246, 246, 246, + /* 190 */ 327, 246, 480, 575, 1075, 808, 204, 545, 1075, 1075, + /* 200 */ 1077, 1030, 738, 861, 1030, 530, 1034, 1041, 1216, 1439, + /* 210 */ 1450, 1474, 1281, 91, 1474, 91, 1301, 1484, 1491, 1469, + /* 220 */ 1491, 1469, 1343, 1484, 1491, 1484, 1469, 1343, 1343, 1424, + /* 230 */ 1428, 1484, 1432, 1484, 1484, 1484, 1518, 1489, 1518, 1489, + /* 240 */ 1474, 91, 91, 1529, 91, 1532, 1538, 91, 1532, 91, + /* 250 */ 1543, 91, 91, 1484, 91, 1518, 5, 5, 5, 5, + /* 260 */ 5, 5, 5, 5, 5, 5, 5, 1484, 618, 618, + /* 270 */ 1518, 376, 376, 376, 1369, 1482, 1474, 400, 1591, 1408, + /* 280 */ 1411, 1529, 400, 1216, 1484, 376, 1344, 1347, 1344, 1347, + /* 290 */ 1341, 1440, 1344, 1356, 1362, 1374, 1216, 1340, 1364, 1372, + /* 300 */ 1385, 1491, 1636, 1542, 1394, 1532, 400, 400, 1347, 376, + /* 310 */ 376, 376, 376, 1347, 376, 1505, 400, 506, 400, 1491, + /* 320 */ 1588, 1590, 376, 1484, 400, 1678, 1666, 1518, 3071, 3071, + /* 330 */ 3071, 3071, 3071, 3071, 3071, 3071, 3071, 36, 462, 306, + /* 340 */ 565, 1069, 435, 805, 551, 15, 30, 650, 779, 40, + /* 350 */ 40, 40, 40, 40, 40, 40, 40, 40, 759, 151, + /* 360 */ 416, 1217, 1217, 730, 461, 457, 468, 678, 479, 961, + /* 370 */ 863, 334, 334, 727, 1184, 774, 727, 727, 727, 1262, + /* 380 */ 1103, 503, 1020, 1273, 1155, 1331, 1187, 1230, 1234, 1242, + /* 390 */ 1307, 1332, 388, 936, 1352, 1085, 1127, 1323, 981, 1326, + /* 400 */ 1333, 1354, 1225, 1090, 637, 1355, 1359, 1360, 1361, 1363, + /* 410 */ 1365, 1375, 1366, 1203, 1274, 873, 1367, 1368, 1370, 1371, + /* 420 */ 1373, 1377, 1072, 991, 1278, 1342, 1348, 1320, 1380, 1710, + /* 430 */ 1717, 1718, 1674, 1722, 1688, 1508, 1699, 1700, 1702, 1517, + /* 440 */ 1742, 1706, 1709, 1524, 1712, 1750, 1528, 1751, 1716, 1755, + /* 450 */ 1719, 1758, 1737, 1766, 1732, 1551, 1771, 1565, 1773, 1569, + /* 460 */ 1572, 1576, 1583, 1783, 1784, 1785, 1593, 1592, 1790, 1791, + /* 470 */ 1645, 1744, 1745, 1795, 1759, 1797, 1798, 1762, 1749, 1802, + /* 480 */ 1754, 1804, 1760, 1806, 1807, 1808, 1761, 1811, 1812, 1813, + /* 490 */ 1815, 1816, 1817, 1657, 1782, 1820, 1661, 1824, 1825, 1826, + /* 500 */ 1827, 1832, 1833, 1840, 1843, 1844, 1845, 1846, 1847, 1855, + /* 510 */ 1857, 1858, 1859, 1860, 1780, 1830, 1805, 1851, 1861, 1863, + /* 520 */ 1864, 1866, 1867, 1874, 1854, 1878, 1733, 1879, 1703, 1881, + /* 530 */ 1738, 1884, 1885, 1869, 1838, 1870, 1839, 1893, 1835, 1873, + /* 540 */ 1894, 1836, 1896, 1848, 1897, 1909, 1876, 1865, 1875, 1911, + /* 550 */ 1877, 1868, 1880, 1915, 1886, 1882, 1883, 1921, 1889, 1924, + /* 560 */ 1890, 1892, 1895, 1888, 1891, 1913, 1898, 1929, 1899, 1901, + /* 570 */ 1931, 1936, 1938, 1939, 1902, 1756, 1941, 1888, 1900, 1945, + /* 580 */ 1950, 1904, 1951, 1952, 1916, 1903, 1917, 1957, 1926, 1907, + /* 590 */ 1919, 1964, 1928, 1918, 1925, 1966, 1933, 1922, 1930, 1968, + /* 600 */ 1976, 1983, 1986, 1987, 1988, 1908, 1905, 1953, 1967, 1992, + /* 610 */ 1956, 1958, 1960, 1962, 1963, 1969, 1979, 1981, 1961, 1970, + /* 620 */ 1984, 1990, 1991, 1993, 2005, 1998, 2023, 2002, 1972, 2028, + /* 630 */ 2007, 1996, 2034, 2035, 2036, 2000, 2039, 2004, 2042, 2022, + /* 640 */ 2025, 2009, 2010, 2012, 1944, 1946, 2053, 1912, 1948, 1850, + /* 650 */ 1888, 2013, 2058, 1914, 2024, 2037, 2063, 1862, 2043, 1932, + /* 660 */ 1935, 2066, 2067, 1949, 1943, 1954, 1955, 2065, 2038, 1796, + /* 670 */ 1971, 1973, 1975, 2019, 1974, 2026, 2006, 1994, 2040, 2050, + /* 680 */ 2003, 1989, 2029, 2030, 2008, 2061, 2049, 2051, 2032, 2079, + /* 690 */ 1801, 2011, 2027, 2127, 2098, 1871, 2095, 2103, 2105, 2106, + /* 700 */ 2107, 2109, 2041, 2044, 2100, 1910, 2114, 2101, 2152, 2153, + /* 710 */ 2048, 2115, 2052, 2054, 2055, 2057, 2060, 1985, 2064, 2156, + /* 720 */ 2117, 1995, 2068, 2056, 1888, 2123, 2131, 2069, 1940, 2071, + /* 730 */ 2178, 2160, 1959, 2077, 2086, 2089, 2090, 2092, 2093, 2147, + /* 740 */ 2096, 2099, 2154, 2094, 2182, 1997, 2104, 2091, 2102, 2169, + /* 750 */ 2176, 2118, 2116, 2188, 2120, 2121, 2190, 2124, 2122, 2196, + /* 760 */ 2130, 2134, 2201, 2136, 2137, 2206, 2141, 2119, 2126, 2128, + /* 770 */ 2132, 2142, 2216, 2145, 2220, 2155, 2216, 2216, 2236, 2189, + /* 780 */ 2192, 2227, 2228, 2229, 2230, 2234, 2235, 2237, 2248, 2250, + /* 790 */ 2193, 2191, 2212, 2194, 2262, 2261, 2268, 2270, 2286, 2273, + /* 800 */ 2275, 2277, 2238, 1961, 2280, 1970, 2281, 2283, 2284, 2295, + /* 810 */ 2306, 2296, 2313, 2298, 2285, 2303, 2346, 2310, 2297, 2309, + /* 820 */ 2352, 2317, 2304, 2322, 2366, 2330, 2318, 2326, 2370, 2335, + /* 830 */ 2336, 2374, 2353, 2343, 2355, 2358, 2359, 2360, 2363, 2367, }; #define YY_REDUCE_COUNT (336) -#define YY_REDUCE_MIN (-423) -#define YY_REDUCE_MAX (2721) +#define YY_REDUCE_MIN (-430) +#define YY_REDUCE_MAX (2613) static const short yy_reduce_ofst[] = { - /* 0 */ -149, -302, 387, 199, 419, 646, 680, 866, 899, 1026, - /* 10 */ 457, 1134, 1192, 1229, 1262, 1305, -84, 1342, 1400, 1417, - /* 20 */ 1438, 1537, 1564, 1595, 1632, 1705, 1730, 1773, 1803, 1788, - /* 30 */ 1868, 1886, 1981, 1998, 2014, 2091, 2110, 2177, 2206, 2235, - /* 40 */ 2273, 2330, 2348, 2405, 2425, 2441, 2540, 2556, 2623, 2638, - /* 50 */ 2721, -189, -339, -423, 163, -421, 525, 676, 685, 279, - /* 60 */ 321, 744, -176, -311, -308, 536, 787, 674, 756, -379, - /* 70 */ -248, -356, -192, -288, 4, -244, -329, 39, 181, 383, - /* 80 */ -306, -312, -31, 138, 198, -328, -137, 246, 325, 426, - /* 90 */ 464, -107, 75, -223, 470, 531, -91, 491, 623, 443, - /* 100 */ 626, 494, 658, 662, -381, 673, 684, 600, 712, 476, - /* 110 */ 604, 651, 724, 236, -54, -54, -371, 282, 115, 305, - /* 120 */ 393, 433, 454, 493, 545, 573, 578, 597, 772, 778, - /* 130 */ 818, 845, 880, 893, 895, 906, 911, 161, -293, -123, - /* 140 */ 398, 535, 773, 561, -293, -129, 360, 300, 455, 704, - /* 150 */ -318, 749, -98, 116, 266, 544, 694, 861, 833, 847, - /* 160 */ 865, 872, 883, 920, 620, 656, 703, 755, 863, 902, - /* 170 */ 930, 863, 785, -369, 1011, 896, 854, 871, 1005, 884, - /* 180 */ 982, 982, 995, 1020, 989, 1045, 991, 910, 914, 915, - /* 190 */ 985, 917, 982, 1050, 1012, 1058, 1025, 997, 1019, 1038, - /* 200 */ 982, 980, 980, 960, 980, 990, 984, 1082, 1044, 1029, - /* 210 */ 1040, 1062, 1059, 1130, 1067, 1133, 1078, 1147, 1148, 1101, - /* 220 */ 1151, 1104, 1108, 1157, 1158, 1160, 1111, 1115, 1117, 1152, - /* 230 */ 1156, 1169, 1161, 1171, 1173, 1174, 1185, 1184, 1189, 1186, - /* 240 */ 1109, 1175, 1177, 1149, 1181, 1193, 1131, 1187, 1197, 1191, - /* 250 */ 1144, 1200, 1203, 1210, 1204, 1218, 1199, 1208, 1209, 1214, - /* 260 */ 1215, 1217, 1219, 1220, 1222, 1223, 1224, 1231, 1227, 1241, - /* 270 */ 1246, 1179, 1206, 1230, 1135, 1167, 1178, 1248, 1182, 1188, - /* 280 */ 1194, 1232, 1255, 1235, 1264, 1237, 1140, 1236, 1154, 1238, - /* 290 */ 1145, 1159, 1163, 1166, 1205, 1207, 1242, 1164, 1162, 1172, - /* 300 */ 980, 1314, 1239, 1212, 1240, 1323, 1326, 1330, 1279, 1298, - /* 310 */ 1299, 1300, 1301, 1286, 1308, 1304, 1355, 1335, 1360, 1365, - /* 320 */ 1258, 1337, 1331, 1373, 1369, 1387, 1392, 1389, 1311, 1303, - /* 330 */ 1318, 1321, 1366, 1376, 1380, 1394, 1398, + /* 0 */ 431, -303, 149, 185, -23, 390, 421, 630, 662, 872, + /* 10 */ 967, 1150, 1276, 1310, 1384, 1418, 488, -81, 1451, 1527, + /* 20 */ 1557, 1635, 1652, 1669, 1734, 1764, 1829, 1849, 1872, 1887, + /* 30 */ 1906, 1980, 1999, 2015, 2073, 2097, 2140, 2166, 2209, 2233, + /* 40 */ 2276, 2291, 2307, 2384, 2403, 2419, 2477, 2501, 2544, 2570, + /* 50 */ 2613, -305, -202, 384, -187, 31, 451, 558, 660, 541, + /* 60 */ 707, 763, 643, -340, -341, -99, 228, -177, 89, -380, + /* 70 */ -211, 401, 403, -356, -351, -390, -330, -333, -257, 140, + /* 80 */ -218, 412, 487, 619, 628, -312, -225, 634, 669, 681, + /* 90 */ 696, -97, 179, -2, 739, 793, -284, 250, 642, 187, + /* 100 */ 809, 354, 858, 882, -383, 892, 894, 425, 896, 522, + /* 110 */ 455, 620, 905, -66, -425, -425, -296, -149, 35, 159, + /* 120 */ 182, 397, 452, 485, 534, 638, 722, 820, 843, 844, + /* 130 */ 849, 886, 898, 900, 901, 929, 930, -61, -270, -245, + /* 140 */ -342, 278, 429, 632, -270, 206, 350, 12, 531, 698, + /* 150 */ 751, 761, 509, 670, 520, 776, -307, 313, 765, 782, + /* 160 */ 869, 885, 906, 941, -385, 291, 347, 395, 419, 440, + /* 170 */ 478, 419, -430, 686, 754, 870, 857, 855, 1005, 887, + /* 180 */ 982, 982, 999, 1007, 979, 1047, 993, 918, 919, 921, + /* 190 */ 998, 922, 982, 1060, 1009, 1064, 1057, 1031, 1053, 1055, + /* 200 */ 982, 985, 985, 977, 985, 1011, 1004, 1106, 1062, 1045, + /* 210 */ 1048, 1061, 1054, 1130, 1065, 1131, 1076, 1144, 1149, 1104, + /* 220 */ 1152, 1105, 1109, 1158, 1159, 1161, 1113, 1112, 1118, 1154, + /* 230 */ 1157, 1170, 1162, 1172, 1174, 1175, 1185, 1183, 1188, 1186, + /* 240 */ 1108, 1173, 1176, 1145, 1180, 1190, 1133, 1189, 1195, 1191, + /* 250 */ 1146, 1193, 1196, 1204, 1197, 1214, 1192, 1194, 1198, 1199, + /* 260 */ 1200, 1201, 1202, 1205, 1207, 1208, 1215, 1218, 1224, 1226, + /* 270 */ 1223, 1178, 1179, 1181, 1153, 1168, 1171, 1241, 1209, 1182, + /* 280 */ 1210, 1211, 1251, 1213, 1259, 1219, 1137, 1220, 1140, 1221, + /* 290 */ 1139, 1142, 1156, 1151, 1147, 1164, 1222, 1148, 1160, 1166, + /* 300 */ 985, 1291, 1227, 1177, 1212, 1311, 1305, 1308, 1257, 1277, + /* 310 */ 1279, 1280, 1282, 1263, 1283, 1271, 1321, 1302, 1322, 1330, + /* 320 */ 1228, 1303, 1294, 1337, 1334, 1350, 1349, 1351, 1284, 1268, + /* 330 */ 1286, 1287, 1327, 1336, 1339, 1346, 1387, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 10 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 20 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 30 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 40 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 50 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 60 */ 1876, 2209, 1876, 1876, 2172, 1876, 1876, 1876, 1876, 1876, - /* 70 */ 1876, 1876, 1876, 1876, 1876, 1876, 2179, 1876, 1876, 1876, - /* 80 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 90 */ 1876, 1876, 1876, 1876, 1876, 1876, 1973, 1876, 1876, 1876, - /* 100 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 110 */ 1876, 1876, 1876, 1971, 2411, 1876, 1876, 1876, 1876, 1876, - /* 120 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 130 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2423, 1876, - /* 140 */ 1876, 1947, 1947, 1876, 2423, 2423, 2423, 1971, 2383, 2383, - /* 150 */ 1876, 1876, 1973, 2247, 1876, 1876, 1876, 1876, 1876, 1876, - /* 160 */ 1876, 1876, 2096, 1906, 1876, 1876, 1876, 1876, 2120, 1876, - /* 170 */ 1876, 1876, 2235, 1876, 1876, 2452, 2512, 1876, 1876, 2455, - /* 180 */ 1876, 1876, 1876, 1876, 2184, 1876, 2442, 1876, 1876, 1876, - /* 190 */ 1876, 1876, 1876, 1876, 1876, 1876, 2049, 2229, 1876, 1876, - /* 200 */ 1876, 2415, 2429, 2496, 2416, 2413, 2436, 1876, 2446, 1876, - /* 210 */ 2271, 1876, 2261, 1973, 1876, 1973, 2222, 2167, 1876, 2177, - /* 220 */ 1876, 2177, 2174, 1876, 1876, 1876, 2177, 2174, 2174, 2038, - /* 230 */ 2034, 1876, 2032, 1876, 1876, 1876, 1876, 1931, 1876, 1931, - /* 240 */ 1876, 1973, 1973, 1876, 1973, 1876, 1876, 1973, 1876, 1973, - /* 250 */ 1876, 1973, 1973, 1876, 1973, 1876, 1876, 1876, 1876, 1876, - /* 260 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 270 */ 1876, 1876, 1876, 1876, 2259, 2245, 1876, 1971, 1876, 2233, - /* 280 */ 2231, 1876, 1971, 2446, 1876, 1876, 2466, 2461, 2466, 2461, - /* 290 */ 2480, 2476, 2466, 2485, 2482, 2448, 2446, 2515, 2502, 2498, - /* 300 */ 2429, 1876, 1876, 2434, 2432, 1876, 1971, 1971, 2461, 1876, - /* 310 */ 1876, 1876, 1876, 2461, 1876, 1876, 1971, 1876, 1971, 1876, - /* 320 */ 1876, 2065, 1876, 1876, 1971, 1876, 1915, 1876, 2224, 2250, - /* 330 */ 2205, 2205, 2099, 2099, 2099, 1974, 1881, 1876, 1876, 1876, - /* 340 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2479, - /* 350 */ 2478, 2336, 1876, 2387, 2386, 2385, 2376, 2335, 2061, 1876, - /* 360 */ 1876, 2334, 2333, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 370 */ 1876, 2196, 2195, 2327, 1876, 1876, 2328, 2326, 2325, 1876, - /* 380 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 390 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 400 */ 1876, 1876, 1876, 2499, 2503, 1876, 1876, 1876, 1876, 1876, - /* 410 */ 1876, 2412, 1876, 1876, 1876, 2307, 1876, 1876, 1876, 1876, - /* 420 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 430 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 440 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 450 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 460 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2173, 1876, - /* 470 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 480 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 490 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 500 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 510 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 520 */ 1876, 1876, 1876, 1876, 1876, 2188, 1876, 1876, 1876, 1876, - /* 530 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 540 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 550 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1920, 2314, 1876, - /* 560 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 570 */ 1876, 1876, 2317, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 580 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 590 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 600 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 610 */ 1876, 1876, 1876, 2013, 2012, 1876, 1876, 1876, 1876, 1876, - /* 620 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 630 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2318, - /* 640 */ 1876, 1876, 1876, 1876, 1876, 2309, 1876, 1876, 1876, 1876, - /* 650 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 660 */ 1876, 1876, 2495, 2449, 1876, 1876, 1876, 1876, 1876, 1876, - /* 670 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 680 */ 1876, 1876, 2307, 1876, 2477, 1876, 1876, 2493, 1876, 2497, - /* 690 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2422, 2418, 1876, - /* 700 */ 1876, 2414, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 710 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2306, - /* 720 */ 1876, 2373, 1876, 1876, 1876, 2407, 1876, 1876, 2358, 1876, - /* 730 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 2318, 1876, - /* 740 */ 2321, 1876, 1876, 1876, 1876, 1876, 2093, 1876, 1876, 1876, - /* 750 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 760 */ 1876, 1876, 2077, 2075, 2074, 2073, 1876, 2106, 1876, 1876, - /* 770 */ 1876, 2102, 2101, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 780 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1992, - /* 790 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1984, 1876, - /* 800 */ 1983, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 810 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, - /* 820 */ 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1876, 1905, 1876, - /* 830 */ 1876, 1876, 1876, 1876, 1876, + /* 0 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 10 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 20 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 30 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 40 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 50 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 60 */ 1884, 2219, 1884, 1884, 2182, 1884, 1884, 1884, 1884, 1884, + /* 70 */ 1884, 1884, 1884, 1884, 1884, 1884, 2189, 1884, 1884, 1884, + /* 80 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 90 */ 1884, 1884, 1884, 1884, 1884, 1884, 1981, 1884, 1884, 1884, + /* 100 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 110 */ 1884, 1884, 1884, 1979, 2422, 1884, 1884, 1884, 1884, 1884, + /* 120 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 130 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2434, 1884, + /* 140 */ 1884, 1955, 1955, 1884, 2434, 2434, 2434, 1979, 2394, 2394, + /* 150 */ 1884, 1884, 1981, 2257, 1884, 1884, 1884, 1884, 1884, 1884, + /* 160 */ 1884, 1884, 2104, 1914, 1884, 1884, 1884, 1884, 2128, 1884, + /* 170 */ 1884, 1884, 2245, 1884, 1884, 2463, 2523, 1884, 1884, 2466, + /* 180 */ 1884, 1884, 1884, 1884, 2194, 1884, 2453, 1884, 1884, 1884, + /* 190 */ 1884, 1884, 1884, 1884, 1884, 1884, 2057, 2239, 1884, 1884, + /* 200 */ 1884, 2426, 2440, 2507, 2427, 2424, 2447, 1884, 2457, 1884, + /* 210 */ 2282, 1884, 2271, 1981, 1884, 1981, 2232, 2177, 1884, 2187, + /* 220 */ 1884, 2187, 2184, 1884, 1884, 1884, 2187, 2184, 2184, 2046, + /* 230 */ 2042, 1884, 2040, 1884, 1884, 1884, 1884, 1939, 1884, 1939, + /* 240 */ 1884, 1981, 1981, 1884, 1981, 1884, 1884, 1981, 1884, 1981, + /* 250 */ 1884, 1981, 1981, 1884, 1981, 1884, 1884, 1884, 1884, 1884, + /* 260 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 270 */ 1884, 1884, 1884, 1884, 2269, 2255, 1884, 1979, 1884, 2243, + /* 280 */ 2241, 1884, 1979, 2457, 1884, 1884, 2477, 2472, 2477, 2472, + /* 290 */ 2491, 2487, 2477, 2496, 2493, 2459, 2457, 2526, 2513, 2509, + /* 300 */ 2440, 1884, 1884, 2445, 2443, 1884, 1979, 1979, 2472, 1884, + /* 310 */ 1884, 1884, 1884, 2472, 1884, 1884, 1979, 1884, 1979, 1884, + /* 320 */ 1884, 2073, 1884, 1884, 1979, 1884, 1923, 1884, 2234, 2260, + /* 330 */ 2215, 2215, 2107, 2107, 2107, 1982, 1889, 1884, 1884, 1884, + /* 340 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2490, + /* 350 */ 2489, 2347, 1884, 2398, 2397, 2396, 2387, 2346, 2069, 1884, + /* 360 */ 1884, 2345, 2344, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 370 */ 1884, 2206, 2205, 2338, 1884, 1884, 2339, 2337, 2336, 1884, + /* 380 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 390 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 400 */ 1884, 1884, 1884, 2510, 2514, 1884, 1884, 1884, 1884, 1884, + /* 410 */ 1884, 2423, 1884, 1884, 1884, 2318, 1884, 1884, 1884, 1884, + /* 420 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 430 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 440 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 450 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 460 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 470 */ 2183, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 480 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 490 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 500 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 510 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 520 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 530 */ 2198, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 540 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 550 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 560 */ 1884, 1884, 1928, 2325, 1884, 1884, 1884, 1884, 1884, 1884, + /* 570 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2328, 1884, 1884, + /* 580 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 590 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 600 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 610 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2021, 2020, + /* 620 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 630 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 640 */ 1884, 1884, 1884, 1884, 2329, 1884, 1884, 1884, 1884, 1884, + /* 650 */ 2320, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 660 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2506, 2460, 1884, + /* 670 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 680 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2318, 1884, 2488, + /* 690 */ 1884, 1884, 2504, 1884, 2508, 1884, 1884, 1884, 1884, 1884, + /* 700 */ 1884, 1884, 2433, 2429, 1884, 1884, 2425, 1884, 1884, 1884, + /* 710 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 720 */ 1884, 1884, 1884, 1884, 2317, 1884, 2384, 1884, 1884, 1884, + /* 730 */ 2418, 1884, 1884, 2369, 1884, 1884, 1884, 1884, 1884, 1884, + /* 740 */ 1884, 1884, 1884, 2329, 1884, 2332, 1884, 1884, 1884, 1884, + /* 750 */ 1884, 2101, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 760 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 2085, 2083, 2082, + /* 770 */ 2081, 1884, 2114, 1884, 1884, 1884, 2110, 2109, 1884, 1884, + /* 780 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 790 */ 1884, 1884, 1884, 1884, 2000, 1884, 1884, 1884, 1884, 1884, + /* 800 */ 1884, 1884, 1884, 1992, 1884, 1991, 1884, 1884, 1884, 1884, + /* 810 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 820 */ 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, 1884, + /* 830 */ 1884, 1884, 1884, 1913, 1884, 1884, 1884, 1884, 1884, 1884, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1232,7 +1559,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 296, /* END => ABORT */ + 297, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1300,7 +1627,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ 0, /* VIEWS => nothing */ - 296, /* VIEW => ABORT */ + 297, /* VIEW => ABORT */ + 0, /* COMPACTS => nothing */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ 0, /* LIKE => nothing */ @@ -1425,55 +1753,55 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 296, /* AFTER => ABORT */ - 296, /* ATTACH => ABORT */ - 296, /* BEFORE => ABORT */ - 296, /* BEGIN => ABORT */ - 296, /* BITAND => ABORT */ - 296, /* BITNOT => ABORT */ - 296, /* BITOR => ABORT */ - 296, /* BLOCKS => ABORT */ - 296, /* CHANGE => ABORT */ - 296, /* COMMA => ABORT */ - 296, /* CONCAT => ABORT */ - 296, /* CONFLICT => ABORT */ - 296, /* COPY => ABORT */ - 296, /* DEFERRED => ABORT */ - 296, /* DELIMITERS => ABORT */ - 296, /* DETACH => ABORT */ - 296, /* DIVIDE => ABORT */ - 296, /* DOT => ABORT */ - 296, /* EACH => ABORT */ - 296, /* FAIL => ABORT */ - 296, /* FILE => ABORT */ - 296, /* FOR => ABORT */ - 296, /* GLOB => ABORT */ - 296, /* ID => ABORT */ - 296, /* IMMEDIATE => ABORT */ - 296, /* IMPORT => ABORT */ - 296, /* INITIALLY => ABORT */ - 296, /* INSTEAD => ABORT */ - 296, /* ISNULL => ABORT */ - 296, /* KEY => ABORT */ - 296, /* MODULES => ABORT */ - 296, /* NK_BITNOT => ABORT */ - 296, /* NK_SEMI => ABORT */ - 296, /* NOTNULL => ABORT */ - 296, /* OF => ABORT */ - 296, /* PLUS => ABORT */ - 296, /* PRIVILEGE => ABORT */ - 296, /* RAISE => ABORT */ - 296, /* RESTRICT => ABORT */ - 296, /* ROW => ABORT */ - 296, /* SEMI => ABORT */ - 296, /* STAR => ABORT */ - 296, /* STATEMENT => ABORT */ - 296, /* STRICT => ABORT */ - 296, /* STRING => ABORT */ - 296, /* TIMES => ABORT */ - 296, /* VALUES => ABORT */ - 296, /* VARIABLE => ABORT */ - 296, /* WAL => ABORT */ + 297, /* AFTER => ABORT */ + 297, /* ATTACH => ABORT */ + 297, /* BEFORE => ABORT */ + 297, /* BEGIN => ABORT */ + 297, /* BITAND => ABORT */ + 297, /* BITNOT => ABORT */ + 297, /* BITOR => ABORT */ + 297, /* BLOCKS => ABORT */ + 297, /* CHANGE => ABORT */ + 297, /* COMMA => ABORT */ + 297, /* CONCAT => ABORT */ + 297, /* CONFLICT => ABORT */ + 297, /* COPY => ABORT */ + 297, /* DEFERRED => ABORT */ + 297, /* DELIMITERS => ABORT */ + 297, /* DETACH => ABORT */ + 297, /* DIVIDE => ABORT */ + 297, /* DOT => ABORT */ + 297, /* EACH => ABORT */ + 297, /* FAIL => ABORT */ + 297, /* FILE => ABORT */ + 297, /* FOR => ABORT */ + 297, /* GLOB => ABORT */ + 297, /* ID => ABORT */ + 297, /* IMMEDIATE => ABORT */ + 297, /* IMPORT => ABORT */ + 297, /* INITIALLY => ABORT */ + 297, /* INSTEAD => ABORT */ + 297, /* ISNULL => ABORT */ + 297, /* KEY => ABORT */ + 297, /* MODULES => ABORT */ + 297, /* NK_BITNOT => ABORT */ + 297, /* NK_SEMI => ABORT */ + 297, /* NOTNULL => ABORT */ + 297, /* OF => ABORT */ + 297, /* PLUS => ABORT */ + 297, /* PRIVILEGE => ABORT */ + 297, /* RAISE => ABORT */ + 297, /* RESTRICT => ABORT */ + 297, /* ROW => ABORT */ + 297, /* SEMI => ABORT */ + 297, /* STAR => ABORT */ + 297, /* STATEMENT => ABORT */ + 297, /* STRICT => ABORT */ + 297, /* STRING => ABORT */ + 297, /* TIMES => ABORT */ + 297, /* VALUES => ABORT */ + 297, /* VARIABLE => ABORT */ + 297, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1525,6 +1853,7 @@ struct yyParser { }; typedef struct yyParser yyParser; +#include #ifndef NDEBUG #include static FILE *yyTraceFILE = 0; @@ -1734,340 +2063,341 @@ static const char *const yyTokenName[] = { /* 170 */ "ALIVE", /* 171 */ "VIEWS", /* 172 */ "VIEW", - /* 173 */ "NORMAL", - /* 174 */ "CHILD", - /* 175 */ "LIKE", - /* 176 */ "TBNAME", - /* 177 */ "QTAGS", - /* 178 */ "AS", - /* 179 */ "SYSTEM", - /* 180 */ "INDEX", - /* 181 */ "FUNCTION", - /* 182 */ "INTERVAL", - /* 183 */ "COUNT", - /* 184 */ "LAST_ROW", - /* 185 */ "META", - /* 186 */ "ONLY", - /* 187 */ "TOPIC", - /* 188 */ "CONSUMER", - /* 189 */ "GROUP", - /* 190 */ "DESC", - /* 191 */ "DESCRIBE", - /* 192 */ "RESET", - /* 193 */ "QUERY", - /* 194 */ "CACHE", - /* 195 */ "EXPLAIN", - /* 196 */ "ANALYZE", - /* 197 */ "VERBOSE", - /* 198 */ "NK_BOOL", - /* 199 */ "RATIO", - /* 200 */ "NK_FLOAT", - /* 201 */ "OUTPUTTYPE", - /* 202 */ "AGGREGATE", - /* 203 */ "BUFSIZE", - /* 204 */ "LANGUAGE", - /* 205 */ "REPLACE", - /* 206 */ "STREAM", - /* 207 */ "INTO", - /* 208 */ "PAUSE", - /* 209 */ "RESUME", - /* 210 */ "TRIGGER", - /* 211 */ "AT_ONCE", - /* 212 */ "WINDOW_CLOSE", - /* 213 */ "IGNORE", - /* 214 */ "EXPIRED", - /* 215 */ "FILL_HISTORY", - /* 216 */ "UPDATE", - /* 217 */ "SUBTABLE", - /* 218 */ "UNTREATED", - /* 219 */ "KILL", - /* 220 */ "CONNECTION", - /* 221 */ "TRANSACTION", - /* 222 */ "BALANCE", - /* 223 */ "VGROUP", - /* 224 */ "LEADER", - /* 225 */ "MERGE", - /* 226 */ "REDISTRIBUTE", - /* 227 */ "SPLIT", - /* 228 */ "DELETE", - /* 229 */ "INSERT", - /* 230 */ "NULL", - /* 231 */ "NK_QUESTION", - /* 232 */ "NK_ALIAS", - /* 233 */ "NK_ARROW", - /* 234 */ "ROWTS", - /* 235 */ "QSTART", - /* 236 */ "QEND", - /* 237 */ "QDURATION", - /* 238 */ "WSTART", - /* 239 */ "WEND", - /* 240 */ "WDURATION", - /* 241 */ "IROWTS", - /* 242 */ "ISFILLED", - /* 243 */ "CAST", - /* 244 */ "NOW", - /* 245 */ "TODAY", - /* 246 */ "TIMEZONE", - /* 247 */ "CLIENT_VERSION", - /* 248 */ "SERVER_VERSION", - /* 249 */ "SERVER_STATUS", - /* 250 */ "CURRENT_USER", - /* 251 */ "CASE", - /* 252 */ "WHEN", - /* 253 */ "THEN", - /* 254 */ "ELSE", - /* 255 */ "BETWEEN", - /* 256 */ "IS", - /* 257 */ "NK_LT", - /* 258 */ "NK_GT", - /* 259 */ "NK_LE", - /* 260 */ "NK_GE", - /* 261 */ "NK_NE", - /* 262 */ "MATCH", - /* 263 */ "NMATCH", - /* 264 */ "CONTAINS", - /* 265 */ "IN", - /* 266 */ "JOIN", - /* 267 */ "INNER", - /* 268 */ "SELECT", - /* 269 */ "NK_HINT", - /* 270 */ "DISTINCT", - /* 271 */ "WHERE", - /* 272 */ "PARTITION", - /* 273 */ "BY", - /* 274 */ "SESSION", - /* 275 */ "STATE_WINDOW", - /* 276 */ "EVENT_WINDOW", - /* 277 */ "SLIDING", - /* 278 */ "FILL", - /* 279 */ "VALUE", - /* 280 */ "VALUE_F", - /* 281 */ "NONE", - /* 282 */ "PREV", - /* 283 */ "NULL_F", - /* 284 */ "LINEAR", - /* 285 */ "NEXT", - /* 286 */ "HAVING", - /* 287 */ "RANGE", - /* 288 */ "EVERY", - /* 289 */ "ORDER", - /* 290 */ "SLIMIT", - /* 291 */ "SOFFSET", - /* 292 */ "LIMIT", - /* 293 */ "OFFSET", - /* 294 */ "ASC", - /* 295 */ "NULLS", - /* 296 */ "ABORT", - /* 297 */ "AFTER", - /* 298 */ "ATTACH", - /* 299 */ "BEFORE", - /* 300 */ "BEGIN", - /* 301 */ "BITAND", - /* 302 */ "BITNOT", - /* 303 */ "BITOR", - /* 304 */ "BLOCKS", - /* 305 */ "CHANGE", - /* 306 */ "COMMA", - /* 307 */ "CONCAT", - /* 308 */ "CONFLICT", - /* 309 */ "COPY", - /* 310 */ "DEFERRED", - /* 311 */ "DELIMITERS", - /* 312 */ "DETACH", - /* 313 */ "DIVIDE", - /* 314 */ "DOT", - /* 315 */ "EACH", - /* 316 */ "FAIL", - /* 317 */ "FILE", - /* 318 */ "FOR", - /* 319 */ "GLOB", - /* 320 */ "ID", - /* 321 */ "IMMEDIATE", - /* 322 */ "IMPORT", - /* 323 */ "INITIALLY", - /* 324 */ "INSTEAD", - /* 325 */ "ISNULL", - /* 326 */ "KEY", - /* 327 */ "MODULES", - /* 328 */ "NK_BITNOT", - /* 329 */ "NK_SEMI", - /* 330 */ "NOTNULL", - /* 331 */ "OF", - /* 332 */ "PLUS", - /* 333 */ "PRIVILEGE", - /* 334 */ "RAISE", - /* 335 */ "RESTRICT", - /* 336 */ "ROW", - /* 337 */ "SEMI", - /* 338 */ "STAR", - /* 339 */ "STATEMENT", - /* 340 */ "STRICT", - /* 341 */ "STRING", - /* 342 */ "TIMES", - /* 343 */ "VALUES", - /* 344 */ "VARIABLE", - /* 345 */ "WAL", - /* 346 */ "cmd", - /* 347 */ "account_options", - /* 348 */ "alter_account_options", - /* 349 */ "literal", - /* 350 */ "alter_account_option", - /* 351 */ "ip_range_list", - /* 352 */ "white_list", - /* 353 */ "white_list_opt", - /* 354 */ "user_name", - /* 355 */ "sysinfo_opt", - /* 356 */ "privileges", - /* 357 */ "priv_level", - /* 358 */ "with_opt", - /* 359 */ "priv_type_list", - /* 360 */ "priv_type", - /* 361 */ "db_name", - /* 362 */ "table_name", - /* 363 */ "topic_name", - /* 364 */ "search_condition", - /* 365 */ "dnode_endpoint", - /* 366 */ "force_opt", - /* 367 */ "unsafe_opt", - /* 368 */ "not_exists_opt", - /* 369 */ "db_options", - /* 370 */ "exists_opt", - /* 371 */ "alter_db_options", - /* 372 */ "speed_opt", - /* 373 */ "start_opt", - /* 374 */ "end_opt", - /* 375 */ "integer_list", - /* 376 */ "variable_list", - /* 377 */ "retention_list", - /* 378 */ "signed", - /* 379 */ "alter_db_option", - /* 380 */ "retention", - /* 381 */ "full_table_name", - /* 382 */ "column_def_list", - /* 383 */ "tags_def_opt", - /* 384 */ "table_options", - /* 385 */ "multi_create_clause", - /* 386 */ "tags_def", - /* 387 */ "multi_drop_clause", - /* 388 */ "alter_table_clause", - /* 389 */ "alter_table_options", - /* 390 */ "column_name", - /* 391 */ "type_name", - /* 392 */ "signed_literal", - /* 393 */ "create_subtable_clause", - /* 394 */ "specific_cols_opt", - /* 395 */ "expression_list", - /* 396 */ "drop_table_clause", - /* 397 */ "col_name_list", - /* 398 */ "column_def", - /* 399 */ "duration_list", - /* 400 */ "rollup_func_list", - /* 401 */ "alter_table_option", - /* 402 */ "duration_literal", - /* 403 */ "rollup_func_name", - /* 404 */ "function_name", - /* 405 */ "col_name", - /* 406 */ "db_kind_opt", - /* 407 */ "table_kind_db_name_cond_opt", - /* 408 */ "like_pattern_opt", - /* 409 */ "db_name_cond_opt", - /* 410 */ "table_name_cond", - /* 411 */ "from_db_opt", - /* 412 */ "tag_list_opt", - /* 413 */ "table_kind", - /* 414 */ "tag_item", - /* 415 */ "column_alias", - /* 416 */ "index_options", - /* 417 */ "full_index_name", - /* 418 */ "index_name", - /* 419 */ "func_list", - /* 420 */ "sliding_opt", - /* 421 */ "sma_stream_opt", - /* 422 */ "func", - /* 423 */ "sma_func_name", - /* 424 */ "with_meta", - /* 425 */ "query_or_subquery", - /* 426 */ "where_clause_opt", - /* 427 */ "cgroup_name", - /* 428 */ "analyze_opt", - /* 429 */ "explain_options", - /* 430 */ "insert_query", - /* 431 */ "or_replace_opt", - /* 432 */ "agg_func_opt", - /* 433 */ "bufsize_opt", - /* 434 */ "language_opt", - /* 435 */ "full_view_name", - /* 436 */ "view_name", - /* 437 */ "stream_name", - /* 438 */ "stream_options", - /* 439 */ "col_list_opt", - /* 440 */ "tag_def_or_ref_opt", - /* 441 */ "subtable_opt", - /* 442 */ "ignore_opt", - /* 443 */ "expression", - /* 444 */ "on_vgroup_id", - /* 445 */ "dnode_list", - /* 446 */ "literal_func", - /* 447 */ "literal_list", - /* 448 */ "table_alias", - /* 449 */ "expr_or_subquery", - /* 450 */ "pseudo_column", - /* 451 */ "column_reference", - /* 452 */ "function_expression", - /* 453 */ "case_when_expression", - /* 454 */ "star_func", - /* 455 */ "star_func_para_list", - /* 456 */ "noarg_func", - /* 457 */ "other_para_list", - /* 458 */ "star_func_para", - /* 459 */ "when_then_list", - /* 460 */ "case_when_else_opt", - /* 461 */ "common_expression", - /* 462 */ "when_then_expr", - /* 463 */ "predicate", - /* 464 */ "compare_op", - /* 465 */ "in_op", - /* 466 */ "in_predicate_value", - /* 467 */ "boolean_value_expression", - /* 468 */ "boolean_primary", - /* 469 */ "from_clause_opt", - /* 470 */ "table_reference_list", - /* 471 */ "table_reference", - /* 472 */ "table_primary", - /* 473 */ "joined_table", - /* 474 */ "alias_opt", - /* 475 */ "subquery", - /* 476 */ "parenthesized_joined_table", - /* 477 */ "join_type", - /* 478 */ "query_specification", - /* 479 */ "hint_list", - /* 480 */ "set_quantifier_opt", - /* 481 */ "tag_mode_opt", - /* 482 */ "select_list", - /* 483 */ "partition_by_clause_opt", - /* 484 */ "range_opt", - /* 485 */ "every_opt", - /* 486 */ "fill_opt", - /* 487 */ "twindow_clause_opt", - /* 488 */ "group_by_clause_opt", - /* 489 */ "having_clause_opt", - /* 490 */ "select_item", - /* 491 */ "partition_list", - /* 492 */ "partition_item", - /* 493 */ "interval_sliding_duration_literal", - /* 494 */ "fill_mode", - /* 495 */ "group_by_list", - /* 496 */ "query_expression", - /* 497 */ "query_simple", - /* 498 */ "order_by_clause_opt", - /* 499 */ "slimit_clause_opt", - /* 500 */ "limit_clause_opt", - /* 501 */ "union_query_expression", - /* 502 */ "query_simple_or_subquery", - /* 503 */ "sort_specification_list", - /* 504 */ "sort_specification", - /* 505 */ "ordering_specification_opt", - /* 506 */ "null_ordering_opt", + /* 173 */ "COMPACTS", + /* 174 */ "NORMAL", + /* 175 */ "CHILD", + /* 176 */ "LIKE", + /* 177 */ "TBNAME", + /* 178 */ "QTAGS", + /* 179 */ "AS", + /* 180 */ "SYSTEM", + /* 181 */ "INDEX", + /* 182 */ "FUNCTION", + /* 183 */ "INTERVAL", + /* 184 */ "COUNT", + /* 185 */ "LAST_ROW", + /* 186 */ "META", + /* 187 */ "ONLY", + /* 188 */ "TOPIC", + /* 189 */ "CONSUMER", + /* 190 */ "GROUP", + /* 191 */ "DESC", + /* 192 */ "DESCRIBE", + /* 193 */ "RESET", + /* 194 */ "QUERY", + /* 195 */ "CACHE", + /* 196 */ "EXPLAIN", + /* 197 */ "ANALYZE", + /* 198 */ "VERBOSE", + /* 199 */ "NK_BOOL", + /* 200 */ "RATIO", + /* 201 */ "NK_FLOAT", + /* 202 */ "OUTPUTTYPE", + /* 203 */ "AGGREGATE", + /* 204 */ "BUFSIZE", + /* 205 */ "LANGUAGE", + /* 206 */ "REPLACE", + /* 207 */ "STREAM", + /* 208 */ "INTO", + /* 209 */ "PAUSE", + /* 210 */ "RESUME", + /* 211 */ "TRIGGER", + /* 212 */ "AT_ONCE", + /* 213 */ "WINDOW_CLOSE", + /* 214 */ "IGNORE", + /* 215 */ "EXPIRED", + /* 216 */ "FILL_HISTORY", + /* 217 */ "UPDATE", + /* 218 */ "SUBTABLE", + /* 219 */ "UNTREATED", + /* 220 */ "KILL", + /* 221 */ "CONNECTION", + /* 222 */ "TRANSACTION", + /* 223 */ "BALANCE", + /* 224 */ "VGROUP", + /* 225 */ "LEADER", + /* 226 */ "MERGE", + /* 227 */ "REDISTRIBUTE", + /* 228 */ "SPLIT", + /* 229 */ "DELETE", + /* 230 */ "INSERT", + /* 231 */ "NULL", + /* 232 */ "NK_QUESTION", + /* 233 */ "NK_ALIAS", + /* 234 */ "NK_ARROW", + /* 235 */ "ROWTS", + /* 236 */ "QSTART", + /* 237 */ "QEND", + /* 238 */ "QDURATION", + /* 239 */ "WSTART", + /* 240 */ "WEND", + /* 241 */ "WDURATION", + /* 242 */ "IROWTS", + /* 243 */ "ISFILLED", + /* 244 */ "CAST", + /* 245 */ "NOW", + /* 246 */ "TODAY", + /* 247 */ "TIMEZONE", + /* 248 */ "CLIENT_VERSION", + /* 249 */ "SERVER_VERSION", + /* 250 */ "SERVER_STATUS", + /* 251 */ "CURRENT_USER", + /* 252 */ "CASE", + /* 253 */ "WHEN", + /* 254 */ "THEN", + /* 255 */ "ELSE", + /* 256 */ "BETWEEN", + /* 257 */ "IS", + /* 258 */ "NK_LT", + /* 259 */ "NK_GT", + /* 260 */ "NK_LE", + /* 261 */ "NK_GE", + /* 262 */ "NK_NE", + /* 263 */ "MATCH", + /* 264 */ "NMATCH", + /* 265 */ "CONTAINS", + /* 266 */ "IN", + /* 267 */ "JOIN", + /* 268 */ "INNER", + /* 269 */ "SELECT", + /* 270 */ "NK_HINT", + /* 271 */ "DISTINCT", + /* 272 */ "WHERE", + /* 273 */ "PARTITION", + /* 274 */ "BY", + /* 275 */ "SESSION", + /* 276 */ "STATE_WINDOW", + /* 277 */ "EVENT_WINDOW", + /* 278 */ "SLIDING", + /* 279 */ "FILL", + /* 280 */ "VALUE", + /* 281 */ "VALUE_F", + /* 282 */ "NONE", + /* 283 */ "PREV", + /* 284 */ "NULL_F", + /* 285 */ "LINEAR", + /* 286 */ "NEXT", + /* 287 */ "HAVING", + /* 288 */ "RANGE", + /* 289 */ "EVERY", + /* 290 */ "ORDER", + /* 291 */ "SLIMIT", + /* 292 */ "SOFFSET", + /* 293 */ "LIMIT", + /* 294 */ "OFFSET", + /* 295 */ "ASC", + /* 296 */ "NULLS", + /* 297 */ "ABORT", + /* 298 */ "AFTER", + /* 299 */ "ATTACH", + /* 300 */ "BEFORE", + /* 301 */ "BEGIN", + /* 302 */ "BITAND", + /* 303 */ "BITNOT", + /* 304 */ "BITOR", + /* 305 */ "BLOCKS", + /* 306 */ "CHANGE", + /* 307 */ "COMMA", + /* 308 */ "CONCAT", + /* 309 */ "CONFLICT", + /* 310 */ "COPY", + /* 311 */ "DEFERRED", + /* 312 */ "DELIMITERS", + /* 313 */ "DETACH", + /* 314 */ "DIVIDE", + /* 315 */ "DOT", + /* 316 */ "EACH", + /* 317 */ "FAIL", + /* 318 */ "FILE", + /* 319 */ "FOR", + /* 320 */ "GLOB", + /* 321 */ "ID", + /* 322 */ "IMMEDIATE", + /* 323 */ "IMPORT", + /* 324 */ "INITIALLY", + /* 325 */ "INSTEAD", + /* 326 */ "ISNULL", + /* 327 */ "KEY", + /* 328 */ "MODULES", + /* 329 */ "NK_BITNOT", + /* 330 */ "NK_SEMI", + /* 331 */ "NOTNULL", + /* 332 */ "OF", + /* 333 */ "PLUS", + /* 334 */ "PRIVILEGE", + /* 335 */ "RAISE", + /* 336 */ "RESTRICT", + /* 337 */ "ROW", + /* 338 */ "SEMI", + /* 339 */ "STAR", + /* 340 */ "STATEMENT", + /* 341 */ "STRICT", + /* 342 */ "STRING", + /* 343 */ "TIMES", + /* 344 */ "VALUES", + /* 345 */ "VARIABLE", + /* 346 */ "WAL", + /* 347 */ "cmd", + /* 348 */ "account_options", + /* 349 */ "alter_account_options", + /* 350 */ "literal", + /* 351 */ "alter_account_option", + /* 352 */ "ip_range_list", + /* 353 */ "white_list", + /* 354 */ "white_list_opt", + /* 355 */ "user_name", + /* 356 */ "sysinfo_opt", + /* 357 */ "privileges", + /* 358 */ "priv_level", + /* 359 */ "with_opt", + /* 360 */ "priv_type_list", + /* 361 */ "priv_type", + /* 362 */ "db_name", + /* 363 */ "table_name", + /* 364 */ "topic_name", + /* 365 */ "search_condition", + /* 366 */ "dnode_endpoint", + /* 367 */ "force_opt", + /* 368 */ "unsafe_opt", + /* 369 */ "not_exists_opt", + /* 370 */ "db_options", + /* 371 */ "exists_opt", + /* 372 */ "alter_db_options", + /* 373 */ "speed_opt", + /* 374 */ "start_opt", + /* 375 */ "end_opt", + /* 376 */ "integer_list", + /* 377 */ "variable_list", + /* 378 */ "retention_list", + /* 379 */ "signed", + /* 380 */ "alter_db_option", + /* 381 */ "retention", + /* 382 */ "full_table_name", + /* 383 */ "column_def_list", + /* 384 */ "tags_def_opt", + /* 385 */ "table_options", + /* 386 */ "multi_create_clause", + /* 387 */ "tags_def", + /* 388 */ "multi_drop_clause", + /* 389 */ "alter_table_clause", + /* 390 */ "alter_table_options", + /* 391 */ "column_name", + /* 392 */ "type_name", + /* 393 */ "signed_literal", + /* 394 */ "create_subtable_clause", + /* 395 */ "specific_cols_opt", + /* 396 */ "expression_list", + /* 397 */ "drop_table_clause", + /* 398 */ "col_name_list", + /* 399 */ "column_def", + /* 400 */ "duration_list", + /* 401 */ "rollup_func_list", + /* 402 */ "alter_table_option", + /* 403 */ "duration_literal", + /* 404 */ "rollup_func_name", + /* 405 */ "function_name", + /* 406 */ "col_name", + /* 407 */ "db_kind_opt", + /* 408 */ "table_kind_db_name_cond_opt", + /* 409 */ "like_pattern_opt", + /* 410 */ "db_name_cond_opt", + /* 411 */ "table_name_cond", + /* 412 */ "from_db_opt", + /* 413 */ "tag_list_opt", + /* 414 */ "table_kind", + /* 415 */ "tag_item", + /* 416 */ "column_alias", + /* 417 */ "index_options", + /* 418 */ "full_index_name", + /* 419 */ "index_name", + /* 420 */ "func_list", + /* 421 */ "sliding_opt", + /* 422 */ "sma_stream_opt", + /* 423 */ "func", + /* 424 */ "sma_func_name", + /* 425 */ "with_meta", + /* 426 */ "query_or_subquery", + /* 427 */ "where_clause_opt", + /* 428 */ "cgroup_name", + /* 429 */ "analyze_opt", + /* 430 */ "explain_options", + /* 431 */ "insert_query", + /* 432 */ "or_replace_opt", + /* 433 */ "agg_func_opt", + /* 434 */ "bufsize_opt", + /* 435 */ "language_opt", + /* 436 */ "full_view_name", + /* 437 */ "view_name", + /* 438 */ "stream_name", + /* 439 */ "stream_options", + /* 440 */ "col_list_opt", + /* 441 */ "tag_def_or_ref_opt", + /* 442 */ "subtable_opt", + /* 443 */ "ignore_opt", + /* 444 */ "expression", + /* 445 */ "on_vgroup_id", + /* 446 */ "dnode_list", + /* 447 */ "literal_func", + /* 448 */ "literal_list", + /* 449 */ "table_alias", + /* 450 */ "expr_or_subquery", + /* 451 */ "pseudo_column", + /* 452 */ "column_reference", + /* 453 */ "function_expression", + /* 454 */ "case_when_expression", + /* 455 */ "star_func", + /* 456 */ "star_func_para_list", + /* 457 */ "noarg_func", + /* 458 */ "other_para_list", + /* 459 */ "star_func_para", + /* 460 */ "when_then_list", + /* 461 */ "case_when_else_opt", + /* 462 */ "common_expression", + /* 463 */ "when_then_expr", + /* 464 */ "predicate", + /* 465 */ "compare_op", + /* 466 */ "in_op", + /* 467 */ "in_predicate_value", + /* 468 */ "boolean_value_expression", + /* 469 */ "boolean_primary", + /* 470 */ "from_clause_opt", + /* 471 */ "table_reference_list", + /* 472 */ "table_reference", + /* 473 */ "table_primary", + /* 474 */ "joined_table", + /* 475 */ "alias_opt", + /* 476 */ "subquery", + /* 477 */ "parenthesized_joined_table", + /* 478 */ "join_type", + /* 479 */ "query_specification", + /* 480 */ "hint_list", + /* 481 */ "set_quantifier_opt", + /* 482 */ "tag_mode_opt", + /* 483 */ "select_list", + /* 484 */ "partition_by_clause_opt", + /* 485 */ "range_opt", + /* 486 */ "every_opt", + /* 487 */ "fill_opt", + /* 488 */ "twindow_clause_opt", + /* 489 */ "group_by_clause_opt", + /* 490 */ "having_clause_opt", + /* 491 */ "select_item", + /* 492 */ "partition_list", + /* 493 */ "partition_item", + /* 494 */ "interval_sliding_duration_literal", + /* 495 */ "fill_mode", + /* 496 */ "group_by_list", + /* 497 */ "query_expression", + /* 498 */ "query_simple", + /* 499 */ "order_by_clause_opt", + /* 500 */ "slimit_clause_opt", + /* 501 */ "limit_clause_opt", + /* 502 */ "union_query_expression", + /* 503 */ "query_simple_or_subquery", + /* 504 */ "sort_specification_list", + /* 505 */ "sort_specification", + /* 506 */ "ordering_specification_opt", + /* 507 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2362,358 +2692,361 @@ static const char *const yyRuleName[] = { /* 284 */ "cmd ::= SHOW CLUSTER ALIVE", /* 285 */ "cmd ::= SHOW db_name_cond_opt VIEWS", /* 286 */ "cmd ::= SHOW CREATE VIEW full_table_name", - /* 287 */ "table_kind_db_name_cond_opt ::=", - /* 288 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 289 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 290 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 291 */ "table_kind ::= NORMAL", - /* 292 */ "table_kind ::= CHILD", - /* 293 */ "db_name_cond_opt ::=", - /* 294 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 295 */ "like_pattern_opt ::=", - /* 296 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 297 */ "table_name_cond ::= table_name", - /* 298 */ "from_db_opt ::=", - /* 299 */ "from_db_opt ::= FROM db_name", - /* 300 */ "tag_list_opt ::=", - /* 301 */ "tag_list_opt ::= tag_item", - /* 302 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 303 */ "tag_item ::= TBNAME", - /* 304 */ "tag_item ::= QTAGS", - /* 305 */ "tag_item ::= column_name", - /* 306 */ "tag_item ::= column_name column_alias", - /* 307 */ "tag_item ::= column_name AS column_alias", - /* 308 */ "db_kind_opt ::=", - /* 309 */ "db_kind_opt ::= USER", - /* 310 */ "db_kind_opt ::= SYSTEM", - /* 311 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 312 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 313 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 314 */ "full_index_name ::= index_name", - /* 315 */ "full_index_name ::= db_name NK_DOT index_name", - /* 316 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 317 */ "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", - /* 318 */ "func_list ::= func", - /* 319 */ "func_list ::= func_list NK_COMMA func", - /* 320 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 321 */ "sma_func_name ::= function_name", - /* 322 */ "sma_func_name ::= COUNT", - /* 323 */ "sma_func_name ::= FIRST", - /* 324 */ "sma_func_name ::= LAST", - /* 325 */ "sma_func_name ::= LAST_ROW", - /* 326 */ "sma_stream_opt ::=", - /* 327 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 328 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 329 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 330 */ "with_meta ::= AS", - /* 331 */ "with_meta ::= WITH META AS", - /* 332 */ "with_meta ::= ONLY META AS", - /* 333 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 334 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 335 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 336 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 337 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 338 */ "cmd ::= DESC full_table_name", - /* 339 */ "cmd ::= DESCRIBE full_table_name", - /* 340 */ "cmd ::= RESET QUERY CACHE", - /* 341 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 342 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 343 */ "analyze_opt ::=", - /* 344 */ "analyze_opt ::= ANALYZE", - /* 345 */ "explain_options ::=", - /* 346 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 347 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 348 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 349 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 350 */ "agg_func_opt ::=", - /* 351 */ "agg_func_opt ::= AGGREGATE", - /* 352 */ "bufsize_opt ::=", - /* 353 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 354 */ "language_opt ::=", - /* 355 */ "language_opt ::= LANGUAGE NK_STRING", - /* 356 */ "or_replace_opt ::=", - /* 357 */ "or_replace_opt ::= OR REPLACE", - /* 358 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", - /* 359 */ "cmd ::= DROP VIEW exists_opt full_view_name", - /* 360 */ "full_view_name ::= view_name", - /* 361 */ "full_view_name ::= db_name NK_DOT view_name", - /* 362 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 363 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 364 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 365 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 366 */ "col_list_opt ::=", - /* 367 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 368 */ "tag_def_or_ref_opt ::=", - /* 369 */ "tag_def_or_ref_opt ::= tags_def", - /* 370 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 371 */ "stream_options ::=", - /* 372 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 373 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 374 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 375 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 376 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 377 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 378 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 379 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 380 */ "subtable_opt ::=", - /* 381 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 382 */ "ignore_opt ::=", - /* 383 */ "ignore_opt ::= IGNORE UNTREATED", - /* 384 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 385 */ "cmd ::= KILL QUERY NK_STRING", - /* 386 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 387 */ "cmd ::= BALANCE VGROUP", - /* 388 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 389 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 390 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 391 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 392 */ "on_vgroup_id ::=", - /* 393 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 394 */ "dnode_list ::= DNODE NK_INTEGER", - /* 395 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 396 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 397 */ "cmd ::= query_or_subquery", - /* 398 */ "cmd ::= insert_query", - /* 399 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 400 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 401 */ "literal ::= NK_INTEGER", - /* 402 */ "literal ::= NK_FLOAT", - /* 403 */ "literal ::= NK_STRING", - /* 404 */ "literal ::= NK_BOOL", - /* 405 */ "literal ::= TIMESTAMP NK_STRING", - /* 406 */ "literal ::= duration_literal", - /* 407 */ "literal ::= NULL", - /* 408 */ "literal ::= NK_QUESTION", - /* 409 */ "duration_literal ::= NK_VARIABLE", - /* 410 */ "signed ::= NK_INTEGER", - /* 411 */ "signed ::= NK_PLUS NK_INTEGER", - /* 412 */ "signed ::= NK_MINUS NK_INTEGER", - /* 413 */ "signed ::= NK_FLOAT", - /* 414 */ "signed ::= NK_PLUS NK_FLOAT", - /* 415 */ "signed ::= NK_MINUS NK_FLOAT", - /* 416 */ "signed_literal ::= signed", - /* 417 */ "signed_literal ::= NK_STRING", - /* 418 */ "signed_literal ::= NK_BOOL", - /* 419 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 420 */ "signed_literal ::= duration_literal", - /* 421 */ "signed_literal ::= NULL", - /* 422 */ "signed_literal ::= literal_func", - /* 423 */ "signed_literal ::= NK_QUESTION", - /* 424 */ "literal_list ::= signed_literal", - /* 425 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 426 */ "db_name ::= NK_ID", - /* 427 */ "table_name ::= NK_ID", - /* 428 */ "column_name ::= NK_ID", - /* 429 */ "function_name ::= NK_ID", - /* 430 */ "view_name ::= NK_ID", - /* 431 */ "table_alias ::= NK_ID", - /* 432 */ "column_alias ::= NK_ID", - /* 433 */ "column_alias ::= NK_ALIAS", - /* 434 */ "user_name ::= NK_ID", - /* 435 */ "topic_name ::= NK_ID", - /* 436 */ "stream_name ::= NK_ID", - /* 437 */ "cgroup_name ::= NK_ID", - /* 438 */ "index_name ::= NK_ID", - /* 439 */ "expr_or_subquery ::= expression", - /* 440 */ "expression ::= literal", - /* 441 */ "expression ::= pseudo_column", - /* 442 */ "expression ::= column_reference", - /* 443 */ "expression ::= function_expression", - /* 444 */ "expression ::= case_when_expression", - /* 445 */ "expression ::= NK_LP expression NK_RP", - /* 446 */ "expression ::= NK_PLUS expr_or_subquery", - /* 447 */ "expression ::= NK_MINUS expr_or_subquery", - /* 448 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 449 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 450 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 451 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 452 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 453 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 454 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 455 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 456 */ "expression_list ::= expr_or_subquery", - /* 457 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 458 */ "column_reference ::= column_name", - /* 459 */ "column_reference ::= table_name NK_DOT column_name", - /* 460 */ "column_reference ::= NK_ALIAS", - /* 461 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 462 */ "pseudo_column ::= ROWTS", - /* 463 */ "pseudo_column ::= TBNAME", - /* 464 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 465 */ "pseudo_column ::= QSTART", - /* 466 */ "pseudo_column ::= QEND", - /* 467 */ "pseudo_column ::= QDURATION", - /* 468 */ "pseudo_column ::= WSTART", - /* 469 */ "pseudo_column ::= WEND", - /* 470 */ "pseudo_column ::= WDURATION", - /* 471 */ "pseudo_column ::= IROWTS", - /* 472 */ "pseudo_column ::= ISFILLED", - /* 473 */ "pseudo_column ::= QTAGS", - /* 474 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 475 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 476 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 477 */ "function_expression ::= literal_func", - /* 478 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 479 */ "literal_func ::= NOW", - /* 480 */ "noarg_func ::= NOW", - /* 481 */ "noarg_func ::= TODAY", - /* 482 */ "noarg_func ::= TIMEZONE", - /* 483 */ "noarg_func ::= DATABASE", - /* 484 */ "noarg_func ::= CLIENT_VERSION", - /* 485 */ "noarg_func ::= SERVER_VERSION", - /* 486 */ "noarg_func ::= SERVER_STATUS", - /* 487 */ "noarg_func ::= CURRENT_USER", - /* 488 */ "noarg_func ::= USER", - /* 489 */ "star_func ::= COUNT", - /* 490 */ "star_func ::= FIRST", - /* 491 */ "star_func ::= LAST", - /* 492 */ "star_func ::= LAST_ROW", - /* 493 */ "star_func_para_list ::= NK_STAR", - /* 494 */ "star_func_para_list ::= other_para_list", - /* 495 */ "other_para_list ::= star_func_para", - /* 496 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 497 */ "star_func_para ::= expr_or_subquery", - /* 498 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 499 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 500 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 501 */ "when_then_list ::= when_then_expr", - /* 502 */ "when_then_list ::= when_then_list when_then_expr", - /* 503 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 504 */ "case_when_else_opt ::=", - /* 505 */ "case_when_else_opt ::= ELSE common_expression", - /* 506 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 507 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 508 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 509 */ "predicate ::= expr_or_subquery IS NULL", - /* 510 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 511 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 512 */ "compare_op ::= NK_LT", - /* 513 */ "compare_op ::= NK_GT", - /* 514 */ "compare_op ::= NK_LE", - /* 515 */ "compare_op ::= NK_GE", - /* 516 */ "compare_op ::= NK_NE", - /* 517 */ "compare_op ::= NK_EQ", - /* 518 */ "compare_op ::= LIKE", - /* 519 */ "compare_op ::= NOT LIKE", - /* 520 */ "compare_op ::= MATCH", - /* 521 */ "compare_op ::= NMATCH", - /* 522 */ "compare_op ::= CONTAINS", - /* 523 */ "in_op ::= IN", - /* 524 */ "in_op ::= NOT IN", - /* 525 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 526 */ "boolean_value_expression ::= boolean_primary", - /* 527 */ "boolean_value_expression ::= NOT boolean_primary", - /* 528 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 529 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 530 */ "boolean_primary ::= predicate", - /* 531 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 532 */ "common_expression ::= expr_or_subquery", - /* 533 */ "common_expression ::= boolean_value_expression", - /* 534 */ "from_clause_opt ::=", - /* 535 */ "from_clause_opt ::= FROM table_reference_list", - /* 536 */ "table_reference_list ::= table_reference", - /* 537 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 538 */ "table_reference ::= table_primary", - /* 539 */ "table_reference ::= joined_table", - /* 540 */ "table_primary ::= table_name alias_opt", - /* 541 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 542 */ "table_primary ::= subquery alias_opt", - /* 543 */ "table_primary ::= parenthesized_joined_table", - /* 544 */ "alias_opt ::=", - /* 545 */ "alias_opt ::= table_alias", - /* 546 */ "alias_opt ::= AS table_alias", - /* 547 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 548 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 549 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 550 */ "join_type ::=", - /* 551 */ "join_type ::= INNER", - /* 552 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 553 */ "hint_list ::=", - /* 554 */ "hint_list ::= NK_HINT", - /* 555 */ "tag_mode_opt ::=", - /* 556 */ "tag_mode_opt ::= TAGS", - /* 557 */ "set_quantifier_opt ::=", - /* 558 */ "set_quantifier_opt ::= DISTINCT", - /* 559 */ "set_quantifier_opt ::= ALL", - /* 560 */ "select_list ::= select_item", - /* 561 */ "select_list ::= select_list NK_COMMA select_item", - /* 562 */ "select_item ::= NK_STAR", - /* 563 */ "select_item ::= common_expression", - /* 564 */ "select_item ::= common_expression column_alias", - /* 565 */ "select_item ::= common_expression AS column_alias", - /* 566 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 567 */ "where_clause_opt ::=", - /* 568 */ "where_clause_opt ::= WHERE search_condition", - /* 569 */ "partition_by_clause_opt ::=", - /* 570 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 571 */ "partition_list ::= partition_item", - /* 572 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 573 */ "partition_item ::= expr_or_subquery", - /* 574 */ "partition_item ::= expr_or_subquery column_alias", - /* 575 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 576 */ "twindow_clause_opt ::=", - /* 577 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 578 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 579 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 580 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 581 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 582 */ "sliding_opt ::=", - /* 583 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 584 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 585 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 586 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 587 */ "fill_opt ::=", - /* 588 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 589 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 590 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 591 */ "fill_mode ::= NONE", - /* 592 */ "fill_mode ::= PREV", - /* 593 */ "fill_mode ::= NULL", - /* 594 */ "fill_mode ::= NULL_F", - /* 595 */ "fill_mode ::= LINEAR", - /* 596 */ "fill_mode ::= NEXT", - /* 597 */ "group_by_clause_opt ::=", - /* 598 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 599 */ "group_by_list ::= expr_or_subquery", - /* 600 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 601 */ "having_clause_opt ::=", - /* 602 */ "having_clause_opt ::= HAVING search_condition", - /* 603 */ "range_opt ::=", - /* 604 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 605 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 606 */ "every_opt ::=", - /* 607 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 608 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 609 */ "query_simple ::= query_specification", - /* 610 */ "query_simple ::= union_query_expression", - /* 611 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 612 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 613 */ "query_simple_or_subquery ::= query_simple", - /* 614 */ "query_simple_or_subquery ::= subquery", - /* 615 */ "query_or_subquery ::= query_expression", - /* 616 */ "query_or_subquery ::= subquery", - /* 617 */ "order_by_clause_opt ::=", - /* 618 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 619 */ "slimit_clause_opt ::=", - /* 620 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 621 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 622 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 623 */ "limit_clause_opt ::=", - /* 624 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 625 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 626 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 627 */ "subquery ::= NK_LP query_expression NK_RP", - /* 628 */ "subquery ::= NK_LP subquery NK_RP", - /* 629 */ "search_condition ::= common_expression", - /* 630 */ "sort_specification_list ::= sort_specification", - /* 631 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 632 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 633 */ "ordering_specification_opt ::=", - /* 634 */ "ordering_specification_opt ::= ASC", - /* 635 */ "ordering_specification_opt ::= DESC", - /* 636 */ "null_ordering_opt ::=", - /* 637 */ "null_ordering_opt ::= NULLS FIRST", - /* 638 */ "null_ordering_opt ::= NULLS LAST", + /* 287 */ "cmd ::= SHOW COMPACTS", + /* 288 */ "cmd ::= SHOW COMPACT NK_INTEGER", + /* 289 */ "table_kind_db_name_cond_opt ::=", + /* 290 */ "table_kind_db_name_cond_opt ::= table_kind", + /* 291 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", + /* 292 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", + /* 293 */ "table_kind ::= NORMAL", + /* 294 */ "table_kind ::= CHILD", + /* 295 */ "db_name_cond_opt ::=", + /* 296 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 297 */ "like_pattern_opt ::=", + /* 298 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 299 */ "table_name_cond ::= table_name", + /* 300 */ "from_db_opt ::=", + /* 301 */ "from_db_opt ::= FROM db_name", + /* 302 */ "tag_list_opt ::=", + /* 303 */ "tag_list_opt ::= tag_item", + /* 304 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 305 */ "tag_item ::= TBNAME", + /* 306 */ "tag_item ::= QTAGS", + /* 307 */ "tag_item ::= column_name", + /* 308 */ "tag_item ::= column_name column_alias", + /* 309 */ "tag_item ::= column_name AS column_alias", + /* 310 */ "db_kind_opt ::=", + /* 311 */ "db_kind_opt ::= USER", + /* 312 */ "db_kind_opt ::= SYSTEM", + /* 313 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 314 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 315 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 316 */ "full_index_name ::= index_name", + /* 317 */ "full_index_name ::= db_name NK_DOT index_name", + /* 318 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 319 */ "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", + /* 320 */ "func_list ::= func", + /* 321 */ "func_list ::= func_list NK_COMMA func", + /* 322 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 323 */ "sma_func_name ::= function_name", + /* 324 */ "sma_func_name ::= COUNT", + /* 325 */ "sma_func_name ::= FIRST", + /* 326 */ "sma_func_name ::= LAST", + /* 327 */ "sma_func_name ::= LAST_ROW", + /* 328 */ "sma_stream_opt ::=", + /* 329 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 330 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 331 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 332 */ "with_meta ::= AS", + /* 333 */ "with_meta ::= WITH META AS", + /* 334 */ "with_meta ::= ONLY META AS", + /* 335 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 336 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 337 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 338 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 339 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 340 */ "cmd ::= DESC full_table_name", + /* 341 */ "cmd ::= DESCRIBE full_table_name", + /* 342 */ "cmd ::= RESET QUERY CACHE", + /* 343 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 344 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 345 */ "analyze_opt ::=", + /* 346 */ "analyze_opt ::= ANALYZE", + /* 347 */ "explain_options ::=", + /* 348 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 349 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 350 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 351 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 352 */ "agg_func_opt ::=", + /* 353 */ "agg_func_opt ::= AGGREGATE", + /* 354 */ "bufsize_opt ::=", + /* 355 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 356 */ "language_opt ::=", + /* 357 */ "language_opt ::= LANGUAGE NK_STRING", + /* 358 */ "or_replace_opt ::=", + /* 359 */ "or_replace_opt ::= OR REPLACE", + /* 360 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 361 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 362 */ "full_view_name ::= view_name", + /* 363 */ "full_view_name ::= db_name NK_DOT view_name", + /* 364 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 365 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 366 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 367 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 368 */ "col_list_opt ::=", + /* 369 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 370 */ "tag_def_or_ref_opt ::=", + /* 371 */ "tag_def_or_ref_opt ::= tags_def", + /* 372 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", + /* 373 */ "stream_options ::=", + /* 374 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 375 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 376 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 377 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 378 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 379 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 380 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 381 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 382 */ "subtable_opt ::=", + /* 383 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 384 */ "ignore_opt ::=", + /* 385 */ "ignore_opt ::= IGNORE UNTREATED", + /* 386 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 387 */ "cmd ::= KILL QUERY NK_STRING", + /* 388 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 389 */ "cmd ::= KILL COMPACT NK_INTEGER", + /* 390 */ "cmd ::= BALANCE VGROUP", + /* 391 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 392 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 393 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 394 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 395 */ "on_vgroup_id ::=", + /* 396 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 397 */ "dnode_list ::= DNODE NK_INTEGER", + /* 398 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 399 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 400 */ "cmd ::= query_or_subquery", + /* 401 */ "cmd ::= insert_query", + /* 402 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 403 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 404 */ "literal ::= NK_INTEGER", + /* 405 */ "literal ::= NK_FLOAT", + /* 406 */ "literal ::= NK_STRING", + /* 407 */ "literal ::= NK_BOOL", + /* 408 */ "literal ::= TIMESTAMP NK_STRING", + /* 409 */ "literal ::= duration_literal", + /* 410 */ "literal ::= NULL", + /* 411 */ "literal ::= NK_QUESTION", + /* 412 */ "duration_literal ::= NK_VARIABLE", + /* 413 */ "signed ::= NK_INTEGER", + /* 414 */ "signed ::= NK_PLUS NK_INTEGER", + /* 415 */ "signed ::= NK_MINUS NK_INTEGER", + /* 416 */ "signed ::= NK_FLOAT", + /* 417 */ "signed ::= NK_PLUS NK_FLOAT", + /* 418 */ "signed ::= NK_MINUS NK_FLOAT", + /* 419 */ "signed_literal ::= signed", + /* 420 */ "signed_literal ::= NK_STRING", + /* 421 */ "signed_literal ::= NK_BOOL", + /* 422 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 423 */ "signed_literal ::= duration_literal", + /* 424 */ "signed_literal ::= NULL", + /* 425 */ "signed_literal ::= literal_func", + /* 426 */ "signed_literal ::= NK_QUESTION", + /* 427 */ "literal_list ::= signed_literal", + /* 428 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 429 */ "db_name ::= NK_ID", + /* 430 */ "table_name ::= NK_ID", + /* 431 */ "column_name ::= NK_ID", + /* 432 */ "function_name ::= NK_ID", + /* 433 */ "view_name ::= NK_ID", + /* 434 */ "table_alias ::= NK_ID", + /* 435 */ "column_alias ::= NK_ID", + /* 436 */ "column_alias ::= NK_ALIAS", + /* 437 */ "user_name ::= NK_ID", + /* 438 */ "topic_name ::= NK_ID", + /* 439 */ "stream_name ::= NK_ID", + /* 440 */ "cgroup_name ::= NK_ID", + /* 441 */ "index_name ::= NK_ID", + /* 442 */ "expr_or_subquery ::= expression", + /* 443 */ "expression ::= literal", + /* 444 */ "expression ::= pseudo_column", + /* 445 */ "expression ::= column_reference", + /* 446 */ "expression ::= function_expression", + /* 447 */ "expression ::= case_when_expression", + /* 448 */ "expression ::= NK_LP expression NK_RP", + /* 449 */ "expression ::= NK_PLUS expr_or_subquery", + /* 450 */ "expression ::= NK_MINUS expr_or_subquery", + /* 451 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 452 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 453 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 454 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 455 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 456 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 457 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 458 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 459 */ "expression_list ::= expr_or_subquery", + /* 460 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 461 */ "column_reference ::= column_name", + /* 462 */ "column_reference ::= table_name NK_DOT column_name", + /* 463 */ "column_reference ::= NK_ALIAS", + /* 464 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 465 */ "pseudo_column ::= ROWTS", + /* 466 */ "pseudo_column ::= TBNAME", + /* 467 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 468 */ "pseudo_column ::= QSTART", + /* 469 */ "pseudo_column ::= QEND", + /* 470 */ "pseudo_column ::= QDURATION", + /* 471 */ "pseudo_column ::= WSTART", + /* 472 */ "pseudo_column ::= WEND", + /* 473 */ "pseudo_column ::= WDURATION", + /* 474 */ "pseudo_column ::= IROWTS", + /* 475 */ "pseudo_column ::= ISFILLED", + /* 476 */ "pseudo_column ::= QTAGS", + /* 477 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 478 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 479 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 480 */ "function_expression ::= literal_func", + /* 481 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 482 */ "literal_func ::= NOW", + /* 483 */ "noarg_func ::= NOW", + /* 484 */ "noarg_func ::= TODAY", + /* 485 */ "noarg_func ::= TIMEZONE", + /* 486 */ "noarg_func ::= DATABASE", + /* 487 */ "noarg_func ::= CLIENT_VERSION", + /* 488 */ "noarg_func ::= SERVER_VERSION", + /* 489 */ "noarg_func ::= SERVER_STATUS", + /* 490 */ "noarg_func ::= CURRENT_USER", + /* 491 */ "noarg_func ::= USER", + /* 492 */ "star_func ::= COUNT", + /* 493 */ "star_func ::= FIRST", + /* 494 */ "star_func ::= LAST", + /* 495 */ "star_func ::= LAST_ROW", + /* 496 */ "star_func_para_list ::= NK_STAR", + /* 497 */ "star_func_para_list ::= other_para_list", + /* 498 */ "other_para_list ::= star_func_para", + /* 499 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 500 */ "star_func_para ::= expr_or_subquery", + /* 501 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 502 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 503 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 504 */ "when_then_list ::= when_then_expr", + /* 505 */ "when_then_list ::= when_then_list when_then_expr", + /* 506 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 507 */ "case_when_else_opt ::=", + /* 508 */ "case_when_else_opt ::= ELSE common_expression", + /* 509 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 510 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 511 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 512 */ "predicate ::= expr_or_subquery IS NULL", + /* 513 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 514 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 515 */ "compare_op ::= NK_LT", + /* 516 */ "compare_op ::= NK_GT", + /* 517 */ "compare_op ::= NK_LE", + /* 518 */ "compare_op ::= NK_GE", + /* 519 */ "compare_op ::= NK_NE", + /* 520 */ "compare_op ::= NK_EQ", + /* 521 */ "compare_op ::= LIKE", + /* 522 */ "compare_op ::= NOT LIKE", + /* 523 */ "compare_op ::= MATCH", + /* 524 */ "compare_op ::= NMATCH", + /* 525 */ "compare_op ::= CONTAINS", + /* 526 */ "in_op ::= IN", + /* 527 */ "in_op ::= NOT IN", + /* 528 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 529 */ "boolean_value_expression ::= boolean_primary", + /* 530 */ "boolean_value_expression ::= NOT boolean_primary", + /* 531 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 532 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 533 */ "boolean_primary ::= predicate", + /* 534 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 535 */ "common_expression ::= expr_or_subquery", + /* 536 */ "common_expression ::= boolean_value_expression", + /* 537 */ "from_clause_opt ::=", + /* 538 */ "from_clause_opt ::= FROM table_reference_list", + /* 539 */ "table_reference_list ::= table_reference", + /* 540 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 541 */ "table_reference ::= table_primary", + /* 542 */ "table_reference ::= joined_table", + /* 543 */ "table_primary ::= table_name alias_opt", + /* 544 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 545 */ "table_primary ::= subquery alias_opt", + /* 546 */ "table_primary ::= parenthesized_joined_table", + /* 547 */ "alias_opt ::=", + /* 548 */ "alias_opt ::= table_alias", + /* 549 */ "alias_opt ::= AS table_alias", + /* 550 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 551 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 552 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 553 */ "join_type ::=", + /* 554 */ "join_type ::= INNER", + /* 555 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 556 */ "hint_list ::=", + /* 557 */ "hint_list ::= NK_HINT", + /* 558 */ "tag_mode_opt ::=", + /* 559 */ "tag_mode_opt ::= TAGS", + /* 560 */ "set_quantifier_opt ::=", + /* 561 */ "set_quantifier_opt ::= DISTINCT", + /* 562 */ "set_quantifier_opt ::= ALL", + /* 563 */ "select_list ::= select_item", + /* 564 */ "select_list ::= select_list NK_COMMA select_item", + /* 565 */ "select_item ::= NK_STAR", + /* 566 */ "select_item ::= common_expression", + /* 567 */ "select_item ::= common_expression column_alias", + /* 568 */ "select_item ::= common_expression AS column_alias", + /* 569 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 570 */ "where_clause_opt ::=", + /* 571 */ "where_clause_opt ::= WHERE search_condition", + /* 572 */ "partition_by_clause_opt ::=", + /* 573 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 574 */ "partition_list ::= partition_item", + /* 575 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 576 */ "partition_item ::= expr_or_subquery", + /* 577 */ "partition_item ::= expr_or_subquery column_alias", + /* 578 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 579 */ "twindow_clause_opt ::=", + /* 580 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 581 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 582 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 583 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 584 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 585 */ "sliding_opt ::=", + /* 586 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 587 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 588 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 589 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 590 */ "fill_opt ::=", + /* 591 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 592 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 593 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 594 */ "fill_mode ::= NONE", + /* 595 */ "fill_mode ::= PREV", + /* 596 */ "fill_mode ::= NULL", + /* 597 */ "fill_mode ::= NULL_F", + /* 598 */ "fill_mode ::= LINEAR", + /* 599 */ "fill_mode ::= NEXT", + /* 600 */ "group_by_clause_opt ::=", + /* 601 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 602 */ "group_by_list ::= expr_or_subquery", + /* 603 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 604 */ "having_clause_opt ::=", + /* 605 */ "having_clause_opt ::= HAVING search_condition", + /* 606 */ "range_opt ::=", + /* 607 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 608 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 609 */ "every_opt ::=", + /* 610 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 611 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 612 */ "query_simple ::= query_specification", + /* 613 */ "query_simple ::= union_query_expression", + /* 614 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 615 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 616 */ "query_simple_or_subquery ::= query_simple", + /* 617 */ "query_simple_or_subquery ::= subquery", + /* 618 */ "query_or_subquery ::= query_expression", + /* 619 */ "query_or_subquery ::= subquery", + /* 620 */ "order_by_clause_opt ::=", + /* 621 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 622 */ "slimit_clause_opt ::=", + /* 623 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 624 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 625 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 626 */ "limit_clause_opt ::=", + /* 627 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 628 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 629 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 630 */ "subquery ::= NK_LP query_expression NK_RP", + /* 631 */ "subquery ::= NK_LP subquery NK_RP", + /* 632 */ "search_condition ::= common_expression", + /* 633 */ "sort_specification_list ::= sort_specification", + /* 634 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 635 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 636 */ "ordering_specification_opt ::=", + /* 637 */ "ordering_specification_opt ::= ASC", + /* 638 */ "ordering_specification_opt ::= DESC", + /* 639 */ "null_ordering_opt ::=", + /* 640 */ "null_ordering_opt ::= NULLS FIRST", + /* 641 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2840,233 +3173,267 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 346: /* cmd */ - case 349: /* literal */ - case 358: /* with_opt */ - case 364: /* search_condition */ - case 369: /* db_options */ - case 371: /* alter_db_options */ - case 373: /* start_opt */ - case 374: /* end_opt */ - case 378: /* signed */ - case 380: /* retention */ - case 381: /* full_table_name */ - case 384: /* table_options */ - case 388: /* alter_table_clause */ - case 389: /* alter_table_options */ - case 392: /* signed_literal */ - case 393: /* create_subtable_clause */ - case 396: /* drop_table_clause */ - case 398: /* column_def */ - case 402: /* duration_literal */ - case 403: /* rollup_func_name */ - case 405: /* col_name */ - case 408: /* like_pattern_opt */ - case 409: /* db_name_cond_opt */ - case 410: /* table_name_cond */ - case 411: /* from_db_opt */ - case 414: /* tag_item */ - case 416: /* index_options */ - case 417: /* full_index_name */ - case 420: /* sliding_opt */ - case 421: /* sma_stream_opt */ - case 422: /* func */ - case 425: /* query_or_subquery */ - case 426: /* where_clause_opt */ - case 429: /* explain_options */ - case 430: /* insert_query */ - case 435: /* full_view_name */ - case 438: /* stream_options */ - case 441: /* subtable_opt */ - case 443: /* expression */ - case 446: /* literal_func */ - case 449: /* expr_or_subquery */ - case 450: /* pseudo_column */ - case 451: /* column_reference */ - case 452: /* function_expression */ - case 453: /* case_when_expression */ - case 458: /* star_func_para */ - case 460: /* case_when_else_opt */ - case 461: /* common_expression */ - case 462: /* when_then_expr */ - case 463: /* predicate */ - case 466: /* in_predicate_value */ - case 467: /* boolean_value_expression */ - case 468: /* boolean_primary */ - case 469: /* from_clause_opt */ - case 470: /* table_reference_list */ - case 471: /* table_reference */ - case 472: /* table_primary */ - case 473: /* joined_table */ - case 475: /* subquery */ - case 476: /* parenthesized_joined_table */ - case 478: /* query_specification */ - case 484: /* range_opt */ - case 485: /* every_opt */ - case 486: /* fill_opt */ - case 487: /* twindow_clause_opt */ - case 489: /* having_clause_opt */ - case 490: /* select_item */ - case 492: /* partition_item */ - case 493: /* interval_sliding_duration_literal */ - case 496: /* query_expression */ - case 497: /* query_simple */ - case 499: /* slimit_clause_opt */ - case 500: /* limit_clause_opt */ - case 501: /* union_query_expression */ - case 502: /* query_simple_or_subquery */ - case 504: /* sort_specification */ + case 347: /* cmd */ + case 350: /* literal */ + case 359: /* with_opt */ + case 365: /* search_condition */ + case 370: /* db_options */ + case 372: /* alter_db_options */ + case 374: /* start_opt */ + case 375: /* end_opt */ + case 379: /* signed */ + case 381: /* retention */ + case 382: /* full_table_name */ + case 385: /* table_options */ + case 389: /* alter_table_clause */ + case 390: /* alter_table_options */ + case 393: /* signed_literal */ + case 394: /* create_subtable_clause */ + case 397: /* drop_table_clause */ + case 399: /* column_def */ + case 403: /* duration_literal */ + case 404: /* rollup_func_name */ + case 406: /* col_name */ + case 409: /* like_pattern_opt */ + case 410: /* db_name_cond_opt */ + case 411: /* table_name_cond */ + case 412: /* from_db_opt */ + case 415: /* tag_item */ + case 417: /* index_options */ + case 418: /* full_index_name */ + case 421: /* sliding_opt */ + case 422: /* sma_stream_opt */ + case 423: /* func */ + case 426: /* query_or_subquery */ + case 427: /* where_clause_opt */ + case 430: /* explain_options */ + case 431: /* insert_query */ + case 436: /* full_view_name */ + case 439: /* stream_options */ + case 442: /* subtable_opt */ + case 444: /* expression */ + case 447: /* literal_func */ + case 450: /* expr_or_subquery */ + case 451: /* pseudo_column */ + case 452: /* column_reference */ + case 453: /* function_expression */ + case 454: /* case_when_expression */ + case 459: /* star_func_para */ + case 461: /* case_when_else_opt */ + case 462: /* common_expression */ + case 463: /* when_then_expr */ + case 464: /* predicate */ + case 467: /* in_predicate_value */ + case 468: /* boolean_value_expression */ + case 469: /* boolean_primary */ + case 470: /* from_clause_opt */ + case 471: /* table_reference_list */ + case 472: /* table_reference */ + case 473: /* table_primary */ + case 474: /* joined_table */ + case 476: /* subquery */ + case 477: /* parenthesized_joined_table */ + case 479: /* query_specification */ + case 485: /* range_opt */ + case 486: /* every_opt */ + case 487: /* fill_opt */ + case 488: /* twindow_clause_opt */ + case 490: /* having_clause_opt */ + case 491: /* select_item */ + case 493: /* partition_item */ + case 494: /* interval_sliding_duration_literal */ + case 497: /* query_expression */ + case 498: /* query_simple */ + case 500: /* slimit_clause_opt */ + case 501: /* limit_clause_opt */ + case 502: /* union_query_expression */ + case 503: /* query_simple_or_subquery */ + case 505: /* sort_specification */ { - nodesDestroyNode((yypminor->yy80)); +#line 7 "sql.y" + nodesDestroyNode((yypminor->yy232)); +#line 3255 "sql.c" } break; - case 347: /* account_options */ - case 348: /* alter_account_options */ - case 350: /* alter_account_option */ - case 372: /* speed_opt */ - case 424: /* with_meta */ - case 433: /* bufsize_opt */ + case 348: /* account_options */ + case 349: /* alter_account_options */ + case 351: /* alter_account_option */ + case 373: /* speed_opt */ + case 425: /* with_meta */ + case 434: /* bufsize_opt */ { +#line 54 "sql.y" +#line 3267 "sql.c" } break; - case 351: /* ip_range_list */ - case 352: /* white_list */ - case 353: /* white_list_opt */ - case 375: /* integer_list */ - case 376: /* variable_list */ - case 377: /* retention_list */ - case 382: /* column_def_list */ - case 383: /* tags_def_opt */ - case 385: /* multi_create_clause */ - case 386: /* tags_def */ - case 387: /* multi_drop_clause */ - case 394: /* specific_cols_opt */ - case 395: /* expression_list */ - case 397: /* col_name_list */ - case 399: /* duration_list */ - case 400: /* rollup_func_list */ - case 412: /* tag_list_opt */ - case 419: /* func_list */ - case 439: /* col_list_opt */ - case 440: /* tag_def_or_ref_opt */ - case 445: /* dnode_list */ - case 447: /* literal_list */ - case 455: /* star_func_para_list */ - case 457: /* other_para_list */ - case 459: /* when_then_list */ - case 479: /* hint_list */ - case 482: /* select_list */ - case 483: /* partition_by_clause_opt */ - case 488: /* group_by_clause_opt */ - case 491: /* partition_list */ - case 495: /* group_by_list */ - case 498: /* order_by_clause_opt */ - case 503: /* sort_specification_list */ + case 352: /* ip_range_list */ + case 353: /* white_list */ + case 354: /* white_list_opt */ + case 376: /* integer_list */ + case 377: /* variable_list */ + case 378: /* retention_list */ + case 383: /* column_def_list */ + case 384: /* tags_def_opt */ + case 386: /* multi_create_clause */ + case 387: /* tags_def */ + case 388: /* multi_drop_clause */ + case 395: /* specific_cols_opt */ + case 396: /* expression_list */ + case 398: /* col_name_list */ + case 400: /* duration_list */ + case 401: /* rollup_func_list */ + case 413: /* tag_list_opt */ + case 420: /* func_list */ + case 440: /* col_list_opt */ + case 441: /* tag_def_or_ref_opt */ + case 446: /* dnode_list */ + case 448: /* literal_list */ + case 456: /* star_func_para_list */ + case 458: /* other_para_list */ + case 460: /* when_then_list */ + case 480: /* hint_list */ + case 483: /* select_list */ + case 484: /* partition_by_clause_opt */ + case 489: /* group_by_clause_opt */ + case 492: /* partition_list */ + case 496: /* group_by_list */ + case 499: /* order_by_clause_opt */ + case 504: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy106)); +#line 85 "sql.y" + nodesDestroyList((yypminor->yy88)); +#line 3306 "sql.c" } break; - case 354: /* user_name */ - case 361: /* db_name */ - case 362: /* table_name */ - case 363: /* topic_name */ - case 365: /* dnode_endpoint */ - case 390: /* column_name */ - case 404: /* function_name */ - case 415: /* column_alias */ - case 418: /* index_name */ - case 423: /* sma_func_name */ - case 427: /* cgroup_name */ - case 434: /* language_opt */ - case 436: /* view_name */ - case 437: /* stream_name */ - case 444: /* on_vgroup_id */ - case 448: /* table_alias */ - case 454: /* star_func */ - case 456: /* noarg_func */ - case 474: /* alias_opt */ + case 355: /* user_name */ + case 362: /* db_name */ + case 363: /* table_name */ + case 364: /* topic_name */ + case 366: /* dnode_endpoint */ + case 391: /* column_name */ + case 405: /* function_name */ + case 416: /* column_alias */ + case 419: /* index_name */ + case 424: /* sma_func_name */ + case 428: /* cgroup_name */ + case 435: /* language_opt */ + case 437: /* view_name */ + case 438: /* stream_name */ + case 445: /* on_vgroup_id */ + case 449: /* table_alias */ + case 455: /* star_func */ + case 457: /* noarg_func */ + case 475: /* alias_opt */ { +#line 812 "sql.y" +#line 3331 "sql.c" } break; - case 355: /* sysinfo_opt */ + case 356: /* sysinfo_opt */ { +#line 112 "sql.y" +#line 3338 "sql.c" } break; - case 356: /* privileges */ - case 359: /* priv_type_list */ - case 360: /* priv_type */ + case 357: /* privileges */ + case 360: /* priv_type_list */ + case 361: /* priv_type */ { +#line 121 "sql.y" +#line 3347 "sql.c" } break; - case 357: /* priv_level */ + case 358: /* priv_level */ { +#line 138 "sql.y" +#line 3354 "sql.c" } break; - case 366: /* force_opt */ - case 367: /* unsafe_opt */ - case 368: /* not_exists_opt */ - case 370: /* exists_opt */ - case 428: /* analyze_opt */ - case 431: /* or_replace_opt */ - case 432: /* agg_func_opt */ - case 442: /* ignore_opt */ - case 480: /* set_quantifier_opt */ - case 481: /* tag_mode_opt */ + case 367: /* force_opt */ + case 368: /* unsafe_opt */ + case 369: /* not_exists_opt */ + case 371: /* exists_opt */ + case 429: /* analyze_opt */ + case 432: /* or_replace_opt */ + case 433: /* agg_func_opt */ + case 443: /* ignore_opt */ + case 481: /* set_quantifier_opt */ + case 482: /* tag_mode_opt */ { +#line 167 "sql.y" +#line 3370 "sql.c" } break; - case 379: /* alter_db_option */ - case 401: /* alter_table_option */ + case 380: /* alter_db_option */ + case 402: /* alter_table_option */ { +#line 265 "sql.y" +#line 3378 "sql.c" } break; - case 391: /* type_name */ + case 392: /* type_name */ { +#line 388 "sql.y" +#line 3385 "sql.c" } break; - case 406: /* db_kind_opt */ - case 413: /* table_kind */ + case 407: /* db_kind_opt */ + case 414: /* table_kind */ { +#line 553 "sql.y" +#line 3393 "sql.c" } break; - case 407: /* table_kind_db_name_cond_opt */ + case 408: /* table_kind_db_name_cond_opt */ { +#line 518 "sql.y" +#line 3400 "sql.c" } break; - case 464: /* compare_op */ - case 465: /* in_op */ + case 465: /* compare_op */ + case 466: /* in_op */ { +#line 1002 "sql.y" +#line 3408 "sql.c" } break; - case 477: /* join_type */ + case 478: /* join_type */ { +#line 1078 "sql.y" +#line 3415 "sql.c" } break; - case 494: /* fill_mode */ + case 495: /* fill_mode */ { +#line 1169 "sql.y" +#line 3422 "sql.c" } break; - case 505: /* ordering_specification_opt */ + case 506: /* ordering_specification_opt */ { +#line 1254 "sql.y" +#line 3429 "sql.c" } break; - case 506: /* null_ordering_opt */ + case 507: /* null_ordering_opt */ { +#line 1260 "sql.y" +#line 3436 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3233,7 +3600,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -3355,645 +3722,648 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 346, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 346, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 347, /* (2) account_options ::= */ - 347, /* (3) account_options ::= account_options PPS literal */ - 347, /* (4) account_options ::= account_options TSERIES literal */ - 347, /* (5) account_options ::= account_options STORAGE literal */ - 347, /* (6) account_options ::= account_options STREAMS literal */ - 347, /* (7) account_options ::= account_options QTIME literal */ - 347, /* (8) account_options ::= account_options DBS literal */ - 347, /* (9) account_options ::= account_options USERS literal */ - 347, /* (10) account_options ::= account_options CONNS literal */ - 347, /* (11) account_options ::= account_options STATE literal */ - 348, /* (12) alter_account_options ::= alter_account_option */ - 348, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 350, /* (14) alter_account_option ::= PASS literal */ - 350, /* (15) alter_account_option ::= PPS literal */ - 350, /* (16) alter_account_option ::= TSERIES literal */ - 350, /* (17) alter_account_option ::= STORAGE literal */ - 350, /* (18) alter_account_option ::= STREAMS literal */ - 350, /* (19) alter_account_option ::= QTIME literal */ - 350, /* (20) alter_account_option ::= DBS literal */ - 350, /* (21) alter_account_option ::= USERS literal */ - 350, /* (22) alter_account_option ::= CONNS literal */ - 350, /* (23) alter_account_option ::= STATE literal */ - 351, /* (24) ip_range_list ::= NK_STRING */ - 351, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 352, /* (26) white_list ::= HOST ip_range_list */ - 353, /* (27) white_list_opt ::= */ - 353, /* (28) white_list_opt ::= white_list */ - 346, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 346, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 346, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 346, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 346, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 346, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 346, /* (35) cmd ::= DROP USER user_name */ - 355, /* (36) sysinfo_opt ::= */ - 355, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 346, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 346, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 356, /* (40) privileges ::= ALL */ - 356, /* (41) privileges ::= priv_type_list */ - 356, /* (42) privileges ::= SUBSCRIBE */ - 359, /* (43) priv_type_list ::= priv_type */ - 359, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 360, /* (45) priv_type ::= READ */ - 360, /* (46) priv_type ::= WRITE */ - 360, /* (47) priv_type ::= ALTER */ - 357, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 357, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ - 357, /* (50) priv_level ::= db_name NK_DOT table_name */ - 357, /* (51) priv_level ::= topic_name */ - 358, /* (52) with_opt ::= */ - 358, /* (53) with_opt ::= WITH search_condition */ - 346, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ - 346, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 346, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 346, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 346, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 346, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 346, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 346, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 346, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ - 346, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 346, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ - 365, /* (65) dnode_endpoint ::= NK_STRING */ - 365, /* (66) dnode_endpoint ::= NK_ID */ - 365, /* (67) dnode_endpoint ::= NK_IPTOKEN */ - 366, /* (68) force_opt ::= */ - 366, /* (69) force_opt ::= FORCE */ - 367, /* (70) unsafe_opt ::= UNSAFE */ - 346, /* (71) cmd ::= ALTER LOCAL NK_STRING */ - 346, /* (72) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 346, /* (73) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 346, /* (74) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 346, /* (75) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 346, /* (76) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 346, /* (77) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 346, /* (78) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 346, /* (79) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 346, /* (80) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 346, /* (81) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 346, /* (82) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 346, /* (83) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 346, /* (84) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 346, /* (85) cmd ::= DROP DATABASE exists_opt db_name */ - 346, /* (86) cmd ::= USE db_name */ - 346, /* (87) cmd ::= ALTER DATABASE db_name alter_db_options */ - 346, /* (88) cmd ::= FLUSH DATABASE db_name */ - 346, /* (89) cmd ::= TRIM DATABASE db_name speed_opt */ - 346, /* (90) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 368, /* (91) not_exists_opt ::= IF NOT EXISTS */ - 368, /* (92) not_exists_opt ::= */ - 370, /* (93) exists_opt ::= IF EXISTS */ - 370, /* (94) exists_opt ::= */ - 369, /* (95) db_options ::= */ - 369, /* (96) db_options ::= db_options BUFFER NK_INTEGER */ - 369, /* (97) db_options ::= db_options CACHEMODEL NK_STRING */ - 369, /* (98) db_options ::= db_options CACHESIZE NK_INTEGER */ - 369, /* (99) db_options ::= db_options COMP NK_INTEGER */ - 369, /* (100) db_options ::= db_options DURATION NK_INTEGER */ - 369, /* (101) db_options ::= db_options DURATION NK_VARIABLE */ - 369, /* (102) db_options ::= db_options MAXROWS NK_INTEGER */ - 369, /* (103) db_options ::= db_options MINROWS NK_INTEGER */ - 369, /* (104) db_options ::= db_options KEEP integer_list */ - 369, /* (105) db_options ::= db_options KEEP variable_list */ - 369, /* (106) db_options ::= db_options PAGES NK_INTEGER */ - 369, /* (107) db_options ::= db_options PAGESIZE NK_INTEGER */ - 369, /* (108) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 369, /* (109) db_options ::= db_options PRECISION NK_STRING */ - 369, /* (110) db_options ::= db_options REPLICA NK_INTEGER */ - 369, /* (111) db_options ::= db_options VGROUPS NK_INTEGER */ - 369, /* (112) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 369, /* (113) db_options ::= db_options RETENTIONS retention_list */ - 369, /* (114) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 369, /* (115) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 369, /* (116) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 369, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 369, /* (118) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 369, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 369, /* (120) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 369, /* (121) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 369, /* (122) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 369, /* (123) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 369, /* (124) db_options ::= db_options TABLE_PREFIX signed */ - 369, /* (125) db_options ::= db_options TABLE_SUFFIX signed */ - 369, /* (126) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 371, /* (127) alter_db_options ::= alter_db_option */ - 371, /* (128) alter_db_options ::= alter_db_options alter_db_option */ - 379, /* (129) alter_db_option ::= BUFFER NK_INTEGER */ - 379, /* (130) alter_db_option ::= CACHEMODEL NK_STRING */ - 379, /* (131) alter_db_option ::= CACHESIZE NK_INTEGER */ - 379, /* (132) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 379, /* (133) alter_db_option ::= KEEP integer_list */ - 379, /* (134) alter_db_option ::= KEEP variable_list */ - 379, /* (135) alter_db_option ::= PAGES NK_INTEGER */ - 379, /* (136) alter_db_option ::= REPLICA NK_INTEGER */ - 379, /* (137) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 379, /* (138) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 379, /* (139) alter_db_option ::= MINROWS NK_INTEGER */ - 379, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 379, /* (141) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 379, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 379, /* (143) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 379, /* (144) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 375, /* (145) integer_list ::= NK_INTEGER */ - 375, /* (146) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 376, /* (147) variable_list ::= NK_VARIABLE */ - 376, /* (148) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 377, /* (149) retention_list ::= retention */ - 377, /* (150) retention_list ::= retention_list NK_COMMA retention */ - 380, /* (151) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 380, /* (152) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 372, /* (153) speed_opt ::= */ - 372, /* (154) speed_opt ::= BWLIMIT NK_INTEGER */ - 373, /* (155) start_opt ::= */ - 373, /* (156) start_opt ::= START WITH NK_INTEGER */ - 373, /* (157) start_opt ::= START WITH NK_STRING */ - 373, /* (158) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 374, /* (159) end_opt ::= */ - 374, /* (160) end_opt ::= END WITH NK_INTEGER */ - 374, /* (161) end_opt ::= END WITH NK_STRING */ - 374, /* (162) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 346, /* (163) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 346, /* (164) cmd ::= CREATE TABLE multi_create_clause */ - 346, /* (165) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 346, /* (166) cmd ::= DROP TABLE multi_drop_clause */ - 346, /* (167) cmd ::= DROP STABLE exists_opt full_table_name */ - 346, /* (168) cmd ::= ALTER TABLE alter_table_clause */ - 346, /* (169) cmd ::= ALTER STABLE alter_table_clause */ - 388, /* (170) alter_table_clause ::= full_table_name alter_table_options */ - 388, /* (171) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 388, /* (172) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 388, /* (173) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 388, /* (174) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 388, /* (175) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 388, /* (176) alter_table_clause ::= full_table_name DROP TAG column_name */ - 388, /* (177) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 388, /* (178) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 388, /* (179) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - 385, /* (180) multi_create_clause ::= create_subtable_clause */ - 385, /* (181) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 393, /* (182) 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 */ - 387, /* (183) multi_drop_clause ::= drop_table_clause */ - 387, /* (184) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 396, /* (185) drop_table_clause ::= exists_opt full_table_name */ - 394, /* (186) specific_cols_opt ::= */ - 394, /* (187) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 381, /* (188) full_table_name ::= table_name */ - 381, /* (189) full_table_name ::= db_name NK_DOT table_name */ - 382, /* (190) column_def_list ::= column_def */ - 382, /* (191) column_def_list ::= column_def_list NK_COMMA column_def */ - 398, /* (192) column_def ::= column_name type_name */ - 391, /* (193) type_name ::= BOOL */ - 391, /* (194) type_name ::= TINYINT */ - 391, /* (195) type_name ::= SMALLINT */ - 391, /* (196) type_name ::= INT */ - 391, /* (197) type_name ::= INTEGER */ - 391, /* (198) type_name ::= BIGINT */ - 391, /* (199) type_name ::= FLOAT */ - 391, /* (200) type_name ::= DOUBLE */ - 391, /* (201) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 391, /* (202) type_name ::= TIMESTAMP */ - 391, /* (203) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 391, /* (204) type_name ::= TINYINT UNSIGNED */ - 391, /* (205) type_name ::= SMALLINT UNSIGNED */ - 391, /* (206) type_name ::= INT UNSIGNED */ - 391, /* (207) type_name ::= BIGINT UNSIGNED */ - 391, /* (208) type_name ::= JSON */ - 391, /* (209) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 391, /* (210) type_name ::= MEDIUMBLOB */ - 391, /* (211) type_name ::= BLOB */ - 391, /* (212) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 391, /* (213) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 391, /* (214) type_name ::= DECIMAL */ - 391, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 391, /* (216) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 383, /* (217) tags_def_opt ::= */ - 383, /* (218) tags_def_opt ::= tags_def */ - 386, /* (219) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 384, /* (220) table_options ::= */ - 384, /* (221) table_options ::= table_options COMMENT NK_STRING */ - 384, /* (222) table_options ::= table_options MAX_DELAY duration_list */ - 384, /* (223) table_options ::= table_options WATERMARK duration_list */ - 384, /* (224) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 384, /* (225) table_options ::= table_options TTL NK_INTEGER */ - 384, /* (226) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 384, /* (227) table_options ::= table_options DELETE_MARK duration_list */ - 389, /* (228) alter_table_options ::= alter_table_option */ - 389, /* (229) alter_table_options ::= alter_table_options alter_table_option */ - 401, /* (230) alter_table_option ::= COMMENT NK_STRING */ - 401, /* (231) alter_table_option ::= TTL NK_INTEGER */ - 399, /* (232) duration_list ::= duration_literal */ - 399, /* (233) duration_list ::= duration_list NK_COMMA duration_literal */ - 400, /* (234) rollup_func_list ::= rollup_func_name */ - 400, /* (235) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 403, /* (236) rollup_func_name ::= function_name */ - 403, /* (237) rollup_func_name ::= FIRST */ - 403, /* (238) rollup_func_name ::= LAST */ - 397, /* (239) col_name_list ::= col_name */ - 397, /* (240) col_name_list ::= col_name_list NK_COMMA col_name */ - 405, /* (241) col_name ::= column_name */ - 346, /* (242) cmd ::= SHOW DNODES */ - 346, /* (243) cmd ::= SHOW USERS */ - 346, /* (244) cmd ::= SHOW USER PRIVILEGES */ - 346, /* (245) cmd ::= SHOW db_kind_opt DATABASES */ - 346, /* (246) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 346, /* (247) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 346, /* (248) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 346, /* (249) cmd ::= SHOW MNODES */ - 346, /* (250) cmd ::= SHOW QNODES */ - 346, /* (251) cmd ::= SHOW FUNCTIONS */ - 346, /* (252) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 346, /* (253) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 346, /* (254) cmd ::= SHOW STREAMS */ - 346, /* (255) cmd ::= SHOW ACCOUNTS */ - 346, /* (256) cmd ::= SHOW APPS */ - 346, /* (257) cmd ::= SHOW CONNECTIONS */ - 346, /* (258) cmd ::= SHOW LICENCES */ - 346, /* (259) cmd ::= SHOW GRANTS */ - 346, /* (260) cmd ::= SHOW CREATE DATABASE db_name */ - 346, /* (261) cmd ::= SHOW CREATE TABLE full_table_name */ - 346, /* (262) cmd ::= SHOW CREATE STABLE full_table_name */ - 346, /* (263) cmd ::= SHOW QUERIES */ - 346, /* (264) cmd ::= SHOW SCORES */ - 346, /* (265) cmd ::= SHOW TOPICS */ - 346, /* (266) cmd ::= SHOW VARIABLES */ - 346, /* (267) cmd ::= SHOW CLUSTER VARIABLES */ - 346, /* (268) cmd ::= SHOW LOCAL VARIABLES */ - 346, /* (269) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 346, /* (270) cmd ::= SHOW BNODES */ - 346, /* (271) cmd ::= SHOW SNODES */ - 346, /* (272) cmd ::= SHOW CLUSTER */ - 346, /* (273) cmd ::= SHOW TRANSACTIONS */ - 346, /* (274) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 346, /* (275) cmd ::= SHOW CONSUMERS */ - 346, /* (276) cmd ::= SHOW SUBSCRIPTIONS */ - 346, /* (277) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 346, /* (278) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 346, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 346, /* (280) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 346, /* (281) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 346, /* (282) cmd ::= SHOW VNODES */ - 346, /* (283) cmd ::= SHOW db_name_cond_opt ALIVE */ - 346, /* (284) cmd ::= SHOW CLUSTER ALIVE */ - 346, /* (285) cmd ::= SHOW db_name_cond_opt VIEWS */ - 346, /* (286) cmd ::= SHOW CREATE VIEW full_table_name */ - 407, /* (287) table_kind_db_name_cond_opt ::= */ - 407, /* (288) table_kind_db_name_cond_opt ::= table_kind */ - 407, /* (289) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 407, /* (290) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 413, /* (291) table_kind ::= NORMAL */ - 413, /* (292) table_kind ::= CHILD */ - 409, /* (293) db_name_cond_opt ::= */ - 409, /* (294) db_name_cond_opt ::= db_name NK_DOT */ - 408, /* (295) like_pattern_opt ::= */ - 408, /* (296) like_pattern_opt ::= LIKE NK_STRING */ - 410, /* (297) table_name_cond ::= table_name */ - 411, /* (298) from_db_opt ::= */ - 411, /* (299) from_db_opt ::= FROM db_name */ - 412, /* (300) tag_list_opt ::= */ - 412, /* (301) tag_list_opt ::= tag_item */ - 412, /* (302) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 414, /* (303) tag_item ::= TBNAME */ - 414, /* (304) tag_item ::= QTAGS */ - 414, /* (305) tag_item ::= column_name */ - 414, /* (306) tag_item ::= column_name column_alias */ - 414, /* (307) tag_item ::= column_name AS column_alias */ - 406, /* (308) db_kind_opt ::= */ - 406, /* (309) db_kind_opt ::= USER */ - 406, /* (310) db_kind_opt ::= SYSTEM */ - 346, /* (311) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 346, /* (312) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 346, /* (313) cmd ::= DROP INDEX exists_opt full_index_name */ - 417, /* (314) full_index_name ::= index_name */ - 417, /* (315) full_index_name ::= db_name NK_DOT index_name */ - 416, /* (316) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 416, /* (317) 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 */ - 419, /* (318) func_list ::= func */ - 419, /* (319) func_list ::= func_list NK_COMMA func */ - 422, /* (320) func ::= sma_func_name NK_LP expression_list NK_RP */ - 423, /* (321) sma_func_name ::= function_name */ - 423, /* (322) sma_func_name ::= COUNT */ - 423, /* (323) sma_func_name ::= FIRST */ - 423, /* (324) sma_func_name ::= LAST */ - 423, /* (325) sma_func_name ::= LAST_ROW */ - 421, /* (326) sma_stream_opt ::= */ - 421, /* (327) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 421, /* (328) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 421, /* (329) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 424, /* (330) with_meta ::= AS */ - 424, /* (331) with_meta ::= WITH META AS */ - 424, /* (332) with_meta ::= ONLY META AS */ - 346, /* (333) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 346, /* (334) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 346, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 346, /* (336) cmd ::= DROP TOPIC exists_opt topic_name */ - 346, /* (337) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 346, /* (338) cmd ::= DESC full_table_name */ - 346, /* (339) cmd ::= DESCRIBE full_table_name */ - 346, /* (340) cmd ::= RESET QUERY CACHE */ - 346, /* (341) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 346, /* (342) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 428, /* (343) analyze_opt ::= */ - 428, /* (344) analyze_opt ::= ANALYZE */ - 429, /* (345) explain_options ::= */ - 429, /* (346) explain_options ::= explain_options VERBOSE NK_BOOL */ - 429, /* (347) explain_options ::= explain_options RATIO NK_FLOAT */ - 346, /* (348) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - 346, /* (349) cmd ::= DROP FUNCTION exists_opt function_name */ - 432, /* (350) agg_func_opt ::= */ - 432, /* (351) agg_func_opt ::= AGGREGATE */ - 433, /* (352) bufsize_opt ::= */ - 433, /* (353) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 434, /* (354) language_opt ::= */ - 434, /* (355) language_opt ::= LANGUAGE NK_STRING */ - 431, /* (356) or_replace_opt ::= */ - 431, /* (357) or_replace_opt ::= OR REPLACE */ - 346, /* (358) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 346, /* (359) cmd ::= DROP VIEW exists_opt full_view_name */ - 435, /* (360) full_view_name ::= view_name */ - 435, /* (361) full_view_name ::= db_name NK_DOT view_name */ - 346, /* (362) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - 346, /* (363) cmd ::= DROP STREAM exists_opt stream_name */ - 346, /* (364) cmd ::= PAUSE STREAM exists_opt stream_name */ - 346, /* (365) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 439, /* (366) col_list_opt ::= */ - 439, /* (367) col_list_opt ::= NK_LP col_name_list NK_RP */ - 440, /* (368) tag_def_or_ref_opt ::= */ - 440, /* (369) tag_def_or_ref_opt ::= tags_def */ - 440, /* (370) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 438, /* (371) stream_options ::= */ - 438, /* (372) stream_options ::= stream_options TRIGGER AT_ONCE */ - 438, /* (373) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 438, /* (374) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 438, /* (375) stream_options ::= stream_options WATERMARK duration_literal */ - 438, /* (376) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 438, /* (377) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 438, /* (378) stream_options ::= stream_options DELETE_MARK duration_literal */ - 438, /* (379) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 441, /* (380) subtable_opt ::= */ - 441, /* (381) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 442, /* (382) ignore_opt ::= */ - 442, /* (383) ignore_opt ::= IGNORE UNTREATED */ - 346, /* (384) cmd ::= KILL CONNECTION NK_INTEGER */ - 346, /* (385) cmd ::= KILL QUERY NK_STRING */ - 346, /* (386) cmd ::= KILL TRANSACTION NK_INTEGER */ - 346, /* (387) cmd ::= BALANCE VGROUP */ - 346, /* (388) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 346, /* (389) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 346, /* (390) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 346, /* (391) cmd ::= SPLIT VGROUP NK_INTEGER */ - 444, /* (392) on_vgroup_id ::= */ - 444, /* (393) on_vgroup_id ::= ON NK_INTEGER */ - 445, /* (394) dnode_list ::= DNODE NK_INTEGER */ - 445, /* (395) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 346, /* (396) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 346, /* (397) cmd ::= query_or_subquery */ - 346, /* (398) cmd ::= insert_query */ - 430, /* (399) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 430, /* (400) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 349, /* (401) literal ::= NK_INTEGER */ - 349, /* (402) literal ::= NK_FLOAT */ - 349, /* (403) literal ::= NK_STRING */ - 349, /* (404) literal ::= NK_BOOL */ - 349, /* (405) literal ::= TIMESTAMP NK_STRING */ - 349, /* (406) literal ::= duration_literal */ - 349, /* (407) literal ::= NULL */ - 349, /* (408) literal ::= NK_QUESTION */ - 402, /* (409) duration_literal ::= NK_VARIABLE */ - 378, /* (410) signed ::= NK_INTEGER */ - 378, /* (411) signed ::= NK_PLUS NK_INTEGER */ - 378, /* (412) signed ::= NK_MINUS NK_INTEGER */ - 378, /* (413) signed ::= NK_FLOAT */ - 378, /* (414) signed ::= NK_PLUS NK_FLOAT */ - 378, /* (415) signed ::= NK_MINUS NK_FLOAT */ - 392, /* (416) signed_literal ::= signed */ - 392, /* (417) signed_literal ::= NK_STRING */ - 392, /* (418) signed_literal ::= NK_BOOL */ - 392, /* (419) signed_literal ::= TIMESTAMP NK_STRING */ - 392, /* (420) signed_literal ::= duration_literal */ - 392, /* (421) signed_literal ::= NULL */ - 392, /* (422) signed_literal ::= literal_func */ - 392, /* (423) signed_literal ::= NK_QUESTION */ - 447, /* (424) literal_list ::= signed_literal */ - 447, /* (425) literal_list ::= literal_list NK_COMMA signed_literal */ - 361, /* (426) db_name ::= NK_ID */ - 362, /* (427) table_name ::= NK_ID */ - 390, /* (428) column_name ::= NK_ID */ - 404, /* (429) function_name ::= NK_ID */ - 436, /* (430) view_name ::= NK_ID */ - 448, /* (431) table_alias ::= NK_ID */ - 415, /* (432) column_alias ::= NK_ID */ - 415, /* (433) column_alias ::= NK_ALIAS */ - 354, /* (434) user_name ::= NK_ID */ - 363, /* (435) topic_name ::= NK_ID */ - 437, /* (436) stream_name ::= NK_ID */ - 427, /* (437) cgroup_name ::= NK_ID */ - 418, /* (438) index_name ::= NK_ID */ - 449, /* (439) expr_or_subquery ::= expression */ - 443, /* (440) expression ::= literal */ - 443, /* (441) expression ::= pseudo_column */ - 443, /* (442) expression ::= column_reference */ - 443, /* (443) expression ::= function_expression */ - 443, /* (444) expression ::= case_when_expression */ - 443, /* (445) expression ::= NK_LP expression NK_RP */ - 443, /* (446) expression ::= NK_PLUS expr_or_subquery */ - 443, /* (447) expression ::= NK_MINUS expr_or_subquery */ - 443, /* (448) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 443, /* (449) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 443, /* (450) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 443, /* (451) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 443, /* (452) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 443, /* (453) expression ::= column_reference NK_ARROW NK_STRING */ - 443, /* (454) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 443, /* (455) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 395, /* (456) expression_list ::= expr_or_subquery */ - 395, /* (457) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 451, /* (458) column_reference ::= column_name */ - 451, /* (459) column_reference ::= table_name NK_DOT column_name */ - 451, /* (460) column_reference ::= NK_ALIAS */ - 451, /* (461) column_reference ::= table_name NK_DOT NK_ALIAS */ - 450, /* (462) pseudo_column ::= ROWTS */ - 450, /* (463) pseudo_column ::= TBNAME */ - 450, /* (464) pseudo_column ::= table_name NK_DOT TBNAME */ - 450, /* (465) pseudo_column ::= QSTART */ - 450, /* (466) pseudo_column ::= QEND */ - 450, /* (467) pseudo_column ::= QDURATION */ - 450, /* (468) pseudo_column ::= WSTART */ - 450, /* (469) pseudo_column ::= WEND */ - 450, /* (470) pseudo_column ::= WDURATION */ - 450, /* (471) pseudo_column ::= IROWTS */ - 450, /* (472) pseudo_column ::= ISFILLED */ - 450, /* (473) pseudo_column ::= QTAGS */ - 452, /* (474) function_expression ::= function_name NK_LP expression_list NK_RP */ - 452, /* (475) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 452, /* (476) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 452, /* (477) function_expression ::= literal_func */ - 446, /* (478) literal_func ::= noarg_func NK_LP NK_RP */ - 446, /* (479) literal_func ::= NOW */ - 456, /* (480) noarg_func ::= NOW */ - 456, /* (481) noarg_func ::= TODAY */ - 456, /* (482) noarg_func ::= TIMEZONE */ - 456, /* (483) noarg_func ::= DATABASE */ - 456, /* (484) noarg_func ::= CLIENT_VERSION */ - 456, /* (485) noarg_func ::= SERVER_VERSION */ - 456, /* (486) noarg_func ::= SERVER_STATUS */ - 456, /* (487) noarg_func ::= CURRENT_USER */ - 456, /* (488) noarg_func ::= USER */ - 454, /* (489) star_func ::= COUNT */ - 454, /* (490) star_func ::= FIRST */ - 454, /* (491) star_func ::= LAST */ - 454, /* (492) star_func ::= LAST_ROW */ - 455, /* (493) star_func_para_list ::= NK_STAR */ - 455, /* (494) star_func_para_list ::= other_para_list */ - 457, /* (495) other_para_list ::= star_func_para */ - 457, /* (496) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 458, /* (497) star_func_para ::= expr_or_subquery */ - 458, /* (498) star_func_para ::= table_name NK_DOT NK_STAR */ - 453, /* (499) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 453, /* (500) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 459, /* (501) when_then_list ::= when_then_expr */ - 459, /* (502) when_then_list ::= when_then_list when_then_expr */ - 462, /* (503) when_then_expr ::= WHEN common_expression THEN common_expression */ - 460, /* (504) case_when_else_opt ::= */ - 460, /* (505) case_when_else_opt ::= ELSE common_expression */ - 463, /* (506) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 463, /* (507) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 463, /* (508) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 463, /* (509) predicate ::= expr_or_subquery IS NULL */ - 463, /* (510) predicate ::= expr_or_subquery IS NOT NULL */ - 463, /* (511) predicate ::= expr_or_subquery in_op in_predicate_value */ - 464, /* (512) compare_op ::= NK_LT */ - 464, /* (513) compare_op ::= NK_GT */ - 464, /* (514) compare_op ::= NK_LE */ - 464, /* (515) compare_op ::= NK_GE */ - 464, /* (516) compare_op ::= NK_NE */ - 464, /* (517) compare_op ::= NK_EQ */ - 464, /* (518) compare_op ::= LIKE */ - 464, /* (519) compare_op ::= NOT LIKE */ - 464, /* (520) compare_op ::= MATCH */ - 464, /* (521) compare_op ::= NMATCH */ - 464, /* (522) compare_op ::= CONTAINS */ - 465, /* (523) in_op ::= IN */ - 465, /* (524) in_op ::= NOT IN */ - 466, /* (525) in_predicate_value ::= NK_LP literal_list NK_RP */ - 467, /* (526) boolean_value_expression ::= boolean_primary */ - 467, /* (527) boolean_value_expression ::= NOT boolean_primary */ - 467, /* (528) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 467, /* (529) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 468, /* (530) boolean_primary ::= predicate */ - 468, /* (531) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 461, /* (532) common_expression ::= expr_or_subquery */ - 461, /* (533) common_expression ::= boolean_value_expression */ - 469, /* (534) from_clause_opt ::= */ - 469, /* (535) from_clause_opt ::= FROM table_reference_list */ - 470, /* (536) table_reference_list ::= table_reference */ - 470, /* (537) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 471, /* (538) table_reference ::= table_primary */ - 471, /* (539) table_reference ::= joined_table */ - 472, /* (540) table_primary ::= table_name alias_opt */ - 472, /* (541) table_primary ::= db_name NK_DOT table_name alias_opt */ - 472, /* (542) table_primary ::= subquery alias_opt */ - 472, /* (543) table_primary ::= parenthesized_joined_table */ - 474, /* (544) alias_opt ::= */ - 474, /* (545) alias_opt ::= table_alias */ - 474, /* (546) alias_opt ::= AS table_alias */ - 476, /* (547) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 476, /* (548) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 473, /* (549) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 477, /* (550) join_type ::= */ - 477, /* (551) join_type ::= INNER */ - 478, /* (552) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 479, /* (553) hint_list ::= */ - 479, /* (554) hint_list ::= NK_HINT */ - 481, /* (555) tag_mode_opt ::= */ - 481, /* (556) tag_mode_opt ::= TAGS */ - 480, /* (557) set_quantifier_opt ::= */ - 480, /* (558) set_quantifier_opt ::= DISTINCT */ - 480, /* (559) set_quantifier_opt ::= ALL */ - 482, /* (560) select_list ::= select_item */ - 482, /* (561) select_list ::= select_list NK_COMMA select_item */ - 490, /* (562) select_item ::= NK_STAR */ - 490, /* (563) select_item ::= common_expression */ - 490, /* (564) select_item ::= common_expression column_alias */ - 490, /* (565) select_item ::= common_expression AS column_alias */ - 490, /* (566) select_item ::= table_name NK_DOT NK_STAR */ - 426, /* (567) where_clause_opt ::= */ - 426, /* (568) where_clause_opt ::= WHERE search_condition */ - 483, /* (569) partition_by_clause_opt ::= */ - 483, /* (570) partition_by_clause_opt ::= PARTITION BY partition_list */ - 491, /* (571) partition_list ::= partition_item */ - 491, /* (572) partition_list ::= partition_list NK_COMMA partition_item */ - 492, /* (573) partition_item ::= expr_or_subquery */ - 492, /* (574) partition_item ::= expr_or_subquery column_alias */ - 492, /* (575) partition_item ::= expr_or_subquery AS column_alias */ - 487, /* (576) twindow_clause_opt ::= */ - 487, /* (577) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 487, /* (578) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 487, /* (579) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 487, /* (580) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 487, /* (581) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 420, /* (582) sliding_opt ::= */ - 420, /* (583) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 493, /* (584) interval_sliding_duration_literal ::= NK_VARIABLE */ - 493, /* (585) interval_sliding_duration_literal ::= NK_STRING */ - 493, /* (586) interval_sliding_duration_literal ::= NK_INTEGER */ - 486, /* (587) fill_opt ::= */ - 486, /* (588) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 486, /* (589) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 486, /* (590) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 494, /* (591) fill_mode ::= NONE */ - 494, /* (592) fill_mode ::= PREV */ - 494, /* (593) fill_mode ::= NULL */ - 494, /* (594) fill_mode ::= NULL_F */ - 494, /* (595) fill_mode ::= LINEAR */ - 494, /* (596) fill_mode ::= NEXT */ - 488, /* (597) group_by_clause_opt ::= */ - 488, /* (598) group_by_clause_opt ::= GROUP BY group_by_list */ - 495, /* (599) group_by_list ::= expr_or_subquery */ - 495, /* (600) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 489, /* (601) having_clause_opt ::= */ - 489, /* (602) having_clause_opt ::= HAVING search_condition */ - 484, /* (603) range_opt ::= */ - 484, /* (604) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 484, /* (605) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 485, /* (606) every_opt ::= */ - 485, /* (607) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 496, /* (608) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 497, /* (609) query_simple ::= query_specification */ - 497, /* (610) query_simple ::= union_query_expression */ - 501, /* (611) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 501, /* (612) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 502, /* (613) query_simple_or_subquery ::= query_simple */ - 502, /* (614) query_simple_or_subquery ::= subquery */ - 425, /* (615) query_or_subquery ::= query_expression */ - 425, /* (616) query_or_subquery ::= subquery */ - 498, /* (617) order_by_clause_opt ::= */ - 498, /* (618) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 499, /* (619) slimit_clause_opt ::= */ - 499, /* (620) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 499, /* (621) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 499, /* (622) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 500, /* (623) limit_clause_opt ::= */ - 500, /* (624) limit_clause_opt ::= LIMIT NK_INTEGER */ - 500, /* (625) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 500, /* (626) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 475, /* (627) subquery ::= NK_LP query_expression NK_RP */ - 475, /* (628) subquery ::= NK_LP subquery NK_RP */ - 364, /* (629) search_condition ::= common_expression */ - 503, /* (630) sort_specification_list ::= sort_specification */ - 503, /* (631) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 504, /* (632) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 505, /* (633) ordering_specification_opt ::= */ - 505, /* (634) ordering_specification_opt ::= ASC */ - 505, /* (635) ordering_specification_opt ::= DESC */ - 506, /* (636) null_ordering_opt ::= */ - 506, /* (637) null_ordering_opt ::= NULLS FIRST */ - 506, /* (638) null_ordering_opt ::= NULLS LAST */ + 347, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 347, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 348, /* (2) account_options ::= */ + 348, /* (3) account_options ::= account_options PPS literal */ + 348, /* (4) account_options ::= account_options TSERIES literal */ + 348, /* (5) account_options ::= account_options STORAGE literal */ + 348, /* (6) account_options ::= account_options STREAMS literal */ + 348, /* (7) account_options ::= account_options QTIME literal */ + 348, /* (8) account_options ::= account_options DBS literal */ + 348, /* (9) account_options ::= account_options USERS literal */ + 348, /* (10) account_options ::= account_options CONNS literal */ + 348, /* (11) account_options ::= account_options STATE literal */ + 349, /* (12) alter_account_options ::= alter_account_option */ + 349, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 351, /* (14) alter_account_option ::= PASS literal */ + 351, /* (15) alter_account_option ::= PPS literal */ + 351, /* (16) alter_account_option ::= TSERIES literal */ + 351, /* (17) alter_account_option ::= STORAGE literal */ + 351, /* (18) alter_account_option ::= STREAMS literal */ + 351, /* (19) alter_account_option ::= QTIME literal */ + 351, /* (20) alter_account_option ::= DBS literal */ + 351, /* (21) alter_account_option ::= USERS literal */ + 351, /* (22) alter_account_option ::= CONNS literal */ + 351, /* (23) alter_account_option ::= STATE literal */ + 352, /* (24) ip_range_list ::= NK_STRING */ + 352, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 353, /* (26) white_list ::= HOST ip_range_list */ + 354, /* (27) white_list_opt ::= */ + 354, /* (28) white_list_opt ::= white_list */ + 347, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 347, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 347, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 347, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 347, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 347, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 347, /* (35) cmd ::= DROP USER user_name */ + 356, /* (36) sysinfo_opt ::= */ + 356, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 347, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 347, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 357, /* (40) privileges ::= ALL */ + 357, /* (41) privileges ::= priv_type_list */ + 357, /* (42) privileges ::= SUBSCRIBE */ + 360, /* (43) priv_type_list ::= priv_type */ + 360, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 361, /* (45) priv_type ::= READ */ + 361, /* (46) priv_type ::= WRITE */ + 361, /* (47) priv_type ::= ALTER */ + 358, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 358, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 358, /* (50) priv_level ::= db_name NK_DOT table_name */ + 358, /* (51) priv_level ::= topic_name */ + 359, /* (52) with_opt ::= */ + 359, /* (53) with_opt ::= WITH search_condition */ + 347, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 347, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 347, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 347, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 347, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 347, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 347, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 347, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 347, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 347, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 347, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 366, /* (65) dnode_endpoint ::= NK_STRING */ + 366, /* (66) dnode_endpoint ::= NK_ID */ + 366, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 367, /* (68) force_opt ::= */ + 367, /* (69) force_opt ::= FORCE */ + 368, /* (70) unsafe_opt ::= UNSAFE */ + 347, /* (71) cmd ::= ALTER LOCAL NK_STRING */ + 347, /* (72) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 347, /* (73) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 347, /* (74) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 347, /* (75) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 347, /* (76) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 347, /* (77) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 347, /* (78) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 347, /* (79) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 347, /* (80) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 347, /* (81) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 347, /* (82) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 347, /* (83) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 347, /* (84) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 347, /* (85) cmd ::= DROP DATABASE exists_opt db_name */ + 347, /* (86) cmd ::= USE db_name */ + 347, /* (87) cmd ::= ALTER DATABASE db_name alter_db_options */ + 347, /* (88) cmd ::= FLUSH DATABASE db_name */ + 347, /* (89) cmd ::= TRIM DATABASE db_name speed_opt */ + 347, /* (90) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 369, /* (91) not_exists_opt ::= IF NOT EXISTS */ + 369, /* (92) not_exists_opt ::= */ + 371, /* (93) exists_opt ::= IF EXISTS */ + 371, /* (94) exists_opt ::= */ + 370, /* (95) db_options ::= */ + 370, /* (96) db_options ::= db_options BUFFER NK_INTEGER */ + 370, /* (97) db_options ::= db_options CACHEMODEL NK_STRING */ + 370, /* (98) db_options ::= db_options CACHESIZE NK_INTEGER */ + 370, /* (99) db_options ::= db_options COMP NK_INTEGER */ + 370, /* (100) db_options ::= db_options DURATION NK_INTEGER */ + 370, /* (101) db_options ::= db_options DURATION NK_VARIABLE */ + 370, /* (102) db_options ::= db_options MAXROWS NK_INTEGER */ + 370, /* (103) db_options ::= db_options MINROWS NK_INTEGER */ + 370, /* (104) db_options ::= db_options KEEP integer_list */ + 370, /* (105) db_options ::= db_options KEEP variable_list */ + 370, /* (106) db_options ::= db_options PAGES NK_INTEGER */ + 370, /* (107) db_options ::= db_options PAGESIZE NK_INTEGER */ + 370, /* (108) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 370, /* (109) db_options ::= db_options PRECISION NK_STRING */ + 370, /* (110) db_options ::= db_options REPLICA NK_INTEGER */ + 370, /* (111) db_options ::= db_options VGROUPS NK_INTEGER */ + 370, /* (112) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 370, /* (113) db_options ::= db_options RETENTIONS retention_list */ + 370, /* (114) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 370, /* (115) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 370, /* (116) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 370, /* (117) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 370, /* (118) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 370, /* (119) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 370, /* (120) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 370, /* (121) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 370, /* (122) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 370, /* (123) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 370, /* (124) db_options ::= db_options TABLE_PREFIX signed */ + 370, /* (125) db_options ::= db_options TABLE_SUFFIX signed */ + 370, /* (126) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 372, /* (127) alter_db_options ::= alter_db_option */ + 372, /* (128) alter_db_options ::= alter_db_options alter_db_option */ + 380, /* (129) alter_db_option ::= BUFFER NK_INTEGER */ + 380, /* (130) alter_db_option ::= CACHEMODEL NK_STRING */ + 380, /* (131) alter_db_option ::= CACHESIZE NK_INTEGER */ + 380, /* (132) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 380, /* (133) alter_db_option ::= KEEP integer_list */ + 380, /* (134) alter_db_option ::= KEEP variable_list */ + 380, /* (135) alter_db_option ::= PAGES NK_INTEGER */ + 380, /* (136) alter_db_option ::= REPLICA NK_INTEGER */ + 380, /* (137) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 380, /* (138) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 380, /* (139) alter_db_option ::= MINROWS NK_INTEGER */ + 380, /* (140) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 380, /* (141) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 380, /* (142) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 380, /* (143) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 380, /* (144) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 376, /* (145) integer_list ::= NK_INTEGER */ + 376, /* (146) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 377, /* (147) variable_list ::= NK_VARIABLE */ + 377, /* (148) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 378, /* (149) retention_list ::= retention */ + 378, /* (150) retention_list ::= retention_list NK_COMMA retention */ + 381, /* (151) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 381, /* (152) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 373, /* (153) speed_opt ::= */ + 373, /* (154) speed_opt ::= BWLIMIT NK_INTEGER */ + 374, /* (155) start_opt ::= */ + 374, /* (156) start_opt ::= START WITH NK_INTEGER */ + 374, /* (157) start_opt ::= START WITH NK_STRING */ + 374, /* (158) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 375, /* (159) end_opt ::= */ + 375, /* (160) end_opt ::= END WITH NK_INTEGER */ + 375, /* (161) end_opt ::= END WITH NK_STRING */ + 375, /* (162) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 347, /* (163) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 347, /* (164) cmd ::= CREATE TABLE multi_create_clause */ + 347, /* (165) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 347, /* (166) cmd ::= DROP TABLE multi_drop_clause */ + 347, /* (167) cmd ::= DROP STABLE exists_opt full_table_name */ + 347, /* (168) cmd ::= ALTER TABLE alter_table_clause */ + 347, /* (169) cmd ::= ALTER STABLE alter_table_clause */ + 389, /* (170) alter_table_clause ::= full_table_name alter_table_options */ + 389, /* (171) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 389, /* (172) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 389, /* (173) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 389, /* (174) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 389, /* (175) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 389, /* (176) alter_table_clause ::= full_table_name DROP TAG column_name */ + 389, /* (177) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 389, /* (178) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 389, /* (179) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + 386, /* (180) multi_create_clause ::= create_subtable_clause */ + 386, /* (181) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 394, /* (182) 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 */ + 388, /* (183) multi_drop_clause ::= drop_table_clause */ + 388, /* (184) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 397, /* (185) drop_table_clause ::= exists_opt full_table_name */ + 395, /* (186) specific_cols_opt ::= */ + 395, /* (187) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 382, /* (188) full_table_name ::= table_name */ + 382, /* (189) full_table_name ::= db_name NK_DOT table_name */ + 383, /* (190) column_def_list ::= column_def */ + 383, /* (191) column_def_list ::= column_def_list NK_COMMA column_def */ + 399, /* (192) column_def ::= column_name type_name */ + 392, /* (193) type_name ::= BOOL */ + 392, /* (194) type_name ::= TINYINT */ + 392, /* (195) type_name ::= SMALLINT */ + 392, /* (196) type_name ::= INT */ + 392, /* (197) type_name ::= INTEGER */ + 392, /* (198) type_name ::= BIGINT */ + 392, /* (199) type_name ::= FLOAT */ + 392, /* (200) type_name ::= DOUBLE */ + 392, /* (201) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 392, /* (202) type_name ::= TIMESTAMP */ + 392, /* (203) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 392, /* (204) type_name ::= TINYINT UNSIGNED */ + 392, /* (205) type_name ::= SMALLINT UNSIGNED */ + 392, /* (206) type_name ::= INT UNSIGNED */ + 392, /* (207) type_name ::= BIGINT UNSIGNED */ + 392, /* (208) type_name ::= JSON */ + 392, /* (209) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 392, /* (210) type_name ::= MEDIUMBLOB */ + 392, /* (211) type_name ::= BLOB */ + 392, /* (212) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 392, /* (213) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 392, /* (214) type_name ::= DECIMAL */ + 392, /* (215) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 392, /* (216) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 384, /* (217) tags_def_opt ::= */ + 384, /* (218) tags_def_opt ::= tags_def */ + 387, /* (219) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 385, /* (220) table_options ::= */ + 385, /* (221) table_options ::= table_options COMMENT NK_STRING */ + 385, /* (222) table_options ::= table_options MAX_DELAY duration_list */ + 385, /* (223) table_options ::= table_options WATERMARK duration_list */ + 385, /* (224) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 385, /* (225) table_options ::= table_options TTL NK_INTEGER */ + 385, /* (226) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 385, /* (227) table_options ::= table_options DELETE_MARK duration_list */ + 390, /* (228) alter_table_options ::= alter_table_option */ + 390, /* (229) alter_table_options ::= alter_table_options alter_table_option */ + 402, /* (230) alter_table_option ::= COMMENT NK_STRING */ + 402, /* (231) alter_table_option ::= TTL NK_INTEGER */ + 400, /* (232) duration_list ::= duration_literal */ + 400, /* (233) duration_list ::= duration_list NK_COMMA duration_literal */ + 401, /* (234) rollup_func_list ::= rollup_func_name */ + 401, /* (235) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 404, /* (236) rollup_func_name ::= function_name */ + 404, /* (237) rollup_func_name ::= FIRST */ + 404, /* (238) rollup_func_name ::= LAST */ + 398, /* (239) col_name_list ::= col_name */ + 398, /* (240) col_name_list ::= col_name_list NK_COMMA col_name */ + 406, /* (241) col_name ::= column_name */ + 347, /* (242) cmd ::= SHOW DNODES */ + 347, /* (243) cmd ::= SHOW USERS */ + 347, /* (244) cmd ::= SHOW USER PRIVILEGES */ + 347, /* (245) cmd ::= SHOW db_kind_opt DATABASES */ + 347, /* (246) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 347, /* (247) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 347, /* (248) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 347, /* (249) cmd ::= SHOW MNODES */ + 347, /* (250) cmd ::= SHOW QNODES */ + 347, /* (251) cmd ::= SHOW FUNCTIONS */ + 347, /* (252) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 347, /* (253) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 347, /* (254) cmd ::= SHOW STREAMS */ + 347, /* (255) cmd ::= SHOW ACCOUNTS */ + 347, /* (256) cmd ::= SHOW APPS */ + 347, /* (257) cmd ::= SHOW CONNECTIONS */ + 347, /* (258) cmd ::= SHOW LICENCES */ + 347, /* (259) cmd ::= SHOW GRANTS */ + 347, /* (260) cmd ::= SHOW CREATE DATABASE db_name */ + 347, /* (261) cmd ::= SHOW CREATE TABLE full_table_name */ + 347, /* (262) cmd ::= SHOW CREATE STABLE full_table_name */ + 347, /* (263) cmd ::= SHOW QUERIES */ + 347, /* (264) cmd ::= SHOW SCORES */ + 347, /* (265) cmd ::= SHOW TOPICS */ + 347, /* (266) cmd ::= SHOW VARIABLES */ + 347, /* (267) cmd ::= SHOW CLUSTER VARIABLES */ + 347, /* (268) cmd ::= SHOW LOCAL VARIABLES */ + 347, /* (269) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 347, /* (270) cmd ::= SHOW BNODES */ + 347, /* (271) cmd ::= SHOW SNODES */ + 347, /* (272) cmd ::= SHOW CLUSTER */ + 347, /* (273) cmd ::= SHOW TRANSACTIONS */ + 347, /* (274) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 347, /* (275) cmd ::= SHOW CONSUMERS */ + 347, /* (276) cmd ::= SHOW SUBSCRIPTIONS */ + 347, /* (277) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 347, /* (278) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 347, /* (279) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 347, /* (280) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 347, /* (281) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 347, /* (282) cmd ::= SHOW VNODES */ + 347, /* (283) cmd ::= SHOW db_name_cond_opt ALIVE */ + 347, /* (284) cmd ::= SHOW CLUSTER ALIVE */ + 347, /* (285) cmd ::= SHOW db_name_cond_opt VIEWS */ + 347, /* (286) cmd ::= SHOW CREATE VIEW full_table_name */ + 347, /* (287) cmd ::= SHOW COMPACTS */ + 347, /* (288) cmd ::= SHOW COMPACT NK_INTEGER */ + 408, /* (289) table_kind_db_name_cond_opt ::= */ + 408, /* (290) table_kind_db_name_cond_opt ::= table_kind */ + 408, /* (291) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 408, /* (292) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 414, /* (293) table_kind ::= NORMAL */ + 414, /* (294) table_kind ::= CHILD */ + 410, /* (295) db_name_cond_opt ::= */ + 410, /* (296) db_name_cond_opt ::= db_name NK_DOT */ + 409, /* (297) like_pattern_opt ::= */ + 409, /* (298) like_pattern_opt ::= LIKE NK_STRING */ + 411, /* (299) table_name_cond ::= table_name */ + 412, /* (300) from_db_opt ::= */ + 412, /* (301) from_db_opt ::= FROM db_name */ + 413, /* (302) tag_list_opt ::= */ + 413, /* (303) tag_list_opt ::= tag_item */ + 413, /* (304) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 415, /* (305) tag_item ::= TBNAME */ + 415, /* (306) tag_item ::= QTAGS */ + 415, /* (307) tag_item ::= column_name */ + 415, /* (308) tag_item ::= column_name column_alias */ + 415, /* (309) tag_item ::= column_name AS column_alias */ + 407, /* (310) db_kind_opt ::= */ + 407, /* (311) db_kind_opt ::= USER */ + 407, /* (312) db_kind_opt ::= SYSTEM */ + 347, /* (313) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 347, /* (314) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 347, /* (315) cmd ::= DROP INDEX exists_opt full_index_name */ + 418, /* (316) full_index_name ::= index_name */ + 418, /* (317) full_index_name ::= db_name NK_DOT index_name */ + 417, /* (318) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 417, /* (319) 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 */ + 420, /* (320) func_list ::= func */ + 420, /* (321) func_list ::= func_list NK_COMMA func */ + 423, /* (322) func ::= sma_func_name NK_LP expression_list NK_RP */ + 424, /* (323) sma_func_name ::= function_name */ + 424, /* (324) sma_func_name ::= COUNT */ + 424, /* (325) sma_func_name ::= FIRST */ + 424, /* (326) sma_func_name ::= LAST */ + 424, /* (327) sma_func_name ::= LAST_ROW */ + 422, /* (328) sma_stream_opt ::= */ + 422, /* (329) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 422, /* (330) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 422, /* (331) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 425, /* (332) with_meta ::= AS */ + 425, /* (333) with_meta ::= WITH META AS */ + 425, /* (334) with_meta ::= ONLY META AS */ + 347, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 347, /* (336) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 347, /* (337) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 347, /* (338) cmd ::= DROP TOPIC exists_opt topic_name */ + 347, /* (339) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 347, /* (340) cmd ::= DESC full_table_name */ + 347, /* (341) cmd ::= DESCRIBE full_table_name */ + 347, /* (342) cmd ::= RESET QUERY CACHE */ + 347, /* (343) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 347, /* (344) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 429, /* (345) analyze_opt ::= */ + 429, /* (346) analyze_opt ::= ANALYZE */ + 430, /* (347) explain_options ::= */ + 430, /* (348) explain_options ::= explain_options VERBOSE NK_BOOL */ + 430, /* (349) explain_options ::= explain_options RATIO NK_FLOAT */ + 347, /* (350) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 347, /* (351) cmd ::= DROP FUNCTION exists_opt function_name */ + 433, /* (352) agg_func_opt ::= */ + 433, /* (353) agg_func_opt ::= AGGREGATE */ + 434, /* (354) bufsize_opt ::= */ + 434, /* (355) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 435, /* (356) language_opt ::= */ + 435, /* (357) language_opt ::= LANGUAGE NK_STRING */ + 432, /* (358) or_replace_opt ::= */ + 432, /* (359) or_replace_opt ::= OR REPLACE */ + 347, /* (360) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 347, /* (361) cmd ::= DROP VIEW exists_opt full_view_name */ + 436, /* (362) full_view_name ::= view_name */ + 436, /* (363) full_view_name ::= db_name NK_DOT view_name */ + 347, /* (364) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + 347, /* (365) cmd ::= DROP STREAM exists_opt stream_name */ + 347, /* (366) cmd ::= PAUSE STREAM exists_opt stream_name */ + 347, /* (367) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 440, /* (368) col_list_opt ::= */ + 440, /* (369) col_list_opt ::= NK_LP col_name_list NK_RP */ + 441, /* (370) tag_def_or_ref_opt ::= */ + 441, /* (371) tag_def_or_ref_opt ::= tags_def */ + 441, /* (372) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 439, /* (373) stream_options ::= */ + 439, /* (374) stream_options ::= stream_options TRIGGER AT_ONCE */ + 439, /* (375) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 439, /* (376) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 439, /* (377) stream_options ::= stream_options WATERMARK duration_literal */ + 439, /* (378) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 439, /* (379) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 439, /* (380) stream_options ::= stream_options DELETE_MARK duration_literal */ + 439, /* (381) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 442, /* (382) subtable_opt ::= */ + 442, /* (383) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 443, /* (384) ignore_opt ::= */ + 443, /* (385) ignore_opt ::= IGNORE UNTREATED */ + 347, /* (386) cmd ::= KILL CONNECTION NK_INTEGER */ + 347, /* (387) cmd ::= KILL QUERY NK_STRING */ + 347, /* (388) cmd ::= KILL TRANSACTION NK_INTEGER */ + 347, /* (389) cmd ::= KILL COMPACT NK_INTEGER */ + 347, /* (390) cmd ::= BALANCE VGROUP */ + 347, /* (391) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 347, /* (392) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 347, /* (393) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 347, /* (394) cmd ::= SPLIT VGROUP NK_INTEGER */ + 445, /* (395) on_vgroup_id ::= */ + 445, /* (396) on_vgroup_id ::= ON NK_INTEGER */ + 446, /* (397) dnode_list ::= DNODE NK_INTEGER */ + 446, /* (398) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 347, /* (399) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 347, /* (400) cmd ::= query_or_subquery */ + 347, /* (401) cmd ::= insert_query */ + 431, /* (402) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 431, /* (403) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 350, /* (404) literal ::= NK_INTEGER */ + 350, /* (405) literal ::= NK_FLOAT */ + 350, /* (406) literal ::= NK_STRING */ + 350, /* (407) literal ::= NK_BOOL */ + 350, /* (408) literal ::= TIMESTAMP NK_STRING */ + 350, /* (409) literal ::= duration_literal */ + 350, /* (410) literal ::= NULL */ + 350, /* (411) literal ::= NK_QUESTION */ + 403, /* (412) duration_literal ::= NK_VARIABLE */ + 379, /* (413) signed ::= NK_INTEGER */ + 379, /* (414) signed ::= NK_PLUS NK_INTEGER */ + 379, /* (415) signed ::= NK_MINUS NK_INTEGER */ + 379, /* (416) signed ::= NK_FLOAT */ + 379, /* (417) signed ::= NK_PLUS NK_FLOAT */ + 379, /* (418) signed ::= NK_MINUS NK_FLOAT */ + 393, /* (419) signed_literal ::= signed */ + 393, /* (420) signed_literal ::= NK_STRING */ + 393, /* (421) signed_literal ::= NK_BOOL */ + 393, /* (422) signed_literal ::= TIMESTAMP NK_STRING */ + 393, /* (423) signed_literal ::= duration_literal */ + 393, /* (424) signed_literal ::= NULL */ + 393, /* (425) signed_literal ::= literal_func */ + 393, /* (426) signed_literal ::= NK_QUESTION */ + 448, /* (427) literal_list ::= signed_literal */ + 448, /* (428) literal_list ::= literal_list NK_COMMA signed_literal */ + 362, /* (429) db_name ::= NK_ID */ + 363, /* (430) table_name ::= NK_ID */ + 391, /* (431) column_name ::= NK_ID */ + 405, /* (432) function_name ::= NK_ID */ + 437, /* (433) view_name ::= NK_ID */ + 449, /* (434) table_alias ::= NK_ID */ + 416, /* (435) column_alias ::= NK_ID */ + 416, /* (436) column_alias ::= NK_ALIAS */ + 355, /* (437) user_name ::= NK_ID */ + 364, /* (438) topic_name ::= NK_ID */ + 438, /* (439) stream_name ::= NK_ID */ + 428, /* (440) cgroup_name ::= NK_ID */ + 419, /* (441) index_name ::= NK_ID */ + 450, /* (442) expr_or_subquery ::= expression */ + 444, /* (443) expression ::= literal */ + 444, /* (444) expression ::= pseudo_column */ + 444, /* (445) expression ::= column_reference */ + 444, /* (446) expression ::= function_expression */ + 444, /* (447) expression ::= case_when_expression */ + 444, /* (448) expression ::= NK_LP expression NK_RP */ + 444, /* (449) expression ::= NK_PLUS expr_or_subquery */ + 444, /* (450) expression ::= NK_MINUS expr_or_subquery */ + 444, /* (451) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 444, /* (452) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 444, /* (453) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 444, /* (454) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 444, /* (455) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 444, /* (456) expression ::= column_reference NK_ARROW NK_STRING */ + 444, /* (457) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 444, /* (458) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 396, /* (459) expression_list ::= expr_or_subquery */ + 396, /* (460) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 452, /* (461) column_reference ::= column_name */ + 452, /* (462) column_reference ::= table_name NK_DOT column_name */ + 452, /* (463) column_reference ::= NK_ALIAS */ + 452, /* (464) column_reference ::= table_name NK_DOT NK_ALIAS */ + 451, /* (465) pseudo_column ::= ROWTS */ + 451, /* (466) pseudo_column ::= TBNAME */ + 451, /* (467) pseudo_column ::= table_name NK_DOT TBNAME */ + 451, /* (468) pseudo_column ::= QSTART */ + 451, /* (469) pseudo_column ::= QEND */ + 451, /* (470) pseudo_column ::= QDURATION */ + 451, /* (471) pseudo_column ::= WSTART */ + 451, /* (472) pseudo_column ::= WEND */ + 451, /* (473) pseudo_column ::= WDURATION */ + 451, /* (474) pseudo_column ::= IROWTS */ + 451, /* (475) pseudo_column ::= ISFILLED */ + 451, /* (476) pseudo_column ::= QTAGS */ + 453, /* (477) function_expression ::= function_name NK_LP expression_list NK_RP */ + 453, /* (478) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 453, /* (479) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 453, /* (480) function_expression ::= literal_func */ + 447, /* (481) literal_func ::= noarg_func NK_LP NK_RP */ + 447, /* (482) literal_func ::= NOW */ + 457, /* (483) noarg_func ::= NOW */ + 457, /* (484) noarg_func ::= TODAY */ + 457, /* (485) noarg_func ::= TIMEZONE */ + 457, /* (486) noarg_func ::= DATABASE */ + 457, /* (487) noarg_func ::= CLIENT_VERSION */ + 457, /* (488) noarg_func ::= SERVER_VERSION */ + 457, /* (489) noarg_func ::= SERVER_STATUS */ + 457, /* (490) noarg_func ::= CURRENT_USER */ + 457, /* (491) noarg_func ::= USER */ + 455, /* (492) star_func ::= COUNT */ + 455, /* (493) star_func ::= FIRST */ + 455, /* (494) star_func ::= LAST */ + 455, /* (495) star_func ::= LAST_ROW */ + 456, /* (496) star_func_para_list ::= NK_STAR */ + 456, /* (497) star_func_para_list ::= other_para_list */ + 458, /* (498) other_para_list ::= star_func_para */ + 458, /* (499) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 459, /* (500) star_func_para ::= expr_or_subquery */ + 459, /* (501) star_func_para ::= table_name NK_DOT NK_STAR */ + 454, /* (502) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 454, /* (503) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 460, /* (504) when_then_list ::= when_then_expr */ + 460, /* (505) when_then_list ::= when_then_list when_then_expr */ + 463, /* (506) when_then_expr ::= WHEN common_expression THEN common_expression */ + 461, /* (507) case_when_else_opt ::= */ + 461, /* (508) case_when_else_opt ::= ELSE common_expression */ + 464, /* (509) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 464, /* (510) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 464, /* (511) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 464, /* (512) predicate ::= expr_or_subquery IS NULL */ + 464, /* (513) predicate ::= expr_or_subquery IS NOT NULL */ + 464, /* (514) predicate ::= expr_or_subquery in_op in_predicate_value */ + 465, /* (515) compare_op ::= NK_LT */ + 465, /* (516) compare_op ::= NK_GT */ + 465, /* (517) compare_op ::= NK_LE */ + 465, /* (518) compare_op ::= NK_GE */ + 465, /* (519) compare_op ::= NK_NE */ + 465, /* (520) compare_op ::= NK_EQ */ + 465, /* (521) compare_op ::= LIKE */ + 465, /* (522) compare_op ::= NOT LIKE */ + 465, /* (523) compare_op ::= MATCH */ + 465, /* (524) compare_op ::= NMATCH */ + 465, /* (525) compare_op ::= CONTAINS */ + 466, /* (526) in_op ::= IN */ + 466, /* (527) in_op ::= NOT IN */ + 467, /* (528) in_predicate_value ::= NK_LP literal_list NK_RP */ + 468, /* (529) boolean_value_expression ::= boolean_primary */ + 468, /* (530) boolean_value_expression ::= NOT boolean_primary */ + 468, /* (531) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 468, /* (532) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 469, /* (533) boolean_primary ::= predicate */ + 469, /* (534) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 462, /* (535) common_expression ::= expr_or_subquery */ + 462, /* (536) common_expression ::= boolean_value_expression */ + 470, /* (537) from_clause_opt ::= */ + 470, /* (538) from_clause_opt ::= FROM table_reference_list */ + 471, /* (539) table_reference_list ::= table_reference */ + 471, /* (540) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 472, /* (541) table_reference ::= table_primary */ + 472, /* (542) table_reference ::= joined_table */ + 473, /* (543) table_primary ::= table_name alias_opt */ + 473, /* (544) table_primary ::= db_name NK_DOT table_name alias_opt */ + 473, /* (545) table_primary ::= subquery alias_opt */ + 473, /* (546) table_primary ::= parenthesized_joined_table */ + 475, /* (547) alias_opt ::= */ + 475, /* (548) alias_opt ::= table_alias */ + 475, /* (549) alias_opt ::= AS table_alias */ + 477, /* (550) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 477, /* (551) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 474, /* (552) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 478, /* (553) join_type ::= */ + 478, /* (554) join_type ::= INNER */ + 479, /* (555) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 480, /* (556) hint_list ::= */ + 480, /* (557) hint_list ::= NK_HINT */ + 482, /* (558) tag_mode_opt ::= */ + 482, /* (559) tag_mode_opt ::= TAGS */ + 481, /* (560) set_quantifier_opt ::= */ + 481, /* (561) set_quantifier_opt ::= DISTINCT */ + 481, /* (562) set_quantifier_opt ::= ALL */ + 483, /* (563) select_list ::= select_item */ + 483, /* (564) select_list ::= select_list NK_COMMA select_item */ + 491, /* (565) select_item ::= NK_STAR */ + 491, /* (566) select_item ::= common_expression */ + 491, /* (567) select_item ::= common_expression column_alias */ + 491, /* (568) select_item ::= common_expression AS column_alias */ + 491, /* (569) select_item ::= table_name NK_DOT NK_STAR */ + 427, /* (570) where_clause_opt ::= */ + 427, /* (571) where_clause_opt ::= WHERE search_condition */ + 484, /* (572) partition_by_clause_opt ::= */ + 484, /* (573) partition_by_clause_opt ::= PARTITION BY partition_list */ + 492, /* (574) partition_list ::= partition_item */ + 492, /* (575) partition_list ::= partition_list NK_COMMA partition_item */ + 493, /* (576) partition_item ::= expr_or_subquery */ + 493, /* (577) partition_item ::= expr_or_subquery column_alias */ + 493, /* (578) partition_item ::= expr_or_subquery AS column_alias */ + 488, /* (579) twindow_clause_opt ::= */ + 488, /* (580) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 488, /* (581) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 488, /* (582) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 488, /* (583) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 488, /* (584) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 421, /* (585) sliding_opt ::= */ + 421, /* (586) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 494, /* (587) interval_sliding_duration_literal ::= NK_VARIABLE */ + 494, /* (588) interval_sliding_duration_literal ::= NK_STRING */ + 494, /* (589) interval_sliding_duration_literal ::= NK_INTEGER */ + 487, /* (590) fill_opt ::= */ + 487, /* (591) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 487, /* (592) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 487, /* (593) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 495, /* (594) fill_mode ::= NONE */ + 495, /* (595) fill_mode ::= PREV */ + 495, /* (596) fill_mode ::= NULL */ + 495, /* (597) fill_mode ::= NULL_F */ + 495, /* (598) fill_mode ::= LINEAR */ + 495, /* (599) fill_mode ::= NEXT */ + 489, /* (600) group_by_clause_opt ::= */ + 489, /* (601) group_by_clause_opt ::= GROUP BY group_by_list */ + 496, /* (602) group_by_list ::= expr_or_subquery */ + 496, /* (603) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 490, /* (604) having_clause_opt ::= */ + 490, /* (605) having_clause_opt ::= HAVING search_condition */ + 485, /* (606) range_opt ::= */ + 485, /* (607) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 485, /* (608) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 486, /* (609) every_opt ::= */ + 486, /* (610) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 497, /* (611) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 498, /* (612) query_simple ::= query_specification */ + 498, /* (613) query_simple ::= union_query_expression */ + 502, /* (614) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 502, /* (615) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 503, /* (616) query_simple_or_subquery ::= query_simple */ + 503, /* (617) query_simple_or_subquery ::= subquery */ + 426, /* (618) query_or_subquery ::= query_expression */ + 426, /* (619) query_or_subquery ::= subquery */ + 499, /* (620) order_by_clause_opt ::= */ + 499, /* (621) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 500, /* (622) slimit_clause_opt ::= */ + 500, /* (623) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 500, /* (624) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 500, /* (625) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 501, /* (626) limit_clause_opt ::= */ + 501, /* (627) limit_clause_opt ::= LIMIT NK_INTEGER */ + 501, /* (628) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 501, /* (629) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 476, /* (630) subquery ::= NK_LP query_expression NK_RP */ + 476, /* (631) subquery ::= NK_LP subquery NK_RP */ + 365, /* (632) search_condition ::= common_expression */ + 504, /* (633) sort_specification_list ::= sort_specification */ + 504, /* (634) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 505, /* (635) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 506, /* (636) ordering_specification_opt ::= */ + 506, /* (637) ordering_specification_opt ::= ASC */ + 506, /* (638) ordering_specification_opt ::= DESC */ + 507, /* (639) null_ordering_opt ::= */ + 507, /* (640) null_ordering_opt ::= NULLS FIRST */ + 507, /* (641) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4286,358 +4656,361 @@ static const signed char yyRuleInfoNRhs[] = { -3, /* (284) cmd ::= SHOW CLUSTER ALIVE */ -3, /* (285) cmd ::= SHOW db_name_cond_opt VIEWS */ -4, /* (286) cmd ::= SHOW CREATE VIEW full_table_name */ - 0, /* (287) table_kind_db_name_cond_opt ::= */ - -1, /* (288) table_kind_db_name_cond_opt ::= table_kind */ - -2, /* (289) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - -3, /* (290) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - -1, /* (291) table_kind ::= NORMAL */ - -1, /* (292) table_kind ::= CHILD */ - 0, /* (293) db_name_cond_opt ::= */ - -2, /* (294) db_name_cond_opt ::= db_name NK_DOT */ - 0, /* (295) like_pattern_opt ::= */ - -2, /* (296) like_pattern_opt ::= LIKE NK_STRING */ - -1, /* (297) table_name_cond ::= table_name */ - 0, /* (298) from_db_opt ::= */ - -2, /* (299) from_db_opt ::= FROM db_name */ - 0, /* (300) tag_list_opt ::= */ - -1, /* (301) tag_list_opt ::= tag_item */ - -3, /* (302) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - -1, /* (303) tag_item ::= TBNAME */ - -1, /* (304) tag_item ::= QTAGS */ - -1, /* (305) tag_item ::= column_name */ - -2, /* (306) tag_item ::= column_name column_alias */ - -3, /* (307) tag_item ::= column_name AS column_alias */ - 0, /* (308) db_kind_opt ::= */ - -1, /* (309) db_kind_opt ::= USER */ - -1, /* (310) db_kind_opt ::= SYSTEM */ - -8, /* (311) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - -9, /* (312) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - -4, /* (313) cmd ::= DROP INDEX exists_opt full_index_name */ - -1, /* (314) full_index_name ::= index_name */ - -3, /* (315) full_index_name ::= db_name NK_DOT index_name */ - -10, /* (316) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - -12, /* (317) 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 */ - -1, /* (318) func_list ::= func */ - -3, /* (319) func_list ::= func_list NK_COMMA func */ - -4, /* (320) func ::= sma_func_name NK_LP expression_list NK_RP */ - -1, /* (321) sma_func_name ::= function_name */ - -1, /* (322) sma_func_name ::= COUNT */ - -1, /* (323) sma_func_name ::= FIRST */ - -1, /* (324) sma_func_name ::= LAST */ - -1, /* (325) sma_func_name ::= LAST_ROW */ - 0, /* (326) sma_stream_opt ::= */ - -3, /* (327) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - -3, /* (328) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - -3, /* (329) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - -1, /* (330) with_meta ::= AS */ - -3, /* (331) with_meta ::= WITH META AS */ - -3, /* (332) with_meta ::= ONLY META AS */ - -6, /* (333) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - -7, /* (334) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - -8, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - -4, /* (336) cmd ::= DROP TOPIC exists_opt topic_name */ - -7, /* (337) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - -2, /* (338) cmd ::= DESC full_table_name */ - -2, /* (339) cmd ::= DESCRIBE full_table_name */ - -3, /* (340) cmd ::= RESET QUERY CACHE */ - -4, /* (341) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - -4, /* (342) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 0, /* (343) analyze_opt ::= */ - -1, /* (344) analyze_opt ::= ANALYZE */ - 0, /* (345) explain_options ::= */ - -3, /* (346) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (347) explain_options ::= explain_options RATIO NK_FLOAT */ - -12, /* (348) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - -4, /* (349) cmd ::= DROP FUNCTION exists_opt function_name */ - 0, /* (350) agg_func_opt ::= */ - -1, /* (351) agg_func_opt ::= AGGREGATE */ - 0, /* (352) bufsize_opt ::= */ - -2, /* (353) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 0, /* (354) language_opt ::= */ - -2, /* (355) language_opt ::= LANGUAGE NK_STRING */ - 0, /* (356) or_replace_opt ::= */ - -2, /* (357) or_replace_opt ::= OR REPLACE */ - -6, /* (358) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - -4, /* (359) cmd ::= DROP VIEW exists_opt full_view_name */ - -1, /* (360) full_view_name ::= view_name */ - -3, /* (361) full_view_name ::= db_name NK_DOT view_name */ - -12, /* (362) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - -4, /* (363) cmd ::= DROP STREAM exists_opt stream_name */ - -4, /* (364) cmd ::= PAUSE STREAM exists_opt stream_name */ - -5, /* (365) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 0, /* (366) col_list_opt ::= */ - -3, /* (367) col_list_opt ::= NK_LP col_name_list NK_RP */ - 0, /* (368) tag_def_or_ref_opt ::= */ - -1, /* (369) tag_def_or_ref_opt ::= tags_def */ - -4, /* (370) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 0, /* (371) stream_options ::= */ - -3, /* (372) stream_options ::= stream_options TRIGGER AT_ONCE */ - -3, /* (373) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - -4, /* (374) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - -3, /* (375) stream_options ::= stream_options WATERMARK duration_literal */ - -4, /* (376) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - -3, /* (377) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - -3, /* (378) stream_options ::= stream_options DELETE_MARK duration_literal */ - -4, /* (379) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 0, /* (380) subtable_opt ::= */ - -4, /* (381) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 0, /* (382) ignore_opt ::= */ - -2, /* (383) ignore_opt ::= IGNORE UNTREATED */ - -3, /* (384) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (385) cmd ::= KILL QUERY NK_STRING */ - -3, /* (386) cmd ::= KILL TRANSACTION NK_INTEGER */ - -2, /* (387) cmd ::= BALANCE VGROUP */ - -4, /* (388) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - -4, /* (389) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (390) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (391) cmd ::= SPLIT VGROUP NK_INTEGER */ - 0, /* (392) on_vgroup_id ::= */ - -2, /* (393) on_vgroup_id ::= ON NK_INTEGER */ - -2, /* (394) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (395) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -4, /* (396) cmd ::= DELETE FROM full_table_name where_clause_opt */ - -1, /* (397) cmd ::= query_or_subquery */ - -1, /* (398) cmd ::= insert_query */ - -7, /* (399) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - -4, /* (400) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - -1, /* (401) literal ::= NK_INTEGER */ - -1, /* (402) literal ::= NK_FLOAT */ - -1, /* (403) literal ::= NK_STRING */ - -1, /* (404) literal ::= NK_BOOL */ - -2, /* (405) literal ::= TIMESTAMP NK_STRING */ - -1, /* (406) literal ::= duration_literal */ - -1, /* (407) literal ::= NULL */ - -1, /* (408) literal ::= NK_QUESTION */ - -1, /* (409) duration_literal ::= NK_VARIABLE */ - -1, /* (410) signed ::= NK_INTEGER */ - -2, /* (411) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (412) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (413) signed ::= NK_FLOAT */ - -2, /* (414) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (415) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (416) signed_literal ::= signed */ - -1, /* (417) signed_literal ::= NK_STRING */ - -1, /* (418) signed_literal ::= NK_BOOL */ - -2, /* (419) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (420) signed_literal ::= duration_literal */ - -1, /* (421) signed_literal ::= NULL */ - -1, /* (422) signed_literal ::= literal_func */ - -1, /* (423) signed_literal ::= NK_QUESTION */ - -1, /* (424) literal_list ::= signed_literal */ - -3, /* (425) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (426) db_name ::= NK_ID */ - -1, /* (427) table_name ::= NK_ID */ - -1, /* (428) column_name ::= NK_ID */ - -1, /* (429) function_name ::= NK_ID */ - -1, /* (430) view_name ::= NK_ID */ - -1, /* (431) table_alias ::= NK_ID */ - -1, /* (432) column_alias ::= NK_ID */ - -1, /* (433) column_alias ::= NK_ALIAS */ - -1, /* (434) user_name ::= NK_ID */ - -1, /* (435) topic_name ::= NK_ID */ - -1, /* (436) stream_name ::= NK_ID */ - -1, /* (437) cgroup_name ::= NK_ID */ - -1, /* (438) index_name ::= NK_ID */ - -1, /* (439) expr_or_subquery ::= expression */ - -1, /* (440) expression ::= literal */ - -1, /* (441) expression ::= pseudo_column */ - -1, /* (442) expression ::= column_reference */ - -1, /* (443) expression ::= function_expression */ - -1, /* (444) expression ::= case_when_expression */ - -3, /* (445) expression ::= NK_LP expression NK_RP */ - -2, /* (446) expression ::= NK_PLUS expr_or_subquery */ - -2, /* (447) expression ::= NK_MINUS expr_or_subquery */ - -3, /* (448) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - -3, /* (449) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - -3, /* (450) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - -3, /* (451) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - -3, /* (452) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - -3, /* (453) expression ::= column_reference NK_ARROW NK_STRING */ - -3, /* (454) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - -3, /* (455) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - -1, /* (456) expression_list ::= expr_or_subquery */ - -3, /* (457) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - -1, /* (458) column_reference ::= column_name */ - -3, /* (459) column_reference ::= table_name NK_DOT column_name */ - -1, /* (460) column_reference ::= NK_ALIAS */ - -3, /* (461) column_reference ::= table_name NK_DOT NK_ALIAS */ - -1, /* (462) pseudo_column ::= ROWTS */ - -1, /* (463) pseudo_column ::= TBNAME */ - -3, /* (464) pseudo_column ::= table_name NK_DOT TBNAME */ - -1, /* (465) pseudo_column ::= QSTART */ - -1, /* (466) pseudo_column ::= QEND */ - -1, /* (467) pseudo_column ::= QDURATION */ - -1, /* (468) pseudo_column ::= WSTART */ - -1, /* (469) pseudo_column ::= WEND */ - -1, /* (470) pseudo_column ::= WDURATION */ - -1, /* (471) pseudo_column ::= IROWTS */ - -1, /* (472) pseudo_column ::= ISFILLED */ - -1, /* (473) pseudo_column ::= QTAGS */ - -4, /* (474) function_expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (475) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - -6, /* (476) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - -1, /* (477) function_expression ::= literal_func */ - -3, /* (478) literal_func ::= noarg_func NK_LP NK_RP */ - -1, /* (479) literal_func ::= NOW */ - -1, /* (480) noarg_func ::= NOW */ - -1, /* (481) noarg_func ::= TODAY */ - -1, /* (482) noarg_func ::= TIMEZONE */ - -1, /* (483) noarg_func ::= DATABASE */ - -1, /* (484) noarg_func ::= CLIENT_VERSION */ - -1, /* (485) noarg_func ::= SERVER_VERSION */ - -1, /* (486) noarg_func ::= SERVER_STATUS */ - -1, /* (487) noarg_func ::= CURRENT_USER */ - -1, /* (488) noarg_func ::= USER */ - -1, /* (489) star_func ::= COUNT */ - -1, /* (490) star_func ::= FIRST */ - -1, /* (491) star_func ::= LAST */ - -1, /* (492) star_func ::= LAST_ROW */ - -1, /* (493) star_func_para_list ::= NK_STAR */ - -1, /* (494) star_func_para_list ::= other_para_list */ - -1, /* (495) other_para_list ::= star_func_para */ - -3, /* (496) other_para_list ::= other_para_list NK_COMMA star_func_para */ - -1, /* (497) star_func_para ::= expr_or_subquery */ - -3, /* (498) star_func_para ::= table_name NK_DOT NK_STAR */ - -4, /* (499) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - -5, /* (500) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - -1, /* (501) when_then_list ::= when_then_expr */ - -2, /* (502) when_then_list ::= when_then_list when_then_expr */ - -4, /* (503) when_then_expr ::= WHEN common_expression THEN common_expression */ - 0, /* (504) case_when_else_opt ::= */ - -2, /* (505) case_when_else_opt ::= ELSE common_expression */ - -3, /* (506) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - -5, /* (507) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - -6, /* (508) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - -3, /* (509) predicate ::= expr_or_subquery IS NULL */ - -4, /* (510) predicate ::= expr_or_subquery IS NOT NULL */ - -3, /* (511) predicate ::= expr_or_subquery in_op in_predicate_value */ - -1, /* (512) compare_op ::= NK_LT */ - -1, /* (513) compare_op ::= NK_GT */ - -1, /* (514) compare_op ::= NK_LE */ - -1, /* (515) compare_op ::= NK_GE */ - -1, /* (516) compare_op ::= NK_NE */ - -1, /* (517) compare_op ::= NK_EQ */ - -1, /* (518) compare_op ::= LIKE */ - -2, /* (519) compare_op ::= NOT LIKE */ - -1, /* (520) compare_op ::= MATCH */ - -1, /* (521) compare_op ::= NMATCH */ - -1, /* (522) compare_op ::= CONTAINS */ - -1, /* (523) in_op ::= IN */ - -2, /* (524) in_op ::= NOT IN */ - -3, /* (525) in_predicate_value ::= NK_LP literal_list NK_RP */ - -1, /* (526) boolean_value_expression ::= boolean_primary */ - -2, /* (527) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (528) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (529) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (530) boolean_primary ::= predicate */ - -3, /* (531) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (532) common_expression ::= expr_or_subquery */ - -1, /* (533) common_expression ::= boolean_value_expression */ - 0, /* (534) from_clause_opt ::= */ - -2, /* (535) from_clause_opt ::= FROM table_reference_list */ - -1, /* (536) table_reference_list ::= table_reference */ - -3, /* (537) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (538) table_reference ::= table_primary */ - -1, /* (539) table_reference ::= joined_table */ - -2, /* (540) table_primary ::= table_name alias_opt */ - -4, /* (541) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (542) table_primary ::= subquery alias_opt */ - -1, /* (543) table_primary ::= parenthesized_joined_table */ - 0, /* (544) alias_opt ::= */ - -1, /* (545) alias_opt ::= table_alias */ - -2, /* (546) alias_opt ::= AS table_alias */ - -3, /* (547) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (548) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (549) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (550) join_type ::= */ - -1, /* (551) join_type ::= INNER */ - -14, /* (552) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 0, /* (553) hint_list ::= */ - -1, /* (554) hint_list ::= NK_HINT */ - 0, /* (555) tag_mode_opt ::= */ - -1, /* (556) tag_mode_opt ::= TAGS */ - 0, /* (557) set_quantifier_opt ::= */ - -1, /* (558) set_quantifier_opt ::= DISTINCT */ - -1, /* (559) set_quantifier_opt ::= ALL */ - -1, /* (560) select_list ::= select_item */ - -3, /* (561) select_list ::= select_list NK_COMMA select_item */ - -1, /* (562) select_item ::= NK_STAR */ - -1, /* (563) select_item ::= common_expression */ - -2, /* (564) select_item ::= common_expression column_alias */ - -3, /* (565) select_item ::= common_expression AS column_alias */ - -3, /* (566) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (567) where_clause_opt ::= */ - -2, /* (568) where_clause_opt ::= WHERE search_condition */ - 0, /* (569) partition_by_clause_opt ::= */ - -3, /* (570) partition_by_clause_opt ::= PARTITION BY partition_list */ - -1, /* (571) partition_list ::= partition_item */ - -3, /* (572) partition_list ::= partition_list NK_COMMA partition_item */ - -1, /* (573) partition_item ::= expr_or_subquery */ - -2, /* (574) partition_item ::= expr_or_subquery column_alias */ - -3, /* (575) partition_item ::= expr_or_subquery AS column_alias */ - 0, /* (576) twindow_clause_opt ::= */ - -6, /* (577) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - -4, /* (578) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - -6, /* (579) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (580) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -7, /* (581) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 0, /* (582) sliding_opt ::= */ - -4, /* (583) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (584) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (585) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (586) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (587) fill_opt ::= */ - -4, /* (588) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (589) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (590) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (591) fill_mode ::= NONE */ - -1, /* (592) fill_mode ::= PREV */ - -1, /* (593) fill_mode ::= NULL */ - -1, /* (594) fill_mode ::= NULL_F */ - -1, /* (595) fill_mode ::= LINEAR */ - -1, /* (596) fill_mode ::= NEXT */ - 0, /* (597) group_by_clause_opt ::= */ - -3, /* (598) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (599) group_by_list ::= expr_or_subquery */ - -3, /* (600) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (601) having_clause_opt ::= */ - -2, /* (602) having_clause_opt ::= HAVING search_condition */ - 0, /* (603) range_opt ::= */ - -6, /* (604) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (605) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (606) every_opt ::= */ - -4, /* (607) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (608) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (609) query_simple ::= query_specification */ - -1, /* (610) query_simple ::= union_query_expression */ - -4, /* (611) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (612) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (613) query_simple_or_subquery ::= query_simple */ - -1, /* (614) query_simple_or_subquery ::= subquery */ - -1, /* (615) query_or_subquery ::= query_expression */ - -1, /* (616) query_or_subquery ::= subquery */ - 0, /* (617) order_by_clause_opt ::= */ - -3, /* (618) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (619) slimit_clause_opt ::= */ - -2, /* (620) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (621) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (622) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (623) limit_clause_opt ::= */ - -2, /* (624) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (625) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (626) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (627) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (628) subquery ::= NK_LP subquery NK_RP */ - -1, /* (629) search_condition ::= common_expression */ - -1, /* (630) sort_specification_list ::= sort_specification */ - -3, /* (631) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (632) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (633) ordering_specification_opt ::= */ - -1, /* (634) ordering_specification_opt ::= ASC */ - -1, /* (635) ordering_specification_opt ::= DESC */ - 0, /* (636) null_ordering_opt ::= */ - -2, /* (637) null_ordering_opt ::= NULLS FIRST */ - -2, /* (638) null_ordering_opt ::= NULLS LAST */ + -2, /* (287) cmd ::= SHOW COMPACTS */ + -3, /* (288) cmd ::= SHOW COMPACT NK_INTEGER */ + 0, /* (289) table_kind_db_name_cond_opt ::= */ + -1, /* (290) table_kind_db_name_cond_opt ::= table_kind */ + -2, /* (291) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + -3, /* (292) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + -1, /* (293) table_kind ::= NORMAL */ + -1, /* (294) table_kind ::= CHILD */ + 0, /* (295) db_name_cond_opt ::= */ + -2, /* (296) db_name_cond_opt ::= db_name NK_DOT */ + 0, /* (297) like_pattern_opt ::= */ + -2, /* (298) like_pattern_opt ::= LIKE NK_STRING */ + -1, /* (299) table_name_cond ::= table_name */ + 0, /* (300) from_db_opt ::= */ + -2, /* (301) from_db_opt ::= FROM db_name */ + 0, /* (302) tag_list_opt ::= */ + -1, /* (303) tag_list_opt ::= tag_item */ + -3, /* (304) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + -1, /* (305) tag_item ::= TBNAME */ + -1, /* (306) tag_item ::= QTAGS */ + -1, /* (307) tag_item ::= column_name */ + -2, /* (308) tag_item ::= column_name column_alias */ + -3, /* (309) tag_item ::= column_name AS column_alias */ + 0, /* (310) db_kind_opt ::= */ + -1, /* (311) db_kind_opt ::= USER */ + -1, /* (312) db_kind_opt ::= SYSTEM */ + -8, /* (313) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + -9, /* (314) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + -4, /* (315) cmd ::= DROP INDEX exists_opt full_index_name */ + -1, /* (316) full_index_name ::= index_name */ + -3, /* (317) full_index_name ::= db_name NK_DOT index_name */ + -10, /* (318) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + -12, /* (319) 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 */ + -1, /* (320) func_list ::= func */ + -3, /* (321) func_list ::= func_list NK_COMMA func */ + -4, /* (322) func ::= sma_func_name NK_LP expression_list NK_RP */ + -1, /* (323) sma_func_name ::= function_name */ + -1, /* (324) sma_func_name ::= COUNT */ + -1, /* (325) sma_func_name ::= FIRST */ + -1, /* (326) sma_func_name ::= LAST */ + -1, /* (327) sma_func_name ::= LAST_ROW */ + 0, /* (328) sma_stream_opt ::= */ + -3, /* (329) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + -3, /* (330) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + -3, /* (331) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + -1, /* (332) with_meta ::= AS */ + -3, /* (333) with_meta ::= WITH META AS */ + -3, /* (334) with_meta ::= ONLY META AS */ + -6, /* (335) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + -7, /* (336) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + -8, /* (337) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + -4, /* (338) cmd ::= DROP TOPIC exists_opt topic_name */ + -7, /* (339) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + -2, /* (340) cmd ::= DESC full_table_name */ + -2, /* (341) cmd ::= DESCRIBE full_table_name */ + -3, /* (342) cmd ::= RESET QUERY CACHE */ + -4, /* (343) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + -4, /* (344) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 0, /* (345) analyze_opt ::= */ + -1, /* (346) analyze_opt ::= ANALYZE */ + 0, /* (347) explain_options ::= */ + -3, /* (348) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (349) explain_options ::= explain_options RATIO NK_FLOAT */ + -12, /* (350) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + -4, /* (351) cmd ::= DROP FUNCTION exists_opt function_name */ + 0, /* (352) agg_func_opt ::= */ + -1, /* (353) agg_func_opt ::= AGGREGATE */ + 0, /* (354) bufsize_opt ::= */ + -2, /* (355) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 0, /* (356) language_opt ::= */ + -2, /* (357) language_opt ::= LANGUAGE NK_STRING */ + 0, /* (358) or_replace_opt ::= */ + -2, /* (359) or_replace_opt ::= OR REPLACE */ + -6, /* (360) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + -4, /* (361) cmd ::= DROP VIEW exists_opt full_view_name */ + -1, /* (362) full_view_name ::= view_name */ + -3, /* (363) full_view_name ::= db_name NK_DOT view_name */ + -12, /* (364) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + -4, /* (365) cmd ::= DROP STREAM exists_opt stream_name */ + -4, /* (366) cmd ::= PAUSE STREAM exists_opt stream_name */ + -5, /* (367) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 0, /* (368) col_list_opt ::= */ + -3, /* (369) col_list_opt ::= NK_LP col_name_list NK_RP */ + 0, /* (370) tag_def_or_ref_opt ::= */ + -1, /* (371) tag_def_or_ref_opt ::= tags_def */ + -4, /* (372) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 0, /* (373) stream_options ::= */ + -3, /* (374) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (375) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -4, /* (376) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + -3, /* (377) stream_options ::= stream_options WATERMARK duration_literal */ + -4, /* (378) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + -3, /* (379) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + -3, /* (380) stream_options ::= stream_options DELETE_MARK duration_literal */ + -4, /* (381) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 0, /* (382) subtable_opt ::= */ + -4, /* (383) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 0, /* (384) ignore_opt ::= */ + -2, /* (385) ignore_opt ::= IGNORE UNTREATED */ + -3, /* (386) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (387) cmd ::= KILL QUERY NK_STRING */ + -3, /* (388) cmd ::= KILL TRANSACTION NK_INTEGER */ + -3, /* (389) cmd ::= KILL COMPACT NK_INTEGER */ + -2, /* (390) cmd ::= BALANCE VGROUP */ + -4, /* (391) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + -4, /* (392) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (393) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (394) cmd ::= SPLIT VGROUP NK_INTEGER */ + 0, /* (395) on_vgroup_id ::= */ + -2, /* (396) on_vgroup_id ::= ON NK_INTEGER */ + -2, /* (397) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (398) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -4, /* (399) cmd ::= DELETE FROM full_table_name where_clause_opt */ + -1, /* (400) cmd ::= query_or_subquery */ + -1, /* (401) cmd ::= insert_query */ + -7, /* (402) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + -4, /* (403) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + -1, /* (404) literal ::= NK_INTEGER */ + -1, /* (405) literal ::= NK_FLOAT */ + -1, /* (406) literal ::= NK_STRING */ + -1, /* (407) literal ::= NK_BOOL */ + -2, /* (408) literal ::= TIMESTAMP NK_STRING */ + -1, /* (409) literal ::= duration_literal */ + -1, /* (410) literal ::= NULL */ + -1, /* (411) literal ::= NK_QUESTION */ + -1, /* (412) duration_literal ::= NK_VARIABLE */ + -1, /* (413) signed ::= NK_INTEGER */ + -2, /* (414) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (415) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (416) signed ::= NK_FLOAT */ + -2, /* (417) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (418) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (419) signed_literal ::= signed */ + -1, /* (420) signed_literal ::= NK_STRING */ + -1, /* (421) signed_literal ::= NK_BOOL */ + -2, /* (422) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (423) signed_literal ::= duration_literal */ + -1, /* (424) signed_literal ::= NULL */ + -1, /* (425) signed_literal ::= literal_func */ + -1, /* (426) signed_literal ::= NK_QUESTION */ + -1, /* (427) literal_list ::= signed_literal */ + -3, /* (428) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (429) db_name ::= NK_ID */ + -1, /* (430) table_name ::= NK_ID */ + -1, /* (431) column_name ::= NK_ID */ + -1, /* (432) function_name ::= NK_ID */ + -1, /* (433) view_name ::= NK_ID */ + -1, /* (434) table_alias ::= NK_ID */ + -1, /* (435) column_alias ::= NK_ID */ + -1, /* (436) column_alias ::= NK_ALIAS */ + -1, /* (437) user_name ::= NK_ID */ + -1, /* (438) topic_name ::= NK_ID */ + -1, /* (439) stream_name ::= NK_ID */ + -1, /* (440) cgroup_name ::= NK_ID */ + -1, /* (441) index_name ::= NK_ID */ + -1, /* (442) expr_or_subquery ::= expression */ + -1, /* (443) expression ::= literal */ + -1, /* (444) expression ::= pseudo_column */ + -1, /* (445) expression ::= column_reference */ + -1, /* (446) expression ::= function_expression */ + -1, /* (447) expression ::= case_when_expression */ + -3, /* (448) expression ::= NK_LP expression NK_RP */ + -2, /* (449) expression ::= NK_PLUS expr_or_subquery */ + -2, /* (450) expression ::= NK_MINUS expr_or_subquery */ + -3, /* (451) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + -3, /* (452) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + -3, /* (453) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + -3, /* (454) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + -3, /* (455) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + -3, /* (456) expression ::= column_reference NK_ARROW NK_STRING */ + -3, /* (457) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + -3, /* (458) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + -1, /* (459) expression_list ::= expr_or_subquery */ + -3, /* (460) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + -1, /* (461) column_reference ::= column_name */ + -3, /* (462) column_reference ::= table_name NK_DOT column_name */ + -1, /* (463) column_reference ::= NK_ALIAS */ + -3, /* (464) column_reference ::= table_name NK_DOT NK_ALIAS */ + -1, /* (465) pseudo_column ::= ROWTS */ + -1, /* (466) pseudo_column ::= TBNAME */ + -3, /* (467) pseudo_column ::= table_name NK_DOT TBNAME */ + -1, /* (468) pseudo_column ::= QSTART */ + -1, /* (469) pseudo_column ::= QEND */ + -1, /* (470) pseudo_column ::= QDURATION */ + -1, /* (471) pseudo_column ::= WSTART */ + -1, /* (472) pseudo_column ::= WEND */ + -1, /* (473) pseudo_column ::= WDURATION */ + -1, /* (474) pseudo_column ::= IROWTS */ + -1, /* (475) pseudo_column ::= ISFILLED */ + -1, /* (476) pseudo_column ::= QTAGS */ + -4, /* (477) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (478) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (479) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + -1, /* (480) function_expression ::= literal_func */ + -3, /* (481) literal_func ::= noarg_func NK_LP NK_RP */ + -1, /* (482) literal_func ::= NOW */ + -1, /* (483) noarg_func ::= NOW */ + -1, /* (484) noarg_func ::= TODAY */ + -1, /* (485) noarg_func ::= TIMEZONE */ + -1, /* (486) noarg_func ::= DATABASE */ + -1, /* (487) noarg_func ::= CLIENT_VERSION */ + -1, /* (488) noarg_func ::= SERVER_VERSION */ + -1, /* (489) noarg_func ::= SERVER_STATUS */ + -1, /* (490) noarg_func ::= CURRENT_USER */ + -1, /* (491) noarg_func ::= USER */ + -1, /* (492) star_func ::= COUNT */ + -1, /* (493) star_func ::= FIRST */ + -1, /* (494) star_func ::= LAST */ + -1, /* (495) star_func ::= LAST_ROW */ + -1, /* (496) star_func_para_list ::= NK_STAR */ + -1, /* (497) star_func_para_list ::= other_para_list */ + -1, /* (498) other_para_list ::= star_func_para */ + -3, /* (499) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (500) star_func_para ::= expr_or_subquery */ + -3, /* (501) star_func_para ::= table_name NK_DOT NK_STAR */ + -4, /* (502) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + -5, /* (503) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + -1, /* (504) when_then_list ::= when_then_expr */ + -2, /* (505) when_then_list ::= when_then_list when_then_expr */ + -4, /* (506) when_then_expr ::= WHEN common_expression THEN common_expression */ + 0, /* (507) case_when_else_opt ::= */ + -2, /* (508) case_when_else_opt ::= ELSE common_expression */ + -3, /* (509) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + -5, /* (510) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + -6, /* (511) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + -3, /* (512) predicate ::= expr_or_subquery IS NULL */ + -4, /* (513) predicate ::= expr_or_subquery IS NOT NULL */ + -3, /* (514) predicate ::= expr_or_subquery in_op in_predicate_value */ + -1, /* (515) compare_op ::= NK_LT */ + -1, /* (516) compare_op ::= NK_GT */ + -1, /* (517) compare_op ::= NK_LE */ + -1, /* (518) compare_op ::= NK_GE */ + -1, /* (519) compare_op ::= NK_NE */ + -1, /* (520) compare_op ::= NK_EQ */ + -1, /* (521) compare_op ::= LIKE */ + -2, /* (522) compare_op ::= NOT LIKE */ + -1, /* (523) compare_op ::= MATCH */ + -1, /* (524) compare_op ::= NMATCH */ + -1, /* (525) compare_op ::= CONTAINS */ + -1, /* (526) in_op ::= IN */ + -2, /* (527) in_op ::= NOT IN */ + -3, /* (528) in_predicate_value ::= NK_LP literal_list NK_RP */ + -1, /* (529) boolean_value_expression ::= boolean_primary */ + -2, /* (530) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (531) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (532) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (533) boolean_primary ::= predicate */ + -3, /* (534) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (535) common_expression ::= expr_or_subquery */ + -1, /* (536) common_expression ::= boolean_value_expression */ + 0, /* (537) from_clause_opt ::= */ + -2, /* (538) from_clause_opt ::= FROM table_reference_list */ + -1, /* (539) table_reference_list ::= table_reference */ + -3, /* (540) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (541) table_reference ::= table_primary */ + -1, /* (542) table_reference ::= joined_table */ + -2, /* (543) table_primary ::= table_name alias_opt */ + -4, /* (544) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (545) table_primary ::= subquery alias_opt */ + -1, /* (546) table_primary ::= parenthesized_joined_table */ + 0, /* (547) alias_opt ::= */ + -1, /* (548) alias_opt ::= table_alias */ + -2, /* (549) alias_opt ::= AS table_alias */ + -3, /* (550) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (551) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (552) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (553) join_type ::= */ + -1, /* (554) join_type ::= INNER */ + -14, /* (555) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 0, /* (556) hint_list ::= */ + -1, /* (557) hint_list ::= NK_HINT */ + 0, /* (558) tag_mode_opt ::= */ + -1, /* (559) tag_mode_opt ::= TAGS */ + 0, /* (560) set_quantifier_opt ::= */ + -1, /* (561) set_quantifier_opt ::= DISTINCT */ + -1, /* (562) set_quantifier_opt ::= ALL */ + -1, /* (563) select_list ::= select_item */ + -3, /* (564) select_list ::= select_list NK_COMMA select_item */ + -1, /* (565) select_item ::= NK_STAR */ + -1, /* (566) select_item ::= common_expression */ + -2, /* (567) select_item ::= common_expression column_alias */ + -3, /* (568) select_item ::= common_expression AS column_alias */ + -3, /* (569) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (570) where_clause_opt ::= */ + -2, /* (571) where_clause_opt ::= WHERE search_condition */ + 0, /* (572) partition_by_clause_opt ::= */ + -3, /* (573) partition_by_clause_opt ::= PARTITION BY partition_list */ + -1, /* (574) partition_list ::= partition_item */ + -3, /* (575) partition_list ::= partition_list NK_COMMA partition_item */ + -1, /* (576) partition_item ::= expr_or_subquery */ + -2, /* (577) partition_item ::= expr_or_subquery column_alias */ + -3, /* (578) partition_item ::= expr_or_subquery AS column_alias */ + 0, /* (579) twindow_clause_opt ::= */ + -6, /* (580) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + -4, /* (581) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + -6, /* (582) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (583) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -7, /* (584) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 0, /* (585) sliding_opt ::= */ + -4, /* (586) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (587) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (588) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (589) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (590) fill_opt ::= */ + -4, /* (591) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (592) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (593) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (594) fill_mode ::= NONE */ + -1, /* (595) fill_mode ::= PREV */ + -1, /* (596) fill_mode ::= NULL */ + -1, /* (597) fill_mode ::= NULL_F */ + -1, /* (598) fill_mode ::= LINEAR */ + -1, /* (599) fill_mode ::= NEXT */ + 0, /* (600) group_by_clause_opt ::= */ + -3, /* (601) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (602) group_by_list ::= expr_or_subquery */ + -3, /* (603) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (604) having_clause_opt ::= */ + -2, /* (605) having_clause_opt ::= HAVING search_condition */ + 0, /* (606) range_opt ::= */ + -6, /* (607) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (608) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (609) every_opt ::= */ + -4, /* (610) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (611) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (612) query_simple ::= query_specification */ + -1, /* (613) query_simple ::= union_query_expression */ + -4, /* (614) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (615) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (616) query_simple_or_subquery ::= query_simple */ + -1, /* (617) query_simple_or_subquery ::= subquery */ + -1, /* (618) query_or_subquery ::= query_expression */ + -1, /* (619) query_or_subquery ::= subquery */ + 0, /* (620) order_by_clause_opt ::= */ + -3, /* (621) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (622) slimit_clause_opt ::= */ + -2, /* (623) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (624) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (625) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (626) limit_clause_opt ::= */ + -2, /* (627) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (628) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (629) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (630) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (631) subquery ::= NK_LP subquery NK_RP */ + -1, /* (632) search_condition ::= common_expression */ + -1, /* (633) sort_specification_list ::= sort_specification */ + -3, /* (634) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (635) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (636) ordering_specification_opt ::= */ + -1, /* (637) ordering_specification_opt ::= ASC */ + -1, /* (638) ordering_specification_opt ::= DESC */ + 0, /* (639) null_ordering_opt ::= */ + -2, /* (640) null_ordering_opt ::= NULLS FIRST */ + -2, /* (641) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -4667,54 +5040,6 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } - yymsp = yypParser->yytos; - } -#endif - } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -4728,15 +5053,21 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ +#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,347,&yymsp[0].minor); - break; - case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ -{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 5058 "sql.c" yy_destructor(yypParser,348,&yymsp[0].minor); break; + case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ +#line 51 "sql.y" +{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 5064 "sql.c" + yy_destructor(yypParser,349,&yymsp[0].minor); + break; case 2: /* account_options ::= */ +#line 55 "sql.y" { } +#line 5070 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -4747,20 +5078,26 @@ 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,347,&yymsp[-2].minor); +{ yy_destructor(yypParser,348,&yymsp[-2].minor); +#line 56 "sql.y" { } - yy_destructor(yypParser,349,&yymsp[0].minor); +#line 5084 "sql.c" + yy_destructor(yypParser,350,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,350,&yymsp[0].minor); +{ yy_destructor(yypParser,351,&yymsp[0].minor); +#line 68 "sql.y" { } +#line 5092 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,348,&yymsp[-1].minor); +{ yy_destructor(yypParser,349,&yymsp[-1].minor); +#line 69 "sql.y" { } - yy_destructor(yypParser,350,&yymsp[0].minor); +#line 5099 "sql.c" + yy_destructor(yypParser,351,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -4773,501 +5110,735 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); +#line 73 "sql.y" { } - yy_destructor(yypParser,349,&yymsp[0].minor); +#line 5115 "sql.c" + yy_destructor(yypParser,350,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy106 = yylhsminor.yy106; +#line 86 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5121 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; +#line 87 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5127 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy106 = yymsp[0].minor.yy106; } +#line 91 "sql.y" +{ yymsp[-1].minor.yy88 = yymsp[0].minor.yy88; } +#line 5133 "sql.c" break; case 27: /* white_list_opt ::= */ case 186: /* specific_cols_opt ::= */ yytestcase(yyruleno==186); case 217: /* tags_def_opt ::= */ yytestcase(yyruleno==217); - case 300: /* tag_list_opt ::= */ yytestcase(yyruleno==300); - case 366: /* col_list_opt ::= */ yytestcase(yyruleno==366); - case 368: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==368); - case 569: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==569); - case 597: /* group_by_clause_opt ::= */ yytestcase(yyruleno==597); - case 617: /* order_by_clause_opt ::= */ yytestcase(yyruleno==617); -{ yymsp[1].minor.yy106 = NULL; } + case 302: /* tag_list_opt ::= */ yytestcase(yyruleno==302); + case 368: /* col_list_opt ::= */ yytestcase(yyruleno==368); + case 370: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==370); + case 572: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==572); + case 600: /* group_by_clause_opt ::= */ yytestcase(yyruleno==600); + case 620: /* order_by_clause_opt ::= */ yytestcase(yyruleno==620); +#line 95 "sql.y" +{ yymsp[1].minor.yy88 = NULL; } +#line 5146 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 218: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==218); - case 369: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==369); - case 494: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==494); -{ yylhsminor.yy106 = yymsp[0].minor.yy106; } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 371: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==371); + case 497: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==497); +#line 96 "sql.y" +{ yylhsminor.yy88 = yymsp[0].minor.yy88; } +#line 5154 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ +#line 100 "sql.y" { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy785, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy431); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy106); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy993, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy279); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy88); } +#line 5163 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 104 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy993, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 5168 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 105 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy993, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 5173 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 106 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy993, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 5178 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy106); } +#line 107 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy993, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy88); } +#line 5183 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy106); } +#line 108 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy993, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy88); } +#line 5188 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy785); } +#line 109 "sql.y" +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy993); } +#line 5193 "sql.c" break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy431 = 1; } +#line 113 "sql.y" +{ yymsp[1].minor.yy279 = 1; } +#line 5198 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy431 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 114 "sql.y" +{ yymsp[-1].minor.yy279 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5203 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy987, &yymsp[-3].minor.yy573, &yymsp[0].minor.yy785, yymsp[-2].minor.yy80); } +#line 117 "sql.y" +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy993, yymsp[-2].minor.yy232); } +#line 5208 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy987, &yymsp[-3].minor.yy573, &yymsp[0].minor.yy785, yymsp[-2].minor.yy80); } +#line 118 "sql.y" +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy993, yymsp[-2].minor.yy232); } +#line 5213 "sql.c" break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_ALL; } +#line 122 "sql.y" +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALL; } +#line 5218 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy987 = yymsp[0].minor.yy987; } - yymsp[0].minor.yy987 = yylhsminor.yy987; +#line 123 "sql.y" +{ yylhsminor.yy221 = yymsp[0].minor.yy221; } +#line 5224 "sql.c" + yymsp[0].minor.yy221 = yylhsminor.yy221; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 124 "sql.y" +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 5230 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy987 = yymsp[-2].minor.yy987 | yymsp[0].minor.yy987; } - yymsp[-2].minor.yy987 = yylhsminor.yy987; +#line 129 "sql.y" +{ yylhsminor.yy221 = yymsp[-2].minor.yy221 | yymsp[0].minor.yy221; } +#line 5235 "sql.c" + yymsp[-2].minor.yy221 = yylhsminor.yy221; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_READ; } +#line 133 "sql.y" +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_READ; } +#line 5241 "sql.c" break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_WRITE; } +#line 134 "sql.y" +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_WRITE; } +#line 5246 "sql.c" break; case 47: /* priv_type ::= ALTER */ -{ yymsp[0].minor.yy987 = PRIVILEGE_TYPE_ALTER; } +#line 135 "sql.y" +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALTER; } +#line 5251 "sql.c" break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy573.first = yymsp[-2].minor.yy0; yylhsminor.yy573.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy573 = yylhsminor.yy573; +#line 139 "sql.y" +{ yylhsminor.yy241.first = yymsp[-2].minor.yy0; yylhsminor.yy241.second = yymsp[0].minor.yy0; } +#line 5256 "sql.c" + yymsp[-2].minor.yy241 = yylhsminor.yy241; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy573.first = yymsp[-2].minor.yy785; yylhsminor.yy573.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy573 = yylhsminor.yy573; +#line 140 "sql.y" +{ yylhsminor.yy241.first = yymsp[-2].minor.yy993; yylhsminor.yy241.second = yymsp[0].minor.yy0; } +#line 5262 "sql.c" + yymsp[-2].minor.yy241 = yylhsminor.yy241; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy573.first = yymsp[-2].minor.yy785; yylhsminor.yy573.second = yymsp[0].minor.yy785; } - yymsp[-2].minor.yy573 = yylhsminor.yy573; +#line 141 "sql.y" +{ yylhsminor.yy241.first = yymsp[-2].minor.yy993; yylhsminor.yy241.second = yymsp[0].minor.yy993; } +#line 5268 "sql.c" + yymsp[-2].minor.yy241 = yylhsminor.yy241; break; case 51: /* priv_level ::= topic_name */ -{ yylhsminor.yy573.first = yymsp[0].minor.yy785; yylhsminor.yy573.second = nil_token; } - yymsp[0].minor.yy573 = yylhsminor.yy573; +#line 142 "sql.y" +{ yylhsminor.yy241.first = yymsp[0].minor.yy993; yylhsminor.yy241.second = nil_token; } +#line 5274 "sql.c" + yymsp[0].minor.yy241 = yylhsminor.yy241; break; case 52: /* with_opt ::= */ case 155: /* start_opt ::= */ yytestcase(yyruleno==155); case 159: /* end_opt ::= */ yytestcase(yyruleno==159); - case 295: /* like_pattern_opt ::= */ yytestcase(yyruleno==295); - case 380: /* subtable_opt ::= */ yytestcase(yyruleno==380); - case 504: /* case_when_else_opt ::= */ yytestcase(yyruleno==504); - case 534: /* from_clause_opt ::= */ yytestcase(yyruleno==534); - case 567: /* where_clause_opt ::= */ yytestcase(yyruleno==567); - case 576: /* twindow_clause_opt ::= */ yytestcase(yyruleno==576); - case 582: /* sliding_opt ::= */ yytestcase(yyruleno==582); - case 587: /* fill_opt ::= */ yytestcase(yyruleno==587); - case 601: /* having_clause_opt ::= */ yytestcase(yyruleno==601); - case 603: /* range_opt ::= */ yytestcase(yyruleno==603); - case 606: /* every_opt ::= */ yytestcase(yyruleno==606); - case 619: /* slimit_clause_opt ::= */ yytestcase(yyruleno==619); - case 623: /* limit_clause_opt ::= */ yytestcase(yyruleno==623); -{ yymsp[1].minor.yy80 = NULL; } + case 297: /* like_pattern_opt ::= */ yytestcase(yyruleno==297); + case 382: /* subtable_opt ::= */ yytestcase(yyruleno==382); + case 507: /* case_when_else_opt ::= */ yytestcase(yyruleno==507); + case 537: /* from_clause_opt ::= */ yytestcase(yyruleno==537); + case 570: /* where_clause_opt ::= */ yytestcase(yyruleno==570); + case 579: /* twindow_clause_opt ::= */ yytestcase(yyruleno==579); + case 585: /* sliding_opt ::= */ yytestcase(yyruleno==585); + case 590: /* fill_opt ::= */ yytestcase(yyruleno==590); + case 604: /* having_clause_opt ::= */ yytestcase(yyruleno==604); + case 606: /* range_opt ::= */ yytestcase(yyruleno==606); + case 609: /* every_opt ::= */ yytestcase(yyruleno==609); + case 622: /* slimit_clause_opt ::= */ yytestcase(yyruleno==622); + case 626: /* limit_clause_opt ::= */ yytestcase(yyruleno==626); +#line 144 "sql.y" +{ yymsp[1].minor.yy232 = NULL; } +#line 5295 "sql.c" break; case 53: /* with_opt ::= WITH search_condition */ - case 535: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==535); - case 568: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==568); - case 602: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==602); -{ yymsp[-1].minor.yy80 = yymsp[0].minor.yy80; } + case 538: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==538); + case 571: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==571); + case 605: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==605); +#line 145 "sql.y" +{ yymsp[-1].minor.yy232 = yymsp[0].minor.yy232; } +#line 5303 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy785, NULL); } +#line 148 "sql.y" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy993, NULL); } +#line 5308 "sql.c" break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } +#line 149 "sql.y" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0); } +#line 5313 "sql.c" break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy923, false); } +#line 150 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy985, false); } +#line 5318 "sql.c" break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy923, false); } +#line 151 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy993, yymsp[0].minor.yy985, false); } +#line 5323 "sql.c" break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy923); } +#line 152 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy985); } +#line 5328 "sql.c" break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, false, yymsp[0].minor.yy923); } +#line 153 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy993, false, yymsp[0].minor.yy985); } +#line 5333 "sql.c" break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ +#line 154 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } +#line 5338 "sql.c" break; case 61: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ +#line 155 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5343 "sql.c" break; case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ +#line 156 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } +#line 5348 "sql.c" break; case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ +#line 157 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5353 "sql.c" break; case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ +#line 158 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } +#line 5358 "sql.c" break; case 65: /* dnode_endpoint ::= NK_STRING */ case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); case 67: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==67); - case 322: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==322); - case 323: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==323); - case 324: /* sma_func_name ::= LAST */ yytestcase(yyruleno==324); - case 325: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==325); - case 426: /* db_name ::= NK_ID */ yytestcase(yyruleno==426); - case 427: /* table_name ::= NK_ID */ yytestcase(yyruleno==427); - case 428: /* column_name ::= NK_ID */ yytestcase(yyruleno==428); - case 429: /* function_name ::= NK_ID */ yytestcase(yyruleno==429); - case 430: /* view_name ::= NK_ID */ yytestcase(yyruleno==430); - case 431: /* table_alias ::= NK_ID */ yytestcase(yyruleno==431); - case 432: /* column_alias ::= NK_ID */ yytestcase(yyruleno==432); - case 433: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==433); - case 434: /* user_name ::= NK_ID */ yytestcase(yyruleno==434); - case 435: /* topic_name ::= NK_ID */ yytestcase(yyruleno==435); - case 436: /* stream_name ::= NK_ID */ yytestcase(yyruleno==436); - case 437: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==437); - case 438: /* index_name ::= NK_ID */ yytestcase(yyruleno==438); - case 480: /* noarg_func ::= NOW */ yytestcase(yyruleno==480); - case 481: /* noarg_func ::= TODAY */ yytestcase(yyruleno==481); - case 482: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==482); - case 483: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==483); - case 484: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==484); - case 485: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==485); - case 486: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==486); - case 487: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==487); - case 488: /* noarg_func ::= USER */ yytestcase(yyruleno==488); - case 489: /* star_func ::= COUNT */ yytestcase(yyruleno==489); - case 490: /* star_func ::= FIRST */ yytestcase(yyruleno==490); - case 491: /* star_func ::= LAST */ yytestcase(yyruleno==491); - case 492: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==492); -{ yylhsminor.yy785 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy785 = yylhsminor.yy785; + case 324: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==324); + case 325: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==325); + case 326: /* sma_func_name ::= LAST */ yytestcase(yyruleno==326); + case 327: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==327); + case 429: /* db_name ::= NK_ID */ yytestcase(yyruleno==429); + case 430: /* table_name ::= NK_ID */ yytestcase(yyruleno==430); + case 431: /* column_name ::= NK_ID */ yytestcase(yyruleno==431); + case 432: /* function_name ::= NK_ID */ yytestcase(yyruleno==432); + case 433: /* view_name ::= NK_ID */ yytestcase(yyruleno==433); + case 434: /* table_alias ::= NK_ID */ yytestcase(yyruleno==434); + case 435: /* column_alias ::= NK_ID */ yytestcase(yyruleno==435); + case 436: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==436); + case 437: /* user_name ::= NK_ID */ yytestcase(yyruleno==437); + case 438: /* topic_name ::= NK_ID */ yytestcase(yyruleno==438); + case 439: /* stream_name ::= NK_ID */ yytestcase(yyruleno==439); + case 440: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==440); + case 441: /* index_name ::= NK_ID */ yytestcase(yyruleno==441); + case 483: /* noarg_func ::= NOW */ yytestcase(yyruleno==483); + case 484: /* noarg_func ::= TODAY */ yytestcase(yyruleno==484); + case 485: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==485); + case 486: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==486); + case 487: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==487); + case 488: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==488); + case 489: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==489); + case 490: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==490); + case 491: /* noarg_func ::= USER */ yytestcase(yyruleno==491); + case 492: /* star_func ::= COUNT */ yytestcase(yyruleno==492); + case 493: /* star_func ::= FIRST */ yytestcase(yyruleno==493); + case 494: /* star_func ::= LAST */ yytestcase(yyruleno==494); + case 495: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==495); +#line 162 "sql.y" +{ yylhsminor.yy993 = yymsp[0].minor.yy0; } +#line 5395 "sql.c" + yymsp[0].minor.yy993 = yylhsminor.yy993; break; case 68: /* force_opt ::= */ case 92: /* not_exists_opt ::= */ yytestcase(yyruleno==92); case 94: /* exists_opt ::= */ yytestcase(yyruleno==94); - case 343: /* analyze_opt ::= */ yytestcase(yyruleno==343); - case 350: /* agg_func_opt ::= */ yytestcase(yyruleno==350); - case 356: /* or_replace_opt ::= */ yytestcase(yyruleno==356); - case 382: /* ignore_opt ::= */ yytestcase(yyruleno==382); - case 555: /* tag_mode_opt ::= */ yytestcase(yyruleno==555); - case 557: /* set_quantifier_opt ::= */ yytestcase(yyruleno==557); -{ yymsp[1].minor.yy923 = false; } + case 345: /* analyze_opt ::= */ yytestcase(yyruleno==345); + case 352: /* agg_func_opt ::= */ yytestcase(yyruleno==352); + case 358: /* or_replace_opt ::= */ yytestcase(yyruleno==358); + case 384: /* ignore_opt ::= */ yytestcase(yyruleno==384); + case 558: /* tag_mode_opt ::= */ yytestcase(yyruleno==558); + case 560: /* set_quantifier_opt ::= */ yytestcase(yyruleno==560); +#line 168 "sql.y" +{ yymsp[1].minor.yy985 = false; } +#line 5409 "sql.c" break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); - case 344: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==344); - case 351: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==351); - case 556: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==556); - case 558: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==558); -{ yymsp[0].minor.yy923 = true; } + case 346: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==346); + case 353: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==353); + case 559: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==559); + case 561: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==561); +#line 169 "sql.y" +{ yymsp[0].minor.yy985 = true; } +#line 5419 "sql.c" break; case 71: /* cmd ::= ALTER LOCAL NK_STRING */ +#line 176 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 5424 "sql.c" break; case 72: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ +#line 177 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5429 "sql.c" break; case 73: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +#line 180 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5434 "sql.c" break; case 74: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +#line 181 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5439 "sql.c" break; case 75: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ +#line 182 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5444 "sql.c" break; case 76: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ +#line 185 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5449 "sql.c" break; case 77: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ +#line 186 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5454 "sql.c" break; case 78: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ +#line 189 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5459 "sql.c" break; case 79: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ +#line 190 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5464 "sql.c" break; case 80: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ +#line 193 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5469 "sql.c" break; case 81: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ +#line 194 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5474 "sql.c" break; case 82: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ +#line 195 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5479 "sql.c" break; case 83: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ +#line 198 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } +#line 5484 "sql.c" break; case 84: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy923, &yymsp[-1].minor.yy785, yymsp[0].minor.yy80); } +#line 201 "sql.y" +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy985, &yymsp[-1].minor.yy993, yymsp[0].minor.yy232); } +#line 5489 "sql.c" break; case 85: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } +#line 202 "sql.y" +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 5494 "sql.c" break; case 86: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } +#line 203 "sql.y" +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy993); } +#line 5499 "sql.c" break; case 87: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy80); } +#line 204 "sql.y" +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy993, yymsp[0].minor.yy232); } +#line 5504 "sql.c" break; case 88: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } +#line 205 "sql.y" +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy993); } +#line 5509 "sql.c" break; case 89: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy982); } +#line 206 "sql.y" +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy993, yymsp[0].minor.yy92); } +#line 5514 "sql.c" break; case 90: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy785, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } +#line 207 "sql.y" +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy993, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 5519 "sql.c" break; case 91: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy923 = true; } +#line 211 "sql.y" +{ yymsp[-2].minor.yy985 = true; } +#line 5524 "sql.c" break; case 93: /* exists_opt ::= IF EXISTS */ - case 357: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==357); - case 383: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==383); -{ yymsp[-1].minor.yy923 = true; } + case 359: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==359); + case 385: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==385); +#line 216 "sql.y" +{ yymsp[-1].minor.yy985 = true; } +#line 5531 "sql.c" break; case 95: /* db_options ::= */ -{ yymsp[1].minor.yy80 = createDefaultDatabaseOptions(pCxt); } +#line 219 "sql.y" +{ yymsp[1].minor.yy232 = createDefaultDatabaseOptions(pCxt); } +#line 5536 "sql.c" break; case 96: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 220 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 5541 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 97: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 221 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 5547 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 98: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 222 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 5553 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 99: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 223 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 5559 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 100: /* db_options ::= db_options DURATION NK_INTEGER */ case 101: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==101); -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 224 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 5566 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 102: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 226 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 5572 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 103: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 227 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 5578 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 104: /* db_options ::= db_options KEEP integer_list */ case 105: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==105); -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP, yymsp[0].minor.yy106); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 228 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_KEEP, yymsp[0].minor.yy88); } +#line 5585 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 106: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 230 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 5591 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 107: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 231 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5597 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 108: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 232 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5603 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 109: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 233 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 5609 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 110: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 234 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 5615 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 111: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 236 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 5621 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 112: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 237 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 5627 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 113: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_RETENTIONS, yymsp[0].minor.yy106); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 238 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_RETENTIONS, yymsp[0].minor.yy88); } +#line 5633 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 114: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 239 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 5639 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 115: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 240 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 5645 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 116: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 241 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 5651 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 117: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 242 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 5657 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 118: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 243 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-3].minor.yy232, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 5667 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; case 119: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 248 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 5673 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 120: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 249 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-3].minor.yy232, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 5683 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; case 121: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 254 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 5689 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 122: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 255 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 5695 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 123: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 256 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 5701 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 124: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy80); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 257 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy232); } +#line 5707 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 125: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy80); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 258 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy232); } +#line 5713 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 126: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 259 "sql.y" +{ yylhsminor.yy232 = setDatabaseOption(pCxt, yymsp[-2].minor.yy232, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 5719 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 127: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy80 = createAlterDatabaseOptions(pCxt); yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yylhsminor.yy80, &yymsp[0].minor.yy455); } - yymsp[0].minor.yy80 = yylhsminor.yy80; +#line 261 "sql.y" +{ yylhsminor.yy232 = createAlterDatabaseOptions(pCxt); yylhsminor.yy232 = setAlterDatabaseOption(pCxt, yylhsminor.yy232, &yymsp[0].minor.yy117); } +#line 5725 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 128: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy80, &yymsp[0].minor.yy455); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 262 "sql.y" +{ yylhsminor.yy232 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy232, &yymsp[0].minor.yy117); } +#line 5731 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; case 129: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 266 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5737 "sql.c" break; case 130: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 267 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5742 "sql.c" break; case 131: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 268 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5747 "sql.c" break; case 132: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 269 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5752 "sql.c" break; case 133: /* alter_db_option ::= KEEP integer_list */ case 134: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==134); -{ yymsp[-1].minor.yy455.type = DB_OPTION_KEEP; yymsp[-1].minor.yy455.pList = yymsp[0].minor.yy106; } +#line 270 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_KEEP; yymsp[-1].minor.yy117.pList = yymsp[0].minor.yy88; } +#line 5758 "sql.c" break; case 135: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_PAGES; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 272 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_PAGES; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5763 "sql.c" break; case 136: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 273 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5768 "sql.c" break; case 137: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 275 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_WAL; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5773 "sql.c" break; case 138: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 276 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5778 "sql.c" break; case 139: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 277 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5783 "sql.c" break; case 140: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 278 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5788 "sql.c" break; case 141: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 279 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy455.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy455.val = t; + yymsp[-2].minor.yy117.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy117.val = t; } +#line 5797 "sql.c" break; case 142: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 284 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5802 "sql.c" break; case 143: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 285 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy455.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy455.val = t; + yymsp[-2].minor.yy117.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy117.val = t; } +#line 5811 "sql.c" break; case 144: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 290 "sql.y" +{ yymsp[-1].minor.yy117.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 5816 "sql.c" break; case 145: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy106 = yylhsminor.yy106; +#line 294 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5821 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 146: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 395: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==395); -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; + case 398: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==398); +#line 295 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5828 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; case 147: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy106 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy106 = yylhsminor.yy106; +#line 299 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5834 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 148: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; +#line 300 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5840 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; case 149: /* retention_list ::= retention */ case 180: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==180); @@ -5275,1260 +5846,1897 @@ static YYACTIONTYPE yy_reduce( case 190: /* column_def_list ::= column_def */ yytestcase(yyruleno==190); case 234: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==234); case 239: /* col_name_list ::= col_name */ yytestcase(yyruleno==239); - case 301: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==301); - case 318: /* func_list ::= func */ yytestcase(yyruleno==318); - case 424: /* literal_list ::= signed_literal */ yytestcase(yyruleno==424); - case 495: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==495); - case 501: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==501); - case 560: /* select_list ::= select_item */ yytestcase(yyruleno==560); - case 571: /* partition_list ::= partition_item */ yytestcase(yyruleno==571); - case 630: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==630); -{ yylhsminor.yy106 = createNodeList(pCxt, yymsp[0].minor.yy80); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 303: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==303); + case 320: /* func_list ::= func */ yytestcase(yyruleno==320); + case 427: /* literal_list ::= signed_literal */ yytestcase(yyruleno==427); + case 498: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==498); + case 504: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==504); + case 563: /* select_list ::= select_item */ yytestcase(yyruleno==563); + case 574: /* partition_list ::= partition_item */ yytestcase(yyruleno==574); + case 633: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==633); +#line 304 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, yymsp[0].minor.yy232); } +#line 5859 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 150: /* retention_list ::= retention_list NK_COMMA retention */ case 184: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==184); case 191: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==191); case 235: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==235); case 240: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==240); - case 302: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==302); - case 319: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==319); - case 425: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==425); - case 496: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==496); - case 561: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==561); - case 572: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==572); - case 631: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==631); -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; + case 304: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==304); + case 321: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==321); + case 428: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==428); + case 499: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==499); + case 564: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==564); + case 575: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==575); + case 634: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==634); +#line 305 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, yymsp[0].minor.yy232); } +#line 5876 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; case 151: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 152: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==152); -{ yylhsminor.yy80 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 307 "sql.y" +{ yylhsminor.yy232 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5883 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 153: /* speed_opt ::= */ - case 352: /* bufsize_opt ::= */ yytestcase(yyruleno==352); -{ yymsp[1].minor.yy982 = 0; } + case 354: /* bufsize_opt ::= */ yytestcase(yyruleno==354); +#line 312 "sql.y" +{ yymsp[1].minor.yy92 = 0; } +#line 5890 "sql.c" break; case 154: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 353: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==353); -{ yymsp[-1].minor.yy982 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 355: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==355); +#line 313 "sql.y" +{ yymsp[-1].minor.yy92 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5896 "sql.c" break; case 156: /* start_opt ::= START WITH NK_INTEGER */ case 160: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==160); -{ yymsp[-2].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 316 "sql.y" +{ yymsp[-2].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 5902 "sql.c" break; case 157: /* start_opt ::= START WITH NK_STRING */ case 161: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==161); -{ yymsp[-2].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 317 "sql.y" +{ yymsp[-2].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5908 "sql.c" break; case 158: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 162: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==162); -{ yymsp[-3].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 318 "sql.y" +{ yymsp[-3].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5914 "sql.c" break; case 163: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 165: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==165); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy923, yymsp[-5].minor.yy80, yymsp[-3].minor.yy106, yymsp[-1].minor.yy106, yymsp[0].minor.yy80); } +#line 327 "sql.y" +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy985, yymsp[-5].minor.yy232, yymsp[-3].minor.yy88, yymsp[-1].minor.yy88, yymsp[0].minor.yy232); } +#line 5920 "sql.c" break; case 164: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy106); } +#line 328 "sql.y" +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy88); } +#line 5925 "sql.c" break; case 166: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy106); } +#line 331 "sql.y" +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy88); } +#line 5930 "sql.c" break; case 167: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } +#line 332 "sql.y" +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy985, yymsp[0].minor.yy232); } +#line 5935 "sql.c" break; case 168: /* cmd ::= ALTER TABLE alter_table_clause */ - case 397: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==397); - case 398: /* cmd ::= insert_query */ yytestcase(yyruleno==398); -{ pCxt->pRootNode = yymsp[0].minor.yy80; } + case 400: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==400); + case 401: /* cmd ::= insert_query */ yytestcase(yyruleno==401); +#line 334 "sql.y" +{ pCxt->pRootNode = yymsp[0].minor.yy232; } +#line 5942 "sql.c" break; case 169: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy80); } +#line 335 "sql.y" +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy232); } +#line 5947 "sql.c" break; case 170: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy80 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 337 "sql.y" +{ yylhsminor.yy232 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 5952 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; case 171: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 339 "sql.y" +{ yylhsminor.yy232 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy993, yymsp[0].minor.yy400); } +#line 5958 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 172: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 340 "sql.y" +{ yylhsminor.yy232 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy232, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy993); } +#line 5964 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; case 173: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 342 "sql.y" +{ yylhsminor.yy232 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy993, yymsp[0].minor.yy400); } +#line 5970 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 174: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 344 "sql.y" +{ yylhsminor.yy232 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy993, &yymsp[0].minor.yy993); } +#line 5976 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 175: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 346 "sql.y" +{ yylhsminor.yy232 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy993, yymsp[0].minor.yy400); } +#line 5982 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 176: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 347 "sql.y" +{ yylhsminor.yy232 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy232, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy993); } +#line 5988 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; case 177: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 349 "sql.y" +{ yylhsminor.yy232 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy993, yymsp[0].minor.yy400); } +#line 5994 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 178: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 351 "sql.y" +{ yylhsminor.yy232 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy232, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy993, &yymsp[0].minor.yy993); } +#line 6000 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 179: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy80 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy80, &yymsp[-2].minor.yy785, yymsp[0].minor.yy80); } - yymsp[-5].minor.yy80 = yylhsminor.yy80; +#line 353 "sql.y" +{ yylhsminor.yy232 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy232, &yymsp[-2].minor.yy993, yymsp[0].minor.yy232); } +#line 6006 "sql.c" + yymsp[-5].minor.yy232 = yylhsminor.yy232; break; case 181: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 502: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==502); -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-1].minor.yy106, yymsp[0].minor.yy80); } - yymsp[-1].minor.yy106 = yylhsminor.yy106; + case 505: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==505); +#line 358 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-1].minor.yy88, yymsp[0].minor.yy232); } +#line 6013 "sql.c" + yymsp[-1].minor.yy88 = yylhsminor.yy88; break; case 182: /* 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.yy80 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy923, yymsp[-8].minor.yy80, yymsp[-6].minor.yy80, yymsp[-5].minor.yy106, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } - yymsp[-9].minor.yy80 = yylhsminor.yy80; +#line 362 "sql.y" +{ yylhsminor.yy232 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy985, yymsp[-8].minor.yy232, yymsp[-6].minor.yy232, yymsp[-5].minor.yy88, yymsp[-2].minor.yy88, yymsp[0].minor.yy232); } +#line 6019 "sql.c" + yymsp[-9].minor.yy232 = yylhsminor.yy232; break; case 185: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy80 = createDropTableClause(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 369 "sql.y" +{ yylhsminor.yy232 = createDropTableClause(pCxt, yymsp[-1].minor.yy985, yymsp[0].minor.yy232); } +#line 6025 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; case 187: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 367: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==367); -{ yymsp[-2].minor.yy106 = yymsp[-1].minor.yy106; } + case 369: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==369); +#line 374 "sql.y" +{ yymsp[-2].minor.yy88 = yymsp[-1].minor.yy88; } +#line 6032 "sql.c" break; case 188: /* full_table_name ::= table_name */ -{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } - yymsp[0].minor.yy80 = yylhsminor.yy80; +#line 376 "sql.y" +{ yylhsminor.yy232 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy993, NULL); } +#line 6037 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 189: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, NULL); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 377 "sql.y" +{ yylhsminor.yy232 = createRealTableNode(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993, NULL); } +#line 6043 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 192: /* column_def ::= column_name type_name */ -{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy292, NULL); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 384 "sql.y" +{ yylhsminor.yy232 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy993, yymsp[0].minor.yy400, NULL); } +#line 6049 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; case 193: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 389 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 6055 "sql.c" break; case 194: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 390 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 6060 "sql.c" break; case 195: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 391 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 6065 "sql.c" break; case 196: /* type_name ::= INT */ case 197: /* type_name ::= INTEGER */ yytestcase(yyruleno==197); -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_INT); } +#line 392 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_INT); } +#line 6071 "sql.c" break; case 198: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 394 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 6076 "sql.c" break; case 199: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 395 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 6081 "sql.c" break; case 200: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 396 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 6086 "sql.c" break; case 201: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 397 "sql.y" +{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 6091 "sql.c" break; case 202: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 398 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 6096 "sql.c" break; case 203: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 399 "sql.y" +{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 6101 "sql.c" break; case 204: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 400 "sql.y" +{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 6106 "sql.c" break; case 205: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 401 "sql.y" +{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 6111 "sql.c" break; case 206: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 402 "sql.y" +{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 6116 "sql.c" break; case 207: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy292 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 403 "sql.y" +{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 6121 "sql.c" break; case 208: /* type_name ::= JSON */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 404 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 6126 "sql.c" break; case 209: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 405 "sql.y" +{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 6131 "sql.c" break; case 210: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 406 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 6136 "sql.c" break; case 211: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 407 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 6141 "sql.c" break; case 212: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 408 "sql.y" +{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 6146 "sql.c" break; case 213: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 409 "sql.y" +{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 6151 "sql.c" break; case 214: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 410 "sql.y" +{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6156 "sql.c" break; case 215: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 411 "sql.y" +{ yymsp[-3].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6161 "sql.c" break; case 216: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy292 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 412 "sql.y" +{ yymsp[-5].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6166 "sql.c" break; case 219: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 370: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==370); -{ yymsp[-3].minor.yy106 = yymsp[-1].minor.yy106; } + case 372: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==372); +#line 421 "sql.y" +{ yymsp[-3].minor.yy88 = yymsp[-1].minor.yy88; } +#line 6172 "sql.c" break; case 220: /* table_options ::= */ -{ yymsp[1].minor.yy80 = createDefaultTableOptions(pCxt); } +#line 423 "sql.y" +{ yymsp[1].minor.yy232 = createDefaultTableOptions(pCxt); } +#line 6177 "sql.c" break; case 221: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 424 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-2].minor.yy232, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 6182 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 222: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy106); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 425 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-2].minor.yy232, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy88); } +#line 6188 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 223: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy106); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 426 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-2].minor.yy232, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy88); } +#line 6194 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 224: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy106); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 427 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-4].minor.yy232, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy88); } +#line 6200 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 225: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 428 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-2].minor.yy232, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 6206 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 226: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_SMA, yymsp[-1].minor.yy106); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 429 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-4].minor.yy232, TABLE_OPTION_SMA, yymsp[-1].minor.yy88); } +#line 6212 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; case 227: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy106); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 430 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-2].minor.yy232, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy88); } +#line 6218 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 228: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy80 = createAlterTableOptions(pCxt); yylhsminor.yy80 = setTableOption(pCxt, yylhsminor.yy80, yymsp[0].minor.yy455.type, &yymsp[0].minor.yy455.val); } - yymsp[0].minor.yy80 = yylhsminor.yy80; +#line 432 "sql.y" +{ yylhsminor.yy232 = createAlterTableOptions(pCxt); yylhsminor.yy232 = setTableOption(pCxt, yylhsminor.yy232, yymsp[0].minor.yy117.type, &yymsp[0].minor.yy117.val); } +#line 6224 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 229: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy455.type, &yymsp[0].minor.yy455.val); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 433 "sql.y" +{ yylhsminor.yy232 = setTableOption(pCxt, yymsp[-1].minor.yy232, yymsp[0].minor.yy117.type, &yymsp[0].minor.yy117.val); } +#line 6230 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; case 230: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy455.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 437 "sql.y" +{ yymsp[-1].minor.yy117.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 6236 "sql.c" break; case 231: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy455.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy455.val = yymsp[0].minor.yy0; } +#line 438 "sql.y" +{ yymsp[-1].minor.yy117.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy117.val = yymsp[0].minor.yy0; } +#line 6241 "sql.c" break; case 232: /* duration_list ::= duration_literal */ - case 456: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==456); -{ yylhsminor.yy106 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 459: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==459); +#line 442 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 6247 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; case 233: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 457: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==457); -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; + case 460: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==460); +#line 443 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 6254 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; case 236: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } - yymsp[0].minor.yy80 = yylhsminor.yy80; +#line 450 "sql.y" +{ yylhsminor.yy232 = createFunctionNode(pCxt, &yymsp[0].minor.yy993, NULL); } +#line 6260 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 237: /* rollup_func_name ::= FIRST */ case 238: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==238); - case 304: /* tag_item ::= QTAGS */ yytestcase(yyruleno==304); -{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 306: /* tag_item ::= QTAGS */ yytestcase(yyruleno==306); +#line 451 "sql.y" +{ yylhsminor.yy232 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6268 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 241: /* col_name ::= column_name */ - case 305: /* tag_item ::= column_name */ yytestcase(yyruleno==305); -{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 307: /* tag_item ::= column_name */ yytestcase(yyruleno==307); +#line 459 "sql.y" +{ yylhsminor.yy232 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy993); } +#line 6275 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; case 242: /* cmd ::= SHOW DNODES */ +#line 462 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } +#line 6281 "sql.c" break; case 243: /* cmd ::= SHOW USERS */ +#line 463 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } +#line 6286 "sql.c" break; case 244: /* cmd ::= SHOW USER PRIVILEGES */ +#line 464 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } +#line 6291 "sql.c" break; case 245: /* cmd ::= SHOW db_kind_opt DATABASES */ +#line 465 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy459); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy281); } +#line 6299 "sql.c" break; case 246: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ +#line 469 "sql.y" { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy709, yymsp[0].minor.yy80, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy133, yymsp[0].minor.yy232, OP_TYPE_LIKE); } +#line 6306 "sql.c" break; case 247: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); } +#line 472 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy232, yymsp[0].minor.yy232, OP_TYPE_LIKE); } +#line 6311 "sql.c" break; case 248: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); } +#line 473 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy232, NULL, OP_TYPE_LIKE); } +#line 6316 "sql.c" break; case 249: /* cmd ::= SHOW MNODES */ +#line 474 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } +#line 6321 "sql.c" break; case 250: /* cmd ::= SHOW QNODES */ +#line 476 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } +#line 6326 "sql.c" break; case 251: /* cmd ::= SHOW FUNCTIONS */ +#line 477 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } +#line 6331 "sql.c" break; case 252: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } +#line 478 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy232, yymsp[-1].minor.yy232, OP_TYPE_EQUAL); } +#line 6336 "sql.c" break; case 253: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } +#line 479 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy993), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy993), OP_TYPE_EQUAL); } +#line 6341 "sql.c" break; case 254: /* cmd ::= SHOW STREAMS */ +#line 480 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } +#line 6346 "sql.c" break; case 255: /* cmd ::= SHOW ACCOUNTS */ +#line 481 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 6351 "sql.c" break; case 256: /* cmd ::= SHOW APPS */ +#line 482 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } +#line 6356 "sql.c" break; case 257: /* cmd ::= SHOW CONNECTIONS */ +#line 483 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } +#line 6361 "sql.c" break; case 258: /* cmd ::= SHOW LICENCES */ case 259: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==259); +#line 484 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } +#line 6367 "sql.c" break; case 260: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } +#line 486 "sql.y" +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy993); } +#line 6372 "sql.c" break; case 261: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy80); } +#line 487 "sql.y" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy232); } +#line 6377 "sql.c" break; case 262: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy80); } +#line 488 "sql.y" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy232); } +#line 6382 "sql.c" break; case 263: /* cmd ::= SHOW QUERIES */ +#line 489 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } +#line 6387 "sql.c" break; case 264: /* cmd ::= SHOW SCORES */ +#line 490 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } +#line 6392 "sql.c" break; case 265: /* cmd ::= SHOW TOPICS */ +#line 491 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } +#line 6397 "sql.c" break; case 266: /* cmd ::= SHOW VARIABLES */ case 267: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==267); +#line 492 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } +#line 6403 "sql.c" break; case 268: /* cmd ::= SHOW LOCAL VARIABLES */ +#line 494 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } +#line 6408 "sql.c" break; case 269: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy80); } +#line 495 "sql.y" +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy232); } +#line 6413 "sql.c" break; case 270: /* cmd ::= SHOW BNODES */ +#line 496 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } +#line 6418 "sql.c" break; case 271: /* cmd ::= SHOW SNODES */ +#line 497 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } +#line 6423 "sql.c" break; case 272: /* cmd ::= SHOW CLUSTER */ +#line 498 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } +#line 6428 "sql.c" break; case 273: /* cmd ::= SHOW TRANSACTIONS */ +#line 499 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } +#line 6433 "sql.c" break; case 274: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy80); } +#line 500 "sql.y" +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy232); } +#line 6438 "sql.c" break; case 275: /* cmd ::= SHOW CONSUMERS */ +#line 501 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +#line 6443 "sql.c" break; case 276: /* cmd ::= SHOW SUBSCRIPTIONS */ +#line 502 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } +#line 6448 "sql.c" break; case 277: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } +#line 503 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy232, yymsp[-1].minor.yy232, OP_TYPE_EQUAL); } +#line 6453 "sql.c" break; case 278: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } +#line 504 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy993), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy993), OP_TYPE_EQUAL); } +#line 6458 "sql.c" break; case 279: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80, yymsp[-3].minor.yy106); } +#line 505 "sql.y" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy232, yymsp[0].minor.yy232, yymsp[-3].minor.yy88); } +#line 6463 "sql.c" break; case 280: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), yymsp[-4].minor.yy106); } +#line 506 "sql.y" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy993), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy993), yymsp[-4].minor.yy88); } +#line 6468 "sql.c" break; case 281: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ +#line 507 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } +#line 6473 "sql.c" break; case 282: /* cmd ::= SHOW VNODES */ +#line 508 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } +#line 6478 "sql.c" break; case 283: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy80, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 510 "sql.y" +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy232, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 6483 "sql.c" break; case 284: /* cmd ::= SHOW CLUSTER ALIVE */ +#line 511 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } +#line 6488 "sql.c" break; case 285: /* cmd ::= SHOW db_name_cond_opt VIEWS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); } +#line 512 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-1].minor.yy232, NULL, OP_TYPE_LIKE); } +#line 6493 "sql.c" break; case 286: /* cmd ::= SHOW CREATE VIEW full_table_name */ -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy80); } +#line 513 "sql.y" +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy232); } +#line 6498 "sql.c" break; - case 287: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy709.kind = SHOW_KIND_ALL; yymsp[1].minor.yy709.dbName = nil_token; } + case 287: /* cmd ::= SHOW COMPACTS */ +#line 514 "sql.y" +{ pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } +#line 6503 "sql.c" break; - case 288: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy709.kind = yymsp[0].minor.yy459; yylhsminor.yy709.dbName = nil_token; } - yymsp[0].minor.yy709 = yylhsminor.yy709; + case 288: /* cmd ::= SHOW COMPACT NK_INTEGER */ +#line 515 "sql.y" +{ pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6508 "sql.c" break; - case 289: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy709.kind = SHOW_KIND_ALL; yylhsminor.yy709.dbName = yymsp[-1].minor.yy785; } - yymsp[-1].minor.yy709 = yylhsminor.yy709; + case 289: /* table_kind_db_name_cond_opt ::= */ +#line 519 "sql.y" +{ yymsp[1].minor.yy133.kind = SHOW_KIND_ALL; yymsp[1].minor.yy133.dbName = nil_token; } +#line 6513 "sql.c" break; - case 290: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy709.kind = yymsp[-2].minor.yy459; yylhsminor.yy709.dbName = yymsp[-1].minor.yy785; } - yymsp[-2].minor.yy709 = yylhsminor.yy709; + case 290: /* table_kind_db_name_cond_opt ::= table_kind */ +#line 520 "sql.y" +{ yylhsminor.yy133.kind = yymsp[0].minor.yy281; yylhsminor.yy133.dbName = nil_token; } +#line 6518 "sql.c" + yymsp[0].minor.yy133 = yylhsminor.yy133; break; - case 291: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_NORMAL; } + case 291: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ +#line 521 "sql.y" +{ yylhsminor.yy133.kind = SHOW_KIND_ALL; yylhsminor.yy133.dbName = yymsp[-1].minor.yy993; } +#line 6524 "sql.c" + yymsp[-1].minor.yy133 = yylhsminor.yy133; break; - case 292: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy459 = SHOW_KIND_TABLES_CHILD; } + case 292: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ +#line 522 "sql.y" +{ yylhsminor.yy133.kind = yymsp[-2].minor.yy281; yylhsminor.yy133.dbName = yymsp[-1].minor.yy993; } +#line 6530 "sql.c" + yymsp[-2].minor.yy133 = yylhsminor.yy133; break; - case 293: /* db_name_cond_opt ::= */ - case 298: /* from_db_opt ::= */ yytestcase(yyruleno==298); -{ yymsp[1].minor.yy80 = createDefaultDatabaseCondValue(pCxt); } + case 293: /* table_kind ::= NORMAL */ +#line 526 "sql.y" +{ yymsp[0].minor.yy281 = SHOW_KIND_TABLES_NORMAL; } +#line 6536 "sql.c" break; - case 294: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy80 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy785); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 294: /* table_kind ::= CHILD */ +#line 527 "sql.y" +{ yymsp[0].minor.yy281 = SHOW_KIND_TABLES_CHILD; } +#line 6541 "sql.c" break; - case 296: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 295: /* db_name_cond_opt ::= */ + case 300: /* from_db_opt ::= */ yytestcase(yyruleno==300); +#line 529 "sql.y" +{ yymsp[1].minor.yy232 = createDefaultDatabaseCondValue(pCxt); } +#line 6547 "sql.c" break; - case 297: /* table_name_cond ::= table_name */ -{ yylhsminor.yy80 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 296: /* db_name_cond_opt ::= db_name NK_DOT */ +#line 530 "sql.y" +{ yylhsminor.yy232 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy993); } +#line 6552 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 299: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy80 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } + case 298: /* like_pattern_opt ::= LIKE NK_STRING */ +#line 533 "sql.y" +{ yymsp[-1].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 6558 "sql.c" break; - case 303: /* tag_item ::= TBNAME */ -{ yylhsminor.yy80 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 299: /* table_name_cond ::= table_name */ +#line 535 "sql.y" +{ yylhsminor.yy232 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy993); } +#line 6563 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 306: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy80 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy785), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 301: /* from_db_opt ::= FROM db_name */ +#line 538 "sql.y" +{ yymsp[-1].minor.yy232 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy993); } +#line 6569 "sql.c" break; - case 307: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy80 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy785), &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 305: /* tag_item ::= TBNAME */ +#line 546 "sql.y" +{ yylhsminor.yy232 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 6574 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 308: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy459 = SHOW_KIND_ALL; } + case 308: /* tag_item ::= column_name column_alias */ +#line 549 "sql.y" +{ yylhsminor.yy232 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy993), &yymsp[0].minor.yy993); } +#line 6580 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 309: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_USER; } + case 309: /* tag_item ::= column_name AS column_alias */ +#line 550 "sql.y" +{ yylhsminor.yy232 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy993), &yymsp[0].minor.yy993); } +#line 6586 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 310: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy459 = SHOW_KIND_DATABASES_SYSTEM; } + case 310: /* db_kind_opt ::= */ +#line 554 "sql.y" +{ yymsp[1].minor.yy281 = SHOW_KIND_ALL; } +#line 6592 "sql.c" break; - case 311: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy923, yymsp[-3].minor.yy80, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } + case 311: /* db_kind_opt ::= USER */ +#line 555 "sql.y" +{ yymsp[0].minor.yy281 = SHOW_KIND_DATABASES_USER; } +#line 6597 "sql.c" break; - case 312: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy923, yymsp[-5].minor.yy80, yymsp[-3].minor.yy80, yymsp[-1].minor.yy106, NULL); } + case 312: /* db_kind_opt ::= SYSTEM */ +#line 556 "sql.y" +{ yymsp[0].minor.yy281 = SHOW_KIND_DATABASES_SYSTEM; } +#line 6602 "sql.c" break; - case 313: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } + case 313: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +#line 560 "sql.y" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy985, yymsp[-3].minor.yy232, yymsp[-1].minor.yy232, NULL, yymsp[0].minor.yy232); } +#line 6607 "sql.c" break; - case 314: /* full_index_name ::= index_name */ -{ yylhsminor.yy80 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 314: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ +#line 562 "sql.y" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy985, yymsp[-5].minor.yy232, yymsp[-3].minor.yy232, yymsp[-1].minor.yy88, NULL); } +#line 6612 "sql.c" break; - case 315: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy80 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 315: /* cmd ::= DROP INDEX exists_opt full_index_name */ +#line 563 "sql.y" +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy985, yymsp[0].minor.yy232); } +#line 6617 "sql.c" break; - case 316: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy80 = createIndexOption(pCxt, yymsp[-7].minor.yy106, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 316: /* full_index_name ::= index_name */ +#line 565 "sql.y" +{ yylhsminor.yy232 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy993); } +#line 6622 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 317: /* 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.yy80 = createIndexOption(pCxt, yymsp[-9].minor.yy106, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 317: /* full_index_name ::= db_name NK_DOT index_name */ +#line 566 "sql.y" +{ yylhsminor.yy232 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993); } +#line 6628 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 320: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy106); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 318: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 569 "sql.y" +{ yymsp[-9].minor.yy232 = createIndexOption(pCxt, yymsp[-7].minor.yy88, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), NULL, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 6634 "sql.c" break; - case 321: /* sma_func_name ::= function_name */ - case 545: /* alias_opt ::= table_alias */ yytestcase(yyruleno==545); -{ yylhsminor.yy785 = yymsp[0].minor.yy785; } - yymsp[0].minor.yy785 = yylhsminor.yy785; + case 319: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 572 "sql.y" +{ yymsp[-11].minor.yy232 = createIndexOption(pCxt, yymsp[-9].minor.yy88, releaseRawExprNode(pCxt, yymsp[-5].minor.yy232), releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 6639 "sql.c" break; - case 326: /* sma_stream_opt ::= */ - case 371: /* stream_options ::= */ yytestcase(yyruleno==371); -{ yymsp[1].minor.yy80 = createStreamOptions(pCxt); } + case 322: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +#line 579 "sql.y" +{ yylhsminor.yy232 = createFunctionNode(pCxt, &yymsp[-3].minor.yy993, yymsp[-1].minor.yy88); } +#line 6644 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 327: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 323: /* sma_func_name ::= function_name */ + case 548: /* alias_opt ::= table_alias */ yytestcase(yyruleno==548); +#line 583 "sql.y" +{ yylhsminor.yy993 = yymsp[0].minor.yy993; } +#line 6651 "sql.c" + yymsp[0].minor.yy993 = yylhsminor.yy993; break; - case 328: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 328: /* sma_stream_opt ::= */ + case 373: /* stream_options ::= */ yytestcase(yyruleno==373); +#line 589 "sql.y" +{ yymsp[1].minor.yy232 = createStreamOptions(pCxt); } +#line 6658 "sql.c" break; - case 329: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 329: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +#line 590 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy232)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy232); yylhsminor.yy232 = yymsp[-2].minor.yy232; } +#line 6663 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 330: /* with_meta ::= AS */ -{ yymsp[0].minor.yy982 = 0; } + case 330: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +#line 591 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy232)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy232); yylhsminor.yy232 = yymsp[-2].minor.yy232; } +#line 6669 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 331: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy982 = 1; } + case 331: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +#line 592 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy232)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy232); yylhsminor.yy232 = yymsp[-2].minor.yy232; } +#line 6675 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 332: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy982 = 2; } + case 332: /* with_meta ::= AS */ +#line 597 "sql.y" +{ yymsp[0].minor.yy92 = 0; } +#line 6681 "sql.c" break; - case 333: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy923, &yymsp[-2].minor.yy785, yymsp[0].minor.yy80); } + case 333: /* with_meta ::= WITH META AS */ +#line 598 "sql.y" +{ yymsp[-2].minor.yy92 = 1; } +#line 6686 "sql.c" break; - case 334: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy923, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy785, yymsp[-2].minor.yy982); } + case 334: /* with_meta ::= ONLY META AS */ +#line 599 "sql.y" +{ yymsp[-2].minor.yy92 = 2; } +#line 6691 "sql.c" break; - case 335: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy923, &yymsp[-4].minor.yy785, yymsp[-1].minor.yy80, yymsp[-3].minor.yy982, yymsp[0].minor.yy80); } + case 335: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +#line 601 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy985, &yymsp[-2].minor.yy993, yymsp[0].minor.yy232); } +#line 6696 "sql.c" break; - case 336: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } + case 336: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +#line 603 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy985, &yymsp[-3].minor.yy993, &yymsp[0].minor.yy993, yymsp[-2].minor.yy92); } +#line 6701 "sql.c" break; - case 337: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy923, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } + case 337: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +#line 605 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy985, &yymsp[-4].minor.yy993, yymsp[-1].minor.yy232, yymsp[-3].minor.yy92, yymsp[0].minor.yy232); } +#line 6706 "sql.c" break; - case 338: /* cmd ::= DESC full_table_name */ - case 339: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==339); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy80); } + case 338: /* cmd ::= DROP TOPIC exists_opt topic_name */ +#line 607 "sql.y" +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 6711 "sql.c" break; - case 340: /* cmd ::= RESET QUERY CACHE */ + case 339: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +#line 608 "sql.y" +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy985, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993); } +#line 6716 "sql.c" + break; + case 340: /* cmd ::= DESC full_table_name */ + case 341: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==341); +#line 611 "sql.y" +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy232); } +#line 6722 "sql.c" + break; + case 342: /* cmd ::= RESET QUERY CACHE */ +#line 615 "sql.y" { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } +#line 6727 "sql.c" break; - case 341: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 342: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==342); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy923, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 343: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 344: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==344); +#line 618 "sql.y" +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy985, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 6733 "sql.c" break; - case 345: /* explain_options ::= */ -{ yymsp[1].minor.yy80 = createDefaultExplainOptions(pCxt); } + case 347: /* explain_options ::= */ +#line 626 "sql.y" +{ yymsp[1].minor.yy232 = createDefaultExplainOptions(pCxt); } +#line 6738 "sql.c" break; - case 346: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy80 = setExplainVerbose(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 348: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +#line 627 "sql.y" +{ yylhsminor.yy232 = setExplainVerbose(pCxt, yymsp[-2].minor.yy232, &yymsp[0].minor.yy0); } +#line 6743 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 347: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy80 = setExplainRatio(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 349: /* explain_options ::= explain_options RATIO NK_FLOAT */ +#line 628 "sql.y" +{ yylhsminor.yy232 = setExplainRatio(pCxt, yymsp[-2].minor.yy232, &yymsp[0].minor.yy0); } +#line 6749 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 348: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy923, yymsp[-9].minor.yy923, &yymsp[-6].minor.yy785, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy292, yymsp[-1].minor.yy982, &yymsp[0].minor.yy785, yymsp[-10].minor.yy923); } + case 350: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +#line 633 "sql.y" +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy985, yymsp[-9].minor.yy985, &yymsp[-6].minor.yy993, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy400, yymsp[-1].minor.yy92, &yymsp[0].minor.yy993, yymsp[-10].minor.yy985); } +#line 6755 "sql.c" break; - case 349: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } + case 351: /* cmd ::= DROP FUNCTION exists_opt function_name */ +#line 634 "sql.y" +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 6760 "sql.c" break; - case 354: /* language_opt ::= */ - case 392: /* on_vgroup_id ::= */ yytestcase(yyruleno==392); -{ yymsp[1].minor.yy785 = nil_token; } + case 356: /* language_opt ::= */ + case 395: /* on_vgroup_id ::= */ yytestcase(yyruleno==395); +#line 648 "sql.y" +{ yymsp[1].minor.yy993 = nil_token; } +#line 6766 "sql.c" break; - case 355: /* language_opt ::= LANGUAGE NK_STRING */ - case 393: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==393); -{ yymsp[-1].minor.yy785 = yymsp[0].minor.yy0; } + case 357: /* language_opt ::= LANGUAGE NK_STRING */ + case 396: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==396); +#line 649 "sql.y" +{ yymsp[-1].minor.yy993 = yymsp[0].minor.yy0; } +#line 6772 "sql.c" break; - case 358: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy923, yymsp[-2].minor.yy80, &yymsp[-1].minor.yy0, yymsp[0].minor.yy80); } + case 360: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +#line 658 "sql.y" +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy985, yymsp[-2].minor.yy232, &yymsp[-1].minor.yy0, yymsp[0].minor.yy232); } +#line 6777 "sql.c" break; - case 359: /* cmd ::= DROP VIEW exists_opt full_view_name */ -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy923, yymsp[0].minor.yy80); } + case 361: /* cmd ::= DROP VIEW exists_opt full_view_name */ +#line 659 "sql.y" +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy985, yymsp[0].minor.yy232); } +#line 6782 "sql.c" break; - case 360: /* full_view_name ::= view_name */ -{ yylhsminor.yy80 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy785); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 362: /* full_view_name ::= view_name */ +#line 661 "sql.y" +{ yylhsminor.yy232 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy993); } +#line 6787 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 361: /* full_view_name ::= db_name NK_DOT view_name */ -{ yylhsminor.yy80 = createViewNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 363: /* full_view_name ::= db_name NK_DOT view_name */ +#line 662 "sql.y" +{ yylhsminor.yy232 = createViewNode(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993); } +#line 6793 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 362: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy923, &yymsp[-8].minor.yy785, yymsp[-5].minor.yy80, yymsp[-7].minor.yy80, yymsp[-3].minor.yy106, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, yymsp[-4].minor.yy106); } + case 364: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +#line 667 "sql.y" +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy985, &yymsp[-8].minor.yy993, yymsp[-5].minor.yy232, yymsp[-7].minor.yy232, yymsp[-3].minor.yy88, yymsp[-2].minor.yy232, yymsp[0].minor.yy232, yymsp[-4].minor.yy88); } +#line 6799 "sql.c" break; - case 363: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } + case 365: /* cmd ::= DROP STREAM exists_opt stream_name */ +#line 668 "sql.y" +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 6804 "sql.c" break; - case 364: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } + case 366: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +#line 669 "sql.y" +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 6809 "sql.c" break; - case 365: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy923, yymsp[-1].minor.yy923, &yymsp[0].minor.yy785); } + case 367: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +#line 670 "sql.y" +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy985, yymsp[-1].minor.yy985, &yymsp[0].minor.yy993); } +#line 6814 "sql.c" break; - case 372: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 373: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==373); -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 374: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 375: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==375); +#line 684 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-2].minor.yy232, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6820 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 374: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 376: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +#line 686 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-3].minor.yy232, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 6826 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 375: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 377: /* stream_options ::= stream_options WATERMARK duration_literal */ +#line 687 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-2].minor.yy232, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 6832 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 376: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 378: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +#line 688 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-3].minor.yy232, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 6838 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 377: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 379: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +#line 689 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-2].minor.yy232, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } +#line 6844 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 378: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-2].minor.yy80, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 380: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +#line 690 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-2].minor.yy232, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 6850 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 379: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy80 = setStreamOptions(pCxt, yymsp[-3].minor.yy80, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 381: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +#line 691 "sql.y" +{ yylhsminor.yy232 = setStreamOptions(pCxt, yymsp[-3].minor.yy232, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6856 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 381: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 583: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==583); - case 607: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==607); -{ yymsp[-3].minor.yy80 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy80); } + case 383: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 586: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==586); + case 610: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==610); +#line 694 "sql.y" +{ yymsp[-3].minor.yy232 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy232); } +#line 6864 "sql.c" break; - case 384: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 386: /* cmd ::= KILL CONNECTION NK_INTEGER */ +#line 702 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } +#line 6869 "sql.c" break; - case 385: /* cmd ::= KILL QUERY NK_STRING */ + case 387: /* cmd ::= KILL QUERY NK_STRING */ +#line 703 "sql.y" { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6874 "sql.c" break; - case 386: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 388: /* cmd ::= KILL TRANSACTION NK_INTEGER */ +#line 704 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } +#line 6879 "sql.c" break; - case 387: /* cmd ::= BALANCE VGROUP */ + case 389: /* cmd ::= KILL COMPACT NK_INTEGER */ +#line 705 "sql.y" +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } +#line 6884 "sql.c" + break; + case 390: /* cmd ::= BALANCE VGROUP */ +#line 708 "sql.y" { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +#line 6889 "sql.c" break; - case 388: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy785); } + case 391: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +#line 709 "sql.y" +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy993); } +#line 6894 "sql.c" break; - case 389: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 392: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +#line 710 "sql.y" { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6899 "sql.c" break; - case 390: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy106); } + case 393: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +#line 711 "sql.y" +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy88); } +#line 6904 "sql.c" break; - case 391: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 394: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +#line 712 "sql.y" { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6909 "sql.c" break; - case 394: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy106 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 397: /* dnode_list ::= DNODE NK_INTEGER */ +#line 721 "sql.y" +{ yymsp[-1].minor.yy88 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6914 "sql.c" break; - case 396: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 399: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +#line 728 "sql.y" +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 6919 "sql.c" break; - case 399: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy80 = createInsertStmt(pCxt, yymsp[-4].minor.yy80, yymsp[-2].minor.yy106, yymsp[0].minor.yy80); } + case 402: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +#line 737 "sql.y" +{ yymsp[-6].minor.yy232 = createInsertStmt(pCxt, yymsp[-4].minor.yy232, yymsp[-2].minor.yy88, yymsp[0].minor.yy232); } +#line 6924 "sql.c" break; - case 400: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy80 = createInsertStmt(pCxt, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } + case 403: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +#line 738 "sql.y" +{ yymsp[-3].minor.yy232 = createInsertStmt(pCxt, yymsp[-1].minor.yy232, NULL, yymsp[0].minor.yy232); } +#line 6929 "sql.c" break; - case 401: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 404: /* literal ::= NK_INTEGER */ +#line 741 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 6934 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 402: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 405: /* literal ::= NK_FLOAT */ +#line 742 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 6940 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 403: /* literal ::= NK_STRING */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 406: /* literal ::= NK_STRING */ +#line 743 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 6946 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 404: /* literal ::= NK_BOOL */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 407: /* literal ::= NK_BOOL */ +#line 744 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 6952 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 405: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 408: /* literal ::= TIMESTAMP NK_STRING */ +#line 745 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 6958 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 406: /* literal ::= duration_literal */ - case 416: /* signed_literal ::= signed */ yytestcase(yyruleno==416); - case 439: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==439); - case 440: /* expression ::= literal */ yytestcase(yyruleno==440); - case 442: /* expression ::= column_reference */ yytestcase(yyruleno==442); - case 443: /* expression ::= function_expression */ yytestcase(yyruleno==443); - case 444: /* expression ::= case_when_expression */ yytestcase(yyruleno==444); - case 477: /* function_expression ::= literal_func */ yytestcase(yyruleno==477); - case 526: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==526); - case 530: /* boolean_primary ::= predicate */ yytestcase(yyruleno==530); - case 532: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==532); - case 533: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==533); - case 536: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==536); - case 538: /* table_reference ::= table_primary */ yytestcase(yyruleno==538); - case 539: /* table_reference ::= joined_table */ yytestcase(yyruleno==539); - case 543: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==543); - case 609: /* query_simple ::= query_specification */ yytestcase(yyruleno==609); - case 610: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==610); - case 613: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==613); - case 615: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==615); -{ yylhsminor.yy80 = yymsp[0].minor.yy80; } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 409: /* literal ::= duration_literal */ + case 419: /* signed_literal ::= signed */ yytestcase(yyruleno==419); + case 442: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==442); + case 443: /* expression ::= literal */ yytestcase(yyruleno==443); + case 445: /* expression ::= column_reference */ yytestcase(yyruleno==445); + case 446: /* expression ::= function_expression */ yytestcase(yyruleno==446); + case 447: /* expression ::= case_when_expression */ yytestcase(yyruleno==447); + case 480: /* function_expression ::= literal_func */ yytestcase(yyruleno==480); + case 529: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==529); + case 533: /* boolean_primary ::= predicate */ yytestcase(yyruleno==533); + case 535: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==535); + case 536: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==536); + case 539: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==539); + case 541: /* table_reference ::= table_primary */ yytestcase(yyruleno==541); + case 542: /* table_reference ::= joined_table */ yytestcase(yyruleno==542); + case 546: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==546); + case 612: /* query_simple ::= query_specification */ yytestcase(yyruleno==612); + case 613: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==613); + case 616: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==616); + case 618: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==618); +#line 746 "sql.y" +{ yylhsminor.yy232 = yymsp[0].minor.yy232; } +#line 6983 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 407: /* literal ::= NULL */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 410: /* literal ::= NULL */ +#line 747 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 6989 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 408: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 411: /* literal ::= NK_QUESTION */ +#line 748 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6995 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 409: /* duration_literal ::= NK_VARIABLE */ - case 584: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==584); - case 585: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==585); - case 586: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==586); -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 412: /* duration_literal ::= NK_VARIABLE */ + case 587: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==587); + case 588: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==588); + case 589: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==589); +#line 750 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7004 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 410: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 413: /* signed ::= NK_INTEGER */ +#line 752 "sql.y" +{ yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7010 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 411: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 414: /* signed ::= NK_PLUS NK_INTEGER */ +#line 753 "sql.y" +{ yymsp[-1].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7016 "sql.c" break; - case 412: /* signed ::= NK_MINUS NK_INTEGER */ + case 415: /* signed ::= NK_MINUS NK_INTEGER */ +#line 754 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 7025 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 413: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 416: /* signed ::= NK_FLOAT */ +#line 759 "sql.y" +{ yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7031 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 414: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 417: /* signed ::= NK_PLUS NK_FLOAT */ +#line 760 "sql.y" +{ yymsp[-1].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7037 "sql.c" break; - case 415: /* signed ::= NK_MINUS NK_FLOAT */ + case 418: /* signed ::= NK_MINUS NK_FLOAT */ +#line 761 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 7046 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 417: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 420: /* signed_literal ::= NK_STRING */ +#line 768 "sql.y" +{ yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7052 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 418: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 421: /* signed_literal ::= NK_BOOL */ +#line 769 "sql.y" +{ yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 7058 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 419: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 422: /* signed_literal ::= TIMESTAMP NK_STRING */ +#line 770 "sql.y" +{ yymsp[-1].minor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7064 "sql.c" break; - case 420: /* signed_literal ::= duration_literal */ - case 422: /* signed_literal ::= literal_func */ yytestcase(yyruleno==422); - case 497: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==497); - case 563: /* select_item ::= common_expression */ yytestcase(yyruleno==563); - case 573: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==573); - case 614: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==614); - case 616: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==616); - case 629: /* search_condition ::= common_expression */ yytestcase(yyruleno==629); -{ yylhsminor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 423: /* signed_literal ::= duration_literal */ + case 425: /* signed_literal ::= literal_func */ yytestcase(yyruleno==425); + case 500: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==500); + case 566: /* select_item ::= common_expression */ yytestcase(yyruleno==566); + case 576: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==576); + case 617: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==617); + case 619: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==619); + case 632: /* search_condition ::= common_expression */ yytestcase(yyruleno==632); +#line 771 "sql.y" +{ yylhsminor.yy232 = releaseRawExprNode(pCxt, yymsp[0].minor.yy232); } +#line 7076 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 421: /* signed_literal ::= NULL */ -{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 424: /* signed_literal ::= NULL */ +#line 772 "sql.y" +{ yylhsminor.yy232 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 7082 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 423: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy80 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 426: /* signed_literal ::= NK_QUESTION */ +#line 774 "sql.y" +{ yylhsminor.yy232 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 7088 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 441: /* expression ::= pseudo_column */ -{ yylhsminor.yy80 = yymsp[0].minor.yy80; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy80, true); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 444: /* expression ::= pseudo_column */ +#line 836 "sql.y" +{ yylhsminor.yy232 = yymsp[0].minor.yy232; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy232, true); } +#line 7094 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 445: /* expression ::= NK_LP expression NK_RP */ - case 531: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==531); - case 628: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==628); -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 448: /* expression ::= NK_LP expression NK_RP */ + case 534: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==534); + case 631: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==631); +#line 840 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy232)); } +#line 7102 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 446: /* expression ::= NK_PLUS expr_or_subquery */ + case 449: /* expression ::= NK_PLUS expr_or_subquery */ +#line 841 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 7111 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 447: /* expression ::= NK_MINUS expr_or_subquery */ + case 450: /* expression ::= NK_MINUS expr_or_subquery */ +#line 845 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy232), NULL)); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 7120 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 448: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 451: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ +#line 849 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7130 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 449: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 452: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ +#line 854 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7140 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 450: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 453: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ +#line 859 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7150 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 451: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 454: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ +#line 864 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7160 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 452: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 455: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ +#line 869 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7170 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 453: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 456: /* expression ::= column_reference NK_ARROW NK_STRING */ +#line 874 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7179 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 454: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 457: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ +#line 878 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7189 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 455: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 458: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ +#line 883 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7199 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 458: /* column_reference ::= column_name */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy785, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 461: /* column_reference ::= column_name */ +#line 894 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy993, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy993)); } +#line 7205 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 459: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 462: /* column_reference ::= table_name NK_DOT column_name */ +#line 895 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993, createColumnNode(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy993)); } +#line 7211 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 460: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 463: /* column_reference ::= NK_ALIAS */ +#line 896 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7217 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 461: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 464: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +#line 897 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0)); } +#line 7223 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 462: /* pseudo_column ::= ROWTS */ - case 463: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==463); - case 465: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==465); - case 466: /* pseudo_column ::= QEND */ yytestcase(yyruleno==466); - case 467: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==467); - case 468: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==468); - case 469: /* pseudo_column ::= WEND */ yytestcase(yyruleno==469); - case 470: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==470); - case 471: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==471); - case 472: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==472); - case 473: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==473); - case 479: /* literal_func ::= NOW */ yytestcase(yyruleno==479); -{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 465: /* pseudo_column ::= ROWTS */ + case 466: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==466); + case 468: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==468); + case 469: /* pseudo_column ::= QEND */ yytestcase(yyruleno==469); + case 470: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==470); + case 471: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==471); + case 472: /* pseudo_column ::= WEND */ yytestcase(yyruleno==472); + case 473: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==473); + case 474: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==474); + case 475: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==475); + case 476: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==476); + case 482: /* literal_func ::= NOW */ yytestcase(yyruleno==482); +#line 899 "sql.y" +{ yylhsminor.yy232 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 7240 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 464: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy785)))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 467: /* pseudo_column ::= table_name NK_DOT TBNAME */ +#line 901 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy993)))); } +#line 7246 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 474: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 475: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==475); -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy106)); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 477: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 478: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==478); +#line 912 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy993, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy993, yymsp[-1].minor.yy88)); } +#line 7253 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 476: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy292)); } - yymsp[-5].minor.yy80 = yylhsminor.yy80; + case 479: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +#line 915 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), yymsp[-1].minor.yy400)); } +#line 7259 "sql.c" + yymsp[-5].minor.yy232 = yylhsminor.yy232; break; - case 478: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy785, NULL)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 481: /* literal_func ::= noarg_func NK_LP NK_RP */ +#line 918 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy993, NULL)); } +#line 7265 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 493: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy106 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 496: /* star_func_para_list ::= NK_STAR */ +#line 942 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7271 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; - case 498: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 566: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==566); -{ yylhsminor.yy80 = createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 501: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 569: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==569); +#line 951 "sql.y" +{ yylhsminor.yy232 = createColumnNode(pCxt, &yymsp[-2].minor.yy993, &yymsp[0].minor.yy0); } +#line 7278 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 499: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy106, yymsp[-1].minor.yy80)); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 502: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +#line 954 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy88, yymsp[-1].minor.yy232)); } +#line 7284 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 500: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-2].minor.yy106, yymsp[-1].minor.yy80)); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; + case 503: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +#line 956 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), yymsp[-2].minor.yy88, yymsp[-1].minor.yy232)); } +#line 7290 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; - case 503: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy80 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + case 506: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +#line 963 "sql.y" +{ yymsp[-3].minor.yy232 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232)); } +#line 7296 "sql.c" break; - case 505: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } + case 508: /* case_when_else_opt ::= ELSE common_expression */ +#line 966 "sql.y" +{ yymsp[-1].minor.yy232 = releaseRawExprNode(pCxt, yymsp[0].minor.yy232); } +#line 7301 "sql.c" break; - case 506: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 511: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==511); + case 509: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 514: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==514); +#line 969 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy428, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy708, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7311 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 507: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 510: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 976 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy232), releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-4].minor.yy80 = yylhsminor.yy80; +#line 7321 "sql.c" + yymsp[-4].minor.yy232 = yylhsminor.yy232; break; - case 508: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 511: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 982 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy232), releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-5].minor.yy80 = yylhsminor.yy80; +#line 7331 "sql.c" + yymsp[-5].minor.yy232 = yylhsminor.yy232; break; - case 509: /* predicate ::= expr_or_subquery IS NULL */ + case 512: /* predicate ::= expr_or_subquery IS NULL */ +#line 987 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), NULL)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7340 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 510: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 513: /* predicate ::= expr_or_subquery IS NOT NULL */ +#line 991 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), NULL)); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 7349 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 512: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_THAN; } + case 515: /* compare_op ::= NK_LT */ +#line 1003 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_LOWER_THAN; } +#line 7355 "sql.c" break; - case 513: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_THAN; } + case 516: /* compare_op ::= NK_GT */ +#line 1004 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_GREATER_THAN; } +#line 7360 "sql.c" break; - case 514: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy428 = OP_TYPE_LOWER_EQUAL; } + case 517: /* compare_op ::= NK_LE */ +#line 1005 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_LOWER_EQUAL; } +#line 7365 "sql.c" break; - case 515: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy428 = OP_TYPE_GREATER_EQUAL; } + case 518: /* compare_op ::= NK_GE */ +#line 1006 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_GREATER_EQUAL; } +#line 7370 "sql.c" break; - case 516: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy428 = OP_TYPE_NOT_EQUAL; } + case 519: /* compare_op ::= NK_NE */ +#line 1007 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_NOT_EQUAL; } +#line 7375 "sql.c" break; - case 517: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy428 = OP_TYPE_EQUAL; } + case 520: /* compare_op ::= NK_EQ */ +#line 1008 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_EQUAL; } +#line 7380 "sql.c" break; - case 518: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy428 = OP_TYPE_LIKE; } + case 521: /* compare_op ::= LIKE */ +#line 1009 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_LIKE; } +#line 7385 "sql.c" break; - case 519: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_LIKE; } + case 522: /* compare_op ::= NOT LIKE */ +#line 1010 "sql.y" +{ yymsp[-1].minor.yy708 = OP_TYPE_NOT_LIKE; } +#line 7390 "sql.c" break; - case 520: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy428 = OP_TYPE_MATCH; } + case 523: /* compare_op ::= MATCH */ +#line 1011 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_MATCH; } +#line 7395 "sql.c" break; - case 521: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy428 = OP_TYPE_NMATCH; } + case 524: /* compare_op ::= NMATCH */ +#line 1012 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_NMATCH; } +#line 7400 "sql.c" break; - case 522: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy428 = OP_TYPE_JSON_CONTAINS; } + case 525: /* compare_op ::= CONTAINS */ +#line 1013 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_JSON_CONTAINS; } +#line 7405 "sql.c" break; - case 523: /* in_op ::= IN */ -{ yymsp[0].minor.yy428 = OP_TYPE_IN; } + case 526: /* in_op ::= IN */ +#line 1017 "sql.y" +{ yymsp[0].minor.yy708 = OP_TYPE_IN; } +#line 7410 "sql.c" break; - case 524: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy428 = OP_TYPE_NOT_IN; } + case 527: /* in_op ::= NOT IN */ +#line 1018 "sql.y" +{ yymsp[-1].minor.yy708 = OP_TYPE_NOT_IN; } +#line 7415 "sql.c" break; - case 525: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 528: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +#line 1020 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy88)); } +#line 7420 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 527: /* boolean_value_expression ::= NOT boolean_primary */ + case 530: /* boolean_value_expression ::= NOT boolean_primary */ +#line 1024 "sql.y" { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy232), NULL)); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; +#line 7429 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 528: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 531: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +#line 1029 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7439 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 529: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 532: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +#line 1035 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); - yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy232); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy232); + yylhsminor.yy232 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; +#line 7449 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 537: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy80 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, NULL); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 540: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +#line 1053 "sql.y" +{ yylhsminor.yy232 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy232, yymsp[0].minor.yy232, NULL); } +#line 7455 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 540: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 543: /* table_primary ::= table_name alias_opt */ +#line 1059 "sql.y" +{ yylhsminor.yy232 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy993, &yymsp[0].minor.yy993); } +#line 7461 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 541: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-3].minor.yy785, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 544: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +#line 1060 "sql.y" +{ yylhsminor.yy232 = createRealTableNode(pCxt, &yymsp[-3].minor.yy993, &yymsp[-1].minor.yy993, &yymsp[0].minor.yy993); } +#line 7467 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 542: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy80 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 545: /* table_primary ::= subquery alias_opt */ +#line 1061 "sql.y" +{ yylhsminor.yy232 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy232), &yymsp[0].minor.yy993); } +#line 7473 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 544: /* alias_opt ::= */ -{ yymsp[1].minor.yy785 = nil_token; } + case 547: /* alias_opt ::= */ +#line 1066 "sql.y" +{ yymsp[1].minor.yy993 = nil_token; } +#line 7479 "sql.c" break; - case 546: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy785 = yymsp[0].minor.yy785; } + case 549: /* alias_opt ::= AS table_alias */ +#line 1068 "sql.y" +{ yymsp[-1].minor.yy993 = yymsp[0].minor.yy993; } +#line 7484 "sql.c" break; - case 547: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 548: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==548); -{ yymsp[-2].minor.yy80 = yymsp[-1].minor.yy80; } + case 550: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 551: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==551); +#line 1070 "sql.y" +{ yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232; } +#line 7490 "sql.c" break; - case 549: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy80 = createJoinTableNode(pCxt, yymsp[-4].minor.yy828, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } - yymsp[-5].minor.yy80 = yylhsminor.yy80; + case 552: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +#line 1075 "sql.y" +{ yylhsminor.yy232 = createJoinTableNode(pCxt, yymsp[-4].minor.yy436, yymsp[-5].minor.yy232, yymsp[-2].minor.yy232, yymsp[0].minor.yy232); } +#line 7495 "sql.c" + yymsp[-5].minor.yy232 = yylhsminor.yy232; break; - case 550: /* join_type ::= */ -{ yymsp[1].minor.yy828 = JOIN_TYPE_INNER; } + case 553: /* join_type ::= */ +#line 1079 "sql.y" +{ yymsp[1].minor.yy436 = JOIN_TYPE_INNER; } +#line 7501 "sql.c" break; - case 551: /* join_type ::= INNER */ -{ yymsp[0].minor.yy828 = JOIN_TYPE_INNER; } + case 554: /* join_type ::= INNER */ +#line 1080 "sql.y" +{ yymsp[0].minor.yy436 = JOIN_TYPE_INNER; } +#line 7506 "sql.c" break; - case 552: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 555: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ +#line 1086 "sql.y" { - yymsp[-13].minor.yy80 = createSelectStmt(pCxt, yymsp[-11].minor.yy923, yymsp[-9].minor.yy106, yymsp[-8].minor.yy80, yymsp[-12].minor.yy106); - yymsp[-13].minor.yy80 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy80, yymsp[-10].minor.yy923); - yymsp[-13].minor.yy80 = addWhereClause(pCxt, yymsp[-13].minor.yy80, yymsp[-7].minor.yy80); - yymsp[-13].minor.yy80 = addPartitionByClause(pCxt, yymsp[-13].minor.yy80, yymsp[-6].minor.yy106); - yymsp[-13].minor.yy80 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy80, yymsp[-2].minor.yy80); - yymsp[-13].minor.yy80 = addGroupByClause(pCxt, yymsp[-13].minor.yy80, yymsp[-1].minor.yy106); - yymsp[-13].minor.yy80 = addHavingClause(pCxt, yymsp[-13].minor.yy80, yymsp[0].minor.yy80); - yymsp[-13].minor.yy80 = addRangeClause(pCxt, yymsp[-13].minor.yy80, yymsp[-5].minor.yy80); - yymsp[-13].minor.yy80 = addEveryClause(pCxt, yymsp[-13].minor.yy80, yymsp[-4].minor.yy80); - yymsp[-13].minor.yy80 = addFillClause(pCxt, yymsp[-13].minor.yy80, yymsp[-3].minor.yy80); + yymsp[-13].minor.yy232 = createSelectStmt(pCxt, yymsp[-11].minor.yy985, yymsp[-9].minor.yy88, yymsp[-8].minor.yy232, yymsp[-12].minor.yy88); + yymsp[-13].minor.yy232 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy232, yymsp[-10].minor.yy985); + yymsp[-13].minor.yy232 = addWhereClause(pCxt, yymsp[-13].minor.yy232, yymsp[-7].minor.yy232); + yymsp[-13].minor.yy232 = addPartitionByClause(pCxt, yymsp[-13].minor.yy232, yymsp[-6].minor.yy88); + yymsp[-13].minor.yy232 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy232, yymsp[-2].minor.yy232); + yymsp[-13].minor.yy232 = addGroupByClause(pCxt, yymsp[-13].minor.yy232, yymsp[-1].minor.yy88); + yymsp[-13].minor.yy232 = addHavingClause(pCxt, yymsp[-13].minor.yy232, yymsp[0].minor.yy232); + yymsp[-13].minor.yy232 = addRangeClause(pCxt, yymsp[-13].minor.yy232, yymsp[-5].minor.yy232); + yymsp[-13].minor.yy232 = addEveryClause(pCxt, yymsp[-13].minor.yy232, yymsp[-4].minor.yy232); + yymsp[-13].minor.yy232 = addFillClause(pCxt, yymsp[-13].minor.yy232, yymsp[-3].minor.yy232); } +#line 7522 "sql.c" break; - case 553: /* hint_list ::= */ -{ yymsp[1].minor.yy106 = createHintNodeList(pCxt, NULL); } + case 556: /* hint_list ::= */ +#line 1101 "sql.y" +{ yymsp[1].minor.yy88 = createHintNodeList(pCxt, NULL); } +#line 7527 "sql.c" break; - case 554: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy106 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 557: /* hint_list ::= NK_HINT */ +#line 1102 "sql.y" +{ yylhsminor.yy88 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 7532 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; - case 559: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy923 = false; } + case 562: /* set_quantifier_opt ::= ALL */ +#line 1113 "sql.y" +{ yymsp[0].minor.yy985 = false; } +#line 7538 "sql.c" break; - case 562: /* select_item ::= NK_STAR */ -{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy80 = yylhsminor.yy80; + case 565: /* select_item ::= NK_STAR */ +#line 1120 "sql.y" +{ yylhsminor.yy232 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 7543 "sql.c" + yymsp[0].minor.yy232 = yylhsminor.yy232; break; - case 564: /* select_item ::= common_expression column_alias */ - case 574: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==574); -{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy785); } - yymsp[-1].minor.yy80 = yylhsminor.yy80; + case 567: /* select_item ::= common_expression column_alias */ + case 577: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==577); +#line 1122 "sql.y" +{ yylhsminor.yy232 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy232), &yymsp[0].minor.yy993); } +#line 7550 "sql.c" + yymsp[-1].minor.yy232 = yylhsminor.yy232; break; - case 565: /* select_item ::= common_expression AS column_alias */ - case 575: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==575); -{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), &yymsp[0].minor.yy785); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 568: /* select_item ::= common_expression AS column_alias */ + case 578: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==578); +#line 1123 "sql.y" +{ yylhsminor.yy232 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), &yymsp[0].minor.yy993); } +#line 7557 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 570: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 598: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==598); - case 618: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==618); -{ yymsp[-2].minor.yy106 = yymsp[0].minor.yy106; } + case 573: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 601: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==601); + case 621: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==621); +#line 1132 "sql.y" +{ yymsp[-2].minor.yy88 = yymsp[0].minor.yy88; } +#line 7565 "sql.c" break; - case 577: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy80 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + case 580: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +#line 1145 "sql.y" +{ yymsp[-5].minor.yy232 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), releaseRawExprNode(pCxt, yymsp[-1].minor.yy232)); } +#line 7570 "sql.c" break; - case 578: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy80 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + case 581: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1146 "sql.y" +{ yymsp[-3].minor.yy232 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy232)); } +#line 7575 "sql.c" break; - case 579: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 582: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1148 "sql.y" +{ yymsp[-5].minor.yy232 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), NULL, yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 7580 "sql.c" break; - case 580: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + case 583: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1152 "sql.y" +{ yymsp[-7].minor.yy232 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy232), releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), yymsp[-1].minor.yy232, yymsp[0].minor.yy232); } +#line 7585 "sql.c" break; - case 581: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy80 = createEventWindowNode(pCxt, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); } + case 584: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +#line 1154 "sql.y" +{ yymsp[-6].minor.yy232 = createEventWindowNode(pCxt, yymsp[-3].minor.yy232, yymsp[0].minor.yy232); } +#line 7590 "sql.c" break; - case 588: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy80 = createFillNode(pCxt, yymsp[-1].minor.yy36, NULL); } + case 591: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +#line 1164 "sql.y" +{ yymsp[-3].minor.yy232 = createFillNode(pCxt, yymsp[-1].minor.yy246, NULL); } +#line 7595 "sql.c" break; - case 589: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } + case 592: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +#line 1165 "sql.y" +{ yymsp[-5].minor.yy232 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy88)); } +#line 7600 "sql.c" break; - case 590: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy106)); } + case 593: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +#line 1166 "sql.y" +{ yymsp[-5].minor.yy232 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy88)); } +#line 7605 "sql.c" break; - case 591: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy36 = FILL_MODE_NONE; } + case 594: /* fill_mode ::= NONE */ +#line 1170 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_NONE; } +#line 7610 "sql.c" break; - case 592: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy36 = FILL_MODE_PREV; } + case 595: /* fill_mode ::= PREV */ +#line 1171 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_PREV; } +#line 7615 "sql.c" break; - case 593: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy36 = FILL_MODE_NULL; } + case 596: /* fill_mode ::= NULL */ +#line 1172 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_NULL; } +#line 7620 "sql.c" break; - case 594: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy36 = FILL_MODE_NULL_F; } + case 597: /* fill_mode ::= NULL_F */ +#line 1173 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_NULL_F; } +#line 7625 "sql.c" break; - case 595: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy36 = FILL_MODE_LINEAR; } + case 598: /* fill_mode ::= LINEAR */ +#line 1174 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_LINEAR; } +#line 7630 "sql.c" break; - case 596: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy36 = FILL_MODE_NEXT; } + case 599: /* fill_mode ::= NEXT */ +#line 1175 "sql.y" +{ yymsp[0].minor.yy246 = FILL_MODE_NEXT; } +#line 7635 "sql.c" break; - case 599: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy106 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[0].minor.yy106 = yylhsminor.yy106; + case 602: /* group_by_list ::= expr_or_subquery */ +#line 1184 "sql.y" +{ yylhsminor.yy88 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } +#line 7640 "sql.c" + yymsp[0].minor.yy88 = yylhsminor.yy88; break; - case 600: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy106 = addNodeToList(pCxt, yymsp[-2].minor.yy106, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy106 = yylhsminor.yy106; + case 603: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +#line 1185 "sql.y" +{ yylhsminor.yy88 = addNodeToList(pCxt, yymsp[-2].minor.yy88, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy232))); } +#line 7646 "sql.c" + yymsp[-2].minor.yy88 = yylhsminor.yy88; break; - case 604: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy80 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + case 607: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +#line 1192 "sql.y" +{ yymsp[-5].minor.yy232 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy232), releaseRawExprNode(pCxt, yymsp[-1].minor.yy232)); } +#line 7652 "sql.c" break; - case 605: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy80 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + case 608: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +#line 1194 "sql.y" +{ yymsp[-3].minor.yy232 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy232)); } +#line 7657 "sql.c" break; - case 608: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 611: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +#line 1201 "sql.y" { - yylhsminor.yy80 = addOrderByClause(pCxt, yymsp[-3].minor.yy80, yymsp[-2].minor.yy106); - yylhsminor.yy80 = addSlimitClause(pCxt, yylhsminor.yy80, yymsp[-1].minor.yy80); - yylhsminor.yy80 = addLimitClause(pCxt, yylhsminor.yy80, yymsp[0].minor.yy80); + yylhsminor.yy232 = addOrderByClause(pCxt, yymsp[-3].minor.yy232, yymsp[-2].minor.yy88); + yylhsminor.yy232 = addSlimitClause(pCxt, yylhsminor.yy232, yymsp[-1].minor.yy232); + yylhsminor.yy232 = addLimitClause(pCxt, yylhsminor.yy232, yymsp[0].minor.yy232); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; +#line 7666 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 611: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); } - yymsp[-3].minor.yy80 = yylhsminor.yy80; + case 614: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +#line 1211 "sql.y" +{ yylhsminor.yy232 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy232, yymsp[0].minor.yy232); } +#line 7672 "sql.c" + yymsp[-3].minor.yy232 = yylhsminor.yy232; break; - case 612: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 615: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +#line 1213 "sql.y" +{ yylhsminor.yy232 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy232, yymsp[0].minor.yy232); } +#line 7678 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 620: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 624: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==624); -{ yymsp[-1].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 623: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 627: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==627); +#line 1227 "sql.y" +{ yymsp[-1].minor.yy232 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 7685 "sql.c" break; - case 621: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 625: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==625); -{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 624: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 628: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==628); +#line 1228 "sql.y" +{ yymsp[-3].minor.yy232 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 7691 "sql.c" break; - case 622: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 626: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==626); -{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 625: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 629: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==629); +#line 1229 "sql.y" +{ yymsp[-3].minor.yy232 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 7697 "sql.c" break; - case 627: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy80); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 630: /* subquery ::= NK_LP query_expression NK_RP */ +#line 1237 "sql.y" +{ yylhsminor.yy232 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy232); } +#line 7702 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 632: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy80 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), yymsp[-1].minor.yy812, yymsp[0].minor.yy763); } - yymsp[-2].minor.yy80 = yylhsminor.yy80; + case 635: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +#line 1251 "sql.y" +{ yylhsminor.yy232 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy232), yymsp[-1].minor.yy834, yymsp[0].minor.yy153); } +#line 7708 "sql.c" + yymsp[-2].minor.yy232 = yylhsminor.yy232; break; - case 633: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy812 = ORDER_ASC; } + case 636: /* ordering_specification_opt ::= */ +#line 1255 "sql.y" +{ yymsp[1].minor.yy834 = ORDER_ASC; } +#line 7714 "sql.c" break; - case 634: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy812 = ORDER_ASC; } + case 637: /* ordering_specification_opt ::= ASC */ +#line 1256 "sql.y" +{ yymsp[0].minor.yy834 = ORDER_ASC; } +#line 7719 "sql.c" break; - case 635: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy812 = ORDER_DESC; } + case 638: /* ordering_specification_opt ::= DESC */ +#line 1257 "sql.y" +{ yymsp[0].minor.yy834 = ORDER_DESC; } +#line 7724 "sql.c" break; - case 636: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy763 = NULL_ORDER_DEFAULT; } + case 639: /* null_ordering_opt ::= */ +#line 1261 "sql.y" +{ yymsp[1].minor.yy153 = NULL_ORDER_DEFAULT; } +#line 7729 "sql.c" break; - case 637: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy763 = NULL_ORDER_FIRST; } + case 640: /* null_ordering_opt ::= NULLS FIRST */ +#line 1262 "sql.y" +{ yymsp[-1].minor.yy153 = NULL_ORDER_FIRST; } +#line 7734 "sql.c" break; - case 638: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy763 = NULL_ORDER_LAST; } + case 641: /* null_ordering_opt ::= NULLS LAST */ +#line 1263 "sql.y" +{ yymsp[-1].minor.yy153 = NULL_ORDER_LAST; } +#line 7739 "sql.c" break; default: break; @@ -6590,6 +7798,7 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ +#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -6600,6 +7809,7 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } +#line 7812 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE @@ -6685,12 +7895,56 @@ void Parse( } #endif - do{ + while(1){ /* Exit by "break" */ + assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ +#ifndef NDEBUG + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); + if( yyTraceFILE ){ + int yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos[yysize].stateno); + }else{ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", + yyTracePrompt, yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == + (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + break; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + break; + } + } +#endif + } + yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -6746,14 +8000,13 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos >= yypParser->yystack - && (yyact = yy_find_reduce_action( - yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE - ){ + while( yypParser->yytos > yypParser->yystack ){ + yyact = yy_find_reduce_action(yypParser->yytos->stateno, + YYERRORSYMBOL); + if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } - if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY @@ -6803,7 +8056,7 @@ void Parse( break; #endif } - }while( yypParser->yytos>yypParser->yystack ); + } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 7b8decc007..f987420ece 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -455,7 +455,6 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { tstrerror(rspCode)); SCH_ERR_JRET(schProcessOnCbBegin(&pJob, &pTask, pParam->queryId, pParam->refId, pParam->taskId)); - code = schHandleResponseMsg(pJob, pTask, pParam->execId, pMsg, rspCode); pMsg->pData = NULL; diff --git a/source/libs/stream/inc/streamBackendRocksdb.h b/source/libs/stream/inc/streamBackendRocksdb.h index bed0f79f02..9bfec5577c 100644 --- a/source/libs/stream/inc/streamBackendRocksdb.h +++ b/source/libs/stream/inc/streamBackendRocksdb.h @@ -79,6 +79,8 @@ typedef struct { TdThreadRwlock chkpDirLock; int64_t dataWritten; + void* pMeta; + } STaskDbWrapper; typedef struct SDbChkp { diff --git a/source/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index 0df36ec391..f709741b57 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -87,10 +87,10 @@ struct SStreamQueue { int8_t status; }; -extern void* streamTimer; -extern int32_t streamBackendId; -extern int32_t streamBackendCfWrapperId; -extern int32_t taskDbWrapperId; +extern void* streamTimer; +extern int32_t streamBackendId; +extern int32_t streamBackendCfWrapperId; +extern int32_t taskDbWrapperId; void streamRetryDispatchData(SStreamTask* pTask, int64_t waitDuration); int32_t streamDispatchStreamBlock(SStreamTask* pTask); @@ -156,6 +156,8 @@ void* streamQueueNextItem(SStreamQueue* pQueue); void streamFreeQitem(SStreamQueueItem* data); int32_t streamQueueGetItemSize(const SStreamQueue* pQueue); +void streamMetaRemoveDB(void* arg, char* key); + typedef enum UPLOAD_TYPE { UPLOAD_DISABLE = -1, UPLOAD_S3 = 0, diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 630650025d..5d2c7ec504 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -982,8 +982,10 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI } int32_t taskDbBuildSnap(void* arg, SArray* pSnap) { SStreamMeta* pMeta = arg; - void* pIter = taosHashIterate(pMeta->pTaskDbUnique, NULL); - int32_t code = 0; + + taosThreadMutexLock(&pMeta->backendMutex); + void* pIter = taosHashIterate(pMeta->pTaskDbUnique, NULL); + int32_t code = 0; while (pIter) { STaskDbWrapper* pTaskDb = *(STaskDbWrapper**)pIter; @@ -1000,6 +1002,8 @@ int32_t taskDbBuildSnap(void* arg, SArray* pSnap) { taosArrayPush(pSnap, &snap); pIter = taosHashIterate(pMeta->pTaskDbUnique, pIter); } + taosThreadMutexUnlock(&pMeta->backendMutex); + return code; } int32_t streamBackendAddInUseChkp(void* arg, int64_t chkpId) { @@ -1810,6 +1814,10 @@ STaskDbWrapper* taskDbOpen(char* path, char* key, int64_t chkpId) { void taskDbDestroy(void* pDb, bool flush) { STaskDbWrapper* wrapper = pDb; + if (wrapper == NULL) return; + + streamMetaRemoveDB(wrapper->pMeta, wrapper->idstr); + qDebug("succ to destroy stream backend:%p", wrapper); int8_t nCf = sizeof(ginitDict) / sizeof(ginitDict[0]); diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index e2561de841..cf0682f037 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -425,6 +425,9 @@ int32_t streamTaskUploadChkp(SStreamTask* pTask, int64_t chkpId, char* taskId) { if (type == UPLOAD_DISABLE) { return 0; } + if (pTask == NULL || pTask->pBackend == NULL) { + return 0; + } SAsyncUploadArg* arg = taosMemoryCalloc(1, sizeof(SAsyncUploadArg)); arg->type = type; arg->taskId = taosStrdup(taskId); @@ -515,7 +518,7 @@ static int uploadCheckpointToS3(char* id, char* path) { char object[PATH_MAX] = {0}; snprintf(object, sizeof(object), "%s%s%s", id, TD_DIRSEP, name); - if (s3PutObjectFromFile2(filename, object) != 0) { + if (s3PutObjectFromFile2(filename, object, 0) != 0) { taosCloseDir(&pDir); return -1; } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 1a67b08749..5fb7db233f 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -720,14 +720,21 @@ int32_t streamTaskSendCheckpointReadyMsg(SStreamTask* pTask) { // this function is only invoked by source task, and send rsp to mnode int32_t streamTaskSendCheckpointSourceRsp(SStreamTask* pTask) { - ASSERT(pTask->info.taskLevel == TASK_LEVEL__SOURCE && taosArrayGetSize(pTask->pReadyMsgList) == 1); - SStreamChkptReadyInfo* pInfo = taosArrayGet(pTask->pReadyMsgList, 0); + taosThreadMutexLock(&pTask->lock); - tmsgSendRsp(&pInfo->msg); + ASSERT(pTask->info.taskLevel == TASK_LEVEL__SOURCE); - taosArrayClear(pTask->pReadyMsgList); - stDebug("s-task:%s level:%d source checkpoint completed msg sent to mnode", pTask->id.idStr, pTask->info.taskLevel); + if (taosArrayGetSize(pTask->pReadyMsgList) == 1) { + SStreamChkptReadyInfo* pInfo = taosArrayGet(pTask->pReadyMsgList, 0); + tmsgSendRsp(&pInfo->msg); + taosArrayClear(pTask->pReadyMsgList); + stDebug("s-task:%s level:%d source checkpoint completed msg sent to mnode", pTask->id.idStr, pTask->info.taskLevel); + } else { + stDebug("s-task:%s level:%d already send rsp to mnode", pTask->id.idStr, pTask->info.taskLevel); + } + + taosThreadMutexUnlock(&pTask->lock); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 807f120cb7..254b6de5b8 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -31,7 +31,6 @@ int32_t streamMetaId = 0; int32_t taskDbWrapperId = 0; static void metaHbToMnode(void* param, void* tmrId); -static void streamMetaClear(SStreamMeta* pMeta); static int32_t streamMetaBegin(SStreamMeta* pMeta); static void streamMetaCloseImpl(void* arg); @@ -251,9 +250,11 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* arg, char* key) { taskDbAddRef(*ppBackend); STaskDbWrapper* pBackend = *ppBackend; + pBackend->pMeta = pMeta; pTask->backendRefId = pBackend->refId; pTask->pBackend = pBackend; + taosThreadMutexUnlock(&pMeta->backendMutex); stDebug("s-task:0x%x set backend %p", pTask->id.taskId, pBackend); @@ -271,6 +272,7 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* arg, char* key) { pTask->pBackend = pBackend; pBackend->refId = tref; pBackend->pTask = pTask; + pBackend->pMeta = pMeta; taosHashPut(pMeta->pTaskDbUnique, key, strlen(key), &pBackend, sizeof(void*)); taosThreadMutexUnlock(&pMeta->backendMutex); @@ -278,6 +280,15 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, void* arg, char* key) { stDebug("s-task:0x%x set backend %p", pTask->id.taskId, pBackend); return 0; } +void streamMetaRemoveDB(void* arg, char* key) { + if (arg == NULL || key == NULL) return; + + SStreamMeta* pMeta = arg; + taosThreadMutexLock(&pMeta->backendMutex); + taosHashRemove(pMeta->pTaskDbUnique, key, strlen(key)); + + taosThreadMutexUnlock(&pMeta->backendMutex); +} SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc, int32_t vgId, int64_t stage) { int32_t code = -1; SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta)); @@ -395,41 +406,6 @@ _err: return NULL; } -int32_t streamMetaReopen(SStreamMeta* pMeta) { - streamMetaClear(pMeta); - - // NOTE: role should not be changed during reopen meta - pMeta->streamBackendRid = -1; - pMeta->streamBackend = NULL; - - char* defaultPath = taosMemoryCalloc(1, strlen(pMeta->path) + 128); - sprintf(defaultPath, "%s%s%s", pMeta->path, TD_DIRSEP, "state"); - taosRemoveDir(defaultPath); - - char* newPath = taosMemoryCalloc(1, strlen(pMeta->path) + 128); - sprintf(newPath, "%s%s%s", pMeta->path, TD_DIRSEP, "received"); - - int32_t code = taosStatFile(newPath, NULL, NULL, NULL); - if (code == 0) { - // directory exists - code = taosRenameFile(newPath, defaultPath); - if (code != 0) { - terrno = TAOS_SYSTEM_ERROR(code); - stError("vgId:%d failed to rename file, from %s to %s, code:%s", pMeta->vgId, newPath, defaultPath, - tstrerror(terrno)); - - taosMemoryFree(defaultPath); - taosMemoryFree(newPath); - return -1; - } - } - - taosMemoryFree(defaultPath); - taosMemoryFree(newPath); - - return 0; -} - // todo refactor: the lock shoud be restricted in one function void streamMetaInitBackend(SStreamMeta* pMeta) { pMeta->streamBackend = streamBackendInit(pMeta->path, pMeta->chkpId, pMeta->vgId); @@ -829,28 +805,27 @@ static void doClear(void* pKey, void* pVal, TBC* pCur, SArray* pRecycleList) { taosArrayDestroy(pRecycleList); } -int32_t streamMetaReloadAllTasks(SStreamMeta* pMeta) { - if (pMeta == NULL) return 0; - - return streamMetaLoadAllTasks(pMeta); -} int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta) { - TBC* pCur = NULL; - int32_t vgId = pMeta->vgId; - - stInfo("vgId:%d load stream tasks from meta files", vgId); - - if (tdbTbcOpen(pMeta->pTaskDb, &pCur, NULL) < 0) { - stError("vgId:%d failed to open stream meta, code:%s", vgId, tstrerror(terrno)); - return -1; - } - + TBC* pCur = NULL; void* pKey = NULL; int32_t kLen = 0; void* pVal = NULL; int32_t vLen = 0; SDecoder decoder; - SArray* pRecycleList = taosArrayInit(4, sizeof(STaskId)); + + if (pMeta == NULL) { + return TSDB_CODE_SUCCESS; + } + + SArray* pRecycleList = taosArrayInit(4, sizeof(STaskId)); + int32_t vgId = pMeta->vgId; + stInfo("vgId:%d load stream tasks from meta files", vgId); + + if (tdbTbcOpen(pMeta->pTaskDb, &pCur, NULL) < 0) { + stError("vgId:%d failed to open stream meta, code:%s", vgId, tstrerror(terrno)); + taosArrayDestroy(pRecycleList); + return -1; + } tdbTbcMoveToFirst(pCur); while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) { diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 276ed08785..776a9db522 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -91,8 +91,8 @@ int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) { } SStreamState* streamStateOpen(char* path, void* pTask, bool specPath, int32_t szPage, int32_t pages) { - stDebug("open stream state, %s", path); SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState)); + stDebug("open stream state %p, %s", pState, path); if (pState == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; @@ -211,7 +211,7 @@ int32_t streamStateDelTaskDb(SStreamState* pState) { SStreamTask* pTask = pState->pTdbState->pOwner; taskDbRemoveRef(pTask->pBackend); taosMemoryFree(pTask); - return 0; + return 0; } void streamStateClose(SStreamState* pState, bool remove) { SStreamTask* pTask = pState->pTdbState->pOwner; @@ -374,8 +374,8 @@ int32_t streamStateClear(SStreamState* pState) { streamStatePut(pState, &key, NULL, 0); while (1) { SStreamStateCur* pCur = streamStateSeekKeyNext(pState, &key); - SWinKey delKey = {0}; - int32_t code = streamStateGetKVByCur(pCur, &delKey, NULL, 0); + SWinKey delKey = {0}; + int32_t code = streamStateGetKVByCur(pCur, &delKey, NULL, 0); streamStateFreeCur(pCur); if (code == 0) { streamStateDel(pState, &delKey); @@ -493,7 +493,7 @@ int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** return -1; } const SStateKey* pKTmp = NULL; - int32_t kLen; + int32_t kLen; if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) { return -1; } @@ -513,7 +513,7 @@ int32_t streamStateFillGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const vo return -1; } const SWinKey* pKTmp = NULL; - int32_t kLen; + int32_t kLen; if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, pVal, pVLen) < 0) { return -1; } @@ -530,7 +530,7 @@ int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const v return -1; } uint64_t groupId = pKey->groupId; - int32_t code = streamStateFillGetKVByCur(pCur, pKey, pVal, pVLen); + int32_t code = streamStateFillGetKVByCur(pCur, pKey, pVal, pVLen); if (code == 0) { if (pKey->groupId == groupId) { return 0; @@ -555,7 +555,7 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key } SStateKey sKey = {.key = *key, .opNum = pState->number}; - int32_t c = 0; + int32_t c = 0; if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c) < 0) { streamStateFreeCur(pCur); return NULL; @@ -710,7 +710,8 @@ int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, void #endif } -int32_t streamStateSessionAllocWinBuffByNextPosition(SStreamState* pState, SStreamStateCur* pCur, const SSessionKey* pKey, void** pVal, int32_t* pVLen) { +int32_t streamStateSessionAllocWinBuffByNextPosition(SStreamState* pState, SStreamStateCur* pCur, + const SSessionKey* pKey, void** pVal, int32_t* pVLen) { #ifdef USE_ROCKSDB return allocSessioncWinBuffByNextPosition(pState->pFileState, pCur, pKey, pVal, pVLen); #else @@ -724,9 +725,9 @@ int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVa #else SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentNext(pState, key); - SSessionKey resKey = *key; - void* tmp = NULL; - int32_t code = streamStateSessionGetKVByCur(pCur, &resKey, &tmp, pVLen); + SSessionKey resKey = *key; + void* tmp = NULL; + int32_t code = streamStateSessionGetKVByCur(pCur, &resKey, &tmp, pVLen); if (code == 0) { if (key->win.skey != resKey.win.skey) { code = -1; @@ -767,7 +768,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, cons } SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; - int32_t c = 0; + int32_t c = 0; if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) { streamStateFreeCur(pCur); return NULL; @@ -798,7 +799,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, cons } SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; - int32_t c = 0; + int32_t c = 0; if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) { streamStateFreeCur(pCur); return NULL; @@ -830,7 +831,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess } SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; - int32_t c = 0; + int32_t c = 0; if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) { streamStateFreeCur(pCur); return NULL; @@ -854,7 +855,7 @@ int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, v return -1; } SStateSessionKey* pKTmp = NULL; - int32_t kLen; + int32_t kLen; if (tdbTbcGet(pCur->pCur, (const void**)&pKTmp, &kLen, (const void**)pVal, pVLen) < 0) { return -1; } @@ -874,13 +875,13 @@ int32_t streamStateSessionClear(SStreamState* pState) { sessionWinStateClear(pState->pFileState); return streamStateSessionClear_rocksdb(pState); #else - SSessionKey key = {.win.skey = 0, .win.ekey = 0, .groupId = 0}; + SSessionKey key = {.win.skey = 0, .win.ekey = 0, .groupId = 0}; SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentNext(pState, &key); while (1) { SSessionKey delKey = {0}; - void* buf = NULL; - int32_t size = 0; - int32_t code = streamStateSessionGetKVByCur(pCur, &delKey, &buf, &size); + void* buf = NULL; + int32_t size = 0; + int32_t code = streamStateSessionGetKVByCur(pCur, &delKey, &buf, &size); if (code == 0 && size > 0) { memset(buf, 0, size); streamStateSessionPut(pState, &delKey, buf, size); @@ -909,14 +910,14 @@ int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* } SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; - int32_t c = 0; + int32_t c = 0; if (tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateSessionKey), &c) < 0) { streamStateFreeCur(pCur); return -1; } SSessionKey resKey = *key; - int32_t code = streamStateSessionGetKVByCur(pCur, &resKey, NULL, 0); + int32_t code = streamStateSessionGetKVByCur(pCur, &resKey, NULL, 0); if (code == 0 && sessionRangeKeyCmpr(key, &resKey) == 0) { *curKey = resKey; streamStateFreeCur(pCur); @@ -952,19 +953,19 @@ int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, return getSessionWinResultBuff(pState->pFileState, key, gap, pVal, pVLen); #else // todo refactor - int32_t res = 0; + int32_t res = 0; SSessionKey originKey = *key; SSessionKey searchKey = *key; searchKey.win.skey = key->win.skey - gap; searchKey.win.ekey = key->win.ekey + gap; int32_t valSize = *pVLen; - void* tmp = tdbRealloc(NULL, valSize); + void* tmp = tdbRealloc(NULL, valSize); if (!tmp) { return -1; } SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev(pState, key); - int32_t code = streamStateSessionGetKVByCur(pCur, key, pVal, pVLen); + int32_t code = streamStateSessionGetKVByCur(pCur, key, pVal, pVLen); if (code == 0) { if (sessionRangeKeyCmpr(&searchKey, key) == 0) { memcpy(tmp, *pVal, valSize); @@ -1007,16 +1008,16 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch #ifdef USE_ROCKSDB return getStateWinResultBuff(pState->pFileState, key, pKeyData, keyDataLen, fn, pVal, pVLen); #else - int32_t res = 0; + int32_t res = 0; SSessionKey tmpKey = *key; - int32_t valSize = *pVLen; - void* tmp = tdbRealloc(NULL, valSize); + int32_t valSize = *pVLen; + void* tmp = tdbRealloc(NULL, valSize); if (!tmp) { return -1; } SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev(pState, key); - int32_t code = streamStateSessionGetKVByCur(pCur, key, pVal, pVLen); + int32_t code = streamStateSessionGetKVByCur(pCur, key, pVal, pVLen); if (code == 0) { if (key->win.skey <= tmpKey.win.skey && tmpKey.win.ekey <= key->win.ekey) { memcpy(tmp, *pVal, valSize); @@ -1115,6 +1116,20 @@ int32_t streamStateDeleteCheckPoint(SStreamState* pState, TSKEY mark) { void streamStateReloadInfo(SStreamState* pState, TSKEY ts) { streamFileStateReloadInfo(pState->pFileState, ts); } +void streamStateCopyBackend(SStreamState* src, SStreamState* dst) { + dst->pFileState = src->pFileState; + dst->parNameMap = src->parNameMap; + dst->number = src->number; + dst->taskId = src->taskId; + dst->streamId = src->streamId; + if (dst->pTdbState == NULL) { + dst->pTdbState = taosMemoryCalloc(1, sizeof(STdbState)); + dst->pTdbState->pOwner = taosMemoryCalloc(1, sizeof(SStreamTask)); + } + dst->dump = 1; + dst->pTdbState->pOwner->pBackend = src->pTdbState->pOwner->pBackend; + return; +} SStreamStateCur* createStreamStateCursor() { SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); pCur->buffIndex = -1; diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index db0217f000..335f9d27d5 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -302,17 +302,25 @@ static void freeUpstreamItem(void* p) { } void tFreeStreamTask(SStreamTask* pTask) { - int32_t taskId = pTask->id.taskId; - + char* p = NULL; + int32_t taskId = pTask->id.taskId; STaskExecStatisInfo* pStatis = &pTask->execInfo; - stDebug("start to free s-task:0x%x, %p, state:%p", taskId, pTask, pTask->pState); + ETaskStatus status1 = TASK_STATUS__UNINIT; + taosThreadMutexLock(&pTask->lock); + if (pTask->status.pSM != NULL) { + status1 = streamTaskGetStatus(pTask, &p); + } + taosThreadMutexUnlock(&pTask->lock); + + stDebug("start to free s-task:0x%x, %p, state:%s", taskId, pTask, p); + + SCheckpointInfo* pCkInfo = &pTask->chkInfo; stDebug("s-task:0x%x task exec summary: create:%" PRId64 ", init:%" PRId64 ", start:%" PRId64 ", updateCount:%d latestUpdate:%" PRId64 ", latestCheckPoint:%" PRId64 ", ver:%" PRId64 " nextProcessVer:%" PRId64 ", checkpointCount:%d", taskId, pStatis->created, pStatis->init, pStatis->start, pStatis->updateCount, pStatis->latestUpdateTs, - pTask->chkInfo.checkpointId, pTask->chkInfo.checkpointVer, pTask->chkInfo.nextProcessVer, - pStatis->checkpoint); + pCkInfo->checkpointId, pCkInfo->checkpointVer, pCkInfo->nextProcessVer, pStatis->checkpoint); // remove the ref by timer while (pTask->status.timerActive > 0) { @@ -335,7 +343,6 @@ void tFreeStreamTask(SStreamTask* pTask) { pTask->msgInfo.pTimer = NULL; } - int32_t status = atomic_load_8((int8_t*)&(pTask->status.taskStatus)); if (pTask->inputq.queue) { streamQueueClose(pTask->inputq.queue, pTask->id.taskId); } @@ -377,9 +384,8 @@ void tFreeStreamTask(SStreamTask* pTask) { if (pTask->pState) { stDebug("s-task:0x%x start to free task state", taskId); - streamStateClose(pTask->pState, status == TASK_STATUS__DROPPING); + streamStateClose(pTask->pState, status1 == TASK_STATUS__DROPPING); taskDbRemoveRef(pTask->pBackend); - } if (pTask->id.idStr != NULL) { @@ -396,7 +402,6 @@ void tFreeStreamTask(SStreamTask* pTask) { } pTask->status.pSM = streamDestroyStateMachine(pTask->status.pSM); - streamTaskDestroyUpstreamInfo(&pTask->upstreamInfo); pTask->msgInfo.pRetryList = taosArrayDestroy(pTask->msgInfo.pRetryList); diff --git a/source/libs/stream/src/streamTaskSm.c b/source/libs/stream/src/streamTaskSm.c index cac3766893..68ae1cce36 100644 --- a/source/libs/stream/src/streamTaskSm.c +++ b/source/libs/stream/src/streamTaskSm.c @@ -56,6 +56,7 @@ static int32_t streamTaskInitStatus(SStreamTask* pTask); static int32_t streamTaskKeepCurrentVerInWal(SStreamTask* pTask); static int32_t initStateTransferTable(); static void doInitStateTransferTable(void); +static int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask); static STaskStateTrans createStateTransform(ETaskStatus current, ETaskStatus next, EStreamTaskEvent event, __state_trans_fn fn, __state_trans_succ_fn succFn, @@ -87,6 +88,13 @@ static int32_t streamTaskDoCheckpoint(SStreamTask* pTask) { return 0; } +int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask) { + if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { + streamTaskSendCheckpointSourceRsp(pTask); + } + return 0; +} + int32_t streamTaskKeepCurrentVerInWal(SStreamTask* pTask) { ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask)); @@ -551,7 +559,7 @@ void doInitStateTransferTable(void) { taosArrayPush(streamTaskSMTrans, &trans); trans = createStateTransform(TASK_STATUS__PAUSE, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); taosArrayPush(streamTaskSMTrans, &trans); - trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); + trans = createStateTransform(TASK_STATUS__CK, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, streamTaskSendTransSuccessMsg, NULL, NULL, true); taosArrayPush(streamTaskSMTrans, &trans); trans = createStateTransform(TASK_STATUS__STREAM_SCAN_HISTORY, TASK_STATUS__DROPPING, TASK_EVENT_DROPPING, NULL, NULL, NULL, true); taosArrayPush(streamTaskSMTrans, &trans); diff --git a/source/libs/sync/inc/syncRaftLog.h b/source/libs/sync/inc/syncRaftLog.h index de8bd81b30..137baab558 100644 --- a/source/libs/sync/inc/syncRaftLog.h +++ b/source/libs/sync/inc/syncRaftLog.h @@ -46,6 +46,7 @@ SyncIndex raftLogBeginIndex(struct SSyncLogStore* pLogStore); SyncIndex raftLogEndIndex(struct SSyncLogStore* pLogStore); int32_t raftLogEntryCount(struct SSyncLogStore* pLogStore); SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore); +SyncIndex raftLogIndexRetention(struct SSyncLogStore* pLogStore, int64_t bytes); SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore); int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry** ppEntry); diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index f8ee99e8a0..66d8edfdfc 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -63,7 +63,6 @@ typedef struct SSyncSnapshotSender { int64_t sendingMS; SyncTerm term; int64_t startTime; - int64_t waitTime; int64_t lastSendTime; bool finish; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 199c7a1445..b8740a2858 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -305,6 +305,10 @@ SyncIndex syncMinMatchIndex(SSyncNode* pSyncNode) { return minMatchIndex; } +static SyncIndex syncLogRetentionIndex(SSyncNode* pSyncNode, int64_t bytes) { + return pSyncNode->pLogStore->syncLogIndexRetention(pSyncNode->pLogStore, bytes); +} + int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { @@ -331,7 +335,6 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { } else { // vnode if (pSyncNode->replicaNum > 1) { - // multi replicas logRetention = SYNC_VNODE_LOG_RETENTION; } } @@ -344,7 +347,9 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { syncNodeRelease(pSyncNode); return 0; } - logRetention = TMAX(logRetention, lastApplyIndex - pSyncNode->minMatchIndex + logRetention); + SyncIndex retentionIndex = + TMAX(pSyncNode->minMatchIndex, syncLogRetentionIndex(pSyncNode, SYNC_WAL_LOG_RETENTION_SIZE)); + logRetention += TMAX(0, lastApplyIndex - retentionIndex); } _DEL_WAL: diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index b167f2ecb6..b9c6838fda 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -70,6 +70,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { pLogStore->syncLogIsEmpty = raftLogIsEmpty; pLogStore->syncLogEntryCount = raftLogEntryCount; pLogStore->syncLogLastIndex = raftLogLastIndex; + pLogStore->syncLogIndexRetention = raftLogIndexRetention; pLogStore->syncLogLastTerm = raftLogLastTerm; pLogStore->syncLogAppendEntry = raftLogAppendEntry; pLogStore->syncLogGetEntry = raftLogGetEntry; @@ -154,6 +155,15 @@ SyncIndex raftLogLastIndex(struct SSyncLogStore* pLogStore) { return lastVer; } +SyncIndex raftLogIndexRetention(struct SSyncLogStore* pLogStore, int64_t bytes) { + SyncIndex lastIndex; + SSyncLogStoreData* pData = pLogStore->data; + SWal* pWal = pData->pWal; + SyncIndex lastVer = walGetVerRetention(pWal, bytes); + + return lastVer; +} + SyncIndex raftLogWriteIndex(struct SSyncLogStore* pLogStore) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 93e81fd8e2..f060e9da13 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -23,8 +23,9 @@ #include "syncReplication.h" #include "syncUtil.h" +static SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths); + static void syncSnapBufferReset(SSyncSnapBuffer *pBuf) { - taosThreadMutexLock(&pBuf->mutex); for (int64_t i = pBuf->start; i < pBuf->end; ++i) { if (pBuf->entryDeleteCb) { pBuf->entryDeleteCb(pBuf->entries[i % pBuf->size]); @@ -34,7 +35,6 @@ static void syncSnapBufferReset(SSyncSnapBuffer *pBuf) { pBuf->start = SYNC_SNAPSHOT_SEQ_BEGIN + 1; pBuf->end = pBuf->start; pBuf->cursor = pBuf->start - 1; - taosThreadMutexUnlock(&pBuf->mutex); } static void syncSnapBufferDestroy(SSyncSnapBuffer **ppBuf) { @@ -81,7 +81,6 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->replicaIndex = replicaIndex; pSender->term = raftStoreGetTerm(pSyncNode); pSender->startTime = -1; - pSender->waitTime = -1; pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; @@ -108,6 +107,19 @@ void syncSnapBlockDestroy(void *ptr) { taosMemoryFree(pBlk); } +static int32_t snapshotSenderClearInfoData(SSyncSnapshotSender *pSender) { + if (pSender->snapshotParam.data) { + taosMemoryFree(pSender->snapshotParam.data); + pSender->snapshotParam.data = NULL; + } + + if (pSender->snapshot.data) { + taosMemoryFree(pSender->snapshot.data); + pSender->snapshot.data = NULL; + } + return 0; +} + void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender == NULL) return; @@ -122,10 +134,8 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { syncSnapBufferDestroy(&pSender->pSndBuf); } - if (pSender->snapshotParam.data) { - taosMemoryFree(pSender->snapshotParam.data); - pSender->snapshotParam.data = NULL; - } + snapshotSenderClearInfoData(pSender); + // free sender taosMemoryFree(pSender); } @@ -198,20 +208,24 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { // update flag int8_t stopped = !atomic_val_compare_exchange_8(&pSender->start, true, false); if (stopped) return; + taosThreadMutexLock(&pSender->pSndBuf->mutex); + { + pSender->finish = finish; - pSender->finish = finish; - pSender->waitTime = -1; + // close reader + if (pSender->pReader != NULL) { + pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); + pSender->pReader = NULL; + } - // close reader - if (pSender->pReader != NULL) { - pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); - pSender->pReader = NULL; + syncSnapBufferReset(pSender->pSndBuf); + + snapshotSenderClearInfoData(pSender); + + SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; + sSInfo(pSender, "snapshot sender stop, to dnode:%d, finish:%d", DID(&destId), finish); } - - syncSnapBufferReset(pSender->pSndBuf); - - SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - sSInfo(pSender, "snapshot sender stop, to dnode:%d, finish:%d", DID(&destId), finish); + taosThreadMutexUnlock(&pSender->pSndBuf->mutex); } int32_t syncSnapSendMsg(SSyncSnapshotSender *pSender, int32_t seq, void *pBlock, int32_t blockLen, int32_t typ) { @@ -324,6 +338,9 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { SSyncSnapBuffer *pSndBuf = pSender->pSndBuf; int32_t code = -1; taosThreadMutexLock(&pSndBuf->mutex); + if (pSender->pReader == NULL || pSender->finish || !snapshotSenderIsStart(pSender)) { + goto _out; + } for (int32_t seq = pSndBuf->cursor + 1; seq < pSndBuf->end; ++seq) { SyncSnapBlock *pBlk = pSndBuf->entries[seq % pSndBuf->size]; @@ -338,6 +355,12 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { pBlk->sendTimeMs = nowMs; } + if (pSender->seq != SYNC_SNAPSHOT_SEQ_END && pSndBuf->end <= pSndBuf->start) { + if (snapshotSend(pSender) != 0) { + goto _out; + } + } + if (pSender->seq == SYNC_SNAPSHOT_SEQ_END && pSndBuf->end <= pSndBuf->start) { if (syncSnapSendMsg(pSender, pSender->seq, NULL, 0, 0) != 0) { goto _out; @@ -361,14 +384,7 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) { return 0; } - int64_t timeNow = taosGetTimestampMs(); - if (pSender->waitTime <= 0) { - pSender->waitTime = timeNow + SNAPSHOT_WAIT_MS; - } - if (timeNow < pSender->waitTime) { - sSDebug(pSender, "snapshot sender waitTime not expired yet, ignore"); - return 0; - } + taosMsleep(1); int32_t code = snapshotSenderStart(pSender); if (code != 0) { @@ -416,6 +432,19 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from return pReceiver; } +static int32_t snapshotReceiverClearInfoData(SSyncSnapshotReceiver *pReceiver) { + if (pReceiver->snapshotParam.data) { + taosMemoryFree(pReceiver->snapshotParam.data); + pReceiver->snapshotParam.data = NULL; + } + + if (pReceiver->snapshot.data) { + taosMemoryFree(pReceiver->snapshot.data); + pReceiver->snapshot.data = NULL; + } + return 0; +} + void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { if (pReceiver == NULL) return; @@ -429,22 +458,13 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { pReceiver->pWriter = NULL; } - // free data of snapshot info - if (pReceiver->snapshotParam.data) { - taosMemoryFree(pReceiver->snapshotParam.data); - pReceiver->snapshotParam.data = NULL; - } - - if (pReceiver->snapshot.data) { - taosMemoryFree(pReceiver->snapshot.data); - pReceiver->snapshot.data = NULL; - } - // free snap buf if (pReceiver->pRcvBuf) { syncSnapBufferDestroy(&pReceiver->pRcvBuf); } + snapshotReceiverClearInfoData(pReceiver); + // free receiver taosMemoryFree(pReceiver); } @@ -504,7 +524,9 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p pReceiver->term = pPreMsg->term; pReceiver->fromId = pPreMsg->srcId; pReceiver->startTime = pPreMsg->startTime; - ASSERT(pReceiver->startTime); + + pReceiver->snapshotParam.start = syncNodeGetSnapBeginIndex(pReceiver->pSyncNode); + pReceiver->snapshotParam.end = -1; sRInfo(pReceiver, "snapshot receiver start, from dnode:%d.", DID(&pReceiver->fromId)); } @@ -514,19 +536,24 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { int8_t stopped = !atomic_val_compare_exchange_8(&pReceiver->start, true, false); if (stopped) return; - - if (pReceiver->pWriter != NULL) { - int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false, - &pReceiver->snapshot); - if (ret != 0) { - sRError(pReceiver, "snapshot receiver stop write failed since %s", terrstr()); + taosThreadMutexLock(&pReceiver->pRcvBuf->mutex); + { + if (pReceiver->pWriter != NULL) { + int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, + false, &pReceiver->snapshot); + if (ret != 0) { + sRError(pReceiver, "snapshot receiver stop write failed since %s", terrstr()); + } + pReceiver->pWriter = NULL; + } else { + sRInfo(pReceiver, "snapshot receiver stop, writer is null"); } - pReceiver->pWriter = NULL; - } else { - sRInfo(pReceiver, "snapshot receiver stop, writer is null"); - } - syncSnapBufferReset(pReceiver->pRcvBuf); + syncSnapBufferReset(pReceiver->pRcvBuf); + + snapshotReceiverClearInfoData(pReceiver); + } + taosThreadMutexUnlock(&pReceiver->pRcvBuf->mutex); } static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { @@ -656,7 +683,10 @@ static int32_t syncSnapReceiverExchgSnapInfo(SSyncNode *pSyncNode, SSyncSnapshot memcpy(pInfo->data, pMsg->data, pMsg->dataLen); // exchange snap info - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, pInfo); + if (pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, pInfo) != 0) { + sRError(pReceiver, "failed to get snapshot info. type: %d", pMsg->payloadType); + goto _out; + } SSyncTLV *datHead = pInfo->data; if (datHead->typ != TDMT_SYNC_PREP_SNAPSHOT_REPLY) { sRError(pReceiver, "unexpected data typ in data of snapshot info. typ: %d", datHead->typ); diff --git a/source/libs/tfs/test/tfsTest.cpp b/source/libs/tfs/test/tfsTest.cpp index 9bbf6bc729..1f16e585ae 100644 --- a/source/libs/tfs/test/tfsTest.cpp +++ b/source/libs/tfs/test/tfsTest.cpp @@ -218,6 +218,7 @@ TEST_F(TfsTest, 04_File) { EXPECT_STREQ(outfile.aname, file0.aname); EXPECT_STREQ(outfile.rname, "fname"); EXPECT_EQ(outfile.pTfs, pTfs); + taosMemoryFree(ret); } { diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index afb982a50a..96537a950e 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -34,6 +34,7 @@ typedef struct SHttpModule { SAsyncPool* asyncPool; TdThread thread; SHashObj* connStatusTable; + int8_t quit; } SHttpModule; typedef struct SHttpMsg { @@ -166,7 +167,7 @@ _OVER: static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port, struct sockaddr_in* dest) { uint32_t ip = taosGetIpv4FromFqdn(server); if (ip == 0xffffffff) { - tError("http-report failed to get http server:%s since %s", server, errno == 0 ? "invalid http server" : terrstr()); + tError("http-report failed to resolving domain names: %s", server); return -1; } char buf[128] = {0}; @@ -190,19 +191,40 @@ static void httpDestroyMsg(SHttpMsg* msg) { taosMemoryFree(msg->cont); taosMemoryFree(msg); } + +static void httpMayDiscardMsg(SHttpModule* http, SAsyncItem* item) { + SHttpMsg *msg = NULL, *quitMsg = NULL; + if (atomic_load_8(&http->quit) == 0) { + return; + } + + while (!QUEUE_IS_EMPTY(&item->qmsg)) { + queue* h = QUEUE_HEAD(&item->qmsg); + QUEUE_REMOVE(h); + msg = QUEUE_DATA(h, SHttpMsg, q); + if (!msg->quit) { + httpDestroyMsg(msg); + } else { + quitMsg = msg; + } + } + if (quitMsg != NULL) { + QUEUE_PUSH(&item->qmsg, &quitMsg->q); + } +} static void httpAsyncCb(uv_async_t* handle) { SAsyncItem* item = handle->data; SHttpModule* http = item->pThrd; SHttpMsg *msg = NULL, *quitMsg = NULL; - - queue wq; + queue wq; QUEUE_INIT(&wq); static int32_t BATCH_SIZE = 5; int32_t count = 0; taosThreadMutexLock(&item->mtx); + httpMayDiscardMsg(http, item); while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) { queue* h = QUEUE_HEAD(&item->qmsg); @@ -497,9 +519,10 @@ static void transHttpDestroyHandle(void* handle) { taosMemoryFree(handle); } static void transHttpEnvInit() { httpRefMgt = taosOpenRef(1, transHttpDestroyHandle); - SHttpModule* http = taosMemoryMalloc(sizeof(SHttpModule)); + SHttpModule* http = taosMemoryCalloc(1, sizeof(SHttpModule)); http->loop = taosMemoryMalloc(sizeof(uv_loop_t)); http->connStatusTable = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + http->quit = 0; uv_loop_init(http->loop); @@ -526,6 +549,8 @@ void transHttpEnvDestroy() { return; } SHttpModule* load = taosAcquireRef(httpRefMgt, httpRef); + + atomic_store_8(&load->quit, 1); httpSendQuit(); taosThreadJoin(load->thread, NULL); diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index da4cda5dc7..e68e93c48e 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -106,4 +106,3 @@ add_test( NAME transUtilUt COMMAND transportTest ) - diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 933014466a..b897eb4922 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -654,6 +654,23 @@ _err: return -1; } +int64_t walGetVerRetention(SWal* pWal, int64_t bytes) { + int64_t ver = -1; + int64_t totSize = 0; + taosThreadMutexLock(&pWal->mutex); + int32_t fileIdx = taosArrayGetSize(pWal->fileInfoSet); + while (--fileIdx) { + SWalFileInfo* pInfo = taosArrayGet(pWal->fileInfoSet, fileIdx); + if (totSize >= bytes) { + ver = pInfo->lastVer; + break; + } + totSize += pInfo->fileSize; + } + taosThreadMutexUnlock(&pWal->mutex); + return ver + 1; +} + int walCheckAndRepairIdx(SWal* pWal) { int32_t sz = taosArrayGetSize(pWal->fileInfoSet); int32_t fileIdx = sz; diff --git a/source/libs/wal/test/walMetaTest.cpp b/source/libs/wal/test/walMetaTest.cpp index 70d8921be3..fb64bec722 100644 --- a/source/libs/wal/test/walMetaTest.cpp +++ b/source/libs/wal/test/walMetaTest.cpp @@ -441,4 +441,5 @@ TEST_F(WalRetentionEnv, repairMeta1) { EXPECT_EQ(newStr[j], pRead->pHead->head.body[j]); } } + walCloseReader(pRead); } diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 8aac606473..9119c1d470 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -24,6 +24,14 @@ extern int wcwidth(wchar_t c); extern int wcswidth(const wchar_t *s, size_t n); +char *tstrdup(const char *str) { +#ifdef WINDOWS + return _strdup(str); +#else + return strdup(str); +#endif +} + #ifdef WINDOWS char *strsep(char **stringp, const char *delim) { char *s; diff --git a/source/os/test/osSystemTests.cpp b/source/os/test/osSystemTests.cpp index dfc92a1b72..86c600f135 100644 --- a/source/os/test/osSystemTests.cpp +++ b/source/os/test/osSystemTests.cpp @@ -38,4 +38,25 @@ TEST(osSystemTest, osSystem1) { #else taosLogTraceToBuf(tmp, sizeof(tmp), 8); #endif + double cpu_engine; + double cpu_system; + float cpu_cores; + int64_t mem_engine; // KB + int64_t mem_system; // KB + + taosGetCpuUsage(&cpu_system, &cpu_engine); + taosGetCpuCores(&cpu_cores, false); + + taosGetProcMemory(&mem_engine); + taosGetSysMemory(&mem_system); + printf("cpu_engine: %f cpu_system: %f\n", cpu_engine, cpu_system); + printf("cpu_cores: %f\n", cpu_cores); + ASSERT_GT(cpu_cores, 0); + ASSERT_GE(mem_engine, 0); + ASSERT_GE(mem_system, 0); + + float numOfCores = 0; + int32_t res = taosGetCpuInfo(tmp, 4096, &numOfCores); + printf("cpu info: %s\n", tmp); + ASSERT_EQ(res, 0); } diff --git a/source/os/test/osTests.cpp b/source/os/test/osTests.cpp index aad3eda9aa..16660a9477 100644 --- a/source/os/test/osTests.cpp +++ b/source/os/test/osTests.cpp @@ -111,11 +111,6 @@ void fileOperateOnBusy(void *param) { ret = taosUnLockFile(pFile); printf("On busy thread unlock file ret:%d\n", ret); -#ifdef _TD_DARWIN_64 - ASSERT_EQ(ret, 0); -#else - ASSERT_NE(ret, 0); -#endif ret = taosCloseFile(&pFile); printf("On busy thread close file ret:%d\n", ret); @@ -134,6 +129,8 @@ TEST(osTest, osFile) { printf("create file success\n"); taosCloseFile(&pOutFD); + taosCloseFile(&pOutFD); + TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); printf("open file\n"); ASSERT_NE(pFile, nullptr); diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 26d149b5b5..bc98461592 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -430,6 +430,7 @@ int32_t taosArraySearchIdx(const SArray* pArray, const void* key, __compar_fn_t return item == NULL ? -1 : (int32_t)((char*)item - (char*)pArray->pData) / pArray->elemSize; } +#ifdef BUILD_NO_CALL static int32_t taosArrayPartition(SArray* pArray, int32_t i, int32_t j, __ext_compar_fn_t fn, const void* userData) { void* key = taosArrayGetP(pArray, i); while (i < j) { @@ -485,6 +486,7 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void } } } +#endif int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode) { int32_t tlen = 0; diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 4bacda48d2..b6b71855f3 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -1097,7 +1097,8 @@ int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t c1 = str[j++]; ++nMatchChar; - if (c == '\\' && pattern[i] == '_' && c1 == '_') { + if (c == '\\' && pattern[i] == c1 && + (c1 == '_' || c1 == '%')) { i++; continue; } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index a869af7d5d..dc5f44cf43 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -324,6 +324,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma index opt TAOS_DEFINE_ERROR(TSDB_CODE_MND_VIEW_ALREADY_EXIST, "view already exists in db") TAOS_DEFINE_ERROR(TSDB_CODE_MND_VIEW_NOT_EXIST, "view not exists in db") +//mnode-compact +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_COMPACT_ID, "Invalid compact id") // dnode TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_OFFLINE, "Dnode is offline") diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index 94f8deee44..f4f3880388 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -33,6 +33,14 @@ ENDIF() INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/src/util/inc) +# arrayTest +add_executable(arrayTest "arrayTest.cpp") +target_link_libraries(arrayTest os util gtest_main) +add_test( + NAME arrayTest + COMMAND arrayTest +) + # # freelistTest # add_executable(freelistTest "") # target_sources(freelistTest diff --git a/source/util/test/arrayTest.cpp b/source/util/test/arrayTest.cpp index a579837791..307719b984 100644 --- a/source/util/test/arrayTest.cpp +++ b/source/util/test/arrayTest.cpp @@ -82,3 +82,138 @@ TEST(arrayTest, array_search_test) { taosArrayDestroy(pa); } + +// call taosArrayResize +TEST(arrayTest, array_data_correct) { + SArray* pa = (SArray*)taosArrayInit(1, sizeof(int32_t)); + SArray* pa1 = (SArray*)taosArrayInit(1, sizeof(int32_t)); + size_t cnt = 1000; + + + for (int32_t i = 0; i < cnt; ++i) { + taosArrayPush(pa, &i); + int32_t v = cnt + i; + taosArrayPush(pa1, &v); + } + ASSERT_EQ(taosArrayGetSize(pa), cnt); + ASSERT_EQ(taosArrayAddBatch(pa, NULL, 0), nullptr); + ASSERT_NE(taosArrayAddBatch(pa, taosArrayGet(pa1, 0), cnt), nullptr); + + int32_t* pv = NULL; + for (int32_t i = 0; i < cnt*2; i++) { + pv = (int32_t*)taosArrayGet(pa, i); + ASSERT_EQ(*pv, i); + } + + taosArrayDestroy(pa); + taosArrayDestroy(pa1); +} + +// free +static void arrayFree(void *param) { + void *pItem = *(void **)param; + if (pItem != NULL) { + taosMemoryFree(pItem); + } +} + +// string compare +static int32_t strCompare(const void *a, const void *b) { + const char *x = *(const char **)a; + const char *y = *(const char **)b; + + return strcmp(x, y); +} + +// int32 compare +static int int32Compare(const void* a, const void* b) { + int32_t l = *(int32_t*)a; + int32_t r = *(int32_t*)b; + return l - r; +} + +// no need free +TEST(arrayTest, check_duplicate_nofree) { + // no need free item + int32_t count = 5; + SArray* pa = taosArrayInit(1, sizeof(int32_t)); + for (int32_t i = 1; i <= count; i++) { + for (int32_t j = 0; j < i; j++) { + taosArrayPush(pa, &i); + //printf(" nofree put i=%d v=%d\n",i, i); + } + } + + taosArrayRemoveDuplicate(pa, int32Compare, NULL); + printf("nofree taosArrayRemoveDuplicate size=%d\n", (int32_t)taosArrayGetSize(pa)); + ASSERT_EQ(taosArrayGetSize(pa), count); + for (int32_t i = 1; i <= count; i++) { + int32_t v = *(int32_t*)taosArrayGet(pa, i-1); + //printf(" nofree get i=%d v=%d\n",i, v); + ASSERT_EQ(v, i); + } + + taosArrayDestroy(pa); +} + +// need free +TEST(arrayTest, check_duplicate_needfree) { + // no need free item + int32_t count = 5; + const char* format="hello-word-%d"; + SArray *pa = taosArrayInit(1, sizeof(char *)); + for (int32_t i = 1; i <= count; i++) { + for (int32_t j = 0; j < i; j++) { + char *v = (char *)taosMemoryCalloc(100, sizeof(char)); + sprintf(v, format, i); + //printf(" needfree put i=%d v=%s\n", i, v); + taosArrayPush(pa, &v); + } + } + + taosArrayRemoveDuplicate(pa, strCompare, arrayFree); + printf("needfree taosArrayRemoveDuplicate size=%d\n", (int32_t)taosArrayGetSize(pa)); + ASSERT_EQ(taosArrayGetSize(pa), count); + char value[100]; + for (int32_t i = 1; i <= count; i++) { + sprintf(value, format, i); + char * v = (char *)taosArrayGetP(pa, i - 1); + //printf(" needfree get i=%d v=%s\n", i, v); + ASSERT_STREQ(v, value); + } + + taosArrayClearP(pa, taosMemoryFree); + taosArrayDestroyP(pa, taosMemoryFree); +} + +// over all +TEST(arrayTest, check_overall) { + + ASSERT_EQ(taosArrayInit(1, 0), nullptr); + ASSERT_EQ(taosArrayGet(NULL, 1), nullptr); + ASSERT_EQ(taosArrayGetP(NULL, 1), nullptr); + ASSERT_EQ(taosArrayInsert(NULL, 1, NULL), nullptr); + + //ASSERT_EQ(taosArrayInit(0x10000000, 10000), nullptr); + //ASSERT_EQ(taosArrayInit_s(10000,0x10000000-1), nullptr); + + SArray* pa = taosArrayInit(1, sizeof(uint64_t)); + ASSERT_EQ(taosArrayGet(pa, 10), nullptr); + ASSERT_EQ(taosArrayGetLast(pa), nullptr); + + uint64_t v = 100; + taosArrayPush(pa, &v); + taosArrayPopFrontBatch(pa, 100); + FDelete fnNull = NULL; + taosArrayClearEx(pa, fnNull); + taosArrayDestroyEx(pa, fnNull); + + int32_t count = 5; + uint64_t list[5]= {1,2,3,4,5}; + + SArray* pb = taosArrayFromList(list, count, sizeof(uint64_t)); + for (int32_t i=0; i < count; i++) { + ASSERT_EQ(*(uint64_t*)taosArrayGet(pb, i), list[i]); + } + taosArrayDestroy(pb); +} \ No newline at end of file diff --git a/source/util/test/pageBufferTest.cpp b/source/util/test/pageBufferTest.cpp index 50d3656ccd..d31ad011d8 100644 --- a/source/util/test/pageBufferTest.cpp +++ b/source/util/test/pageBufferTest.cpp @@ -217,6 +217,7 @@ void testFlushAndReadBackBuffer() { pPg = (SFilePage*)getBufPage(pBuf, pageId); ASSERT_TRUE(checkBufVarData(pPg, rowData + 3, len)); destroyDiskbasedBuf(pBuf); + taosMemoryFree(rowData); } } // namespace diff --git a/source/util/test/utilTests.cpp b/source/util/test/utilTests.cpp index ff1d91aa9d..01a55ae710 100644 --- a/source/util/test/utilTests.cpp +++ b/source/util/test/utilTests.cpp @@ -204,6 +204,11 @@ TEST(utilTest, char_pattern_match_test) { const char* str12 = NULL; ret = patternMatch(pattern12, 4, str12, 0, &pInfo); ASSERT_EQ(ret, TSDB_PATTERN_NOMATCH); + + const char* pattern13 = "a\\%c"; + const char* str13 = "a%c"; + ret = patternMatch(pattern13, 5, str13, strlen(str13), &pInfo); + ASSERT_EQ(ret, TSDB_PATTERN_MATCH); } TEST(utilTest, char_pattern_match_no_terminated) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 59cbbb3147..6266946db3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -#ADD_SUBDIRECTORY(examples/c) -ADD_SUBDIRECTORY(tsim) -ADD_SUBDIRECTORY(test/c) -#ADD_SUBDIRECTORY(comparisonTest/tdengine) + +if(${BUILD_TEST}) + add_subdirectory(taosc_test) +endif(${BUILD_TEST}) \ No newline at end of file diff --git a/tests/army/empty.py b/tests/army/empty.py new file mode 100644 index 0000000000..e3a3f57c74 --- /dev/null +++ b/tests/army/empty.py @@ -0,0 +1,40 @@ +################################################################### +# 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 sys +import time + +import taos +from frame.log import * +from frame.cases import * +from frame.sql import * + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + # run + def run(self): + # check two db query result same + tdLog.info(f"hello world.") + + # stop + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/army/enterprise/multi-level/mlevel_basic.py b/tests/army/enterprise/multi-level/mlevel_basic.py new file mode 100644 index 0000000000..e3a3f57c74 --- /dev/null +++ b/tests/army/enterprise/multi-level/mlevel_basic.py @@ -0,0 +1,40 @@ +################################################################### +# 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 sys +import time + +import taos +from frame.log import * +from frame.cases import * +from frame.sql import * + +class TDTestCase: + # init + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + # run + def run(self): + # check two db query result same + tdLog.info(f"hello world.") + + # stop + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/army/frame/__init__.py b/tests/army/frame/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/army/frame/autogen.py b/tests/army/frame/autogen.py new file mode 100644 index 0000000000..9dca96e7b0 --- /dev/null +++ b/tests/army/frame/autogen.py @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- + +import sys +from frame.log import * +from frame.cases import * +from frame.sql import * +import threading +import random +import string +import time + + +# +# Auto Gen class +# +class AutoGen: + def __init__(self): + self.ts = 1600000000000 + self.batch_size = 100 + seed = time.time() % 10000 + random.seed(seed) + + # set start ts + def set_start_ts(self, ts): + self.ts = ts + + # set batch size + def set_batch_size(self, batch_size): + self.batch_size = batch_size + + # _columns_sql + def gen_columns_sql(self, pre, cnt, binary_len, nchar_len): + types = [ + 'timestamp', + 'tinyint', + 'smallint', + 'tinyint unsigned', + 'smallint unsigned', + 'int', + 'bigint', + 'int unsigned', + 'bigint unsigned', + 'float', + 'double', + 'bool', + f'varchar({binary_len})', + f'nchar({nchar_len})' + ] + + sqls = "" + metas = [] + for i in range(cnt): + colname = f"{pre}{i}" + sel = i % len(types) + coltype = types[sel] + sql = f"{colname} {coltype}" + if sqls != "": + sqls += "," + sqls += sql + metas.append(sel) + + return metas, sqls; + + # gen tags data + def gen_data(self, i, marr): + datas = "" + for c in marr: + data = "" + if c == 0 : # timestamp + data = "%d" % (self.ts + i) + elif c <= 4 : # small + data = "%d"%(i%128) + elif c <= 8 : # int + data = f"{i}" + elif c <= 10 : # float + data = "%f"%(i+i/1000) + elif c <= 11 : # bool + data = "%d"%(i%2) + elif c == 12 : # binary + data = '"' + self.random_string(self.bin_len) + '"' + elif c == 13 : # binary + data = '"' + self.random_string(self.nch_len) + '"' + + if datas != "": + datas += "," + datas += data + + return datas + + # generate specail wide random string + def random_string(self, count): + letters = string.ascii_letters + return ''.join(random.choice(letters) for i in range(count)) + + # create db + def create_db(self, dbname, vgroups = 2, replica = 1): + self.dbname = dbname + tdSql.execute(f'create database {dbname} vgroups {vgroups} replica {replica}') + tdSql.execute(f'use {dbname}') + + # create table or stable + def create_stable(self, stbname, tag_cnt, column_cnt, binary_len, nchar_len): + self.bin_len = binary_len + self.nch_len = nchar_len + self.stbname = stbname + self.mtags, tags = self.gen_columns_sql("t", tag_cnt, binary_len, nchar_len) + self.mcols, cols = self.gen_columns_sql("c", column_cnt - 1, binary_len, nchar_len) + + sql = f"create table {stbname} (ts timestamp, {cols}) tags({tags})" + tdSql.execute(sql) + + # create child table + def create_child(self, stbname, prename, cnt): + self.child_cnt = cnt + self.child_name = prename + for i in range(cnt): + tags_data = self.gen_data(i, self.mtags) + sql = f"create table {prename}{i} using {stbname} tags({tags_data})" + tdSql.execute(sql) + + tdLog.info(f"create child tables {cnt} ok") + + def insert_data_child(self, child_name, cnt, batch_size, step): + values = "" + print("insert child data") + ts = self.ts + + # loop do + for i in range(cnt): + value = self.gen_data(i, self.mcols) + ts += step + values += f"({ts},{value}) " + if batch_size == 1 or (i > 0 and i % batch_size == 0) : + sql = f"insert into {child_name} values {values}" + tdSql.execute(sql) + values = "" + + # end batch + if values != "": + sql = f"insert into {child_name} values {values}" + tdSql.execute(sql) + tdLog.info(f" insert data i={i}") + values = "" + + tdLog.info(f" insert child data {child_name} finished, insert rows={cnt}") + + # insert data + def insert_data(self, cnt): + for i in range(self.child_cnt): + name = f"{self.child_name}{i}" + self.insert_data_child(name, cnt, self.batch_size, 1) + + tdLog.info(f" insert data ok, child table={self.child_cnt} insert rows={cnt}") + + # insert same timestamp to all childs + def insert_samets(self, cnt): + for i in range(self.child_cnt): + name = f"{self.child_name}{i}" + self.insert_data_child(name, cnt, self.batch_size, 0) + + tdLog.info(f" insert same timestamp ok, child table={self.child_cnt} insert rows={cnt}") + + diff --git a/tests/army/frame/boundary.py b/tests/army/frame/boundary.py new file mode 100644 index 0000000000..086821e7cf --- /dev/null +++ b/tests/army/frame/boundary.py @@ -0,0 +1,44 @@ +class DataBoundary: + def __init__(self): + self.TINYINT_BOUNDARY = [-128, 127] + self.SMALLINT_BOUNDARY = [-32768, 32767] + self.INT_BOUNDARY = [-2147483648, 2147483647] + self.BIGINT_BOUNDARY = [-9223372036854775808, 9223372036854775807] + self.UTINYINT_BOUNDARY = [0, 255] + self.USMALLINT_BOUNDARY = [0, 65535] + self.UINT_BOUNDARY = [0, 4294967295] + self.UBIGINT_BOUNDARY = [0, 18446744073709551615] + self.FLOAT_BOUNDARY = [-3.40E+38, 3.40E+38] + self.DOUBLE_BOUNDARY = [-1.7e+308, 1.7e+308] + self.BOOL_BOUNDARY = [True, False] + self.BINARY_MAX_LENGTH = 16374 + self.NCHAR_MAX_LENGTH = 4093 + self.DBNAME_MAX_LENGTH = 64 + self.STBNAME_MAX_LENGTH = 192 + self.TBNAME_MAX_LENGTH = 192 + self.CHILD_TBNAME_MAX_LENGTH = 192 + self.TAG_KEY_MAX_LENGTH = 64 + self.COL_KEY_MAX_LENGTH = 64 + self.MAX_TAG_COUNT = 128 + self.MAX_TAG_COL_COUNT = 4096 + self.mnodeShmSize = [6292480, 2147483647] + self.mnodeShmSize_default = 6292480 + self.vnodeShmSize = [6292480, 2147483647] + self.vnodeShmSize_default = 31458304 + self.DB_PARAM_BUFFER_CONFIG = {"create_name": "buffer", "query_name": "buffer", "vnode_json_key": "szBuf", "boundary": [3, 16384], "default": 96} + self.DB_PARAM_CACHELAST_CONFIG = {"create_name": "cachelast", "query_name": "cache_model", "vnode_json_key": "", "boundary": [0, 1, 2, 3], "default": 0} + self.DB_PARAM_COMP_CONFIG = {"create_name": "comp", "query_name": "compression", "vnode_json_key": "", "boundary": [0, 1, 2], "default": 2} + self.DB_PARAM_DURATION_CONFIG = {"create_name": "duration", "query_name": "duration", "vnode_json_key": "daysPerFile", "boundary": [1, 3650, '60m', '5256000m', '1h', '87600h', '1d', '3650d'], "default": "14400m"} + self.DB_PARAM_FSYNC_CONFIG = {"create_name": "fsync", "query_name": "fsync", "vnode_json_key": "", "boundary": [0, 180000], "default": 3000} + self.DB_PARAM_KEEP_CONFIG = {"create_name": "keep", "query_name": "fsync", "vnode_json_key": "", "boundary": [1, 365000,'1440m','525600000m','24h','8760000h','1d','365000d'], "default": "5256000m,5256000m,5256000m"} + self.DB_PARAM_MAXROWS_CONFIG = {"create_name": "maxrows", "query_name": "maxrows", "vnode_json_key": "maxRows", "boundary": [200, 10000], "default": 4096} + self.DB_PARAM_MINROWS_CONFIG = {"create_name": "minrows", "query_name": "minrows", "vnode_json_key": "minRows", "boundary": [10, 1000], "default": 100} + self.DB_PARAM_NTABLES_CONFIG = {"create_name": "ntables", "query_name": "ntables", "vnode_json_key": "", "boundary": 0, "default": 0} + self.DB_PARAM_PAGES_CONFIG = {"create_name": "pages", "query_name": "pages", "vnode_json_key": "szCache", "boundary": [64], "default": 256} + self.DB_PARAM_PAGESIZE_CONFIG = {"create_name": "pagesize", "query_name": "pagesize", "vnode_json_key": "szPage", "boundary": [1, 16384], "default": 4} + self.DB_PARAM_PRECISION_CONFIG = {"create_name": "precision", "query_name": "precision", "vnode_json_key": "", "boundary": ['ms', 'us', 'ns'], "default": "ms"} + self.DB_PARAM_REPLICA_CONFIG = {"create_name": "replica", "query_name": "replica", "vnode_json_key": "", "boundary": [1], "default": 1} + self.DB_PARAM_SINGLE_STABLE_CONFIG = {"create_name": "single_stable", "query_name": "single_stable_model", "vnode_json_key": "", "boundary": [0, 1], "default": 0} + self.DB_PARAM_STRICT_CONFIG = {"create_name": "strict", "query_name": "strict", "vnode_json_key": "", "boundary": {"off": 0, "strict": 1}, "default": "off"} + self.DB_PARAM_VGROUPS_CONFIG = {"create_name": "vgroups", "query_name": "vgroups", "vnode_json_key": "", "boundary": [1, 32], "default": 2} + self.DB_PARAM_WAL_CONFIG = {"create_name": "wal", "query_name": "wal", "vnode_json_key": "", "boundary": [1, 2], "default": 1} \ No newline at end of file diff --git a/tests/army/frame/cases.py b/tests/army/frame/cases.py new file mode 100644 index 0000000000..590c0d3711 --- /dev/null +++ b/tests/army/frame/cases.py @@ -0,0 +1,150 @@ +################################################################### +# 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 sys +import os +import time +import datetime +import inspect +import importlib +import traceback +from frame.log import * + + +class TDCase: + def __init__(self, name, case): + self.name = name + self.case = case + self._logSql = True + + +class TDCases: + def __init__(self): + self.linuxCases = [] + self.windowsCases = [] + self.clusterCases = [] + + def __dynamicLoadModule(self, fileName): + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + return importlib.import_module(moduleName, package='..') + + def logSql(self, logSql): + self._logSql = logSql + + def addWindows(self, name, case): + self.windowsCases.append(TDCase(name, case)) + + def addLinux(self, name, case): + self.linuxCases.append(TDCase(name, case)) + + def addCluster(self, name, case): + self.clusterCases.append(TDCase(name, case)) + + def runAllLinux(self, conn): + # TODO: load all Linux cases here + runNum = 0 + for tmp in self.linuxCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn) + case.run() + case.stop() + runNum += 1 + continue + + tdLog.info("total %d Linux test case(s) executed" % (runNum)) + + def runOneLinux(self, conn, fileName, replicaVar=1): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.linuxCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn, self._logSql, replicaVar) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + traceback.print_exc() + tdLog.exit("%s failed" % (fileName)) + case.stop() + runNum += 1 + continue + + def runAllWindows(self, conn): + # TODO: load all Windows cases here + runNum = 0 + for tmp in self.windowsCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn) + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Windows test case(s) executed" % (runNum)) + + def runOneWindows(self, conn, fileName, replicaVar=1): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.windowsCases: + if tmp.name.find(fileName) != -1: + case = testModule.TDTestCase() + case.init(conn, self._logSql,replicaVar) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + tdLog.exit("%s failed" % (fileName)) + case.stop() + runNum += 1 + continue + tdLog.notice("total %d Windows case(s) executed" % (runNum)) + + def runAllCluster(self): + # TODO: load all cluster case module here + + runNum = 0 + for tmp in self.clusterCases: + if tmp.name.find(fileName) != -1: + tdLog.notice("run cases like %s" % (fileName)) + case = testModule.TDTestCase() + case.init() + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Cluster test case(s) executed" % (runNum)) + + def runOneCluster(self, fileName): + testModule = self.__dynamicLoadModule(fileName) + + runNum = 0 + for tmp in self.clusterCases: + if tmp.name.find(fileName) != -1: + tdLog.notice("run cases like %s" % (fileName)) + case = testModule.TDTestCase() + case.init() + case.run() + case.stop() + runNum += 1 + continue + + tdLog.notice("total %d Cluster test case(s) executed" % (runNum)) + + +tdCases = TDCases() diff --git a/tests/army/frame/cluster.py b/tests/army/frame/cluster.py new file mode 100644 index 0000000000..4da53840c0 --- /dev/null +++ b/tests/army/frame/cluster.py @@ -0,0 +1,108 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os +import socket + +from frame.log import * +from frame.sql import * +from frame.cases import * +from frame.dnodes import * +from frame.common import * + +class ClusterDnodes(TDDnodes): + """rewrite TDDnodes and make MyDdnodes as TDDnodes child class""" + def __init__(self ,dnodes_lists): + + super(ClusterDnodes,self).__init__() + self.dnodes = dnodes_lists # dnode must be TDDnode instance + self.simDeployed = False + self.testCluster = False + self.valgrind = 0 + self.killValgrind = 1 + + +class ConfigureyCluster: + """This will create defined number of dnodes and create a cluster. + at the same time, it will return TDDnodes list: dnodes, """ + hostname = socket.gethostname() + + def __init__(self): + self.dnodes = [] + self.dnodeNums = 5 + self.independent = True + self.startPort = 6030 + self.portStep = 100 + self.mnodeNums = 0 + + def configure_cluster(self ,dnodeNums=5,mnodeNums=0,independentMnode=True,startPort=6030,portStep=100,hostname="%s"%hostname): + self.startPort=int(startPort) + self.portStep=int(portStep) + self.hostname=hostname + self.dnodeNums = int(dnodeNums) + self.mnodeNums = int(mnodeNums) + self.dnodes = [] + startPort_sec = int(startPort+portStep) + for num in range(1, (self.dnodeNums+1)): + dnode = TDDnode(num) + dnode.addExtraCfg("firstEp", f"{hostname}:{self.startPort}") + dnode.addExtraCfg("fqdn", f"{hostname}") + dnode.addExtraCfg("serverPort", f"{self.startPort + (num-1)*self.portStep}") + dnode.addExtraCfg("secondEp", f"{hostname}:{startPort_sec}") + + # configure dnoe of independent mnodes + if num <= self.mnodeNums and self.mnodeNums != 0 and independentMnode == True : + tdLog.info(f"set mnode:{num} supportVnodes 0") + dnode.addExtraCfg("supportVnodes", 0) + # print(dnode) + self.dnodes.append(dnode) + return self.dnodes + + def create_dnode(self,conn,dnodeNum): + tdSql.init(conn.cursor()) + dnodeNum=int(dnodeNum) + for dnode in self.dnodes[1:dnodeNum]: + # print(dnode.cfgDict) + dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] + tdSql.execute(" create dnode '%s';"%dnode_id) + + + def create_mnode(self,conn,mnodeNums): + tdSql.init(conn.cursor()) + mnodeNums=int(mnodeNums) + for i in range(2,mnodeNums+1): + tdLog.info("create mnode on dnode %d"%i) + tdSql.execute(" create mnode on dnode %d;"%i) + + + + def check_dnode(self,conn): + tdSql.init(conn.cursor()) + count=0 + while count < 5: + tdSql.query("select * from information_schema.ins_dnodes") + # tdLog.debug(tdSql.queryResult) + status=0 + for i in range(self.dnodeNums): + if tdSql.queryResult[i][4] == "ready": + status+=1 + # tdLog.debug(status) + + if status == self.dnodeNums: + tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodeNums) + break + count+=1 + time.sleep(1) + else: + tdLog.exit("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodeNums) + + def checkConnectStatus(self,dnodeNo,hostname=hostname): + dnodeNo = int(dnodeNo) + tdLog.info("check dnode-%d connection"%(dnodeNo+1)) + hostname = socket.gethostname() + port = 6030 + dnodeNo*100 + connectToDnode = tdCom.newcon(host=hostname,port=port) + return connectToDnode + +cluster = ConfigureyCluster() \ No newline at end of file diff --git a/tests/army/frame/common.py b/tests/army/frame/common.py new file mode 100644 index 0000000000..93059ff078 --- /dev/null +++ b/tests/army/frame/common.py @@ -0,0 +1,1867 @@ +################################################################### +# 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 string +import requests +import time +import socket +import json +import toml +from frame.boundary import DataBoundary +import taos +from frame.log import * +from frame.sql import * +from frame.cases import * +from frame.dnodes import * +from frame.common import * +from frame.constant import * +from dataclasses import dataclass,field +from typing import List +from datetime import datetime +import re +@dataclass +class DataSet: + ts_data : List[int] = field(default_factory=list) + int_data : List[int] = field(default_factory=list) + bint_data : List[int] = field(default_factory=list) + sint_data : List[int] = field(default_factory=list) + tint_data : List[int] = field(default_factory=list) + uint_data : List[int] = field(default_factory=list) + ubint_data : List[int] = field(default_factory=list) + usint_data : List[int] = field(default_factory=list) + utint_data : List[int] = field(default_factory=list) + float_data : List[float] = field(default_factory=list) + double_data : List[float] = field(default_factory=list) + bool_data : List[int] = field(default_factory=list) + vchar_data : List[str] = field(default_factory=list) + nchar_data : List[str] = field(default_factory=list) + + def get_order_set(self, + rows, + int_step :int = 1, + bint_step :int = 1, + sint_step :int = 1, + tint_step :int = 1, + uint_step :int = 1, + ubint_step :int = 1, + usint_step :int = 1, + utint_step :int = 1, + float_step :float = 1, + double_step :float = 1, + bool_start :int = 1, + vchar_prefix:str = "vachar_", + vchar_step :int = 1, + nchar_prefix:str = "nchar_测试_", + nchar_step :int = 1, + ts_step :int = 1 + ): + for i in range(rows): + self.int_data.append( int(i * int_step % INT_MAX )) + self.bint_data.append( int(i * bint_step % BIGINT_MAX )) + self.sint_data.append( int(i * sint_step % SMALLINT_MAX )) + self.tint_data.append( int(i * tint_step % TINYINT_MAX )) + self.uint_data.append( int(i * uint_step % INT_UN_MAX )) + self.ubint_data.append( int(i * ubint_step % BIGINT_UN_MAX )) + self.usint_data.append( int(i * usint_step % SMALLINT_UN_MAX )) + self.utint_data.append( int(i * utint_step % TINYINT_UN_MAX )) + self.float_data.append( float(i * float_step % FLOAT_MAX )) + self.double_data.append( float(i * double_step % DOUBLE_MAX )) + self.bool_data.append( bool((i + bool_start) % 2 )) + self.vchar_data.append( f"{vchar_prefix}{i * vchar_step}" ) + self.nchar_data.append( f"{nchar_prefix}{i * nchar_step}") + self.ts_data.append( int(datetime.timestamp(datetime.now()) * 1000 - i * ts_step)) + + def get_disorder_set(self, rows, **kwargs): + for k, v in kwargs.items(): + int_low = v if k == "int_low" else INT_MIN + int_up = v if k == "int_up" else INT_MAX + bint_low = v if k == "bint_low" else BIGINT_MIN + bint_up = v if k == "bint_up" else BIGINT_MAX + sint_low = v if k == "sint_low" else SMALLINT_MIN + sint_up = v if k == "sint_up" else SMALLINT_MAX + tint_low = v if k == "tint_low" else TINYINT_MIN + tint_up = v if k == "tint_up" else TINYINT_MAX + pass + + +class TDCom: + def __init__(self): + self.sml_type = None + self.env_setting = None + self.smlChildTableName_value = None + self.defaultJSONStrType_value = None + self.smlTagNullName_value = None + self.default_varchar_length = 6 + self.default_nchar_length = 6 + self.default_varchar_datatype = "letters" + self.default_nchar_datatype = "letters" + self.default_tagname_prefix = "t" + self.default_colname_prefix = "c" + self.default_stbname_prefix = "stb" + self.default_ctbname_prefix = "ctb" + self.default_tbname_prefix = "tb" + self.default_tag_index_start_num = 1 + self.default_column_index_start_num = 1 + self.default_stbname_index_start_num = 1 + self.default_ctbname_index_start_num = 1 + self.default_tbname_index_start_num = 1 + self.default_tagts_name = "ts" + self.default_colts_name = "ts" + self.dbname = "test" + self.stb_name = "stb" + self.ctb_name = "ctb" + self.tb_name = "tb" + self.tbname = str() + self.need_tagts = False + self.tag_type_str = "" + self.column_type_str = "" + self.columns_str = None + self.ts_value = None + self.tag_value_list = list() + self.column_value_list = list() + self.full_type_list = ["tinyint", "smallint", "int", "bigint", "tinyint unsigned", "smallint unsigned", "int unsigned", "bigint unsigned", "float", "double", "binary", "nchar", "bool"] + self.white_list = ["statsd", "node_exporter", "collectd", "icinga2", "tcollector", "information_schema", "performance_schema"] + self.Boundary = DataBoundary() + self.white_list = ["statsd", "node_exporter", "collectd", "icinga2", "tcollector", "information_schema", "performance_schema"] + self.case_name = str() + self.des_table_suffix = "_output" + self.stream_suffix = "_stream" + self.range_count = 5 + self.default_interval = 5 + self.stream_timeout = 12 + self.create_stream_sleep = 0.5 + self.record_history_ts = str() + self.precision = "ms" + self.date_time = self.genTs(precision=self.precision)[0] + self.subtable = True + self.partition_tbname_alias = "ptn_alias" if self.subtable else "" + self.partition_col_alias = "pcol_alias" if self.subtable else "" + self.partition_tag_alias = "ptag_alias" if self.subtable else "" + self.partition_expression_alias = "pexp_alias" if self.subtable else "" + self.des_table_suffix = "_output" + self.stream_suffix = "_stream" + self.subtable_prefix = "prefix_" if self.subtable else "" + self.subtable_suffix = "_suffix" if self.subtable else "" + self.downsampling_function_list = ["min(c1)", "max(c2)", "sum(c3)", "first(c4)", "last(c5)", "apercentile(c6, 50)", "avg(c7)", "count(c8)", "spread(c1)", + "stddev(c2)", "hyperloglog(c11)", "timediff(1, 0, 1h)", "timezone()", "to_iso8601(1)", 'to_unixtimestamp("1970-01-01T08:00:00+08:00")', "min(t1)", "max(t2)", "sum(t3)", + "first(t4)", "last(t5)", "apercentile(t6, 50)", "avg(t7)", "count(t8)", "spread(t1)", "stddev(t2)", "hyperloglog(t11)"] + self.stb_output_select_str = ','.join(list(map(lambda x:f'`{x}`', self.downsampling_function_list))) + self.tb_output_select_str = ','.join(list(map(lambda x:f'`{x}`', self.downsampling_function_list[0:15]))) + self.stb_source_select_str = ','.join(self.downsampling_function_list) + self.tb_source_select_str = ','.join(self.downsampling_function_list[0:15]) + self.fill_function_list = ["min(c1)", "max(c2)", "sum(c3)", "apercentile(c6, 50)", "avg(c7)", "count(c8)", "spread(c1)", + "stddev(c2)", "hyperloglog(c11)", "timediff(1, 0, 1h)", "timezone()", "to_iso8601(1)", 'to_unixtimestamp("1970-01-01T08:00:00+08:00")', "min(t1)", "max(t2)", "sum(t3)", + "first(t4)", "last(t5)", "apercentile(t6, 50)", "avg(t7)", "count(t8)", "spread(t1)", "stddev(t2)", "hyperloglog(t11)"] + self.fill_stb_output_select_str = ','.join(list(map(lambda x:f'`{x}`', self.fill_function_list))) + self.fill_stb_source_select_str = ','.join(self.fill_function_list) + self.fill_tb_output_select_str = ','.join(list(map(lambda x:f'`{x}`', self.fill_function_list[0:13]))) + self.fill_tb_source_select_str = ','.join(self.fill_function_list[0:13]) + self.ext_tb_source_select_str = ','.join(self.downsampling_function_list[0:13]) + self.stream_case_when_tbname = "tbname" + + self.update = True + self.disorder = True + if self.disorder: + self.update = False + self.partition_by_downsampling_function_list = ["min(c1)", "max(c2)", "sum(c3)", "first(c4)", "last(c5)", "count(c8)", "spread(c1)", + "stddev(c2)", "hyperloglog(c11)", "min(t1)", "max(t2)", "sum(t3)", "first(t4)", "last(t5)", "count(t8)", "spread(t1)", "stddev(t2)"] + + self.stb_data_filter_sql = f'ts >= {self.date_time}+1s and c1 = 1 or c2 > 1 and c3 != 4 or c4 <= 3 and c9 <> 0 or c10 is not Null or c11 is Null or \ + c12 between "na" and "nchar4" and c11 not between "bi" and "binary" and c12 match "nchar[19]" and c12 nmatch "nchar[25]" or c13 = True or \ + c5 in (1, 2, 3) or c6 not in (6, 7) and c12 like "nch%" and c11 not like "bina_" and c6 < 10 or c12 is Null or c8 >= 4 and t1 = 1 or t2 > 1 \ + and t3 != 4 or c4 <= 3 and t9 <> 0 or t10 is not Null or t11 is Null or t12 between "na" and "nchar4" and t11 not between "bi" and "binary" \ + or t12 match "nchar[19]" or t12 nmatch "nchar[25]" or t13 = True or t5 in (1, 2, 3) or t6 not in (6, 7) and t12 like "nch%" \ + and t11 not like "bina_" and t6 <= 10 or t12 is Null or t8 >= 4' + self.tb_data_filter_sql = self.stb_data_filter_sql.partition(" and t1")[0] + + self.filter_source_select_elm = "*" + self.stb_filter_des_select_elm = "ts, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13" + self.partitial_stb_filter_des_select_elm = ",".join(self.stb_filter_des_select_elm.split(",")[:3]) + self.exchange_stb_filter_des_select_elm = ",".join([self.stb_filter_des_select_elm.split(",")[0], self.stb_filter_des_select_elm.split(",")[2], self.stb_filter_des_select_elm.split(",")[1]]) + self.partitial_ext_tb_source_select_str = ','.join(self.downsampling_function_list[0:2]) + self.tb_filter_des_select_elm = self.stb_filter_des_select_elm.partition(", t1")[0] + self.tag_filter_des_select_elm = self.stb_filter_des_select_elm.partition("c13, ")[2] + self.partition_by_stb_output_select_str = ','.join(list(map(lambda x:f'`{x}`', self.partition_by_downsampling_function_list))) + self.partition_by_stb_source_select_str = ','.join(self.partition_by_downsampling_function_list) + self.exchange_tag_filter_des_select_elm = ",".join([self.stb_filter_des_select_elm.partition("c13, ")[2].split(",")[0], self.stb_filter_des_select_elm.partition("c13, ")[2].split(",")[2], self.stb_filter_des_select_elm.partition("c13, ")[2].split(",")[1]]) + self.partitial_tag_filter_des_select_elm = ",".join(self.stb_filter_des_select_elm.partition("c13, ")[2].split(",")[:3]) + self.partitial_tag_stb_filter_des_select_elm = "ts, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, t1, t3, t2, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13" + self.cast_tag_filter_des_select_elm = "t5,t11,t13" + self.cast_tag_stb_filter_des_select_elm = "ts, t1, t2, t3, t4, cast(t1 as TINYINT UNSIGNED), t6, t7, t8, t9, t10, cast(t2 as varchar(256)), t12, cast(t3 as bool)" + self.tag_count = len(self.tag_filter_des_select_elm.split(",")) + self.state_window_range = list() + # def init(self, conn, logSql): + # # tdSql.init(conn.cursor(), logSql) + + def preDefine(self): + header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} + sql_url = "http://127.0.0.1:6041/rest/sql" + sqlt_url = "http://127.0.0.1:6041/rest/sqlt" + sqlutc_url = "http://127.0.0.1:6041/rest/sqlutc" + influx_url = "http://127.0.0.1:6041/influxdb/v1/write" + telnet_url = "http://127.0.0.1:6041/opentsdb/v1/put/telnet" + return header, sql_url, sqlt_url, sqlutc_url, influx_url, telnet_url + + def genTcpParam(self): + MaxBytes = 1024*1024 + host ='127.0.0.1' + port = 6046 + return MaxBytes, host, port + + def tcpClient(self, input): + MaxBytes = tdCom.genTcpParam()[0] + host = tdCom.genTcpParam()[1] + port = tdCom.genTcpParam()[2] + sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + sock.connect((host, port)) + sock.send(input.encode()) + sock.close() + + def restApiPost(self, sql): + requests.post(self.preDefine()[1], sql.encode("utf-8"), headers = self.preDefine()[0]) + + def createDb(self, dbname="test", db_update_tag=0, api_type="taosc"): + if api_type == "taosc": + if db_update_tag == 0: + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname} precision 'us'") + else: + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname} precision 'us' update 1") + elif api_type == "restful": + if db_update_tag == 0: + self.restApiPost(f"drop database if exists {dbname}") + self.restApiPost(f"create database if not exists {dbname} precision 'us'") + else: + self.restApiPost(f"drop database if exists {dbname}") + self.restApiPost(f"create database if not exists {dbname} precision 'us' update 1") + tdSql.execute(f'use {dbname}') + + def genUrl(self, url_type, dbname, precision): + if url_type == "influxdb": + if precision is None: + url = self.preDefine()[4] + "?" + "db=" + dbname + else: + url = self.preDefine()[4] + "?" + "db=" + dbname + "&precision=" + precision + elif url_type == "telnet": + url = self.preDefine()[5] + "/" + dbname + else: + url = self.preDefine()[1] + return url + + def schemalessApiPost(self, sql, url_type="influxdb", dbname="test", precision=None): + if url_type == "influxdb": + url = self.genUrl(url_type, dbname, precision) + elif url_type == "telnet": + url = self.genUrl(url_type, dbname, precision) + res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0]) + return res + + def cleanTb(self, type="taosc", dbname="db"): + ''' + type is taosc or restful + ''' + query_sql = f"show {dbname}.stables" + res_row_list = tdSql.query(query_sql, True) + stb_list = map(lambda x: x[0], res_row_list) + for stb in stb_list: + if type == "taosc": + tdSql.execute(f'drop table if exists {dbname}.`{stb}`') + if not stb[0].isdigit(): + tdSql.execute(f'drop table if exists {dbname}.{stb}') + elif type == "restful": + self.restApiPost(f"drop table if exists {dbname}.`{stb}`") + if not stb[0].isdigit(): + self.restApiPost(f"drop table if exists {dbname}.{stb}") + + def dateToTs(self, datetime_input): + return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) + + def genTs(self, precision="ms", ts="", protype="taosc", ns_tag=None): + """ + protype = "taosc" or "restful" + gen ts and datetime + """ + if precision == "ns": + if ts == "" or ts is None: + ts = time.time_ns() + else: + ts = ts + if ns_tag is None: + dt = ts + else: + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + if protype == "restful": + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + else: + if ts == "" or ts is None: + ts = time.time() + else: + ts = ts + if precision == "ms" or precision is None: + ts = int(round(ts * 1000)) + dt = datetime.fromtimestamp(ts // 1000) + if protype == "taosc": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + '000' + elif protype == "restful": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + else: + pass + elif precision == "us": + ts = int(round(ts * 1000000)) + dt = datetime.fromtimestamp(ts // 1000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000)).zfill(6) + return ts, dt + + def get_long_name(self, length=10, mode="letters"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) + + def getLongName(self, len, mode = "mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + chars = ''.join(random.choice(string.digits) for i in range(len)) + elif mode == "letters": + chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len)) + elif mode == "letters_mixed": + chars = ''.join(random.choice(string.ascii_letters.upper() + string.ascii_letters.lower()) for i in range(len)) + else: + chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len)) + return chars + + def restartTaosd(self, index=1, db_name="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use {db_name}") + + def typeof(self, variate): + v_type=None + if type(variate) is int: + v_type = "int" + elif type(variate) is str: + v_type = "str" + elif type(variate) is float: + v_type = "float" + elif type(variate) is bool: + v_type = "bool" + elif type(variate) is list: + v_type = "list" + elif type(variate) is tuple: + v_type = "tuple" + elif type(variate) is dict: + v_type = "dict" + elif type(variate) is set: + v_type = "set" + return v_type + + def splitNumLetter(self, input_mix_str): + nums, letters = "", "" + for i in input_mix_str: + if i.isdigit(): + nums += i + elif i.isspace(): + pass + else: + letters += i + return nums, letters + + def smlPass(self, func): + smlChildTableName = "no" + def wrapper(*args): + # if tdSql.getVariable("smlChildTableName")[0].upper() == "ID": + if smlChildTableName.upper() == "ID": + return func(*args) + else: + pass + return wrapper + + def close(self): + self.cursor.close() + + ######################################################################################################################################## + # new common API + ######################################################################################################################################## + def create_database(self,tsql, dbName='test',dropFlag=1,**kwargs): + if dropFlag == 1: + tsql.execute("drop database if exists %s"%(dbName)) + ''' + vgroups replica precision strict wal fsync comp cachelast single_stable buffer pagesize pages minrows maxrows duration keep retentions + ''' + sqlString = f'create database if not exists {dbName} ' + + dbParams = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + if param == "precision": + dbParams += f'{param} "{value}" ' + else: + dbParams += f'{param} {value} ' + sqlString += f'{dbParams}' + + tdLog.debug("create db sql: %s"%sqlString) + tsql.execute(sqlString) + tdLog.debug("complete to create database %s"%(dbName)) + return + + # def create_stable(self,tsql, dbName,stbName,column_elm_list=None, tag_elm_list=None): + # colSchema = '' + # for i in range(columnDict['int']): + # colSchema += ', c%d int'%i + # tagSchema = '' + # for i in range(tagDict['int']): + # if i > 0: + # tagSchema += ',' + # tagSchema += 't%d int'%i + + # tsql.execute("create table if not exists %s.%s (ts timestamp %s) tags(%s)"%(dbName, stbName, colSchema, tagSchema)) + # tdLog.debug("complete to create %s.%s" %(dbName, stbName)) + # return + + # def create_ctables(self,tsql, dbName,stbName,ctbNum,tagDict): + # tsql.execute("use %s" %dbName) + # tagsValues = '' + # for i in range(tagDict['int']): + # if i > 0: + # tagsValues += ',' + # tagsValues += '%d'%i + + # pre_create = "create table" + # sql = pre_create + # #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) + # for i in range(ctbNum): + # sql += " %s_%d using %s tags(%s)"%(stbName,i,stbName,tagsValues) + # if (i > 0) and (i%100 == 0): + # tsql.execute(sql) + # sql = pre_create + # if sql != pre_create: + # tsql.execute(sql) + + # tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) + # return + + # def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=0): + # tdLog.debug("start to insert data ............") + # tsql.execute("use %s" %dbName) + # pre_insert = "insert into " + # sql = pre_insert + # if startTs == 0: + # t = time.time() + # startTs = int(round(t * 1000)) + # #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + # for i in range(ctbNum): + # sql += " %s_%d values "%(stbName,i) + # for j in range(rowsPerTbl): + # sql += "(%d, %d, %d)"%(startTs + j, j, j) + # if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + # tsql.execute(sql) + # if j < rowsPerTbl - 1: + # sql = "insert into %s_%d values " %(stbName,i) + # else: + # sql = "insert into " + # #end sql + # if sql != pre_insert: + # #print("insert sql:%s"%sql) + # tsql.execute(sql) + # tdLog.debug("insert data ............ [OK]") + # return + + 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 getClientCfgPath(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + tdLog.info("cfgPath: %s" % cfgPath) + return cfgPath + + def newcon(self,host='localhost',port=6030,user='root',password='taosdata'): + con=taos.connect(host=host, user=user, password=password, port=port) + # print(con) + return con + + def newcur(self,host='localhost',port=6030,user='root',password='taosdata'): + cfgPath = self.getClientCfgPath() + con=taos.connect(host=host, user=user, password=password, config=cfgPath, port=port) + cur=con.cursor() + # print(cur) + return cur + + def newTdSql(self, host='localhost',port=6030,user='root',password='taosdata'): + newTdSql = TDSql() + cur = self.newcur(host=host,port=port,user=user,password=password) + newTdSql.init(cur, False) + return newTdSql + + ################################################################################################################ + # port from the common.py of new test frame + ################################################################################################################ + def gen_default_tag_str(self): + default_tag_str = "" + for tag_type in self.full_type_list: + if tag_type.lower() not in ["varchar", "binary", "nchar"]: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}," + else: + if tag_type.lower() in ["varchar", "binary"]: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}({self.default_varchar_length})," + else: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}({self.default_nchar_length})," + self.default_tag_index_start_num += 1 + if self.need_tagts: + default_tag_str = self.default_tagts_name + " timestamp," + default_tag_str + return default_tag_str[:-1].lstrip() + + def gen_default_column_str(self): + self.default_column_index_start_num = 1 + default_column_str = "" + for col_type in self.full_type_list: + if col_type.lower() not in ["varchar", "binary", "nchar"]: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}," + else: + if col_type.lower() in ["varchar", "binary"]: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}({self.default_varchar_length})," + else: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}({self.default_nchar_length})," + self.default_column_index_start_num += 1 + default_column_str = self.default_colts_name + " timestamp," + default_column_str + return default_column_str[:-1].lstrip() + + def gen_tag_type_str(self, tagname_prefix, tag_elm_list): + tag_index_start_num = 1 + tag_type_str = "" + if tag_elm_list is None: + tag_type_str = self.gen_default_tag_str() + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + tag_type_str += f'{tagname_prefix}{tag_index_start_num} {tag_elm["type"]}, ' + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + tag_type_str = tag_type_str.rstrip()[:-1] + f'({tag_elm["len"]}), ' + tag_index_start_num += 1 + else: + continue + tag_type_str = tag_type_str.rstrip()[:-1] + + return tag_type_str + + def gen_column_type_str(self, colname_prefix, column_elm_list): + column_index_start_num = 1 + column_type_str = "" + if column_elm_list is None: + column_type_str = self.gen_default_column_str() + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + column_type_str += f'{colname_prefix}{column_index_start_num} {column_elm["type"]}, ' + if column_elm["type"] in ["varchar", "binary", "nchar"]: + column_type_str = column_type_str.rstrip()[:-1] + f'({column_elm["len"]}), ' + column_index_start_num += 1 + else: + continue + column_type_str = self.default_colts_name + " timestamp, " + column_type_str.rstrip()[:-1] + return column_type_str + + def gen_random_type_value(self, type_name, binary_length, binary_type, nchar_length, nchar_type): + if type_name.lower() == "tinyint": + return random.randint(self.Boundary.TINYINT_BOUNDARY[0], self.Boundary.TINYINT_BOUNDARY[1]) + elif type_name.lower() == "smallint": + return random.randint(self.Boundary.SMALLINT_BOUNDARY[0], self.Boundary.SMALLINT_BOUNDARY[1]) + elif type_name.lower() == "int": + return random.randint(self.Boundary.INT_BOUNDARY[0], self.Boundary.INT_BOUNDARY[1]) + elif type_name.lower() == "bigint": + return random.randint(self.Boundary.BIGINT_BOUNDARY[0], self.Boundary.BIGINT_BOUNDARY[1]) + elif type_name.lower() == "tinyint unsigned": + return random.randint(self.Boundary.UTINYINT_BOUNDARY[0], self.Boundary.UTINYINT_BOUNDARY[1]) + elif type_name.lower() == "smallint unsigned": + return random.randint(self.Boundary.USMALLINT_BOUNDARY[0], self.Boundary.USMALLINT_BOUNDARY[1]) + elif type_name.lower() == "int unsigned": + return random.randint(self.Boundary.UINT_BOUNDARY[0], self.Boundary.UINT_BOUNDARY[1]) + elif type_name.lower() == "bigint unsigned": + return random.randint(self.Boundary.UBIGINT_BOUNDARY[0], self.Boundary.UBIGINT_BOUNDARY[1]) + elif type_name.lower() == "float": + return random.uniform(self.Boundary.FLOAT_BOUNDARY[0], self.Boundary.FLOAT_BOUNDARY[1]) + elif type_name.lower() == "double": + return random.uniform(self.Boundary.FLOAT_BOUNDARY[0], self.Boundary.FLOAT_BOUNDARY[1]) + elif type_name.lower() == "binary": + return f'{self.get_long_name(binary_length, binary_type)}' + elif type_name.lower() == "varchar": + return self.get_long_name(binary_length, binary_type) + elif type_name.lower() == "nchar": + return self.get_long_name(nchar_length, nchar_type) + elif type_name.lower() == "bool": + return random.choice(self.Boundary.BOOL_BOUNDARY) + elif type_name.lower() == "timestamp": + return self.genTs()[0] + else: + pass + + def gen_tag_value_list(self, tag_elm_list): + tag_value_list = list() + if tag_elm_list is None: + tag_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + tag_value_list.append(self.gen_random_type_value(tag_elm["type"], tag_elm["len"], self.default_varchar_datatype, tag_elm["len"], self.default_nchar_datatype)) + else: + tag_value_list.append(self.gen_random_type_value(tag_elm["type"], "", "", "", "")) + else: + continue + return tag_value_list + + def gen_column_value_list(self, column_elm_list, ts_value=None): + if ts_value is None: + ts_value = self.genTs()[0] + + column_value_list = list() + column_value_list.append(ts_value) + if column_elm_list is None: + column_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if column_elm["type"] in ["varchar", "binary", "nchar"]: + column_value_list.append(self.gen_random_type_value(column_elm["type"], column_elm["len"], self.default_varchar_datatype, column_elm["len"], self.default_nchar_datatype)) + else: + column_value_list.append(self.gen_random_type_value(column_elm["type"], "", "", "", "")) + else: + continue + # column_value_list = [self.ts_value] + self.column_value_list + return column_value_list + + def create_stable(self, tsql, dbname=None, stbname="stb", column_elm_list=None, tag_elm_list=None, + count=1, default_stbname_prefix="stb", **kwargs): + colname_prefix = 'c' + tagname_prefix = 't' + stbname_index_start_num = 1 + stb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + stb_params += f'{param} "{value}" ' + column_type_str = self.gen_column_type_str(colname_prefix, column_elm_list) + tag_type_str = self.gen_tag_type_str(tagname_prefix, tag_elm_list) + + if int(count) <= 1: + create_stable_sql = f'create table {dbname}.{stbname} ({column_type_str}) tags ({tag_type_str}) {stb_params};' + tdLog.info("create stb sql: %s"%create_stable_sql) + tsql.execute(create_stable_sql) + else: + for _ in range(count): + create_stable_sql = f'create table {dbname}.{default_stbname_prefix}{stbname_index_start_num} ({column_type_str}) tags ({tag_type_str}) {stb_params};' + stbname_index_start_num += 1 + tsql.execute(create_stable_sql) + + def create_ctable(self, tsql, dbname=None, stbname=None, tag_elm_list=None, count=1, default_ctbname_prefix="ctb", **kwargs): + ctbname_index_start_num = 0 + ctb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + ctb_params += f'{param} "{value}" ' + tag_value_list = self.gen_tag_value_list(tag_elm_list) + tag_value_str = "" + # tag_value_str = ", ".join(str(v) for v in self.tag_value_list) + for tag_value in tag_value_list: + if isinstance(tag_value, str): + tag_value_str += f'"{tag_value}", ' + else: + tag_value_str += f'{tag_value}, ' + tag_value_str = tag_value_str.rstrip()[:-1] + + if int(count) <= 1: + create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' + tsql.execute(create_ctable_sql) + else: + for _ in range(count): + create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' + ctbname_index_start_num += 1 + tdLog.info("create ctb sql: %s"%create_ctable_sql) + tsql.execute(create_ctable_sql) + + def create_table(self, tsql, dbname=None, tbname="ntb", column_elm_list=None, count=1, **kwargs): + tbname_index_start_num = 1 + tbname_prefix="ntb" + + tb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + tb_params += f'{param} "{value}" ' + column_type_str = self.gen_column_type_str(tbname_prefix, column_elm_list) + + if int(count) <= 1: + create_table_sql = f'create table {dbname}.{tbname} ({column_type_str}) {tb_params};' + tsql.execute(create_table_sql) + else: + for _ in range(count): + create_table_sql = f'create table {dbname}.{tbname_prefix}{tbname_index_start_num} ({column_type_str}) {tb_params};' + tbname_index_start_num += 1 + tsql.execute(create_table_sql) + + def insert_rows(self, tsql, dbname=None, tbname=None, column_ele_list=None, start_ts_value=None, count=1): + if start_ts_value is None: + start_ts_value = self.genTs()[0] + + column_value_list = self.gen_column_value_list(column_ele_list, start_ts_value) + # column_value_str = ", ".join(str(v) for v in self.column_value_list) + column_value_str = "" + for column_value in column_value_list: + if isinstance(column_value, str): + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + column_value_str = column_value_str.rstrip()[:-1] + if int(count) <= 1: + insert_sql = f'insert into {self.tb_name} values ({column_value_str});' + tsql.execute(insert_sql) + else: + for num in range(count): + column_value_list = self.gen_column_value_list(column_ele_list, f'{start_ts_value}+{num}s') + # column_value_str = ", ".join(str(v) for v in column_value_list) + column_value_str = '' + idx = 0 + for column_value in column_value_list: + if isinstance(column_value, str) and idx != 0: + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + idx += 1 + column_value_str = column_value_str.rstrip()[:-1] + insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});' + tsql.execute(insert_sql) + def getOneRow(self, location, containElm): + res_list = list() + if 0 <= location < tdSql.queryRows: + for row in tdSql.queryResult: + if row[location] == containElm: + res_list.append(row) + return res_list + else: + tdLog.exit(f"getOneRow out of range: row_index={location} row_count={self.query_row}") + + def killProcessor(self, processorName): + if (platform.system().lower() == 'windows'): + os.system("TASKKILL /F /IM %s.exe"%processorName) + else: + os.system("unset LD_PRELOAD; pkill %s " % processorName) + + def gen_tag_col_str(self, gen_type, data_type, count): + """ + gen multi tags or cols by gen_type + """ + return ','.join(map(lambda i: f'{gen_type}{i} {data_type}', range(count))) + + # stream + def create_stream(self, stream_name, des_table, source_sql, trigger_mode=None, watermark=None, max_delay=None, ignore_expired=None, ignore_update=None, subtable_value=None, fill_value=None, fill_history_value=None, stb_field_name_value=None, tag_value=None, use_exist_stb=False, use_except=False): + """create_stream + + Args: + stream_name (str): stream_name + des_table (str): target stable + source_sql (str): stream sql + trigger_mode (str, optional): at_once/window_close/max_delay. Defaults to None. + watermark (str, optional): watermark time. Defaults to None. + max_delay (str, optional): max_delay time. Defaults to None. + ignore_expired (int, optional): ignore expired data. Defaults to None. + ignore_update (int, optional): ignore update data. Defaults to None. + subtable_value (str, optional): subtable. Defaults to None. + fill_value (str, optional): fill. Defaults to None. + fill_history_value (int, optional): 0/1. Defaults to None. + stb_field_name_value (str, optional): existed stb. Defaults to None. + tag_value (str, optional): custom tag. Defaults to None. + use_exist_stb (bool, optional): use existed stb tag. Defaults to False. + use_except (bool, optional): Exception tag. Defaults to False. + + Returns: + str: stream + """ + if subtable_value is None: + subtable = "" + else: + subtable = f'subtable({subtable_value})' + + if fill_value is None: + fill = "" + else: + fill = f'fill({fill_value})' + + if fill_history_value is None: + fill_history = "" + else: + fill_history = f'fill_history {fill_history_value}' + + if use_exist_stb: + if stb_field_name_value is None: + stb_field_name = "" + else: + stb_field_name = f'({stb_field_name_value})' + + if tag_value is None: + tags = "" + else: + tags = f'tags({tag_value})' + else: + stb_field_name = "" + tags = "" + + + if trigger_mode is None: + stream_options = "" + if watermark is not None: + stream_options = f'watermark {watermark}' + if ignore_expired: + stream_options += f" ignore expired {ignore_expired}" + else: + stream_options += f" ignore expired 0" + if ignore_update: + stream_options += f" ignore update {ignore_update}" + else: + stream_options += f" ignore update 0" + if not use_except: + tdSql.execute(f'create stream if not exists {stream_name} trigger at_once {stream_options} {fill_history} into {des_table} {subtable} as {source_sql} {fill};') + time.sleep(self.create_stream_sleep) + return None + else: + return f'create stream if not exists {stream_name} {stream_options} {fill_history} into {des_table} {subtable} as {source_sql} {fill};' + else: + if watermark is None: + if trigger_mode == "max_delay": + stream_options = f'trigger {trigger_mode} {max_delay}' + else: + stream_options = f'trigger {trigger_mode}' + else: + if trigger_mode == "max_delay": + stream_options = f'trigger {trigger_mode} {max_delay} watermark {watermark}' + else: + stream_options = f'trigger {trigger_mode} watermark {watermark}' + if ignore_expired: + stream_options += f" ignore expired {ignore_expired}" + else: + stream_options += f" ignore expired 0" + + if ignore_update: + stream_options += f" ignore update {ignore_update}" + else: + stream_options += f" ignore update 0" + if not use_except: + tdSql.execute(f'create stream if not exists {stream_name} {stream_options} {fill_history} into {des_table}{stb_field_name} {tags} {subtable} as {source_sql} {fill};') + time.sleep(self.create_stream_sleep) + return None + else: + return f'create stream if not exists {stream_name} {stream_options} {fill_history} into {des_table}{stb_field_name} {tags} {subtable} as {source_sql} {fill};' + + def pause_stream(self, stream_name, if_exist=True, if_not_exist=False): + """pause_stream + + Args: + stream_name (str): stream_name + if_exist (bool, optional): Defaults to True. + if_not_exist (bool, optional): Defaults to False. + """ + if_exist_value = "if exists" if if_exist else "" + if_not_exist_value = "if not exists" if if_not_exist else "" + tdSql.execute(f'pause stream {if_exist_value} {if_not_exist_value} {stream_name}') + + def resume_stream(self, stream_name, if_exist=True, if_not_exist=False, ignore_untreated=False): + """resume_stream + + Args: + stream_name (str): stream_name + if_exist (bool, optional): Defaults to True. + if_not_exist (bool, optional): Defaults to False. + ignore_untreated (bool, optional): Defaults to False. + """ + if_exist_value = "if exists" if if_exist else "" + if_not_exist_value = "if not exists" if if_not_exist else "" + ignore_untreated_value = "ignore untreated" if ignore_untreated else "" + tdSql.execute(f'resume stream {if_exist_value} {if_not_exist_value} {ignore_untreated_value} {stream_name}') + + def drop_all_streams(self): + """drop all streams + """ + tdSql.query("show streams") + stream_name_list = list(map(lambda x: x[0], tdSql.queryResult)) + for stream_name in stream_name_list: + tdSql.execute(f'drop stream if exists {stream_name};') + + def drop_db(self, dbname="test"): + """drop a db + + Args: + dbname (str, optional): Defaults to "test". + """ + if dbname[0].isdigit(): + tdSql.execute(f'drop database if exists `{dbname}`') + else: + tdSql.execute(f'drop database if exists {dbname}') + + def drop_all_db(self): + """drop all databases + """ + tdSql.query("show databases;") + db_list = list(map(lambda x: x[0], tdSql.queryResult)) + for dbname in db_list: + if dbname not in self.white_list and "telegraf" not in dbname: + tdSql.execute(f'drop database if exists `{dbname}`') + + def time_cast(self, time_value, split_symbol="+"): + """cast bigint to timestamp + + Args: + time_value (bigint): ts + split_symbol (str, optional): split sympol. Defaults to "+". + + Returns: + _type_: timestamp + """ + ts_value = str(time_value).split(split_symbol)[0] + if split_symbol in str(time_value): + ts_value_offset = str(time_value).split(split_symbol)[1] + else: + ts_value_offset = "0s" + return f'cast({ts_value} as timestamp){split_symbol}{ts_value_offset}' + + def clean_env(self): + """drop all streams and databases + """ + self.drop_all_streams() + self.drop_all_db() + + def set_precision_offset(self, precision): + if precision == "ms": + self.offset = 1000 + elif precision == "us": + self.offset = 1000000 + elif precision == "ns": + self.offset = 1000000000 + else: + pass + + def genTs(self, precision="ms", ts="", protype="taosc", ns_tag=None): + """generate ts + + Args: + precision (str, optional): db precision. Defaults to "ms". + ts (str, optional): input ts. Defaults to "". + protype (str, optional): "taosc" or "restful". Defaults to "taosc". + ns_tag (_type_, optional): use ns. Defaults to None. + + Returns: + timestamp, datetime: timestamp and datetime + """ + if precision == "ns": + if ts == "" or ts is None: + ts = time.time_ns() + else: + ts = ts + if ns_tag is None: + dt = ts + else: + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + if protype == "restful": + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + else: + if ts == "" or ts is None: + ts = time.time() + else: + ts = ts + if precision == "ms" or precision is None: + ts = int(round(ts * 1000)) + dt = datetime.fromtimestamp(ts // 1000) + if protype == "taosc": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + '000' + elif protype == "restful": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + else: + pass + elif precision == "us": + ts = int(round(ts * 1000000)) + dt = datetime.fromtimestamp(ts // 1000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000)).zfill(6) + return ts, dt + + def sgen_column_type_str(self, column_elm_list): + """generage column type str + + Args: + column_elm_list (list): column_elm_list + """ + self.column_type_str = "" + if column_elm_list is None: + self.column_type_str = self.gen_default_column_str() + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + self.column_type_str += f'{self.default_colname_prefix}{self.default_column_index_start_num} {column_elm["type"]}, ' + if column_elm["type"] in ["varchar", "binary", "nchar"]: + self.column_type_str = self.column_type_str.rstrip()[:-1] + f'({column_elm["len"]}), ' + self.default_column_index_start_num += 1 + else: + continue + self.column_type_str = self.default_colts_name + " timestamp, " + self.column_type_str.rstrip()[:-1] + + def sgen_tag_type_str(self, tag_elm_list): + """generage tag type str + + Args: + tag_elm_list (list): tag_elm_list + """ + self.tag_type_str = "" + if tag_elm_list is None: + self.tag_type_str = self.gen_default_tag_str() + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + self.tag_type_str += f'{self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_elm["type"]}, ' + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + self.tag_type_str = self.tag_type_str.rstrip()[:-1] + f'({tag_elm["len"]}), ' + self.default_tag_index_start_num += 1 + else: + continue + self.tag_type_str = self.tag_type_str.rstrip()[:-1] + if self.need_tagts: + self.tag_type_str = self.default_tagts_name + " timestamp, " + self.tag_type_str + + def sgen_tag_value_list(self, tag_elm_list, ts_value=None): + """generage tag value str + + Args: + tag_elm_list (list): _description_ + ts_value (timestamp, optional): Defaults to None. + """ + if self.need_tagts: + self.ts_value = self.genTs()[0] + if ts_value is not None: + self.ts_value = ts_value + + if tag_elm_list is None: + self.tag_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + self.tag_value_list.append(self.gen_random_type_value(tag_elm["type"], tag_elm["len"], self.default_varchar_datatype, tag_elm["len"], self.default_nchar_datatype)) + else: + self.tag_value_list.append(self.gen_random_type_value(tag_elm["type"], "", "", "", "")) + else: + continue + # if self.need_tagts and self.ts_value is not None and len(str(self.ts_value)) > 0: + if self.need_tagts: + self.tag_value_list = [self.ts_value] + self.tag_value_list + + def screateDb(self, dbname="test", drop_db=True, **kwargs): + """create database + + Args: + dbname (str, optional): Defaults to "test". + drop_db (bool, optional): Defaults to True. + """ + tdLog.info("creating db ...") + db_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + if param == "precision": + db_params += f'{param} "{value}" ' + else: + db_params += f'{param} {value} ' + if drop_db: + self.drop_db(dbname) + tdSql.execute(f'create database if not exists {dbname} {db_params}') + tdSql.execute(f'use {dbname}') + + def screate_stable(self, dbname=None, stbname="stb", use_name="table", column_elm_list=None, tag_elm_list=None, + need_tagts=False, count=1, default_stbname_prefix="stb", default_stbname_index_start_num=1, + default_column_index_start_num=1, default_tag_index_start_num=1, **kwargs): + """_summary_ + + Args: + dbname (str, optional): Defaults to None. + stbname (str, optional): Defaults to "stb". + use_name (str, optional): stable/table, Defaults to "table". + column_elm_list (list, optional): use for sgen_column_type_str(), Defaults to None. + tag_elm_list (list, optional): use for sgen_tag_type_str(), Defaults to None. + need_tagts (bool, optional): tag use timestamp, Defaults to False. + count (int, optional): stable count, Defaults to 1. + default_stbname_prefix (str, optional): Defaults to "stb". + default_stbname_index_start_num (int, optional): Defaults to 1. + default_column_index_start_num (int, optional): Defaults to 1. + default_tag_index_start_num (int, optional): Defaults to 1. + """ + tdLog.info("creating stable ...") + if dbname is not None: + self.dbname = dbname + self.need_tagts = need_tagts + self.default_stbname_prefix = default_stbname_prefix + self.default_stbname_index_start_num = default_stbname_index_start_num + self.default_column_index_start_num = default_column_index_start_num + self.default_tag_index_start_num = default_tag_index_start_num + stb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + stb_params += f'{param} "{value}" ' + self.sgen_column_type_str(column_elm_list) + self.sgen_tag_type_str(tag_elm_list) + if self.dbname is not None: + stb_name = f'{self.dbname}.{stbname}' + else: + stb_name = stbname + if int(count) <= 1: + create_stable_sql = f'create {use_name} {stb_name} ({self.column_type_str}) tags ({self.tag_type_str}) {stb_params};' + tdSql.execute(create_stable_sql) + else: + for _ in range(count): + create_stable_sql = f'create {use_name} {self.dbname}.{default_stbname_prefix}{default_stbname_index_start_num} ({self.column_type_str}) tags ({self.tag_type_str}) {stb_params};' + default_stbname_index_start_num += 1 + tdSql.execute(create_stable_sql) + + def screate_ctable(self, dbname=None, stbname=None, ctbname="ctb", use_name="table", tag_elm_list=None, ts_value=None, count=1, default_varchar_datatype="letters", default_nchar_datatype="letters", default_ctbname_prefix="ctb", default_ctbname_index_start_num=1, **kwargs): + """_summary_ + + Args: + dbname (str, optional): Defaults to None. + stbname (str, optional): Defaults to None. + ctbname (str, optional): Defaults to "ctb". + use_name (str, optional): Defaults to "table". + tag_elm_list (list, optional): use for sgen_tag_type_str(), Defaults to None. + ts_value (timestamp, optional): Defaults to None. + count (int, optional): ctb count, Defaults to 1. + default_varchar_datatype (str, optional): Defaults to "letters". + default_nchar_datatype (str, optional): Defaults to "letters". + default_ctbname_prefix (str, optional): Defaults to "ctb". + default_ctbname_index_start_num (int, optional): Defaults to 1. + """ + tdLog.info("creating childtable ...") + self.default_varchar_datatype = default_varchar_datatype + self.default_nchar_datatype = default_nchar_datatype + self.default_ctbname_prefix = default_ctbname_prefix + self.default_ctbname_index_start_num = default_ctbname_index_start_num + ctb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + ctb_params += f'{param} "{value}" ' + self.sgen_tag_value_list(tag_elm_list, ts_value) + tag_value_str = "" + # tag_value_str = ", ".join(str(v) for v in self.tag_value_list) + for tag_value in self.tag_value_list: + if isinstance(tag_value, str): + tag_value_str += f'"{tag_value}", ' + else: + tag_value_str += f'{tag_value}, ' + tag_value_str = tag_value_str.rstrip()[:-1] + if dbname is not None: + self.dbname = dbname + ctb_name = f'{self.dbname}.{ctbname}' + else: + ctb_name = ctbname + if stbname is not None: + stb_name = stbname + if int(count) <= 1: + create_ctable_sql = f'create {use_name} {ctb_name} using {stb_name} tags ({tag_value_str}) {ctb_params};' + tdSql.execute(create_ctable_sql) + else: + for _ in range(count): + create_stable_sql = f'create {use_name} {self.dbname}.{default_ctbname_prefix}{default_ctbname_index_start_num} using {self.stb_name} tags ({tag_value_str}) {ctb_params};' + default_ctbname_index_start_num += 1 + tdSql.execute(create_stable_sql) + + def sgen_column_value_list(self, column_elm_list, need_null, ts_value=None): + """_summary_ + + Args: + column_elm_list (list): gen_random_type_value() + need_null (bool): if insert null + ts_value (timestamp, optional): Defaults to None. + """ + self.column_value_list = list() + self.ts_value = self.genTs()[0] + if ts_value is not None: + self.ts_value = ts_value + + if column_elm_list is None: + self.column_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if column_elm["type"] in ["varchar", "binary", "nchar"]: + self.column_value_list.append(self.gen_random_type_value(column_elm["type"], column_elm["len"], self.default_varchar_datatype, column_elm["len"], self.default_nchar_datatype)) + else: + self.column_value_list.append(self.gen_random_type_value(column_elm["type"], "", "", "", "")) + else: + continue + if need_null: + for i in range(int(len(self.column_value_list)/2)): + index_num = random.randint(0, len(self.column_value_list)-1) + self.column_value_list[index_num] = None + self.column_value_list = [self.ts_value] + self.column_value_list + + def screate_table(self, dbname=None, tbname="tb", use_name="table", column_elm_list=None, + count=1, default_tbname_prefix="tb", default_tbname_index_start_num=1, + default_column_index_start_num=1, **kwargs): + """create ctable + + Args: + dbname (str, optional): Defaults to None. + tbname (str, optional): Defaults to "tb". + use_name (str, optional): Defaults to "table". + column_elm_list (list, optional): Defaults to None. + count (int, optional): Defaults to 1. + default_tbname_prefix (str, optional): Defaults to "tb". + default_tbname_index_start_num (int, optional): Defaults to 1. + default_column_index_start_num (int, optional): Defaults to 1. + """ + tdLog.info("creating table ...") + if dbname is not None: + self.dbname = dbname + self.default_tbname_prefix = default_tbname_prefix + self.default_tbname_index_start_num = default_tbname_index_start_num + self.default_column_index_start_num = default_column_index_start_num + tb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + tb_params += f'{param} "{value}" ' + self.sgen_column_type_str(column_elm_list) + if self.dbname is not None: + tb_name = f'{self.dbname}.{tbname}' + else: + tb_name = tbname + if int(count) <= 1: + create_table_sql = f'create {use_name} {tb_name} ({self.column_type_str}) {tb_params};' + tdSql.execute(create_table_sql) + else: + for _ in range(count): + create_table_sql = f'create {use_name} {self.dbname}.{default_tbname_prefix}{default_tbname_index_start_num} ({self.column_type_str}) {tb_params};' + default_tbname_index_start_num += 1 + tdSql.execute(create_table_sql) + + def sinsert_rows(self, dbname=None, tbname=None, column_ele_list=None, ts_value=None, count=1, need_null=False): + """insert rows + + Args: + dbname (str, optional): Defaults to None. + tbname (str, optional): Defaults to None. + column_ele_list (list, optional): Defaults to None. + ts_value (timestamp, optional): Defaults to None. + count (int, optional): Defaults to 1. + need_null (bool, optional): Defaults to False. + """ + tdLog.info("stream inserting ...") + if dbname is not None: + self.dbname = dbname + if tbname is not None: + self.tbname = f'{self.dbname}.{tbname}' + else: + if tbname is not None: + self.tbname = tbname + + self.sgen_column_value_list(column_ele_list, need_null, ts_value) + # column_value_str = ", ".join(str(v) for v in self.column_value_list) + column_value_str = "" + for column_value in self.column_value_list: + if column_value is None: + column_value_str += 'Null, ' + elif isinstance(column_value, str) and "+" not in column_value and "-" not in column_value: + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + column_value_str = column_value_str.rstrip()[:-1] + if int(count) <= 1: + insert_sql = f'insert into {self.tbname} values ({column_value_str});' + tdSql.execute(insert_sql) + else: + for num in range(count): + ts_value = self.genTs()[0] + self.sgen_column_value_list(column_ele_list, need_null, f'{ts_value}+{num}s') + column_value_str = "" + for column_value in self.column_value_list: + if column_value is None: + column_value_str += 'Null, ' + elif isinstance(column_value, str) and "+" not in column_value: + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + column_value_str = column_value_str.rstrip()[:-1] + insert_sql = f'insert into {self.tbname} values ({column_value_str});' + tdSql.execute(insert_sql) + + def sdelete_rows(self, dbname=None, tbname=None, start_ts=None, end_ts=None, ts_key=None): + """delete rows + + Args: + dbname (str, optional): Defaults to None. + tbname (str, optional): Defaults to None. + start_ts (timestamp, optional): range start. Defaults to None. + end_ts (timestamp, optional): range end. Defaults to None. + ts_key (str, optional): timestamp column name. Defaults to None. + """ + if dbname is not None: + self.dbname = dbname + if tbname is not None: + self.tbname = f'{self.dbname}.{tbname}' + else: + if tbname is not None: + self.tbname = tbname + if ts_key is None: + ts_col_name = self.default_colts_name + else: + ts_col_name = ts_key + + base_del_sql = f'delete from {self.tbname} ' + if end_ts is not None: + if ":" in start_ts and "-" in start_ts: + start_ts = f"{start_ts}" + if ":" in end_ts and "-" in end_ts: + end_ts = f"{end_ts}" + base_del_sql += f'where {ts_col_name} between {start_ts} and {end_ts};' + else: + if start_ts is not None: + if ":" in start_ts and "-" in start_ts: + start_ts = f"{start_ts}" + base_del_sql += f'where {ts_col_name} = {start_ts};' + tdSql.execute(base_del_sql) + + def check_stream_field_type(self, sql, input_function): + """confirm stream field + + Args: + sql (str): input sql + input_function (str): scalar + """ + tdSql.query(sql) + res = tdSql.queryResult + if input_function in ["acos", "asin", "atan", "cos", "log", "pow", "sin", "sqrt", "tan"]: + tdSql.checkEqual(res[1][1], "DOUBLE") + tdSql.checkEqual(res[2][1], "DOUBLE") + elif input_function in ["lower", "ltrim", "rtrim", "upper"]: + tdSql.checkEqual(res[1][1], "VARCHAR") + tdSql.checkEqual(res[2][1], "VARCHAR") + tdSql.checkEqual(res[3][1], "NCHAR") + elif input_function in ["char_length", "length"]: + tdSql.checkEqual(res[1][1], "BIGINT") + tdSql.checkEqual(res[2][1], "BIGINT") + tdSql.checkEqual(res[3][1], "BIGINT") + elif input_function in ["concat", "concat_ws"]: + tdSql.checkEqual(res[1][1], "VARCHAR") + tdSql.checkEqual(res[2][1], "NCHAR") + tdSql.checkEqual(res[3][1], "NCHAR") + tdSql.checkEqual(res[4][1], "NCHAR") + elif input_function in ["substr"]: + tdSql.checkEqual(res[1][1], "VARCHAR") + tdSql.checkEqual(res[2][1], "VARCHAR") + tdSql.checkEqual(res[3][1], "VARCHAR") + tdSql.checkEqual(res[4][1], "NCHAR") + else: + tdSql.checkEqual(res[1][1], "INT") + tdSql.checkEqual(res[2][1], "DOUBLE") + + def round_handle(self, input_list): + """round list elem + + Args: + input_list (list): input value list + + Returns: + _type_: round list + """ + tdLog.info("round rows ...") + final_list = list() + for i in input_list: + tmpl = list() + for j in i: + if type(j) != datetime and type(j) != str: + tmpl.append(round(j, 1)) + else: + tmpl.append(j) + final_list.append(tmpl) + return final_list + + def float_handle(self, input_list): + """float list elem + + Args: + input_list (list): input value list + + Returns: + _type_: float list + """ + tdLog.info("float rows ...") + final_list = list() + for i in input_list: + tmpl = list() + for j_i,j_v in enumerate(i): + if type(j_v) != datetime and j_v is not None and str(j_v).isdigit() and j_i <= 12: + tmpl.append(float(j_v)) + else: + tmpl.append(j_v) + final_list.append(tuple(tmpl)) + return final_list + + def str_ts_trans_bigint(self, str_ts): + """trans str ts to bigint + + Args: + str_ts (str): human-date + + Returns: + bigint: bigint-ts + """ + tdSql.query(f'select cast({str_ts} as bigint)') + return tdSql.queryResult[0][0] + + def cast_query_data(self, query_data): + """cast query-result for existed-stb + + Args: + query_data (list): query data list + + Returns: + list: new list after cast + """ + tdLog.info("cast query data ...") + col_type_list = self.column_type_str.split(',') + tag_type_list = self.tag_type_str.split(',') + col_tag_type_list = col_type_list + tag_type_list + nl = list() + for query_data_t in query_data: + query_data_l = list(query_data_t) + for i,v in enumerate(query_data_l): + if v is not None: + if " ".join(col_tag_type_list[i].strip().split(" ")[1:]) == "nchar(6)": + tdSql.query(f'select cast("{v}" as binary(6))') + else: + tdSql.query(f'select cast("{v}" as {" ".join(col_tag_type_list[i].strip().split(" ")[1:])})') + query_data_l[i] = tdSql.queryResult[0][0] + else: + query_data_l[i] = v + nl.append(tuple(query_data_l)) + return nl + + def trans_time_to_s(self, runtime): + """trans time to s + + Args: + runtime (str): 1d/1h/1m... + + Returns: + int: second + """ + if "d" in str(runtime).lower(): + d_num = re.findall("\d+\.?\d*", runtime.replace(" ", ""))[0] + s_num = float(d_num) * 24 * 60 * 60 + elif "h" in str(runtime).lower(): + h_num = re.findall("\d+\.?\d*", runtime.replace(" ", ""))[0] + s_num = float(h_num) * 60 * 60 + elif "m" in str(runtime).lower(): + m_num = re.findall("\d+\.?\d*", runtime.replace(" ", ""))[0] + s_num = float(m_num) * 60 + elif "s" in str(runtime).lower(): + s_num = re.findall("\d+\.?\d*", runtime.replace(" ", ""))[0] + else: + s_num = 60 + return int(s_num) + + def check_query_data(self, sql1, sql2, sorted=False, fill_value=None, tag_value_list=None, defined_tag_count=None, partition=True, use_exist_stb=False, subtable=None, reverse_check=False): + """confirm query result + + Args: + sql1 (str): select .... + sql2 (str): select .... + sorted (bool, optional): if sort result list. Defaults to False. + fill_value (str, optional): fill. Defaults to None. + tag_value_list (list, optional): Defaults to None. + defined_tag_count (int, optional): Defaults to None. + partition (bool, optional): Defaults to True. + use_exist_stb (bool, optional): Defaults to False. + subtable (str, optional): Defaults to None. + reverse_check (bool, optional): not equal. Defaults to False. + + Returns: + bool: False if failed + """ + tdLog.info("checking query data ...") + if tag_value_list: + dvalue = len(self.tag_type_str.split(',')) - defined_tag_count + tdSql.query(sql1) + res1 = tdSql.queryResult + tdSql.query(sql2) + res2 = self.cast_query_data(tdSql.queryResult) if tag_value_list or use_exist_stb else tdSql.queryResult + tdSql.sql = sql1 + new_list = list() + if tag_value_list: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + if i < len(tag_value_list): + if partition: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + list(tag_value_list[i]) + [None]*dvalue)) + else: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + else: + if use_exist_stb: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + new_list.append(tuple(list(v)[:-(13)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + + latency = 0 + if sorted: + res1.sort() + res2.sort() + if fill_value == "LINEAR": + res1 = self.round_handle(res1) + res2 = self.round_handle(res2) + if not reverse_check: + while res1 != res2: + tdLog.info("query retrying ...") + new_list = list() + tdSql.query(sql1) + res1 = tdSql.queryResult + tdSql.query(sql2) + # res2 = tdSql.queryResult + res2 = self.cast_query_data(tdSql.queryResult) if tag_value_list or use_exist_stb else tdSql.queryResult + tdSql.sql = sql1 + + if tag_value_list: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + if i < len(tag_value_list): + if partition: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + list(tag_value_list[i]) + [None]*dvalue)) + else: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + else: + if use_exist_stb: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + new_list.append(tuple(list(v)[:-(13)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + if sorted or tag_value_list: + res1.sort() + res2.sort() + if fill_value == "LINEAR": + res1 = self.round_handle(res1) + res2 = self.round_handle(res2) + if latency < self.stream_timeout: + latency += 0.2 + time.sleep(0.2) + else: + if latency == 0: + return False + tdSql.checkEqual(res1, res2) + # tdSql.checkEqual(res1, res2) if not reverse_check else tdSql.checkNotEqual(res1, res2) + else: + while res1 == res2: + tdLog.info("query retrying ...") + new_list = list() + tdSql.query(sql1) + res1 = tdSql.queryResult + tdSql.query(sql2) + # res2 = tdSql.queryResult + res2 = self.cast_query_data(tdSql.queryResult) if tag_value_list or use_exist_stb else tdSql.queryResult + tdSql.sql = sql1 + + if tag_value_list: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + if i < len(tag_value_list): + if partition: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + list(tag_value_list[i]) + [None]*dvalue)) + else: + new_list.append(tuple(list(v)[:-(dvalue+defined_tag_count)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + else: + if use_exist_stb: + res1 = self.float_handle(res1) + res2 = self.float_handle(res2) + for i,v in enumerate(res2): + new_list.append(tuple(list(v)[:-(13)] + [None]*len(self.tag_type_str.split(',')))) + res2 = new_list + if sorted or tag_value_list: + res1.sort() + res2.sort() + if fill_value == "LINEAR": + res1 = self.round_handle(res1) + res2 = self.round_handle(res2) + if latency < self.stream_timeout: + latency += 0.2 + time.sleep(0.2) + else: + if latency == 0: + return False + tdSql.checkNotEqual(res1, res2) + # tdSql.checkEqual(res1, res2) if not reverse_check else tdSql.checkNotEqual(res1, res2) + + def check_stream_res(self, sql, expected_res, max_delay): + """confirm stream result + + Args: + sql (str): select ... + expected_res (str): expected result + max_delay (int): max_delay value + + Returns: + bool: False if failed + """ + tdSql.query(sql) + latency = 0 + + while tdSql.queryRows != expected_res: + tdSql.query(sql) + if latency < self.stream_timeout: + latency += 0.2 + time.sleep(0.2) + else: + if max_delay is not None: + if latency == 0: + return False + tdSql.checkEqual(tdSql.queryRows, expected_res) + + def check_stream(self, sql1, sql2, expected_count, max_delay=None): + """confirm stream + + Args: + sql1 (str): select ... + sql2 (str): select ... + expected_count (int): expected_count + max_delay (int, optional): max_delay value. Defaults to None. + """ + self.check_stream_res(sql1, expected_count, max_delay) + self.check_query_data(sql1, sql2) + + def cal_watermark_window_close_session_endts(self, start_ts, watermark=None, session=None): + """cal endts for close window + + Args: + start_ts (epoch time): self.date_time + watermark (int, optional): > session. Defaults to None. + session (int, optional): Defaults to None. + + Returns: + int: as followed + """ + if watermark is not None: + return start_ts + watermark*self.offset + 1 + else: + return start_ts + session*self.offset + 1 + + def cal_watermark_window_close_interval_endts(self, start_ts, interval, watermark=None): + """cal endts for close window + + Args: + start_ts (epoch time): self.date_time + interval (int): [s] + watermark (int, optional): [s]. Defaults to None. + + Returns: + _type_: _description_ + """ + if watermark is not None: + return int(start_ts/self.offset)*self.offset + (interval - (int(start_ts/self.offset))%interval)*self.offset + watermark*self.offset + else: + return int(start_ts/self.offset)*self.offset + (interval - (int(start_ts/self.offset))%interval)*self.offset + + def update_delete_history_data(self, delete): + """update and delete history data + + Args: + delete (bool): True/False + """ + self.sinsert_rows(tbname=self.ctb_name, ts_value=self.record_history_ts) + self.sinsert_rows(tbname=self.tb_name, ts_value=self.record_history_ts) + if delete: + self.sdelete_rows(tbname=self.ctb_name, start_ts=self.time_cast(self.record_history_ts, "-")) + self.sdelete_rows(tbname=self.tb_name, start_ts=self.time_cast(self.record_history_ts, "-")) + + def prepare_data(self, interval=None, watermark=None, session=None, state_window=None, state_window_max=127, interation=3, range_count=None, precision="ms", fill_history_value=0, ext_stb=None): + """prepare stream data + + Args: + interval (int, optional): Defaults to None. + watermark (int, optional): Defaults to None. + session (int, optional): Defaults to None. + state_window (str, optional): Defaults to None. + state_window_max (int, optional): Defaults to 127. + interation (int, optional): Defaults to 3. + range_count (int, optional): Defaults to None. + precision (str, optional): Defaults to "ms". + fill_history_value (int, optional): Defaults to 0. + ext_stb (bool, optional): Defaults to None. + """ + self.clean_env() + self.dataDict = { + "stb_name" : f"{self.case_name}_stb", + "ctb_name" : f"{self.case_name}_ct1", + "tb_name" : f"{self.case_name}_tb1", + "ext_stb_name" : f"ext_{self.case_name}_stb", + "ext_ctb_name" : f"ext_{self.case_name}_ct1", + "ext_tb_name" : f"ext_{self.case_name}_tb1", + "interval" : interval, + "watermark": watermark, + "session": session, + "state_window": state_window, + "state_window_max": state_window_max, + "iteration": interation, + "range_count": range_count, + "start_ts": 1655903478508, + } + if range_count is not None: + self.range_count = range_count + if precision is not None: + self.precision = precision + self.set_precision_offset(self.precision) + + self.stb_name = self.dataDict["stb_name"] + self.ctb_name = self.dataDict["ctb_name"] + self.tb_name = self.dataDict["tb_name"] + self.ext_stb_name = self.dataDict["ext_stb_name"] + self.ext_ctb_name = self.dataDict["ext_ctb_name"] + self.ext_tb_name = self.dataDict["ext_tb_name"] + self.stb_stream_des_table = f'{self.stb_name}{self.des_table_suffix}' + self.ctb_stream_des_table = f'{self.ctb_name}{self.des_table_suffix}' + self.tb_stream_des_table = f'{self.tb_name}{self.des_table_suffix}' + self.ext_stb_stream_des_table = f'{self.ext_stb_name}{self.des_table_suffix}' + self.ext_ctb_stream_des_table = f'{self.ext_ctb_name}{self.des_table_suffix}' + self.ext_tb_stream_des_table = f'{self.ext_tb_name}{self.des_table_suffix}' + self.date_time = self.genTs(precision=self.precision)[0] + + self.screateDb(dbname=self.dbname, precision=self.precision) + if ext_stb: + self.screate_stable(dbname=self.dbname, stbname=self.ext_stb_stream_des_table) + self.screate_ctable(dbname=self.dbname, stbname=self.ext_stb_stream_des_table, ctbname=self.ext_ctb_stream_des_table) + self.screate_table(dbname=self.dbname, tbname=self.ext_tb_stream_des_table) + self.screate_stable(dbname=self.dbname, stbname=self.stb_name) + self.screate_ctable(dbname=self.dbname, stbname=self.stb_name, ctbname=self.ctb_name) + self.screate_table(dbname=self.dbname, tbname=self.tb_name) + if fill_history_value == 1: + for i in range(self.range_count): + ts_value = str(self.date_time)+f'-{self.default_interval*(i+1)}s' + self.sinsert_rows(tbname=self.ctb_name, ts_value=ts_value) + self.sinsert_rows(tbname=self.tb_name, ts_value=ts_value) + if i == 1: + self.record_history_ts = ts_value + +def is_json(msg): + if isinstance(msg, str): + try: + json.loads(msg) + return True + except: + return False + else: + return False + +def get_path(tool="taosd"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files or ("%s.exe"%tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + +def dict2toml(in_dict: dict, file:str): + if not isinstance(in_dict, dict): + return "" + with open(file, 'w') as f: + toml.dump(in_dict, f) + +tdCom = TDCom() diff --git a/tests/army/frame/constant.py b/tests/army/frame/constant.py new file mode 100644 index 0000000000..c4541386b4 --- /dev/null +++ b/tests/army/frame/constant.py @@ -0,0 +1,197 @@ +# -*- coding: utf-8 -*- + +# basic type +TAOS_DATA_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", + "FLOAT", "DOUBLE", + "BOOL", + "BINARY", "NCHAR", "VARCHAR", + "TIMESTAMP", + # "MEDIUMBLOB", "BLOB", # add in 3.x + # "DECIMAL", "NUMERIC", # add in 3.x + "JSON", # only for tag +] + +TAOS_NUM_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", "FLOAT", "DOUBLE", + # "DECIMAL", "NUMERIC", # add in 3.x +] +TAOS_CHAR_TYPE = [ + "BINARY", "NCHAR", "VARCHAR", +] +TAOS_BOOL_TYPE = ["BOOL",] +TAOS_TS_TYPE = ["TIMESTAMP",] +TAOS_BIN_TYPE = [ + "MEDIUMBLOB", "BLOB", # add in 3.x +] + +TAOS_TIME_INIT = ["b", "u", "a", "s", "m", "h", "d", "w", "n", "y"] +TAOS_PRECISION = ["ms", "us", "ns"] +PRECISION_DEFAULT = "ms" +PRECISION = PRECISION_DEFAULT + +TAOS_KEYWORDS = [ + "ABORT", "CREATE", "IGNORE", "NULL", "STAR", + "ACCOUNT", "CTIME", "IMMEDIATE", "OF", "STATE", + "ACCOUNTS", "DATABASE", "IMPORT", "OFFSET", "STATEMENT", + "ADD", "DATABASES", "IN", "OR", "STATE_WINDOW", + "AFTER", "DAYS", "INITIALLY", "ORDER", "STORAGE", + "ALL", "DBS", "INSERT", "PARTITIONS", "STREAM", + "ALTER", "DEFERRED", "INSTEAD", "PASS", "STREAMS", + "AND", "DELIMITERS", "INT", "PLUS", "STRING", + "AS", "DESC", "INTEGER", "PPS", "SYNCDB", + "ASC", "DESCRIBE", "INTERVAL", "PRECISION", "TABLE", + "ATTACH", "DETACH", "INTO", "PREV", "TABLES", + "BEFORE", "DISTINCT", "IS", "PRIVILEGE", "TAG", + "BEGIN", "DIVIDE", "ISNULL", "QTIME", "TAGS", + "BETWEEN", "DNODE", "JOIN", "QUERIES", "TBNAME", + "BIGINT", "DNODES", "KEEP", "QUERY", "TIMES", + "BINARY", "DOT", "KEY", "QUORUM", "TIMESTAMP", + "BITAND", "DOUBLE", "KILL", "RAISE", "TINYINT", + "BITNOT", "DROP", "LE", "REM", "TOPIC", + "BITOR", "EACH", "LIKE", "REPLACE", "TOPICS", + "BLOCKS", "END", "LIMIT", "REPLICA", "TRIGGER", + "BOOL", "EQ", "LINEAR", "RESET", "TSERIES", + "BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS", + "CACHE", "EXPLAIN", "LP", "ROW", "UNION", + "CACHEMODEL", "FAIL", "LSHIFT", "RP", "UNSIGNED", + "CASCADE", "FILE", "LT", "RSHIFT", "UPDATE", + "CHANGE", "FILL", "MATCH", "SCORES", "UPLUS", + "CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE", + "COLON", "FOR", "MINROWS", "SEMI", "USER", + "COLUMN", "FROM", "MINUS", "SESSION", "USERS", + "COMMA", "FSYNC", "MNODES", "SET", "USING", + "COMP", "GE", "MODIFY", "SHOW", "VALUES", + "COMPACT", "GLOB", "MODULES", "SLASH", "VARIABLE", + "CONCAT", "GRANTS", "NCHAR", "SLIDING", "VARIABLES", + "CONFLICT", "GROUP", "NE", "SLIMIT", "VGROUPS", + "CONNECTION", "GT", "NONE", "SMALLINT", "VIEW", + "CONNECTIONS", "HAVING", "NOT", "SOFFSET", "VNODES", + "CONNS", "ID", "NOTNULL", "STABLE", "WAL", + "COPY", "IF", "NOW", "STABLES", "WHERE", +] + +NUM_FUNC = [ + "ABS", "ACOS", "ASIN", "ATAN", "CEIL", "COS", "FLOOR", "LOG", "POW", "ROUND", "SIN", "SQRT", "TAN", +] + +STR_FUNC = [ + "CHAR_LENGTH", "CONCAT", "CONCAT_WS", "LENGTH", "LOWER","LTRIM", "RTRIM", "SUBSTR", "UPPER", +] + +CONVER_FUNC = ["CASR", "TO_ISO8601", "TO_JSON", "TP_UNIXTIMESTAMP"] + +SELECT_FUNC = [ + "APERCENTILE", "BOTTOM", "FIRST", "INTERP", "LAST", "MAX", "MIN", "PERCENTILE", "TAIL", "TOP", "UNIQUE", +] + +AGG_FUNC = [ + "AVG", "COUNT", "ELAPSED", "LEASTSQUARES", "MODE", "SPREAD", "STDDEV", "SUM", "HYPERLOGLOG", "HISTOGRAM", +] + +TS_FUNC = [ + "CSUM", "DERIVATIVE", "DIFF", "IRATE", "MAVG", "SAMPLE", "STATECOUNT", "STATEDURATION", "TWA" +] + +SYSINFO_FUNC = [ + "DATABASE", "CLIENT_VERSION", "SERVER_VERSION", "SERVER_STATUS", "CURRENT_USER", "USER" +] + + + +# basic data type boundary +TINYINT_MAX = 127 +TINYINT_MIN = -128 + +TINYINT_UN_MAX = 255 +TINYINT_UN_MIN = 0 + +SMALLINT_MAX = 32767 +SMALLINT_MIN = -32768 + +SMALLINT_UN_MAX = 65535 +SMALLINT_UN_MIN = 0 + +INT_MAX = 2_147_483_647 +INT_MIN = -2_147_483_648 + +INT_UN_MAX = 4_294_967_295 +INT_UN_MIN = 0 + +BIGINT_MAX = 9_223_372_036_854_775_807 +BIGINT_MIN = -9_223_372_036_854_775_808 + +BIGINT_UN_MAX = 18_446_744_073_709_551_615 +BIGINT_UN_MIN = 0 + +FLOAT_MAX = 3.40E+38 +FLOAT_MIN = -3.40E+38 + +DOUBLE_MAX = 1.7E+308 +DOUBLE_MIN = -1.7E+308 + +# schema boundary +BINARY_LENGTH_MAX = 16374 +NCAHR_LENGTH_MAX = 4093 +DBNAME_LENGTH_MAX = 64 + +STBNAME_LENGTH_MAX = 192 +STBNAME_LENGTH_MIN = 1 + +TBNAME_LENGTH_MAX = 192 +TBNAME_LENGTH_MIN = 1 + +CHILD_TBNAME_LENGTH_MAX = 192 +CHILD_TBNAME_LENGTH_MIN = 1 + +TAG_NAME_LENGTH_MAX = 64 +TAG_NAME_LENGTH_MIN = 1 + +COL_NAME_LENGTH_MAX = 64 +COL_NAME_LENGTH_MIN = 1 + +TAG_COUNT_MAX = 128 +TAG_COUNT_MIN = 1 + +COL_COUNT_MAX = 4096 +COL_COUNT_MIN = 2 + +TAG_COL_COUNT_MAX = 4096 +TAG_COL_COUNT_MIN = 3 + +MNODE_SHM_SIZE_MAX = 2_147_483_647 +MNODE_SHM_SIZE_MIN = 6_292_480 +MNODE_SHM_SIZE_DEFAULT = 6_292_480 + +VNODE_SHM_SIZE_MAX = 2_147_483_647 +VNODE_SHM_SIZE_MIN = 6_292_480 +VNODE_SHM_SIZE_DEFAULT = 31_458_304 + +# time_init +TIME_MS = 1 +TIME_US = TIME_MS/1000 +TIME_NS = TIME_US/1000 + +TIME_S = 1000 * TIME_MS +TIME_M = 60 * TIME_S +TIME_H = 60 * TIME_M +TIME_D = 24 * TIME_H +TIME_W = 7 * TIME_D +TIME_N = 30 * TIME_D +TIME_Y = 365 * TIME_D + + +# session parameters +INTERVAL_MIN = 1 * TIME_MS if PRECISION == PRECISION_DEFAULT else 1 * TIME_US + + +# streams and related agg-function +SMA_INDEX_FUNCTIONS = ["MIN", "MAX"] +ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"] +BLOCK_FUNCTIONS = ["SUM", "MIN", "MAX"] +SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] +WATERMARK_MAX = 900000 +WATERMARK_MIN = 0 + +MAX_DELAY_MAX = 900000 +MAX_DELAY_MIN = 1 \ No newline at end of file diff --git a/tests/army/frame/dnodes-default.py b/tests/army/frame/dnodes-default.py new file mode 100644 index 0000000000..a1d1698b00 --- /dev/null +++ b/tests/army/frame/dnodes-default.py @@ -0,0 +1,502 @@ +################################################################### +# 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 sys +import os +import os.path +import subprocess +from frame.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "minTablesPerVnode": "4", + "maxTablesPerVnode": "1000", + "tableIncStepPerVnode": "10000", + "maxVgroupsPerDb": "1000", + "sdbDebugFlag": "143", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + return self.logDir + + def getCfgDir(self): + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + self.cfgPath = os.path.join(self.path,"sim","psim","cfg","taos.cfg") + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","dnode%d" % self.index, "log") + self.dataDir = os.path.join(self.path,"sim","dnode%d" % self.index, "data") + self.cfgDir = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg") + self.cfgPath = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg","taos.cfg") + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = os.path.join(self.path,"sim","psim","dnode%d" % index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = os.path.join(self.path,"sim","psim") + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/army/frame/dnodes-no-random-fail.py b/tests/army/frame/dnodes-no-random-fail.py new file mode 100644 index 0000000000..3b3083396b --- /dev/null +++ b/tests/army/frame/dnodes-no-random-fail.py @@ -0,0 +1,500 @@ +################################################################### +# 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 sys +import os +import os.path +import subprocess +from frame.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "numOfThreadsPerCore": "2.0", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "anyIp": "0", + "sdbDebugFlag": "135", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + return self.logDir + + def getCfgDir(self): + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + self.cfgPath = os.path.join(self.path,"sim","psim","cfg","taos.cfg") + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","dnode%d" % self.index, "log") + self.dataDir = os.path.join(self.path,"sim","dnode%d" % self.index, "data") + self.cfgDir = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg") + self.cfgPath = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg","taos.cfg") + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s --random-file-fail-factor 0 > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = os.path.join(self.path,"sim","psim","dnode%d" % index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = os.path.join(self.path,"sim","psim") + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/army/frame/dnodes-random-fail.py b/tests/army/frame/dnodes-random-fail.py new file mode 100644 index 0000000000..794adfd7ed --- /dev/null +++ b/tests/army/frame/dnodes-random-fail.py @@ -0,0 +1,497 @@ +################################################################### +# 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 sys +import os +import os.path +import subprocess +from frame.log import * + + +class TDSimClient: + def __init__(self): + self.testCluster = False + + self.cfgDict = { + "numOfLogLines": "100000000", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "telemetryReporting": "0", + } + + def init(self, path): + self.__init__() + self.path = path + + def getLogDir(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + return self.logDir + + def getCfgDir(self): + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + self.cfgPath = os.path.join(self.path,"sim","psim","cfg","taos.cfg") + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + + def init(self, path): + self.path = path + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def deploy(self): + self.logDir = os.path.join(self.path,"sim","dnode%d" % self.index, "log") + self.dataDir = os.path.join(self.path,"sim","dnode%d" % self.index, "data") + self.cfgDir = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg") + self.cfgPath = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg","taos.cfg") + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "mkdir -p " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfg("dataDir", self.dataDir) + self.cfg("logDir", self.logDir) + self.cfg("numOfLogLines", "100000000") + self.cfg("mnodeEqualVnodeNum", "0") + self.cfg("walLevel", "2") + self.cfg("fsync", "1000") + self.cfg("statusInterval", "1") + self.cfg("numOfMnodes", "3") + self.cfg("numOfThreadsPerCore", "2.0") + self.cfg("monitor", "0") + self.cfg("maxVnodeConnections", "30000") + self.cfg("maxMgmtConnections", "30000") + self.cfg("maxMeterConnections", "30000") + self.cfg("maxShellConns", "30000") + self.cfg("locale", "en_US.UTF-8") + self.cfg("charset", "UTF-8") + self.cfg("asyncLog", "0") + self.cfg("anyIp", "0") + self.cfg("dDebugFlag", "135") + self.cfg("mDebugFlag", "135") + self.cfg("sdbDebugFlag", "135") + self.cfg("rpcDebugFlag", "135") + self.cfg("tmrDebugFlag", "131") + self.cfg("cDebugFlag", "135") + self.cfg("httpDebugFlag", "135") + self.cfg("monitorDebugFlag", "135") + self.cfg("udebugFlag", "135") + self.cfg("jnidebugFlag", "135") + self.cfg("qdebugFlag", "135") + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def start(self): + buildPath = self.getBuildPath() + + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + + binPath = buildPath + "/build/bin/taosd" + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + cmd = "nohup %s -c %s --alloc-random-fail --random-file-fail-factor 5 > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes" + + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + tdLog.debug("wait 5 seconds for the dnode:%d to start." % (self.index)) + time.sleep(5) + + def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + while(processID): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = os.path.join(self.path,"sim","psim","dnode%d" % index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = os.path.join(self.path,"sim","psim") + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + + def init(self, path): + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" + tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + tdLog.debug("binPath real path %s" % (binPath)) + + # cmd = "sudo cp %s/build/lib/libtaos.so /usr/local/lib/taos/" % (binPath) + # tdLog.debug(cmd) + # os.system(cmd) + + # cmd = "sudo cp %s/build/bin/taos /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + # cmd = "sudo cp %s/build/bin/taosd /usr/local/bin/taos/" % (binPath) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + # tdLog.debug("execute %s" % (cmd)) + + if path == "": + # self.path = os.path.expanduser('~') + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path) + + self.sim = TDSimClient() + self.sim.init(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def deploy(self, index): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy() + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].deploy() + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def stopAll(self): + tdLog.info("stop all dnodes") + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") + while(processID): + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8") + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + +tdDnodes = TDDnodes() diff --git a/tests/army/frame/dnodes.py b/tests/army/frame/dnodes.py new file mode 100644 index 0000000000..5581f29a57 --- /dev/null +++ b/tests/army/frame/dnodes.py @@ -0,0 +1,890 @@ +################################################################### +# 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 sys +import os +import os.path +import platform +import distro +import subprocess +from time import sleep +import base64 +import json +import copy +from fabric2 import Connection +from frame.log import * +from shutil import which + + +class TDSimClient: + def __init__(self, path): + self.testCluster = False + self.path = path + self.cfgDict = { + "fqdn": "localhost", + "numOfLogLines": "100000000", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "uDebugFlag": "135", + "jniDebugFlag": "135", + "qDebugFlag": "135", + "supportVnodes": "1024", + "enableQueryHb": "1", + "telemetryReporting": "0", + "tqDebugflag": "135", + "wDebugflag":"135", + } + + def getLogDir(self): + self.logDir = os.path.join(self.path,"sim","psim","log") + return self.logDir + + def getCfgDir(self): + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + return self.cfgDir + + def setTestCluster(self, value): + self.testCluster = value + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self, *updatecfgDict): + self.logDir = os.path.join(self.path,"sim","psim","log") + self.cfgDir = os.path.join(self.path,"sim","psim","cfg") + self.cfgPath = os.path.join(self.path,"sim","psim","cfg","taos.cfg") + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("logDir", self.logDir) + + for key, value in self.cfgDict.items(): + self.cfg(key, value) + + try: + if bool(updatecfgDict) and updatecfgDict[0] and updatecfgDict[0][0]: + clientCfg = dict (updatecfgDict[0][0].get('clientCfg')) + for key, value in clientCfg.items(): + self.cfg(key, value) + except Exception: + pass + + tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) + + +class TDDnode: + def __init__(self, index): + self.index = index + self.running = 0 + self.deployed = 0 + self.testCluster = False + self.valgrind = 0 + self.asan = False + self.remoteIP = "" + self.cfgDict = { + "fqdn": "localhost", + "monitor": "0", + "maxShellConns": "30000", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "mDebugFlag": "143", + "dDebugFlag": "143", + "vDebugFlag": "143", + "tqDebugFlag": "143", + "cDebugFlag": "143", + "stDebugFlag": "143", + "smaDebugFlag": "143", + "jniDebugFlag": "143", + "qDebugFlag": "143", + "rpcDebugFlag": "143", + "tmrDebugFlag": "131", + "uDebugFlag": "135", + "sDebugFlag": "135", + "wDebugFlag": "135", + "numOfLogLines": "100000000", + "statusInterval": "1", + "enableQueryHb": "1", + "supportVnodes": "1024", + "telemetryReporting": "0" + } + + def init(self, path, remoteIP = ""): + self.path = path + self.remoteIP = remoteIP + if (not self.remoteIP == ""): + try: + self.config = eval(self.remoteIP) + self.remote_conn = Connection(host=self.config["host"], port=self.config["port"], user=self.config["user"], connect_kwargs={'password':self.config["password"]}) + except Exception as r: + print(r) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def setAsan(self, value): + self.asan = value + if value: + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + self.execPath = os.path.abspath(self.path + "/community/tests/script/sh/exec.sh") + else: + self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh") + + def getDataSize(self): + totalSize = 0 + + if (self.deployed == 1): + for dirpath, dirnames, filenames in os.walk(self.dataDir): + for f in filenames: + fp = os.path.join(dirpath, f) + + if not os.path.islink(fp): + totalSize = totalSize + os.path.getsize(fp) + + return totalSize + + def addExtraCfg(self, option, value): + self.cfgDict.update({option: value}) + + def remoteExec(self, updateCfgDict, execCmd): + valgrindStr = '' + if (self.valgrind==1): + valgrindStr = '-g' + remoteCfgDict = copy.deepcopy(updateCfgDict) + if ("logDir" in remoteCfgDict): + del remoteCfgDict["logDir"] + if ("dataDir" in remoteCfgDict): + del remoteCfgDict["dataDir"] + if ("cfgDir" in remoteCfgDict): + del remoteCfgDict["cfgDir"] + remoteCfgDictStr = base64.b64encode(json.dumps(remoteCfgDict).encode()).decode() + execCmdStr = base64.b64encode(execCmd.encode()).decode() + with self.remote_conn.cd((self.config["path"]+sys.path[0].replace(self.path, '')).replace('\\','/')): + self.remote_conn.run("python3 ./test.py %s -d %s -e %s"%(valgrindStr,remoteCfgDictStr,execCmdStr)) + + def deploy(self, *updatecfgDict): + self.logDir = os.path.join(self.path,"sim","dnode%d" % self.index, "log") + self.dataDir = os.path.join(self.path,"sim","dnode%d" % self.index, "data") + self.cfgDir = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg") + self.cfgPath = os.path.join(self.path,"sim","dnode%d" % self.index, "cfg","taos.cfg") + + cmd = "rm -rf " + self.dataDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.logDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + cmd = "rm -rf " + self.cfgDir + if os.system(cmd) != 0: + tdLog.exit(cmd) + + # cmd = "mkdir -p " + self.dataDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.dataDir) + + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) + + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) + + cmd = "touch " + self.cfgPath + if os.system(cmd) != 0: + tdLog.exit(cmd) + + if self.testCluster: + self.startIP() + + if self.testCluster: + self.cfg("masterIp", "192.168.0.1") + self.cfg("secondIp", "192.168.0.2") + self.cfg("publicIp", "192.168.0.%d" % (self.index)) + self.cfg("internalIp", "192.168.0.%d" % (self.index)) + self.cfg("privateIp", "192.168.0.%d" % (self.index)) + self.cfgDict["dataDir"] = self.dataDir + self.cfgDict["logDir"] = self.logDir + # self.cfg("dataDir",self.dataDir) + # self.cfg("logDir",self.logDir) + # print(updatecfgDict) + isFirstDir = 1 + if bool(updatecfgDict) and updatecfgDict[0] and updatecfgDict[0][0]: + for key, value in updatecfgDict[0][0].items(): + if key == "clientCfg" and self.remoteIP == "" and not platform.system().lower() == 'windows': + continue + if value == 'dataDir': + if isFirstDir: + self.cfgDict.pop('dataDir') + self.cfg(value, key) + isFirstDir = 0 + else: + self.cfg(value, key) + else: + self.addExtraCfg(key, value) + if (self.remoteIP == ""): + for key, value in self.cfgDict.items(): + self.cfg(key, value) + else: + self.remoteExec(self.cfgDict, "tdDnodes.deploy(%d,updateCfgDict)"%self.index) + + self.deployed = 1 + tdLog.debug( + "dnode:%d is deployed and configured by %s" % + (self.index, self.cfgPath)) + + def getPath(self, tool="taosd"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files or ("%s.exe"%tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def starttaosd(self): + binPath = self.getPath() + + if (binPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found: %s" % binPath) + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s -c %s" % ( + binPath, self.cfgDir) + else: + if self.asan: + asanDir = "%s/sim/asan/dnode%d.asan" % ( + self.path, self.index) + cmd = "nohup %s -c %s > /dev/null 2> %s & " % ( + binPath, self.cfgDir, asanDir) + else: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --log-file=\"%s/../log/valgrind.log\" --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"%self.cfgDir + + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s %s -c %s" % ( + valgrindCmdline, binPath, self.cfgDir) + else: + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if (not self.remoteIP == ""): + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].deployed=1\ntdDnodes.dnodes[%d].logDir=\"%%s/sim/dnode%%d/log\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.dnodes[%d].cfgDir=\"%%s/sim/dnode%%d/cfg\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.start(%d)"%(self.index-1,self.index-1,self.index-1,self.index,self.index-1,self.index-1,self.index,self.index)) + self.running = 1 + else: + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + if self.valgrind == 0: + time.sleep(0.1) + key1 = 'from offline to online' + bkey1 = bytes(key1, encoding="utf8") + key2= 'TDengine initialized successfully' + bkey2 = bytes(key2, encoding="utf8") + logFile = self.logDir + "/taosdlog.0" + i = 0 + # while not os.path.exists(logFile): + # sleep(0.1) + # i += 1 + # if i > 10: + # break + # tailCmdStr = 'tail -f ' + # if platform.system().lower() == 'windows': + # tailCmdStr = 'tail -n +0 -f ' + # popen = subprocess.Popen( + # tailCmdStr + logFile, + # stdout=subprocess.PIPE, + # stderr=subprocess.PIPE, + # shell=True) + # pid = popen.pid + # # print('Popen.pid:' + str(pid)) + # timeout = time.time() + 60 * 2 + # while True: + # line = popen.stdout.readline().strip() + # print(line) + # if bkey1 in line: + # popen.kill() + # break + # elif bkey2 in line: + # popen.kill() + # break + # if time.time() > timeout: + # print(time.time(),timeout) + # tdLog.exit('wait too long for taosd start') + tdLog.debug("the dnode:%d has been started." % (self.index)) + else: + tdLog.debug( + "wait 10 seconds for the dnode:%d to start." % + (self.index)) + time.sleep(10) + + def start(self): + binPath = self.getPath() + + if (binPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found: %s" % binPath) + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s -c %s" % ( + binPath, self.cfgDir) + else: + if self.asan: + asanDir = "%s/sim/asan/dnode%d.asan" % ( + self.path, self.index) + cmd = "nohup %s -c %s > /dev/null 2> %s & " % ( + binPath, self.cfgDir, asanDir) + else: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --log-file=\"%s/../log/valgrind.log\" --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"%self.cfgDir + + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s %s -c %s" % ( + valgrindCmdline, binPath, self.cfgDir) + else: + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + + print(cmd) + + if (not self.remoteIP == ""): + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].deployed=1\ntdDnodes.dnodes[%d].logDir=\"%%s/sim/dnode%%d/log\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.dnodes[%d].cfgDir=\"%%s/sim/dnode%%d/cfg\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.start(%d)"%(self.index-1,self.index-1,self.index-1,self.index,self.index-1,self.index-1,self.index,self.index)) + self.running = 1 + else: + os.system("rm -rf %s/taosdlog.0"%self.logDir) + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + if self.valgrind == 0: + time.sleep(0.1) + key = 'from offline to online' + bkey = bytes(key, encoding="utf8") + logFile = self.logDir + "/taosdlog.0" + i = 0 + while not os.path.exists(logFile): + sleep(0.1) + i += 1 + if i > 50: + break + with open(logFile) as f: + timeout = time.time() + 10 * 2 + while True: + line = f.readline().encode('utf-8') + if bkey in line: + break + if time.time() > timeout: + tdLog.exit('wait too long for taosd start') + tdLog.debug("the dnode:%d has been started." % (self.index)) + else: + tdLog.debug( + "wait 10 seconds for the dnode:%d to start." % + (self.index)) + time.sleep(10) + + def startWithoutSleep(self): + binPath = self.getPath() + + if (binPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found: %s" % binPath) + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + if self.valgrind == 0: + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s -c %s" % (binPath, self.cfgDir) + else: + if self.asan: + asanDir = "%s/sim/asan/dnode%d.asan" % ( + self.path, self.index) + cmd = "nohup %s -c %s > /dev/null 2> %s & " % ( + binPath, self.cfgDir, asanDir) + else: + cmd = "nohup %s -c %s > /dev/null 2>&1 & " % ( + binPath, self.cfgDir) + else: + valgrindCmdline = "valgrind --log-file=\"%s/../log/valgrind.log\" --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes"%self.cfgDir + if platform.system().lower() == 'windows': + cmd = "mintty -h never %s %s -c %s" % ( + valgrindCmdline, binPath, self.cfgDir) + else: + cmd = "nohup %s %s -c %s 2>&1 & " % ( + valgrindCmdline, binPath, self.cfgDir) + print(cmd) + + if (self.remoteIP == ""): + if os.system(cmd) != 0: + tdLog.exit(cmd) + else: + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].deployed=1\ntdDnodes.dnodes[%d].logDir=\"%%s/sim/dnode%%d/log\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.dnodes[%d].cfgDir=\"%%s/sim/dnode%%d/cfg\"%%(tdDnodes.dnodes[%d].path,%d)\ntdDnodes.startWithoutSleep(%d)"%(self.index-1,self.index-1,self.index-1,self.index,self.index-1,self.index-1,self.index,self.index)) + + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + + def stop(self): + if self.asan: + stopCmd = "%s -s stop -n dnode%d" % (self.execPath, self.index) + tdLog.info("execute script: " + stopCmd) + os.system(stopCmd) + return + + if (not self.remoteIP == ""): + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].running=1\ntdDnodes.dnodes[%d].stop()"%(self.index-1,self.index-1)) + tdLog.info("stop dnode%d"%self.index) + return + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + + onlyKillOnceWindows = 0 + while(processID): + if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + if platform.system().lower() == 'windows': + killCmd = "kill -INT %s > nul 2>&1" % processID + os.system(killCmd) + onlyKillOnceWindows = 1 + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + if not platform.system().lower() == 'windows': + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d > /dev/null" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + + def stoptaosd(self): + tdLog.debug("start to stop taosd on dnode: %d "% (self.index)) + # print(self.asan,self.running,self.remoteIP,self.valgrind) + if self.asan: + stopCmd = "%s -s stop -n dnode%d" % (self.execPath, self.index) + tdLog.info("execute script: " + stopCmd) + os.system(stopCmd) + return + + if (not self.remoteIP == ""): + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].running=1\ntdDnodes.dnodes[%d].stop()"%(self.index-1,self.index-1)) + tdLog.info("stop dnode%d"%self.index) + return + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + if platform.system().lower() == 'windows': + psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' | xargs)" % (self.index) + else: + psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}' | xargs" % (toBeKilled,self.index) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + + onlyKillOnceWindows = 0 + while(processID): + if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): + killCmd = "kill -INT %s > /dev/null 2>&1" % processID + if platform.system().lower() == 'windows': + killCmd = "kill -INT %s > nul 2>&1" % processID + os.system(killCmd) + onlyKillOnceWindows = 1 + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) + + def forcestop(self): + if self.asan: + stopCmd = "%s -s stop -n dnode%d -x SIGKILL" + \ + (self.execPath, self.index) + tdLog.info("execute script: " + stopCmd) + os.system(stopCmd) + return + + if (not self.remoteIP == ""): + self.remoteExec(self.cfgDict, "tdDnodes.dnodes[%d].running=1\ntdDnodes.dnodes[%d].forcestop()"%(self.index-1,self.index-1)) + return + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + if self.running != 0: + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + + onlyKillOnceWindows = 0 + while(processID): + if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): + killCmd = "kill -KILL %s > /dev/null 2>&1" % processID + os.system(killCmd) + onlyKillOnceWindows = 1 + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + for port in range(6030, 6041): + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if self.valgrind: + time.sleep(2) + + self.running = 0 + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) + + def startIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d up" % (self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def stopIP(self): + cmd = "sudo ifconfig lo:%d 192.168.0.%d down" % ( + self.index, self.index) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def cfg(self, option, value): + cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def getDnodeRootDir(self, index): + dnodeRootDir = os.path.join(self.path,"sim","psim","dnode%d" % index) + return dnodeRootDir + + def getDnodesRootDir(self): + dnodesRootDir = os.path.join(self.path,"sim","psim") + return dnodesRootDir + + +class TDDnodes: + def __init__(self): + self.dnodes = [] + self.dnodes.append(TDDnode(1)) + self.dnodes.append(TDDnode(2)) + self.dnodes.append(TDDnode(3)) + self.dnodes.append(TDDnode(4)) + self.dnodes.append(TDDnode(5)) + self.dnodes.append(TDDnode(6)) + self.dnodes.append(TDDnode(7)) + self.dnodes.append(TDDnode(8)) + self.dnodes.append(TDDnode(9)) + self.dnodes.append(TDDnode(10)) + self.simDeployed = False + self.testCluster = False + self.valgrind = 0 + self.asan = False + self.killValgrind = 0 + + def init(self, path, remoteIP = ""): + binPath = self.dnodes[0].getPath() + "/../../../" + # tdLog.debug("binPath %s" % (binPath)) + binPath = os.path.realpath(binPath) + # tdLog.debug("binPath real path %s" % (binPath)) + + if path == "": + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + for i in range(len(self.dnodes)): + self.dnodes[i].init(self.path, remoteIP) + self.sim = TDSimClient(self.path) + + def setTestCluster(self, value): + self.testCluster = value + + def setValgrind(self, value): + self.valgrind = value + + def setAsan(self, value): + self.asan = value + if value: + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + self.stopDnodesPath = os.path.abspath(self.path + "/community/tests/script/sh/stop_dnodes.sh") + self.stopDnodesSigintPath = os.path.abspath(self.path + "/community/tests/script/sh/sigint_stop_dnodes.sh") + else: + self.stopDnodesPath = os.path.abspath(self.path + "/tests/script/sh/stop_dnodes.sh") + self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh") + tdLog.info("run in address sanitizer mode") + + def setKillValgrind(self, value): + self.killValgrind = value + + def deploy(self, index, *updatecfgDict): + self.sim.setTestCluster(self.testCluster) + + if (self.simDeployed == False): + self.sim.deploy(updatecfgDict) + self.simDeployed = True + + self.check(index) + self.dnodes[index - 1].setTestCluster(self.testCluster) + self.dnodes[index - 1].setValgrind(self.valgrind) + self.dnodes[index - 1].setAsan(self.asan) + self.dnodes[index - 1].deploy(updatecfgDict) + + def cfg(self, index, option, value): + self.check(index) + self.dnodes[index - 1].cfg(option, value) + + def starttaosd(self, index): + self.check(index) + self.dnodes[index - 1].starttaosd() + + def stoptaosd(self, index): + self.check(index) + self.dnodes[index - 1].stoptaosd() + + def start(self, index): + self.check(index) + self.dnodes[index - 1].start() + + def startWithoutSleep(self, index): + self.check(index) + self.dnodes[index - 1].startWithoutSleep() + + def stop(self, index): + self.check(index) + self.dnodes[index - 1].stop() + + def getDataSize(self, index): + self.check(index) + return self.dnodes[index - 1].getDataSize() + + def forcestop(self, index): + self.check(index) + self.dnodes[index - 1].forcestop() + + def startIP(self, index): + self.check(index) + + if self.testCluster: + self.dnodes[index - 1].startIP() + + def stopIP(self, index): + self.check(index) + + if self.dnodes[index - 1].testCluster: + self.dnodes[index - 1].stopIP() + + def check(self, index): + if index < 1 or index > 10: + tdLog.exit("index:%d should on a scale of [1, 10]" % (index)) + + def StopAllSigint(self): + tdLog.info("stop all dnodes sigint, asan:%d" % self.asan) + if self.asan: + tdLog.info("execute script: %s" % self.stopDnodesSigintPath) + os.system(self.stopDnodesSigintPath) + tdLog.info("execute finished") + return + + def killProcesser(self, processerName): + if platform.system().lower() == 'windows': + killCmd = ("wmic process where name=\"%s.exe\" call terminate > NUL 2>&1" % processerName) + psCmd = ("wmic process where name=\"%s.exe\" | findstr \"%s.exe\"" % (processerName, processerName)) + else: + killCmd = ( + "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" + % processerName + ) + psCmd = ("ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % processerName) + + processID = "" + + try: + processID = subprocess.check_output(psCmd, shell=True) + while processID: + os.system(killCmd) + time.sleep(1) + try: + processID = subprocess.check_output(psCmd, shell=True) + except Exception as err: + processID = "" + tdLog.debug('**** kill pid warn: {err}') + except Exception as err: + processID = "" + tdLog.debug(f'**** find pid warn: {err}') + + + + def stopAll(self): + tdLog.info("stop all dnodes, asan:%d" % self.asan) + if platform.system().lower() != 'windows': + distro_id = distro.id() + else: + distro_id = "not alpine" + if self.asan and distro_id != "alpine": + tdLog.info("execute script: %s" % self.stopDnodesPath) + os.system(self.stopDnodesPath) + tdLog.info("execute finished") + return + + if (not self.dnodes[0].remoteIP == ""): + self.dnodes[0].remoteExec(self.dnodes[0].cfgDict, "for i in range(len(tdDnodes.dnodes)):\n tdDnodes.dnodes[i].running=1\ntdDnodes.stopAll()") + return + for i in range(len(self.dnodes)): + self.dnodes[i].stop() + + + if (distro_id == "alpine"): + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + print(processID) + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + elif platform.system().lower() == 'windows': + self.killProcesser("taosd") + self.killProcesser("tmq_sim") + self.killProcesser("taosBenchmark") + else: + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + if self.killValgrind == 1: + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + if platform.system().lower() == 'windows': + killCmd = "kill -TERM %s > nul 2>&1" % processID + else: + killCmd = "kill -TERM %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + + def getDnodesRootDir(self): + dnodesRootDir = "%s/sim" % (self.path) + return dnodesRootDir + + def getSimCfgPath(self): + return self.sim.getCfgDir() + + def getSimLogPath(self): + return self.sim.getLogDir() + + def addSimExtraCfg(self, option, value): + self.sim.addExtraCfg(option, value) + + def getAsan(self): + return self.asan + +tdDnodes = TDDnodes() \ No newline at end of file diff --git a/tests/army/frame/gettime.py b/tests/army/frame/gettime.py new file mode 100644 index 0000000000..d4a5e18dc9 --- /dev/null +++ b/tests/army/frame/gettime.py @@ -0,0 +1,65 @@ +################################################################### +# 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 time +from datetime import datetime + +class GetTime: + + def get_ms_timestamp(self,ts_str): + _ts_str = ts_str + if "+" in _ts_str: + timestamp = datetime.fromisoformat(_ts_str) + return int((timestamp-datetime.fromtimestamp(0,timestamp.tzinfo)).total_seconds())*1000+int(timestamp.microsecond / 1000) + if " " in ts_str: + p = ts_str.split(" ")[1] + if len(p) > 15 : + _ts_str = ts_str[:-3] + if ':' in _ts_str and '.' in _ts_str: + timestamp = datetime.strptime(_ts_str, "%Y-%m-%d %H:%M:%S.%f") + date_time = int(int(time.mktime(timestamp.timetuple()))*1000 + timestamp.microsecond/1000) + elif ':' in _ts_str and '.' not in _ts_str: + timestamp = datetime.strptime(_ts_str, "%Y-%m-%d %H:%M:%S") + date_time = int(int(time.mktime(timestamp.timetuple()))*1000 + timestamp.microsecond/1000) + else: + timestamp = datetime.strptime(_ts_str, "%Y-%m-%d") + date_time = int(int(time.mktime(timestamp.timetuple()))*1000 + timestamp.microsecond/1000) + return date_time + def get_us_timestamp(self,ts_str): + _ts = self.get_ms_timestamp(ts_str) * 1000 + if " " in ts_str: + p = ts_str.split(" ")[1] + if len(p) > 12: + us_ts = p[12:15] + _ts += int(us_ts) + return _ts + def get_ns_timestamp(self,ts_str): + _ts = self.get_us_timestamp(ts_str) *1000 + if " " in ts_str: + p = ts_str.split(" ")[1] + if len(p) > 15: + us_ts = p[15:] + _ts += int(us_ts) + return _ts + def time_transform(self,ts_str,precision): + date_time = [] + if precision == 'ms': + for i in ts_str: + date_time.append(self.get_ms_timestamp(i)) + elif precision == 'us': + for i in ts_str: + date_time.append(self.get_us_timestamp(i)) + elif precision == 'ns': + for i in ts_str: + date_time.append(self.get_ns_timestamp(i)) + return date_time \ No newline at end of file diff --git a/tests/army/frame/log.py b/tests/army/frame/log.py new file mode 100644 index 0000000000..000c907ea4 --- /dev/null +++ b/tests/army/frame/log.py @@ -0,0 +1,49 @@ +################################################################### +# 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 sys +import os +import time +import datetime +from distutils.log import warn as printf + + +class TDLog: + def __init__(self): + self.path = "" + + def info(self, info): + print("%s %s\n" % (datetime.datetime.now(), info)) + + def sleep(self, sec): + print("%s sleep %d seconds" % (datetime.datetime.now(), sec)) + time.sleep(sec) + + def debug(self, err): + print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err)) + + def success(self, info): + printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info)) + + def notice(self, err): + print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err)) + + def exit(self, err): + print("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err)) + sys.exit(1) + + def printNoPrefix(self, info): + print("\033[1;36m%s\033[0m" % (info)) + + +tdLog = TDLog() diff --git a/tests/army/frame/pathFinding.py b/tests/army/frame/pathFinding.py new file mode 100644 index 0000000000..df03f0ed68 --- /dev/null +++ b/tests/army/frame/pathFinding.py @@ -0,0 +1,83 @@ +################################################################### +# 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 os +from frame.log import * + + + +class TDFindPath: + """This class is for finding path within TDengine + """ + def __init__(self): + self.file = "" + + + def init(self, file): + """[summary] + + Args: + file (str): the file location you want to start the query. Generally using __file__ + """ + self.file = file + + def getTaosdemoPath(self): + """for finding the path of directory containing taosdemo + + Returns: + str: the path to directory containing taosdemo + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info(f"taosd found in {buildPath}") + return buildPath + "/build/bin/" + + def getTDenginePath(self): + """for finding the root path of TDengine + + Returns: + str: the root path of TDengine + """ + selfPath = os.path.dirname(os.path.realpath(self.file)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + print(projPath) + for root, dirs, files in os.walk(projPath): + if ("sim" in dirs): + print(root) + rootRealPath = os.path.realpath(root) + if (rootRealPath == ""): + tdLog.exit("TDengine not found!") + else: + tdLog.info(f"TDengine found in {rootRealPath}") + return rootRealPath + +tdFindPath = TDFindPath() \ No newline at end of file diff --git a/tests/army/frame/sql.py b/tests/army/frame/sql.py new file mode 100644 index 0000000000..d7dce2bc3e --- /dev/null +++ b/tests/army/frame/sql.py @@ -0,0 +1,655 @@ +################################################################### +# 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 sys +import os +import time +import datetime +import inspect +import traceback +import psutil +import shutil +import pandas as pd +from frame.log import * +from frame.constant import * + +# from datetime import timezone +import time + +def _parse_ns_timestamp(timestr): + dt_obj = datetime.datetime.strptime(timestr[:len(timestr)-3], "%Y-%m-%d %H:%M:%S.%f") + tz = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e9) + int(dt_obj.microsecond * 1000) + int(timestr[-3:]) + return tz + + +def _parse_datetime(timestr): + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + except ValueError: + pass + try: + return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + except ValueError: + pass + +class TDSql: + def __init__(self): + self.queryRows = 0 + self.queryCols = 0 + self.affectedRows = 0 + + def init(self, cursor, log=False): + self.cursor = cursor + + if (log): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + self.cursor.log(caller.filename + ".sql") + + def close(self): + self.cursor.close() + + def prepare(self, dbname="db", drop=True, **kwargs): + tdLog.info(f"prepare database:{dbname}") + s = 'reset query cache' + try: + self.cursor.execute(s) + except: + tdLog.notice("'reset query cache' is not supported") + if drop: + s = f'drop database if exists {dbname}' + self.cursor.execute(s) + s = f'create database {dbname}' + for k, v in kwargs.items(): + s += f" {k} {v}" + if "duration" not in kwargs: + s += " duration 300" + self.cursor.execute(s) + s = f'use {dbname}' + self.cursor.execute(s) + time.sleep(2) + + def error(self, sql, expectedErrno = None, expectErrInfo = None): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + expectErrNotOccured = True + + try: + self.cursor.execute(sql) + except BaseException as e: + expectErrNotOccured = False + self.errno = e.errno + error_info = repr(e) + self.error_info = ','.join(error_info[error_info.index('(')+1:-1].split(",")[:-1]).replace("'","") + # self.error_info = (','.join(error_info.split(",")[:-1]).split("(",1)[1:][0]).replace("'","") + if expectErrNotOccured: + tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql)) + else: + self.queryRows = 0 + self.queryCols = 0 + self.queryResult = None + + if expectedErrno != None: + if expectedErrno == self.errno: + tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) + else: + tdLog.exit("%s(%d) failed: sql:%s, errno %s occured, but not expected errno %s" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) + else: + tdLog.info("sql:%s, expect error occured" % (sql)) + + if expectErrInfo != None: + if expectErrInfo == self.error_info or expectErrInfo in self.error_info: + tdLog.info("sql:%s, expected expectErrInfo %s occured" % (sql, expectErrInfo)) + else: + tdLog.exit("%s(%d) failed: sql:%s, expectErrInfo %s occured, but not expected errno %s" % (caller.filename, caller.lineno, sql, self.error_info, expectErrInfo)) + else: + tdLog.info("sql:%s, expect error occured" % (sql)) + + return self.error_info + + def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None): + self.sql = sql + i=1 + while i <= queryTimes: + try: + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self.cursor.description) + + if count_expected_res is not None: + counter = 0 + while count_expected_res != self.queryResult[0][0]: + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + if counter < queryTimes: + counter += 0.5 + time.sleep(0.5) + else: + return False + if row_tag: + return self.queryResult + return self.queryRows + except Exception as e: + tdLog.notice("Try to query again, query times: %d "%i) + if i == queryTimes: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + i+=1 + time.sleep(1) + pass + + + def is_err_sql(self, sql): + err_flag = True + try: + self.cursor.execute(sql) + except BaseException: + err_flag = False + + return False if err_flag else True + + def getVariable(self, search_attr): + ''' + get variable of search_attr access "show variables" + ''' + try: + sql = 'show variables' + param_list = self.query(sql, row_tag=True) + for param in param_list: + if param[0] == search_attr: + return param[1], param_list + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + + def getColNameList(self, sql, col_tag=None): + self.sql = sql + try: + col_name_list = [] + col_type_list = [] + self.cursor.execute(sql) + for query_col in self.cursor.description: + col_name_list.append(query_col[0]) + col_type_list.append(query_col[1]) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + if col_tag: + return col_name_list, col_type_list + return col_name_list + + def waitedQuery(self, sql, expectRows, timeout): + tdLog.info("sql: %s, try to retrieve %d rows in %d seconds" % (sql, expectRows, timeout)) + self.sql = sql + try: + for i in range(timeout): + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + self.queryRows = len(self.queryResult) + self.queryCols = len(self.cursor.description) + tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + if self.queryRows >= expectRows: + return (self.queryRows, i) + time.sleep(1) + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + return (self.queryRows, timeout) + + def getRows(self): + return self.queryRows + + def checkRows(self, expectRows): + if self.queryRows == expectRows: + tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows)) + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows) + tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) + + def checkRows_range(self, excepte_row_list): + if self.queryRows in excepte_row_list: + tdLog.info(f"sql:{self.sql}, queryRows:{self.queryRows} in expect:{excepte_row_list}") + return True + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{self.sql}, queryRows:{self.queryRows} not in expect:{excepte_row_list}") + + def checkCols(self, expectCols): + if self.queryCols == expectCols: + tdLog.info("sql:%s, queryCols:%d == expect:%d" % (self.sql, self.queryCols, expectCols)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.queryCols, expectCols) + tdLog.exit("%s(%d) failed: sql:%s, queryCols:%d != expect:%d" % args) + + def checkRowCol(self, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, self.sql, row) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args) + if col < 0: + args = (caller.filename, caller.lineno, self.sql, row) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) + if row > self.queryRows: + args = (caller.filename, caller.lineno, self.sql, row, self.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col > self.queryCols: + args = (caller.filename, caller.lineno, self.sql, col, self.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + def checkDataType(self, row, col, dataType): + self.checkRowCol(row, col) + return self.cursor.istype(col, dataType) + + + def checkData(self, row, col, data, show = False): + if row >= self.queryRows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row+1, self.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col >= self.queryCols: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, col+1, self.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + + self.checkRowCol(row, col) + + if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed`` + if isinstance(data,str) : + if (len(data) >= 28): + if self.queryResult[row][col] == _parse_ns_timestamp(data): + if(show): + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + else: + if self.queryResult[row][col].astimezone(datetime.timezone.utc) == _parse_datetime(data).astimezone(datetime.timezone.utc): + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + if(show): + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + elif isinstance(data,int): + if len(str(data)) == 16: + precision = 'us' + elif len(str(data)) == 13: + precision = 'ms' + elif len(str(data)) == 19: + precision = 'ns' + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + success = False + if precision == 'ms': + dt_obj = self.queryResult[row][col] + ts = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1000) + int(dt_obj.microsecond/1000) + if ts == data: + success = True + elif precision == 'us': + dt_obj = self.queryResult[row][col] + ts = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e6) + int(dt_obj.microsecond) + if ts == data: + success = True + elif precision == 'ns': + if data == self.queryResult[row][col]: + success = True + if success: + if(show): + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + elif isinstance(data,datetime.datetime): + dt_obj = self.queryResult[row][col] + delt_data = data-datetime.datetime.fromtimestamp(0,data.tzinfo) + delt_result = self.queryResult[row][col] - datetime.datetime.fromtimestamp(0,self.queryResult[row][col].tzinfo) + if delt_data == delt_result: + if(show): + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + + if str(self.queryResult[row][col]) == str(data): + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + if(show): + tdLog.info("check successfully") + return + + elif isinstance(data, float): + if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + if(show): + tdLog.info("check successfully") + elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + if(show): + tdLog.info("check successfully") + + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + if(show): + tdLog.info("check successfully") + + # return true or false replace exit, no print out + def checkRowColNoExit(self, row, col): + caller = inspect.getframeinfo(inspect.stack()[2][0]) + if row < 0: + args = (caller.filename, caller.lineno, self.sql, row) + return False + if col < 0: + args = (caller.filename, caller.lineno, self.sql, row) + return False + if row > self.queryRows: + args = (caller.filename, caller.lineno, self.sql, row, self.queryRows) + return False + if col > self.queryCols: + args = (caller.filename, caller.lineno, self.sql, col, self.queryCols) + return False + + return True + + + # return true or false replace exit, no print out + def checkDataNoExit(self, row, col, data): + if self.checkRowColNoExit(row, col) == False: + return False + if self.queryResult[row][col] != data: + if self.cursor.istype(col, "TIMESTAMP"): + # suppose user want to check nanosecond timestamp if a longer data passed + if (len(data) >= 28): + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): + return True + else: + if self.queryResult[row][col] == _parse_datetime(data): + return True + return False + + if str(self.queryResult[row][col]) == str(data): + return True + elif isinstance(data, float): + if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: + return True + elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: + return True + else: + return False + else: + return False + + return True + + + # loop execute sql then sleep(waitTime) , if checkData ok break loop + def checkDataLoop(self, row, col, data, sql, loopCount, waitTime): + # loop check util checkData return true + for i in range(loopCount): + self.query(sql) + if self.checkDataNoExit(row, col, data) : + self.checkData(row, col, data) + return + time.sleep(waitTime) + + # last check + self.query(sql) + self.checkData(row, col, data) + + + def getData(self, row, col): + self.checkRowCol(row, col) + return self.queryResult[row][col] + + def getResult(self, sql): + self.sql = sql + try: + self.cursor.execute(sql) + self.queryResult = self.cursor.fetchall() + except Exception as e: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + return self.queryResult + + def executeTimes(self, sql, times): + for i in range(times): + try: + return self.cursor.execute(sql) + except BaseException: + time.sleep(1) + continue + + def execute(self, sql, queryTimes=30, show=False): + self.sql = sql + if show: + tdLog.info(sql) + i=1 + while i <= queryTimes: + try: + self.affectedRows = self.cursor.execute(sql) + return self.affectedRows + except Exception as e: + tdLog.notice("Try to execute sql again, query times: %d "%i) + if i == queryTimes: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, sql, repr(e)) + tdLog.notice("%s(%d) failed: sql:%s, %s" % args) + raise Exception(repr(e)) + i+=1 + time.sleep(1) + pass + + def checkAffectedRows(self, expectAffectedRows): + if self.affectedRows != expectAffectedRows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, self.affectedRows, expectAffectedRows) + tdLog.exit("%s(%d) failed: sql:%s, affectedRows:%d != expect:%d" % args) + + tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows)) + + def checkColNameList(self, col_name_list, expect_col_name_list): + if col_name_list == expect_col_name_list: + tdLog.info("sql:%s, col_name_list:%s == expect_col_name_list:%s" % (self.sql, col_name_list, expect_col_name_list)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, col_name_list, expect_col_name_list) + tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args) + + def __check_equal(self, elm, expect_elm): + if elm == expect_elm: + return True + if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple): + if len(elm) != len(expect_elm): + return False + if len(elm) == 0: + return True + for i in range(len(elm)): + flag = self.__check_equal(elm[i], expect_elm[i]) + if not flag: + return False + return True + return False + + def checkEqual(self, elm, expect_elm): + if elm == expect_elm: + tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm)) + return + if self.__check_equal(elm, expect_elm): + tdLog.info("sql:%s, elm:%s == expect_elm:%s" % (self.sql, elm, expect_elm)) + return + + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) + # tdLog.info("%s(%d) failed: sql:%s, elm:%s != expect_elm:%s" % args) + raise Exception("%s(%d) failed: sql:%s, elm:%s != expect_elm:%s" % args) + + def checkNotEqual(self, elm, expect_elm): + if elm != expect_elm: + tdLog.info("sql:%s, elm:%s != expect_elm:%s" % (self.sql, elm, expect_elm)) + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) + tdLog.info("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) + raise Exception + + def get_times(self, time_str, precision="ms"): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + if time_str[-1] not in TAOS_TIME_INIT: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {time_str} not a standard taos time init") + if precision not in TAOS_PRECISION: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {precision} not a standard taos time precision") + + if time_str[-1] == TAOS_TIME_INIT[0]: + times = int(time_str[:-1]) * TIME_NS + if time_str[-1] == TAOS_TIME_INIT[1]: + times = int(time_str[:-1]) * TIME_US + if time_str[-1] == TAOS_TIME_INIT[2]: + times = int(time_str[:-1]) * TIME_MS + if time_str[-1] == TAOS_TIME_INIT[3]: + times = int(time_str[:-1]) * TIME_S + if time_str[-1] == TAOS_TIME_INIT[4]: + times = int(time_str[:-1]) * TIME_M + if time_str[-1] == TAOS_TIME_INIT[5]: + times = int(time_str[:-1]) * TIME_H + if time_str[-1] == TAOS_TIME_INIT[6]: + times = int(time_str[:-1]) * TIME_D + if time_str[-1] == TAOS_TIME_INIT[7]: + times = int(time_str[:-1]) * TIME_W + if time_str[-1] == TAOS_TIME_INIT[8]: + times = int(time_str[:-1]) * TIME_N + if time_str[-1] == TAOS_TIME_INIT[9]: + times = int(time_str[:-1]) * TIME_Y + + if precision == "ms": + return int(times) + elif precision == "us": + return int(times*1000) + elif precision == "ns": + return int(times*1000*1000) + + def get_type(self, col): + if self.cursor.istype(col, "BOOL"): + return "BOOL" + if self.cursor.istype(col, "INT"): + return "INT" + if self.cursor.istype(col, "BIGINT"): + return "BIGINT" + if self.cursor.istype(col, "TINYINT"): + return "TINYINT" + if self.cursor.istype(col, "SMALLINT"): + return "SMALLINT" + if self.cursor.istype(col, "FLOAT"): + return "FLOAT" + if self.cursor.istype(col, "DOUBLE"): + return "DOUBLE" + if self.cursor.istype(col, "BINARY"): + return "BINARY" + if self.cursor.istype(col, "NCHAR"): + return "NCHAR" + if self.cursor.istype(col, "TIMESTAMP"): + return "TIMESTAMP" + if self.cursor.istype(col, "JSON"): + return "JSON" + if self.cursor.istype(col, "TINYINT UNSIGNED"): + return "TINYINT UNSIGNED" + if self.cursor.istype(col, "SMALLINT UNSIGNED"): + return "SMALLINT UNSIGNED" + if self.cursor.istype(col, "INT UNSIGNED"): + return "INT UNSIGNED" + if self.cursor.istype(col, "BIGINT UNSIGNED"): + return "BIGINT UNSIGNED" + + def taosdStatus(self, state): + tdLog.sleep(5) + pstate = 0 + for i in range(30): + pstate = 0 + pl = pspids() + for pid in pl: + try: + if psProcess(pid).name() == 'taosd': + print('have already started') + pstate = 1 + break + except psNoSuchProcess: + pass + if pstate == state :break + if state or pstate: + tdLog.sleep(1) + continue + pstate = 0 + break + + args=(pstate,state) + if pstate == state: + tdLog.info("taosd state is %d == expect:%d" %args) + else: + tdLog.exit("taosd state is %d != expect:%d" %args) + pass + + def haveFile(self, dir, state): + if os.path.exists(dir) and os.path.isdir(dir): + if not os.listdir(dir): + if state : + tdLog.exit("dir: %s is empty, expect: not empty" %dir) + else: + tdLog.info("dir: %s is empty, expect: empty" %dir) + else: + if state : + tdLog.info("dir: %s is not empty, expect: not empty" %dir) + else: + tdLog.exit("dir: %s is not empty, expect: empty" %dir) + else: + tdLog.exit("dir: %s doesn't exist" %dir) + def createDir(self, dir): + if os.path.exists(dir): + shrmtree(dir) + tdLog.info("dir: %s is removed" %dir) + os.makedirs( dir, 755 ) + tdLog.info("dir: %s is created" %dir) + pass + +tdSql = TDSql() diff --git a/tests/army/frame/sqlset.py b/tests/army/frame/sqlset.py new file mode 100644 index 0000000000..3a56090750 --- /dev/null +++ b/tests/army/frame/sqlset.py @@ -0,0 +1,70 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from sql import tdSql + +class TDSetSql: + def init(self, conn, logSql): + + self.stbname = 'stb' + + def set_create_normaltable_sql(self, ntbname='ntb', + column_dict={'ts':'timestamp','col1':'tinyint','col2':'smallint','col3':'int','col4':'bigint','col5': 'unsigned int','col6': 'unsigned tinyint','col7': 'unsigned smallint', + 'col8': 'unsigned int','col9': 'unsigned bigint','col10': 'float','col11': 'double','col12': 'bool','col13': 'binary(20)','col14': 'nchar(20)'}): + column_sql = '' + for k, v in column_dict.items(): + column_sql += f"{k} {v}," + create_ntb_sql = f'create table {ntbname} ({column_sql[:-1]})' + return create_ntb_sql + + def set_create_stable_sql(self,stbname='stb', + column_dict={'ts':'timestamp','col1':'tinyint','col2':'smallint','col3':'int','col4':'bigint','col5': 'unsigned int','col6': 'unsigned tinyint','col7': 'unsigned smallint', + 'col8': 'unsigned int','col9': 'unsigned bigint','col10': 'float','col11': 'double','col12': 'bool','col13': 'binary(20)','col14': 'nchar(20)'}, + tag_dict={'ts_tag':'timestamp','t1':'tinyint','t2':'smallint','t3':'int','t4':'bigint','t5': 'unsigned int','t6': 'unsigned tinyint','t7': 'unsigned smallint', + 't8': 'unsigned int','t9': 'unsigned bigint','t10': 'float','t11': 'double','t12': 'bool','t13': 'binary(20)','t14': 'nchar(20)'}): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}," + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}," + create_stb_sql = f'create table {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})' + return create_stb_sql + + def set_insertsql(self,column_dict,tbname,binary_str=None,nchar_str=None): + sql = '' + for k, v in column_dict.items(): + if v.lower() == 'timestamp' or v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or \ + v.lower() == 'tinyint unsigned' or v.lower() == 'smallint unsigned' or v.lower() == 'int unsigned' or v.lower() == 'bigint unsigned' or v.lower() == 'bool': + sql += '%d,' + elif v.lower() == 'float' or v.lower() == 'double': + sql += '%f,' + elif 'binary' in v.lower(): + sql += f'"{binary_str}%d",' + elif 'nchar' in v.lower(): + sql += f'"{nchar_str}%d",' + return (f'insert into {tbname} values({sql[:-1]})') + + def insert_values(self,column_dict,i,insert_sql,insert_list,ts): + for k, v in column_dict.items(): + if v.lower() in[ 'tinyint' , 'smallint' , 'int', 'bigint' , 'tinyint unsigned' , 'smallint unsigned' , 'int unsigned' , 'bigint unsigned'] or\ + 'binary' in v.lower() or 'nchar' in v.lower(): + insert_list.append(0 + i) + elif v.lower() == 'float' or v.lower() == 'double': + insert_list.append(0.1 + i) + elif v.lower() == 'bool': + insert_list.append(i % 2) + elif v.lower() == 'timestamp': + insert_list.append(ts + i) + tdSql.execute(insert_sql%(tuple(insert_list))) + \ No newline at end of file diff --git a/tests/army/frame/sub.py b/tests/army/frame/sub.py new file mode 100644 index 0000000000..1fa4dfa674 --- /dev/null +++ b/tests/army/frame/sub.py @@ -0,0 +1,44 @@ +################################################################### + # Copyright (c) 2020 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 sys +import os +import time +import datetime +from frame.log import * + +class TDSub: + def __init__(self): + self.consumedRows = 0 + self.consumedCols = 0 + + def init(self, sub): + self.sub = sub + + def close(self, keepProgress): + self.sub.close(keepProgress) + + def consume(self): + self.result = self.sub.consume() + self.result.fetch_all() + self.consumedRows = self.result.row_count + self.consumedCols = self.result.field_count + return self.consumedRows + + def checkRows(self, expectRows): + if self.consumedRows != expectRows: + tdLog.exit("consumed rows:%d != expect:%d" % (self.consumedRows, expectRows)) + tdLog.info("consumed rows:%d == expect:%d" % (self.consumedRows, expectRows)) + + +tdSub = TDSub() diff --git a/tests/army/frame/taosadapter.py b/tests/army/frame/taosadapter.py new file mode 100644 index 0000000000..7830aab08c --- /dev/null +++ b/tests/army/frame/taosadapter.py @@ -0,0 +1,261 @@ +import requests +from fabric2 import Connection +from frame.log import * +from frame.common import * + + +class TAdapter: + def __init__(self): + self.running = 0 + self.deployed = 0 + self.remoteIP = "" + self.taosadapter_cfg_dict = { + "debug" : True, + "taosConfigDir" : "", + "port" : 6041, + "logLevel" : "error", + "cors" : { + "allowAllOrigins" : True, + }, + "pool" : { + "maxConnect" : 4000, + "maxIdle" : 4000, + "idleTimeout" : "1h" + }, + "ssl" : { + "enable" : False, + "certFile" : "", + "keyFile" : "", + }, + "log" : { + "path" : "", + "rotationCount" : 30, + "rotationTime" : "24h", + "rotationSize" : "1GB", + "enableRecordHttpSql" : True, + "sqlRotationCount" : 2, + "sqlRotationTime" : "24h", + "sqlRotationSize" : "1GB", + }, + "monitor" : { + "collectDuration" : "3s", + "incgroup" : False, + "pauseQueryMemoryThreshold" : 70, + "pauseAllMemoryThreshold" : 80, + "identity" : "", + "writeToTD" : True, + "user" : "root", + "password" : "taosdata", + "writeInterval" : "30s" + }, + "opentsdb" : { + "enable" : True + }, + "influxdb" : { + "enable" : True + }, + "statsd" : { + "enable" : True + }, + "collectd" : { + "enable" : True + }, + "opentsdb_telnet" : { + "enable" : True + }, + "node_exporter" : { + "enable" : True + }, + "prometheus" : { + "enable" : True + }, + } + # TODO: add taosadapter env: + # 1. init cfg.toml.dict :OK + # 2. dump dict to toml : OK + # 3. update cfg.toml.dict :OK + # 4. check adapter exists : OK + # 5. deploy adapter cfg : OK + # 6. adapter start : OK + # 7. adapter stop + + def init(self, path, remoteIP=""): + self.path = path + self.remoteIP = remoteIP + binPath = get_path() + "/../../../" + binPath = os.path.realpath(binPath) + + if path == "": + self.path = os.path.abspath(binPath + "../../") + else: + self.path = os.path.realpath(path) + + if self.remoteIP: + try: + self.config = eval(remoteIP) + self.remote_conn = Connection(host=self.config["host"], port=self.config["port"], user=self.config["user"], connect_kwargs={'password':self.config["password"]}) + except Exception as e: + tdLog.notice(e) + + def update_cfg(self, update_dict :dict): + if not isinstance(update_dict, dict): + return + if "log" in update_dict and "path" in update_dict["log"]: + del update_dict["log"]["path"] + for key, value in update_dict.items(): + if key in ["cors", "pool", "ssl", "log", "monitor", "opentsdb", "influxdb", "statsd", "collectd", "opentsdb_telnet", "node_exporter", "prometheus"]: + if isinstance(value, dict): + for k, v in value.items(): + self.taosadapter_cfg_dict[key][k] = v + else: + self.taosadapter_cfg_dict[key] = value + + def check_adapter(self): + if get_path(tool="taosadapter"): + return False + else: + return True + + def remote_exec(self, updateCfgDict, execCmd): + remoteCfgDict = copy.deepcopy(updateCfgDict) + if "log" in remoteCfgDict and "path" in remoteCfgDict["log"]: + del remoteCfgDict["log"]["path"] + + remoteCfgDictStr = base64.b64encode(toml.dumps(remoteCfgDict).encode()).decode() + execCmdStr = base64.b64encode(execCmd.encode()).decode() + with self.remote_conn.cd((self.config["path"]+sys.path[0].replace(self.path, '')).replace('\\','/')): + self.remote_conn.run(f"python3 ./test.py -D {remoteCfgDictStr} -e {execCmdStr}" ) + + def cfg(self, option, value): + cmd = f"echo {option} = {value} >> {self.cfg_path}" + if os.system(cmd) != 0: + tdLog.exit(cmd) + + def deploy(self, *update_cfg_dict): + self.log_dir = os.path.join(self.path,"sim","dnode1","log") + self.cfg_dir = os.path.join(self.path,"sim","dnode1","cfg") + self.cfg_path = os.path.join(self.cfg_dir,"taosadapter.toml") + + cmd = f"touch {self.cfg_path}" + if os.system(cmd) != 0: + tdLog.exit(cmd) + + self.taosadapter_cfg_dict["log"]["path"] = self.log_dir + if bool(update_cfg_dict): + self.update_cfg(update_dict=update_cfg_dict) + + if (self.remoteIP == ""): + dict2toml(self.taosadapter_cfg_dict, self.cfg_path) + else: + self.remote_exec(self.taosadapter_cfg_dict, "tAdapter.deploy(update_cfg_dict)") + + self.deployed = 1 + + tdLog.debug(f"taosadapter is deployed and configured by {self.cfg_path}") + + def start(self): + bin_path = get_path(tool="taosadapter") + + if (bin_path == ""): + tdLog.exit("taosadapter not found!") + else: + tdLog.info(f"taosadapter found: {bin_path}") + + if platform.system().lower() == 'windows': + cmd = f"mintty -h never {bin_path} -c {self.cfg_path}" + else: + cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null & " + + if self.remoteIP: + self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()") + self.running = 1 + else: + os.system(f"rm -rf {self.log_dir}{os.sep}taosadapter*") + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug(f"taosadapter is running with {cmd} " ) + + time.sleep(0.1) + + taosadapter_port = self.taosadapter_cfg_dict["port"] + for i in range(5): + ip = 'localhost' + if self.remoteIP != "": + ip = self.remoteIP + url = f'http://{ip}:{taosadapter_port}/-/ping' + try: + r = requests.get(url) + if r.status_code == 200: + tdLog.info(f"the taosadapter has been started, using port:{taosadapter_port}") + break + except Exception: + tdLog.info(f"the taosadapter do not started!!!") + time.sleep(1) + + def start_taosadapter(self): + """ + use this method, must deploy taosadapter + """ + bin_path = get_path(tool="taosadapter") + + if (bin_path == ""): + tdLog.exit("taosadapter not found!") + else: + tdLog.info(f"taosadapter found: {bin_path}") + + if self.deployed == 0: + tdLog.exit("taosadapter is not deployed") + + if platform.system().lower() == 'windows': + cmd = f"mintty -h never {bin_path} -c {self.cfg_dir}" + else: + cmd = f"nohup {bin_path} -c {self.cfg_path} > /dev/null & " + + if self.remoteIP: + self.remote_exec(self.taosadapter_cfg_dict, f"tAdapter.deployed=1\ntAdapter.log_dir={self.log_dir}\ntAdapter.cfg_dir={self.cfg_dir}\ntAdapter.start()") + self.running = 1 + else: + if os.system(cmd) != 0: + tdLog.exit(cmd) + self.running = 1 + tdLog.debug(f"taosadapter is running with {cmd} " ) + + time.sleep(0.1) + + def stop(self, force_kill=False): + signal = "-9" if force_kill else "-15" + if self.remoteIP: + self.remote_exec(self.taosadapter_cfg_dict, "tAdapter.running=1\ntAdapter.stop()") + tdLog.info("stop taosadapter") + return + toBeKilled = "taosadapter" + if platform.system().lower() == 'windows': + psCmd = f"ps -ef|grep -w {toBeKilled}| grep -v grep | awk '{{print $2}}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + killCmd = "kill %s %s > nul 2>&1" % (signal, processID) + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + self.running = 0 + tdLog.debug(f"taosadapter is stopped by kill {signal}") + + else: + if self.running != 0: + psCmd = f"ps -ef|grep -w {toBeKilled}| grep -v grep | awk '{{print $2}}'" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + killCmd = "kill %s %s > /dev/null 2>&1" % (signal, processID) + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + port = 6041 + fuserCmd = f"fuser -k -n tcp {port} > /dev/null" + os.system(fuserCmd) + self.running = 0 + tdLog.debug(f"taosadapter is stopped by kill {signal}") + + + +tAdapter = TAdapter() diff --git a/tests/army/frame/taosdemoCfg.py b/tests/army/frame/taosdemoCfg.py new file mode 100644 index 0000000000..5f8198681e --- /dev/null +++ b/tests/army/frame/taosdemoCfg.py @@ -0,0 +1,465 @@ +################################################################### +# 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 sys +import os +import time +import datetime +import inspect +import psutil +import shutil +import json +from frame.log import * +from multiprocessing import cpu_count + + +# TODO: fully test the function. Handle exceptions. +# Handle json format not accepted by taosdemo + +### How to use TaosdemoCfg: +# Before you start: +# Make sure you understand how is taosdemo's JSON file structured. Because the python used does +# not support directory in directory for self objects, the config is being tear to different parts. +# Please make sure you understand which directory represent which part of which type of the file +# This module will reassemble the parts when creating the JSON file. +# +# Basic use example +# step 1:use self.append_sql_stb() to append the insert/query/subscribe directory into the module +# you can append many insert/query/subscribe directory, but pay attention about taosdemo's limit +# step 2:use alter function to alter the specific config +# step 3:use the generation function to generate the files +# +# step 1 and step 2 can be replaced with using import functions +class TDTaosdemoCfg: + def __init__(self): + self.insert_cfg = { + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": cpu_count(), + "create_table_thread_count": cpu_count(), + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 32766, + "max_sql_len": 32766, + "databases": None + } + + self.db = { + "name": 'db', + "drop": 'yes', + "replica": 1, + "duration": 10, + "cache": 16, + "blocks": 6, + "precision": "ms", + "keep": 3650, + "minRows": 100, + "maxRows": 4096, + "comp": 2, + "walLevel": 1, + "cachelast": 0, + "quorum": 1, + "fsync": 3000, + "update": 0 + } + + self.query_cfg = { + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "databases": "db", + "query_times": 2, + "query_mode": "taosc", + "specified_table_query": None, + "super_table_query": None + } + + self.table_query = { + "query_interval": 1, + "concurrent": 3, + "sqls": None + } + + self.stable_query = { + "stblname": "stb", + "query_interval": 1, + "threads": 3, + "sqls": None + } + + self.sub_cfg = { + "filetype": "subscribe", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "databases": "db", + "confirm_parameter_prompt": "no", + "specified_table_query": None, + "super_table_query": None + } + + self.table_sub = { + "concurrent": 1, + "mode": "sync", + "interval": 10000, + "restart": "yes", + "keepProgress": "yes", + "sqls": None + } + + self.stable_sub = { + "stblname": "stb", + "threads": 1, + "mode": "sync", + "interval": 10000, + "restart": "yes", + "keepProgress": "yes", + "sqls": None + } + + self.stbs = [] + self.stb_template = { + "name": "stb", + "child_table_exists": "no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 100, + "childtable_limit": 10, + "childtable_offset": 0, + "interlace_rows": 0, + "insert_interval": 0, + "max_sql_len": 32766, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT", "count": 1}], + "tags": [{"type": "BIGINT", "count": 1}] + } + + self.tb_query_sql = [] + self.tb_query_sql_template = { + "sql": "select last_row(*) from stb_0 ", + "result": "temp/query_res0.txt" + } + + self.stb_query_sql = [] + self.stb_query_sql_template = { + "sql": "select last_row(ts) from xxxx", + "result": "temp/query_res2.txt" + } + + self.tb_sub_sql = [] + self.tb_sub_sql_template = { + "sql": "select * from stb_0 ;", + "result": "temp/subscribe_res0.txt" + } + + self.stb_sub_sql = [] + self.stb_sub_sql_template = { + "sql": "select * from xxxx where ts > '2021-02-25 11:35:00.000' ;", + "result": "temp/subscribe_res1.txt" + } + + # The following functions are import functions for different dicts and lists + # except import_sql, all other import functions will a dict and overwrite the origional dict + # dict_in: the dict used to overwrite the target + def import_insert_cfg(self, dict_in): + self.insert_cfg = dict_in + + def import_db(self, dict_in): + self.db = dict_in + + def import_stbs(self, dict_in): + self.stbs = dict_in + + def import_query_cfg(self, dict_in): + self.query_cfg = dict_in + + def import_table_query(self, dict_in): + self.table_query = dict_in + + def import_stable_query(self, dict_in): + self.stable_query = dict_in + + def import_sub_cfg(self, dict_in): + self.sub_cfg = dict_in + + def import_table_sub(self, dict_in): + self.table_sub = dict_in + + def import_stable_sub(self, dict_in): + self.stable_sub = dict_in + + def import_sql(self, Sql_in, mode): + """used for importing the sql later used + + Args: + Sql_in (dict): the imported sql dict + mode (str): the sql storing location within TDTaosdemoCfg + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + """ + if mode == 'query_table': + self.tb_query_sql = Sql_in + elif mode == 'query_stable': + self.stb_query_sql = Sql_in + elif mode == 'sub_table': + self.tb_sub_sql = Sql_in + elif mode == 'sub_stable': + self.stb_sub_sql = Sql_in + # import functions end + + # The following functions are alter functions for different dicts + # Args: + # key: the key that is going to be modified + # value: the value of the key that is going to be modified + # if key = 'databases' | "specified_table_query" | "super_table_query"|"sqls" + # value will not be used + + def alter_insert_cfg(self, key, value): + + if key == 'databases': + self.insert_cfg[key] = [ + { + 'dbinfo': self.db, + 'super_tables': self.stbs + } + ] + else: + self.insert_cfg[key] = value + + def alter_db(self, key, value): + self.db[key] = value + + def alter_query_tb(self, key, value): + if key == "sqls": + self.table_query[key] = self.tb_query_sql + else: + self.table_query[key] = value + + def alter_query_stb(self, key, value): + if key == "sqls": + self.stable_query[key] = self.stb_query_sql + else: + self.stable_query[key] = value + + def alter_query_cfg(self, key, value): + if key == "specified_table_query": + self.query_cfg["specified_table_query"] = self.table_query + elif key == "super_table_query": + self.query_cfg["super_table_query"] = self.stable_query + else: + self.query_cfg[key] = value + + def alter_sub_cfg(self, key, value): + if key == "specified_table_query": + self.sub_cfg["specified_table_query"] = self.table_sub + elif key == "super_table_query": + self.sub_cfg["super_table_query"] = self.stable_sub + else: + self.sub_cfg[key] = value + + def alter_sub_stb(self, key, value): + if key == "sqls": + self.stable_sub[key] = self.stb_sub_sql + else: + self.stable_sub[key] = value + + def alter_sub_tb(self, key, value): + if key == "sqls": + self.table_sub[key] = self.tb_sub_sql + else: + self.table_sub[key] = value + # alter function ends + + # the following functions are for handling the sql lists + def append_sql_stb(self, target, value): + """for appending sql dict into specific sql list + + Args: + target (str): the target append list + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + value (dict): the sql dict going to be appended + """ + if target == 'insert_stbs': + self.stbs.append(value) + elif target == 'query_table': + self.tb_query_sql.append(value) + elif target == 'query_stable': + self.stb_query_sql.append(value) + elif target == 'sub_table': + self.tb_sub_sql.append(value) + elif target == 'sub_stable': + self.stb_sub_sql.append(value) + + def pop_sql_stb(self, target, index): + """for poping a sql dict from specific sql list + + Args: + target (str): the target append list + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + index (int): the sql dict that is going to be popped + """ + if target == 'insert_stbs': + self.stbs.pop(index) + elif target == 'query_table': + self.tb_query_sql.pop(index) + elif target == 'query_stable': + self.stb_query_sql.pop(index) + elif target == 'sub_table': + self.tb_sub_sql.pop(index) + elif target == 'sub_stable': + self.stb_sub_sql.pop(index) + # sql list modification function end + + # The following functions are get functions for different dicts + def get_db(self): + return self.db + + def get_stb(self): + return self.stbs + + def get_insert_cfg(self): + return self.insert_cfg + + def get_query_cfg(self): + return self.query_cfg + + def get_tb_query(self): + return self.table_query + + def get_stb_query(self): + return self.stable_query + + def get_sub_cfg(self): + return self.sub_cfg + + def get_tb_sub(self): + return self.table_sub + + def get_stb_sub(self): + return self.stable_sub + + def get_sql(self, target): + """general get function for all sql lists + + Args: + target (str): the sql list want to get + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + """ + if target == 'query_table': + return self.tb_query_sql + elif target == 'query_stable': + return self.stb_query_sql + elif target == 'sub_table': + return self.tb_sub_sql + elif target == 'sub_stable': + return self.stb_sub_sql + + def get_template(self, target): + """general get function for the default sql template + + Args: + target (str): the sql list want to get + format: 'fileType_tableType' + fileType: query, sub + tableType: table, stable + unique: 'insert_stbs' + """ + if target == 'insert_stbs': + return self.stb_template + elif target == 'query_table': + return self.tb_query_sql_template + elif target == 'query_stable': + return self.stb_query_sql_template + elif target == 'sub_table': + return self.tb_sub_sql_template + elif target == 'sub_stable': + return self.stb_sub_sql_template + else: + print(f'did not find {target}') + + # the folloing are the file generation functions + """defalut document: + generator functio for generating taosdemo json file + will assemble the dicts and dump the final json + + Args: + pathName (str): the directory wanting the json file to be + fileName (str): the name suffix of the json file + Returns: + str: [pathName]/[filetype]_[filName].json + """ + + def generate_insert_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/insert_{fileName}.json' + self.alter_insert_cfg('databases', None) + with open(cfgFileName, 'w') as file: + json.dump(self.insert_cfg, file) + return cfgFileName + + def generate_query_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/query_{fileName}.json' + self.alter_query_tb('sqls', None) + self.alter_query_stb('sqls', None) + self.alter_query_cfg('specified_table_query', None) + self.alter_query_cfg('super_table_query', None) + with open(cfgFileName, 'w') as file: + json.dump(self.query_cfg, file) + return cfgFileName + + def generate_subscribe_cfg(self, pathName, fileName): + cfgFileName = f'{pathName}/subscribe_{fileName}.json' + self.alter_sub_tb('sqls', None) + self.alter_sub_stb('sqls', None) + self.alter_sub_cfg('specified_table_query', None) + self.alter_sub_cfg('super_table_query', None) + with open(cfgFileName, 'w') as file: + json.dump(self.sub_cfg, file) + return cfgFileName + # file generation functions ends + + def drop_cfg_file(self, fileName): + os.remove(f'{fileName}') + + +taosdemoCfg = TDTaosdemoCfg() diff --git a/tests/army/frame/types.py b/tests/army/frame/types.py new file mode 100644 index 0000000000..218a477026 --- /dev/null +++ b/tests/army/frame/types.py @@ -0,0 +1,38 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from enum import Enum + +class TDSmlProtocolType(Enum): + ''' + Schemaless Protocol types + 0 - unknown + 1 - InfluxDB Line Protocol + 2 - OpenTSDB Telnet Protocl + 3 - OpenTSDB JSON Protocol + ''' + UNKNOWN = 0 + LINE = 1 + TELNET = 2 + JSON = 3 + +class TDSmlTimestampType(Enum): + NOT_CONFIGURED = 0 + HOUR = 1 + MINUTE = 2 + SECOND = 3 + MILLI_SECOND = 4 + MICRO_SECOND = 5 + NANO_SECOND = 6 + + diff --git a/tests/army/loop.sh b/tests/army/loop.sh new file mode 100755 index 0000000000..b3bc9728de --- /dev/null +++ b/tests/army/loop.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set -e +#set -x + +CMD_NAME= +LOOP_TIMES=5 +SLEEP_TIME=0 + +while getopts "hf:t:s:" arg +do + case $arg in + f) + CMD_NAME=$OPTARG + ;; + t) + LOOP_TIMES=$OPTARG + ;; + s) + SLEEP_TIME=$OPTARG + ;; + h) + echo "Usage: $(basename $0) -f [cmd name] " + echo " -t [loop times] " + echo " -s [sleep time] " + exit 0 + ;; + ?) + echo "unknow argument" + ;; + esac +done + +echo LOOP_TIMES ${LOOP_TIMES} +echo CMD_NAME ${CMD_NAME} +echo SLEEP_TIME ${SLEEP_TIME} + +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' + +for ((i=0; i<$LOOP_TIMES; i++ )) +do + echo -e $GREEN loop $i $NC + echo -e $GREEN cmd $CMD_NAME $NC + $CMD_NAME + sleep ${SLEEP_TIME} +done diff --git a/tests/army/pytest.sh b/tests/army/pytest.sh new file mode 100755 index 0000000000..bae0fdf278 --- /dev/null +++ b/tests/army/pytest.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set +e +#set -x +if [[ "$OSTYPE" == "darwin"* ]]; then + TD_OS="Darwin" +else + OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2) + len=$(echo ${#OS}) + len=$((len - 2)) + TD_OS=$(echo -ne ${OS:1:${len}} | cut -d" " -f1) +fi + +UNAME_BIN=$(which uname) +OS_TYPE=$($UNAME_BIN) + +cd . + +# Get responsible directories +CODE_DIR=$(dirname $0) +CODE_DIR=$(pwd) + +IN_TDINTERNAL="community" +if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + +TOP_DIR=$(pwd) +TAOSD_DIR=$(find . -name "taosd" | grep bin | head -n1) + +cut_opt="-f " + +if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then + BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2,3) +else + BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2) +fi + +declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR +declare -x SIM_DIR=$TOP_DIR/sim +PROGRAM=$BUILD_DIR/build/bin/tsim +PRG_DIR=$SIM_DIR/tsim +ASAN_DIR=$SIM_DIR/asan + +chmod -R 777 $PRG_DIR +echo "------------------------------------------------------------------------" +echo "Start TDengine Testing Case ..." +echo "BUILD_DIR: $BUILD_DIR" +echo "SIM_DIR : $SIM_DIR" +echo "CODE_DIR : $CODE_DIR" +echo "ASAN_DIR : $ASAN_DIR" + +# prevent delete / folder or /usr/bin +if [ ${#SIM_DIR} -lt 10 ]; then + echo "len(SIM_DIR) < 10 , danger so exit. SIM_DIR=$SIM_DIR" + exit 1 +fi + +rm -rf $SIM_DIR/* + +mkdir -p $PRG_DIR +mkdir -p $ASAN_DIR + +cd $CODE_DIR +ulimit -n 600000 +ulimit -c unlimited + +#sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e + +echo "ExcuteCmd:" $* + +if [[ "$TD_OS" == "Alpine" ]]; then + $* +else + AsanFile=$ASAN_DIR/psim.info + echo "AsanFile:" $AsanFile + + unset LD_PRELOAD + #export LD_PRELOAD=libasan.so.5 + #export LD_PRELOAD=$(gcc -print-file-name=libasan.so) + export LD_PRELOAD="$(realpath "$(gcc -print-file-name=libasan.so)") $(realpath "$(gcc -print-file-name=libstdc++.so)")" + echo "Preload AsanSo:" $? + + $* -a 2>$AsanFile + + unset LD_PRELOAD + for ((i = 1; i <= 20; i++)); do + AsanFileLen=$(cat $AsanFile | wc -l) + echo "AsanFileLen:" $AsanFileLen + if [ $AsanFileLen -gt 10 ]; then + break + fi + sleep 1 + done + # check case successful + AsanFileSuccessLen=$(grep -w "successfully executed" $AsanFile | wc -l) + echo "AsanFileSuccessLen:" $AsanFileSuccessLen + + if [ $AsanFileSuccessLen -gt 0 ]; then + echo "Execute script successfully and check asan" + $CODE_DIR/../script/sh/checkAsan.sh + else + echo "Execute script failure" + exit 1 + fi +fi diff --git a/tests/army/test.py b/tests/army/test.py new file mode 100644 index 0000000000..cc114e0d16 --- /dev/null +++ b/tests/army/test.py @@ -0,0 +1,688 @@ +#!/usr/bin/python +################################################################### +# 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 +# +################################################################### +# install pip +# pip install src/connector/python/ + +# -*- coding: utf-8 -*- +import os +import sys +import getopt +import subprocess +import time +import base64 +import json +import platform +import socket +import threading +import importlib + +import toml + +from frame.log import * +from frame.dnodes import * +from frame.cases import * +from frame.cluster import * +from frame.taosadapter import * + +import taos +import taosrest +import taosws + +def checkRunTimeError(): + import win32gui + timeCount = 0 + while 1: + time.sleep(1) + timeCount = timeCount + 1 + print("checkRunTimeError",timeCount) + if (timeCount>600): + print("stop the test.") + os.system("TASKKILL /F /IM taosd.exe") + os.system("TASKKILL /F /IM taos.exe") + os.system("TASKKILL /F /IM tmq_sim.exe") + os.system("TASKKILL /F /IM mintty.exe") + os.system("TASKKILL /F /IM python.exe") + quit(0) + hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library") + if hwnd: + os.system("TASKKILL /F /IM taosd.exe") + +# +# run case on previous cluster +# +def runOnPreviousCluster(host, config, fileName): + print("enter run on previeous") + + # load case module + sep = "/" + if platform.system().lower() == 'windows': + sep = os.sep + moduleName = fileName.replace(".py", "").replace(sep, ".") + uModule = importlib.import_module(moduleName) + case = uModule.TDTestCase() + + # create conn + conn = taos.connect(host, config) + + # run case + case.init(conn, False) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + tdLog.exit("%s failed" % (fileName)) + # stop + case.stop() + + +if __name__ == "__main__": + + # + # analysis paramaters + # + fileName = "all" + deployPath = "" + masterIp = "" + testCluster = False + valgrind = 0 + killValgrind = 1 + logSql = True + stop = 0 + restart = False + dnodeNums = 1 + mnodeNums = 0 + updateCfgDict = {} + adapter_cfg_dict = {} + execCmd = "" + queryPolicy = 1 + createDnodeNums = 1 + restful = False + websocket = False + replicaVar = 1 + asan = False + independentMnode = False + previousCluster = False + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:M:Q:C:RWD:n:i:aP', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums','mnodeNums','queryPolicy','createDnodeNums','restful','websocket','adaptercfgupdate','replicaVar','independentMnode','previous']) + for key, value in opts: + if key in ['-h', '--help']: + tdLog.printNoPrefix( + 'A collection of test cases written using Python') + tdLog.printNoPrefix('-f Name of test case file written by Python') + tdLog.printNoPrefix('-p Deploy Path for Simulator') + tdLog.printNoPrefix('-m Master Ip for Simulator') + tdLog.printNoPrefix('-l logSql Flag') + tdLog.printNoPrefix('-s stop All dnodes') + tdLog.printNoPrefix('-c Test Cluster Flag') + tdLog.printNoPrefix('-g valgrind Test Flag') + tdLog.printNoPrefix('-r taosd restart test') + tdLog.printNoPrefix('-d update cfg dict, base64 json str') + tdLog.printNoPrefix('-k not kill valgrind processer') + tdLog.printNoPrefix('-e eval str to run') + tdLog.printNoPrefix('-N start dnodes numbers in clusters') + tdLog.printNoPrefix('-M create mnode numbers in clusters') + tdLog.printNoPrefix('-Q set queryPolicy in one dnode') + tdLog.printNoPrefix('-C create Dnode Numbers in one cluster') + tdLog.printNoPrefix('-R restful realization form') + tdLog.printNoPrefix('-W websocket connection') + tdLog.printNoPrefix('-D taosadapter update cfg dict ') + tdLog.printNoPrefix('-n the number of replicas') + tdLog.printNoPrefix('-i independentMnode Mnode') + tdLog.printNoPrefix('-a address sanitizer mode') + tdLog.printNoPrefix('-P run case with [P]revious cluster, do not create new cluster to run case.') + + sys.exit(0) + + if key in ['-r', '--restart']: + restart = True + + if key in ['-f', '--file']: + fileName = value + + if key in ['-p', '--path']: + deployPath = value + + if key in ['-m', '--master']: + masterIp = value + + if key in ['-l', '--logSql']: + if (value.upper() == "TRUE"): + logSql = True + elif (value.upper() == "FALSE"): + logSql = False + else: + tdLog.printNoPrefix("logSql value %s is invalid" % logSql) + sys.exit(0) + + if key in ['-c', '--cluster']: + testCluster = True + + if key in ['-g', '--valgrind']: + valgrind = 1 + + if key in ['-s', '--stop']: + stop = 1 + + if key in ['-d', '--updateCfgDict']: + try: + updateCfgDict = eval(base64.b64decode(value.encode()).decode()) + except: + print('updateCfgDict convert fail.') + sys.exit(0) + + if key in ['-k', '--killValgrind']: + killValgrind = 1 + + if key in ['-e', '--execCmd']: + try: + execCmd = base64.b64decode(value.encode()).decode() + except: + print('execCmd run fail.') + sys.exit(0) + + if key in ['-N', '--dnodeNums']: + dnodeNums = value + + if key in ['-M', '--mnodeNums']: + mnodeNums = value + + if key in ['-Q', '--queryPolicy']: + queryPolicy = value + + if key in ['-C', '--createDnodeNums']: + createDnodeNums = value + + if key in ['-i', '--independentMnode']: + independentMnode = value + + if key in ['-R', '--restful']: + restful = True + + if key in ['-W', '--websocket']: + websocket = True + + if key in ['-a', '--asan']: + asan = True + + if key in ['-D', '--adaptercfgupdate']: + try: + adaptercfgupdate = eval(base64.b64decode(value.encode()).decode()) + except: + print('adapter cfg update convert fail.') + sys.exit(0) + + if key in ['-n', '--replicaVar']: + replicaVar = value + + if key in ['-P', '--previous']: + previousCluster = True + + # + # do exeCmd command + # + if not execCmd == "": + if restful or websocket: + tAdapter.init(deployPath) + else: + tdDnodes.init(deployPath) + print(execCmd) + exec(execCmd) + quit() + + # + # do stop option + # + if (stop != 0): + if (valgrind == 0): + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + + killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + for port in range(6030, 6041): + usePortPID = "lsof -i tcp:%d | grep LISTEN | awk '{print $2}'" % port + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = "kill -TERM %s" % processID + os.system(killCmd) + fuserCmd = "fuser -k -n tcp %d" % port + os.system(fuserCmd) + if valgrind: + time.sleep(2) + + if restful or websocket: + toBeKilled = "taosadapter" + + # killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled + killCmd = f"pkill {toBeKilled}" + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + # psCmd = f"pgrep {toBeKilled}" + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + port = 6041 + usePortPID = f"lsof -i tcp:{port} | grep LISTEN | awk '{{print $2}}'" + processID = subprocess.check_output(usePortPID, shell=True) + + if processID: + killCmd = f"kill -TERM {processID}" + os.system(killCmd) + fuserCmd = f"fuser -k -n tcp {port}" + os.system(fuserCmd) + + tdLog.info('stop taosadapter') + + tdLog.info('stop All dnodes') + + # + # get hostname + # + if masterIp == "": + host = socket.gethostname() + else: + try: + config = eval(masterIp) + host = config["host"] + except Exception as r: + host = masterIp + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + # + # do previousCluster option + # + if previousCluster: + tdDnodes.init(deployPath, masterIp) + runOnPreviousCluster(host, tdDnodes.getSimCfgPath(), fileName) + tdLog.info("run on previous cluster end.") + quit() + + # + # windows run + # + if platform.system().lower() == 'windows': + fileName = fileName.replace("/", os.sep) + if (masterIp == "" and not fileName == "0-others\\udf_create.py"): + threading.Thread(target=checkRunTimeError,daemon=True).start() + tdLog.info("Procedures for testing self-deployment") + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + key_word = 'tdCases.addWindows' + is_test_framework = 0 + try: + if key_word in open(fileName, encoding='UTF-8').read(): + is_test_framework = 1 + except Exception as r: + print(r) + updateCfgDictStr = '' + # adapter_cfg_dict_str = '' + if is_test_framework: + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + if ((json.dumps(updateCfgDict) == '{}') and hasattr(ucase, 'updatecfgDict')): + updateCfgDict = ucase.updatecfgDict + updateCfgDictStr = "-d %s"%base64.b64encode(json.dumps(updateCfgDict).encode()).decode() + if ((json.dumps(adapter_cfg_dict) == '{}') and hasattr(ucase, 'taosadapter_cfg_dict')): + adapter_cfg_dict = ucase.taosadapter_cfg_dict + # adapter_cfg_dict_str = f"-D {base64.b64encode(toml.dumps(adapter_cfg_dict).encode()).decode()}" + except Exception as r: + print(r) + else: + pass + # if restful: + tAdapter.init(deployPath, masterIp) + tAdapter.stop(force_kill=True) + + if dnodeNums == 1 : + tdDnodes.deploy(1,updateCfgDict) + tdDnodes.start(1) + tdCases.logSql(logSql) + if restful or websocket: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.info(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + else : + tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) + dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode) + tdDnodes = ClusterDnodes(dnodeslist) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + for dnode in tdDnodes.dnodes: + tdDnodes.deploy(dnode.index, updateCfgDict) + for dnode in tdDnodes.dnodes: + tdDnodes.starttaosd(dnode.index) + tdCases.logSql(logSql) + + if restful or websocket: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + # tdLog.info(tdDnodes.getSimCfgPath(),host) + if createDnodeNums == 1: + createDnodeNums=dnodeNums + else: + createDnodeNums=createDnodeNums + cluster.create_dnode(conn,createDnodeNums) + cluster.create_mnode(conn,mnodeNums) + try: + if cluster.check_dnode(conn) : + print("check dnode ready") + except Exception as r: + print(r) + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.info(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + + if ucase is not None and hasattr(ucase, 'noConn') and ucase.noConn == True: + conn = None + else: + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + + if fileName == "all": + tdCases.runAllWindows(conn) + else: + tdCases.runOneWindows(conn, fileName, replicaVar) + + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneWindows(conn, sp[0] + "_" + "restart.py", replicaVar) + else: + tdLog.info("not need to query") + else: + tdDnodes.setKillValgrind(killValgrind) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.setAsan(asan) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addLinux' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace("/", ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + if (json.dumps(updateCfgDict) == '{}'): + updateCfgDict = ucase.updatecfgDict + if (json.dumps(adapter_cfg_dict) == '{}'): + adapter_cfg_dict = ucase.taosadapter_cfg_dict + except: + pass + + if restful or websocket: + tAdapter.init(deployPath, masterIp) + tAdapter.stop(force_kill=True) + + if dnodeNums == 1 : + # dnode is one + tdDnodes.deploy(1,updateCfgDict) + tdDnodes.start(1) + tdCases.logSql(logSql) + + if restful or websocket: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + # tdSql.init(conn.cursor()) + # tdSql.execute("create qnode on dnode 1") + # tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy) + # tdSql.query("show local variables;") + # for i in range(tdSql.queryRows): + # if tdSql.queryResult[i][0] == "queryPolicy" : + # if int(tdSql.queryResult[i][1]) == int(queryPolicy): + # tdLog.info('alter queryPolicy to %d successfully'%queryPolicy) + # else : + # tdLog.debug(tdSql.queryResult) + # tdLog.exit("alter queryPolicy to %d failed"%queryPolicy) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.info(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + + else : + # dnode > 1 cluster + tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums)) + print(independentMnode,"independentMnode valuse") + dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode) + tdDnodes = ClusterDnodes(dnodeslist) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.setAsan(asan) + tdDnodes.stopAll() + for dnode in tdDnodes.dnodes: + tdDnodes.deploy(dnode.index,updateCfgDict) + for dnode in tdDnodes.dnodes: + tdDnodes.starttaosd(dnode.index) + tdCases.logSql(logSql) + + if restful or websocket: + tAdapter.deploy(adapter_cfg_dict) + tAdapter.start() + + # create taos connect + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + print(tdDnodes.getSimCfgPath(),host) + if createDnodeNums == 1: + createDnodeNums=dnodeNums + else: + createDnodeNums=createDnodeNums + cluster.create_dnode(conn,createDnodeNums) + cluster.create_mnode(conn,mnodeNums) + + try: + if cluster.check_dnode(conn) : + print("check dnode ready") + except Exception as r: + print(r) + + # do queryPolicy option + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.info(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + + + # run case + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + + if fileName == "all": + tdCases.runAllLinux(conn) + else: + tdCases.runOneLinux(conn, fileName, replicaVar) + + # do restart option + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041",timezone="utc") + elif websocket: + conn = taosws.connect(f"taosws://root:taosdata@{host}:6041") + else: + conn = taos.connect(host=f"{host}", config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py", replicaVar) + else: + tdLog.info("not need to query") + + # close for end + if conn is not None: + conn.close() + if asan: + tdDnodes.StopAllSigint() + tdLog.info("Address sanitizer mode finished") + sys.exit(0) diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index 758d28948d..40d2e2a887 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -65,7 +65,7 @@ class TDTestCase: tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 24) + tdSql.checkData(0, 0, 26) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 3) @@ -77,7 +77,7 @@ class TDTestCase: tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v desc;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 24) + tdSql.checkData(0, 0, 26) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 5) @@ -93,7 +93,7 @@ class TDTestCase: tdSql.checkData(1, 1, 'performance_schema') tdSql.checkData(0, 0, 3) tdSql.checkData(0, 1, 'tbl_count') - tdSql.checkData(2, 0, 24) + tdSql.checkData(2, 0, 26) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -106,7 +106,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 32) + tdSql.checkData(0, 0, 34) tdSql.execute('create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') @@ -189,7 +189,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 24) + tdSql.checkData(3, 0, 26) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -204,7 +204,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 24) + tdSql.checkData(3, 0, 26) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -215,7 +215,7 @@ class TDTestCase: tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(1, 0, 5) tdSql.checkData(1, 1, 'performance_schema') - tdSql.checkData(2, 0, 24) + tdSql.checkData(2, 0, 26) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 33) + tdSql.checkData(0, 0, 35) tdSql.execute('drop database tbl_count') diff --git a/tests/docs-examples-test/csharp.sh b/tests/docs-examples-test/csharp.sh index c08ffd6d62..9d7867d829 100644 --- a/tests/docs-examples-test/csharp.sh +++ b/tests/docs-examples-test/csharp.sh @@ -11,10 +11,9 @@ dotnet run --project connect/connect.csproj taos -s "drop database if exists power" dotnet run --project sqlInsert/sqlinsert.csproj dotnet run --project query/query.csproj -dotnet run --project asyncQuery/asyncquery.csproj -dotnet run --project subscribe/subscribe.csproj +#dotnet run --project subscribe/subscribe.csproj -taos -s "drop topic if exists topic_example" +#taos -s "drop topic if exists topic_example" taos -s "drop database if exists power" dotnet run --project stmtInsert/stmtinsert.csproj @@ -28,10 +27,12 @@ taos -s "drop database if exists test" dotnet run --project optsJSON/optsJSON.csproj taos -s "create database if not exists test" +taos -s "drop database if exists power" 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 power" +dotnet run --project wsStmt/wsStmt.csproj taos -s "drop database if exists test" taos -s "drop database if exists power" diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 549e24b0a6..8edfb352ab 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -5,6 +5,9 @@ #unit-test ,,y,unit-test,bash test.sh +#army-test +,,y,army,./pytest.sh python3 ./test.py -f empty.py + #system test ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/stream_basic.py ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/scalar_function.py @@ -23,7 +26,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/pause_resume_test.py #,,n,system-test,python3 ./test.py -f 8-stream/vnode_restart.py -N 4 #,,n,system-test,python3 ./test.py -f 8-stream/snode_restart.py -N 4 -#,,n,system-test,python3 ./test.py -f 8-stream/snode_restart_with_checkpoint.py -N 4 +,,n,system-test,python3 ./test.py -f 8-stream/snode_restart_with_checkpoint.py -N 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname_vgroup.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stbJoin.py @@ -240,6 +243,7 @@ e ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/compress_tsz1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/compress_tsz2.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/view/non_marterial_view/test_view.py +,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/test_show_table_distributed.py ,,n,system-test,python3 ./test.py -f 0-others/compatibility.py ,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py ,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index c05df0a852..99d166ee33 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -78,7 +78,7 @@ class TDSql: self.cursor.execute(s) time.sleep(2) - def error(self, sql, expectedErrno = None, expectErrInfo = None): + def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True): caller = inspect.getframeinfo(inspect.stack()[1][0]) expectErrNotOccured = True @@ -97,21 +97,30 @@ class TDSql: self.queryCols = 0 self.queryResult = None - if expectedErrno != None: - if expectedErrno == self.errno: - tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) - else: - tdLog.exit("%s(%d) failed: sql:%s, errno %s occured, but not expected errno %s" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) - else: - tdLog.info("sql:%s, expect error occured" % (sql)) + if fullMatched: + if expectedErrno != None: + if expectedErrno == self.errno: + tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) + else: + tdLog.exit("%s(%d) failed: sql:%s, errno '%s' occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) - if expectErrInfo != None: - if expectErrInfo == self.error_info or expectErrInfo in self.error_info: - tdLog.info("sql:%s, expected expectErrInfo %s occured" % (sql, expectErrInfo)) - else: - tdLog.exit("%s(%d) failed: sql:%s, expectErrInfo %s occured, but not expected errno %s" % (caller.filename, caller.lineno, sql, self.error_info, expectErrInfo)) + if expectErrInfo != None: + if expectErrInfo == self.error_info: + tdLog.info("sql:%s, expected expectErrInfo '%s' occured" % (sql, expectErrInfo)) + else: + tdLog.exit("%s(%d) failed: sql:%s, expectErrInfo '%s' occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.error_info, expectErrInfo)) else: - tdLog.info("sql:%s, expect error occured" % (sql)) + if expectedErrno != None: + if expectedErrno in self.errno: + tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) + else: + tdLog.exit("%s(%d) failed: sql:%s, errno '%s' occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) + + if expectErrInfo != None: + if expectErrInfo in self.error_info: + tdLog.info("sql:%s, expected expectErrInfo '%s' occured" % (sql, expectErrInfo)) + else: + tdLog.exit("%s(%d) failed: sql:%s, expectErrInfo %s occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.error_info, expectErrInfo)) return self.error_info diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index f49a8e0a7d..8bf0fb4700 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -58,7 +58,7 @@ endi sql select tbname from information_schema.ins_tables; print $rows $data00 -if $rows != 33 then +if $rows != 35 then return -1 endi if $data00 != @ins_tables@ then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index 6e65852dcc..315a39e56d 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -53,7 +53,7 @@ sql select stable_name,count(table_name) from information_schema.ins_tables grou if $rows != 3 then return -1 endi -if $data01 != 30 then +if $data01 != 32 then return -1 endi if $data11 != 10 then @@ -72,7 +72,7 @@ endi if $data11 != 5 then return -1 endi -if $data21 != 24 then +if $data21 != 26 then return -1 endi if $data31 != 5 then @@ -97,7 +97,7 @@ endi if $data42 != 3 then return -1 endi -if $data52 != 24 then +if $data52 != 26 then return -1 endi if $data62 != 5 then diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index 2bfe33d0af..20305bf4c1 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -57,7 +57,8 @@ class TDTestCase: self.nchar_str = '涛思数据' self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\ 'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\ - 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views'] + 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views', + 'ins_compacts', 'ins_compact_details'] self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps'] def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) @@ -217,7 +218,7 @@ class TDTestCase: tdSql.checkEqual(20470,len(tdSql.queryResult)) tdSql.query("select * from information_schema.ins_columns where db_name ='information_schema'") - tdSql.checkEqual(210, len(tdSql.queryResult)) + tdSql.checkEqual(219, len(tdSql.queryResult)) tdSql.query("select * from information_schema.ins_columns where db_name ='performance_schema'") tdSql.checkEqual(54, len(tdSql.queryResult)) diff --git a/tests/system-test/0-others/test_show_table_distributed.py b/tests/system-test/0-others/test_show_table_distributed.py new file mode 100644 index 0000000000..c414f8ba88 --- /dev/null +++ b/tests/system-test/0-others/test_show_table_distributed.py @@ -0,0 +1,77 @@ +from itertools import product +import taos +import random +import time +from taos.tmq import * +from util.cases import * +from util.common import * +from util.log import * +from util.sql import * +from util.sqlset import * + + +class TDTestCase: + """This test case is used to veirfy show table distributed command""" + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + # init the tdsql + tdSql.init(conn.cursor()) + self.dbname = "distributed_db" + self.stname = "st" + self.ctnum = 1 + self.row_num = 99 + + # create database + tdSql.execute(f'create database if not exists {self.dbname};') + tdSql.execute(f'use {self.dbname};') + # create super table + tdSql.execute(f'create table {self.dbname}.{self.stname} (ts timestamp, id int, temperature float) tags (name binary(20));') + # create child table + for i in range(self.ctnum): + tdSql.execute(f'create table ct_{str(i+1)} using {self.stname} tags ("name{str(i+1)}");') + # insert data + sql = f"insert into ct_{str(i+1)} values " + for j in range(self.row_num): + sql += f"(now+{j+1}s, {j+1}, {random.uniform(15, 30)}) " + sql += ";" + tdSql.execute(sql) + tdLog.debug("init finished") + + def checkRes(self, queryRes): + mem_rows_num = 0 + stt_rows_num = 0 + for item in queryRes: + if "Inmem_Rows=" in item[0]: + mem_rows_num = int(item[0].split("=")[1].split(" ")[0].replace("[", "").replace("]", "")) + tdLog.debug("mem_rows_num: %s" % mem_rows_num) + if "Stt_Rows=" in item[0]: + stt_rows_num = int(item[0].split("=")[2].replace("[", "").replace("]", "")) + tdLog.debug("stt_rows_num: %s" % stt_rows_num) + return mem_rows_num, stt_rows_num + + def run(self): + tdSql.query(f"show table distributed {self.stname};") + tdLog.debug(tdSql.queryResult) + mem_rows_num, stt_rows_num = self.checkRes(tdSql.queryResult) + tdLog.debug("mem_rows_num: %s, stt_rows_num: %s" % (mem_rows_num, stt_rows_num)) + assert(99 == mem_rows_num and 0 == stt_rows_num) + + tdSql.execute(f"flush database {self.dbname};") + time.sleep(1) + tdSql.query(f"show table distributed {self.stname};") + tdLog.debug(tdSql.queryResult) + mem_rows_num, stt_rows_num = self.checkRes(tdSql.queryResult) + tdLog.debug("mem_rows_num: %s, stt_rows_num: %s" % (mem_rows_num, stt_rows_num)) + assert(0 == mem_rows_num and 99 == stt_rows_num) + + def stop(self): + # remove the user + tdSql.execute(f'drop database {self.dbname};') + # close the connection + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/delete_stable.py b/tests/system-test/1-insert/delete_stable.py index 67561c51e5..bff6548517 100644 --- a/tests/system-test/1-insert/delete_stable.py +++ b/tests/system-test/1-insert/delete_stable.py @@ -24,7 +24,7 @@ from util.common import * from util.sqlset import TDSetSql class TDTestCase: - updatecfgDict = {'tsdbdebugFlag': 143} + updatecfgDict = {'tsdbdebugFlag': 131} def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) @@ -36,7 +36,7 @@ class TDTestCase: self.setsql = TDSetSql() self.stbname = 'stb' self.ntbname = 'ntb' - self.rowNum = 10 + self.rowNum = 3 self.tbnum = 3 self.ts = 1537146000000 self.binary_str = 'taosdata' diff --git a/tests/system-test/1-insert/insert_timestamp.py b/tests/system-test/1-insert/insert_timestamp.py index 621912f664..bc3b1c0275 100644 --- a/tests/system-test/1-insert/insert_timestamp.py +++ b/tests/system-test/1-insert/insert_timestamp.py @@ -1,4 +1,5 @@ -import sys +import datetime +import sys from util.log import * from util.cases import * from util.sql import * @@ -11,57 +12,138 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), True) - #def prepare_data(self): - - def run(self): - tdSql.execute("create database test_insert_timestamp;") + """ + timestamp输入插入规则: + 对于插入的字段类型为timestamp类型的字段,只允许这么几种情况: + timestamp + timestamp +/- interval + interval + timestamp + timestamp可以是字符串譬如:"2023-12-05 00:00:00.000", 也可以是int型, 譬如:1701619200000 + interval支持:b, u, a, s, m, h, d, w 不支持n, y,譬如:1h, 2d + + 仅支持2元表达式,譬如:timestamp + 2h, 不支持2元以上表达,譬如timestamp + 2h + 1d + """ + + tdSql.execute("create database test_insert_timestamp PRECISION 'ns';") tdSql.execute("use test_insert_timestamp;") tdSql.execute("create stable st(ts timestamp, c1 int) tags(id int);") tdSql.execute("create table test_t using st tags(1);") - tdSql.error("insert into test_t values(now + today(), 1 ); ") - tdSql.error("insert into test_t values(now - today(), 1 ); ") - tdSql.error("insert into test_t values(today() + now(), 1 ); ") - tdSql.error("insert into test_t values(today() - now(), 1 ); ") - tdSql.error("insert into test_t values(2h - now(), 1 ); ") - tdSql.error("insert into test_t values(2h - today(), 1 ); ") - tdSql.error("insert into test_t values(2h - 1h, 1 ); ") - tdSql.error("insert into test_t values(2h + 1h, 1 ); ") - tdSql.error("insert into test_t values('2023-11-28 00:00:00.000' + '2023-11-28 00:00:00.000', 1 ); ") - tdSql.error("insert into test_t values('2023-11-28 00:00:00.000' + 1701111600000, 1 ); ") - tdSql.error("insert into test_t values(1701111500000 + 1701111600000, 1 ); ") - tdSql.error("insert into test_insert_timestamp.test_t values(1701111600000 + 1h + 1s, 4); ") + expectErrInfo = "syntax error" + # 异常场景:timestamp + timestamp + tdSql.error("insert into test_t values(now + today(), 1 );", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(now - today(), 1 );", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(today() + now(), 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(today() - now(), 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values('2023-11-28 00:00:00.000' + '2023-11-28 00:00:00.000', 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values('2023-11-28 00:00:00.000' + 1701111600000, 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(1701111500000 + 1701111600000, 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) - tdSql.execute("insert into test_insert_timestamp.test_t values(1701111600000 + 1h, 4); ") - tdSql.execute("insert into test_insert_timestamp.test_t values(2h + 1701111600000, 5); ") - tdSql.execute("insert into test_insert_timestamp.test_t values('2023-11-28 00:00:00.000' + 1h, 1); ") - tdSql.execute("insert into test_insert_timestamp.test_t values(3h + '2023-11-28 00:00:00.000', 3); ") - tdSql.execute("insert into test_insert_timestamp.test_t values(1701111600000 - 1h, 2); ") - tdSql.execute("insert into test_insert_timestamp.test_t values(1701122400000, 6); ") - tdSql.execute("insert into test_insert_timestamp.test_t values('2023-11-28 07:00:00.000', 7); ") + # 异常场景:timestamp + interval + interval + tdSql.error("insert into test_t values(today() + 1d + 1s, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:interval - timestamp + tdSql.error("insert into test_t values(2h - now(), 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(2h - today(), 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:interval + interval + tdSql.error("insert into test_t values(2h - 1h, 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(2h + 1h, 1 ); ", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:非法interval类型n + tdSql.error("insert into test_t values(today() + 2n, 7); ", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:非法interval类型y + tdSql.error("insert into test_t values(today() - 2y, 8);", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:数据类型不对 + tdSql.error("insert into test_t values('a1701619200000', 8);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values('ss2023-12-05 00:00:00.000' + '1701619200000', 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(123456, 1);", expectErrInfo="Timestamp data out of range") + tdSql.error("insert into test_t values(123.456, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(True, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(None, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(null, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + + # 异常场景:格式不对 + tdSql.error("insert into test_t values('2023-122-05 00:00:00.000' + '1701619200000', 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values('2023-12--05 00:00:00.000' + '1701619200000', 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values('12/12/2023' + 10a, 1);", expectErrInfo=expectErrInfo, fullMatched=False) + tdSql.error("insert into test_t values(1701619200000111, 1);", expectErrInfo="Timestamp data out of range", fullMatched=False) + + # 正常场景:timestamp + interval + tdSql.execute("insert into test_t values(today() + 2b, 1);") + tdSql.execute("insert into test_t values(1701619200000000000 + 2u, 2);") + tdSql.execute("insert into test_t values(today + 2a, 3);") + tdSql.execute("insert into test_t values('2023-12-05 23:59:59.999' + 2a, 4);") + tdSql.execute("insert into test_t values(1701921599000000000 + 3a, 5);") + + # 正常场景:timestamp - interval + tdSql.execute("insert into test_t values(today() - 2s, 6);") + tdSql.execute("insert into test_t values(now() - 2m, 7);") + tdSql.execute("insert into test_t values(today - 2h, 8);") + tdSql.execute("insert into test_t values('2023-12-05 00:00:00.000000000' - 2a, 9);") + tdSql.execute("insert into test_t values(1701669000000000000 - 2a, 10);") + + # 正常场景:interval + timestamp + tdSql.execute("insert into test_t values(2d + now, 11);") + tdSql.execute("insert into test_t values(2w + today, 12);") + + # 正常场景:timestamp + tdSql.execute("insert into test_t values('2023-12-05 00:00:00.000', 13);") + tdSql.execute("insert into test_t values(1701629100000000000, 14);") + tdSql.execute("insert into test_t values(now() + 2s, 15);") + tdSql.execute("insert into test_t values('2023-12-05 00:00:59.999999999+07:00' + 10a, 16);") + tdSql.execute("insert into test_t values('2023-12-05T00:00:59.110+07:00' + 10a, 17);") + tdSql.execute("insert into test_t values('2023-12-05' + 10a, 18);") + tdSql.execute("insert into test_t values('2023-11-15', -15);") + tdSql.execute("insert into test_t values(1701619200000000000 - 2a, -10);") + tdSql.execute("insert into test_t values(1701619200000000000, -5);") + tdSql.execute("insert into test_t values('2023-12-05 12:12:12' + 10a, 19);") + + # 验证数据 + tdSql.query(f'select ts,c1 from test_t order by c1;') + tdSql.checkRows(22) + tdSql.checkEqual(tdSql.queryResult[0][0], 1699977600000000000) # c1=-15 + tdSql.checkEqual(tdSql.queryResult[1][0], 1701619199998000000) # c1=-10 + tdSql.checkEqual(tdSql.queryResult[2][0], 1701619200000000000) # c1=-5 + tdSql.checkEqual(tdSql.queryResult[3][0], self.__get_today_ts() + 2) # c1=1 + tdSql.checkEqual(tdSql.queryResult[4][0], 1701619200000002000) # c1=2 + tdSql.checkEqual(tdSql.queryResult[5][0], self.__get_today_ts() + 2000000) # c1=3 + tdSql.checkEqual(tdSql.queryResult[6][0], 1701792000001000000) # c1=4 + tdSql.checkEqual(tdSql.queryResult[7][0], 1701921599003000000) # c1=5 + tdSql.checkEqual(tdSql.queryResult[8][0], self.__get_today_ts() - 2000000000) # c1=6 + tdSql.checkEqual(self.__convert_ts_to_date(tdSql.queryResult[9][0]), str(datetime.date.today())) # c1=7 + tdSql.checkEqual(tdSql.queryResult[10][0], self.__get_today_ts() - 7200000000000) # c1=8 + tdSql.checkEqual(tdSql.queryResult[11][0], 1701705599998000000) # c1=9 + tdSql.checkEqual(tdSql.queryResult[12][0], 1701668999998000000) # c1=10 + tdSql.checkEqual(self.__convert_ts_to_date(tdSql.queryResult[13][0]), str(datetime.date.today() + datetime.timedelta(days=2))) # c1=11 + tdSql.checkEqual(self.__convert_ts_to_date(tdSql.queryResult[14][0]), str(datetime.date.today() + datetime.timedelta(days=14))) # c1=12 + tdSql.checkEqual(tdSql.queryResult[15][0], 1701705600000000000) # c1=13 + tdSql.checkEqual(tdSql.queryResult[16][0], 1701629100000000000) # c1=14 + tdSql.checkEqual(self.__convert_ts_to_date(tdSql.queryResult[17][0]), str(datetime.date.today())) # c1=15 + tdSql.checkEqual(tdSql.queryResult[18][0], 1701709260009999999) # c1=16 + tdSql.checkEqual(tdSql.queryResult[19][0], 1701709259120000000) # c1=17 + tdSql.checkEqual(tdSql.queryResult[20][0], 1701705600010000000) # c1=18 + tdSql.checkEqual(tdSql.queryResult[21][0], 1701749532010000000) # c1=19 - tdSql.query(f'select ts, c1 from test_t order by ts;') - tdSql.checkRows(7) - tdSql.checkEqual(tdSql.queryResult[0][0], datetime.datetime(2023, 11, 28, 1, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[0][1], 1) - tdSql.checkEqual(tdSql.queryResult[1][0], datetime.datetime(2023, 11, 28, 2, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[1][1], 2) - tdSql.checkEqual(tdSql.queryResult[2][0], datetime.datetime(2023, 11, 28, 3, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[2][1], 3) - tdSql.checkEqual(tdSql.queryResult[3][0], datetime.datetime(2023, 11, 28, 4, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[3][1], 4) - tdSql.checkEqual(tdSql.queryResult[4][0], datetime.datetime(2023, 11, 28, 5, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[4][1], 5) - tdSql.checkEqual(tdSql.queryResult[5][0], datetime.datetime(2023, 11, 28, 6, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[5][1], 6) - tdSql.checkEqual(tdSql.queryResult[6][0], datetime.datetime(2023, 11, 28, 7, 0, 0) ) - tdSql.checkEqual(tdSql.queryResult[6][1], 7) - tdSql.execute("drop table if exists test_t ;") tdSql.execute("drop stable if exists st;") tdSql.execute("drop database if exists test_insert_timestamp;") - + + def __convert_ts_to_date(self, ts: int) -> str: + # 创建datetime对象并进行转换 + dt_object = datetime.datetime.fromtimestamp(ts / 1e9) + + # 格式化日期字符串 + formatted_date = dt_object.strftime('%Y-%m-%d') + # print("转换后的日期为:", formatted_date) + return formatted_date + + def __get_today_ts(self) -> int: + return int(time.mktime(time.strptime(str(datetime.date.today()), "%Y-%m-%d"))) * 1000000000 + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/pytest.sh b/tests/system-test/pytest.sh index 2c95516d10..bae0fdf278 100755 --- a/tests/system-test/pytest.sh +++ b/tests/system-test/pytest.sh @@ -58,6 +58,12 @@ echo "SIM_DIR : $SIM_DIR" echo "CODE_DIR : $CODE_DIR" echo "ASAN_DIR : $ASAN_DIR" +# prevent delete / folder or /usr/bin +if [ ${#SIM_DIR} -lt 10 ]; then + echo "len(SIM_DIR) < 10 , danger so exit. SIM_DIR=$SIM_DIR" + exit 1 +fi + rm -rf $SIM_DIR/* mkdir -p $PRG_DIR diff --git a/tests/taosc_test/CMakeLists.txt b/tests/taosc_test/CMakeLists.txt new file mode 100644 index 0000000000..3ea6964462 --- /dev/null +++ b/tests/taosc_test/CMakeLists.txt @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) +PROJECT(TDengine) + +FIND_PATH(HEADER_GTEST_INCLUDE_DIR gtest.h /usr/include/gtest /usr/local/include/gtest /usr/local/taos/include) +FIND_LIBRARY(LIB_GTEST_STATIC_DIR libgtest.a /usr/lib/ /usr/local/lib /usr/lib64 /usr/local/taos/driver/) +FIND_LIBRARY(LIB_GTEST_SHARED_DIR libgtest.so /usr/lib/ /usr/local/lib /usr/lib64 /usr/local/taos/driver/) + +IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) + MESSAGE(STATUS "gTest library found, build os test") + + INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) + AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) + +ENDIF() + +aux_source_directory(src OS_SRC) +# taoscTest +add_executable(taoscTest "taoscTest.cpp") +target_link_libraries(taoscTest taos os gtest_main) +target_include_directories( + taoscTest + PUBLIC "${TD_SOURCE_DIR}/include/os" +) +add_test( + NAME taoscTest + COMMAND taoscTest +) + diff --git a/tests/taosc_test/taoscTest.cpp b/tests/taosc_test/taoscTest.cpp new file mode 100644 index 0000000000..fbdb152ab4 --- /dev/null +++ b/tests/taosc_test/taoscTest.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" +#pragma GCC diagnostic ignored "-Wpointer-arith" + +#include "os.h" +#include "taos.h" + +class taoscTest : public ::testing::Test { + protected: + static void SetUpTestCase() { + printf("start test setup.\n"); + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + TAOS_RES* res = taos_query(taos, "drop database IF EXISTS taosc_test_db;"); + if (taos_errno(res) != 0) { + printf("error in drop database taosc_test_db, reason:%s\n", taos_errstr(res)); + return; + } + taosSsleep(5); + taos_free_result(res); + printf("drop database taosc_test_db,finished.\n"); + + res = taos_query(taos, "create database taosc_test_db;"); + if (taos_errno(res) != 0) { + printf("error in create database taosc_test_db, reason:%s\n", taos_errstr(res)); + return; + } + taosSsleep(5); + taos_free_result(res); + printf("create database taosc_test_db,finished.\n"); + + taos_close(taos); + } + + static void TearDownTestCase() {} + + void SetUp() override {} + + void TearDown() override {} +}; + +tsem_t query_sem; +int getRecordCounts = 0; +int insertCounts = 100; +void* pUserParam = NULL; + +void fetchCallback(void* param, void* res, int32_t numOfRow) { + ASSERT_TRUE(numOfRow >= 0); + if (numOfRow == 0) { + printf("completed\n"); + taos_free_result(res); + tsem_post(&query_sem); + return; + } + + printf("numOfRow = %d \n", numOfRow); + int numFields = taos_num_fields(res); + TAOS_FIELD* fields = taos_fetch_fields(res); + + for (int i = 0; i < numOfRow; ++i) { + TAOS_ROW row = taos_fetch_row(res); + char temp[256] = {0}; + taos_print_row(temp, row, fields, numFields); + // printf("%s\n", temp); + } + + getRecordCounts += numOfRow; + taos_fetch_raw_block_a(res, fetchCallback, param); +} + +void queryCallback(void* param, void* res, int32_t code) { + ASSERT_TRUE(code == 0); + ASSERT_TRUE(param == pUserParam); + taos_fetch_raw_block_a(res, fetchCallback, param); +} + +TEST_F(taoscTest, taos_query_a_test) { + char sql[1024] = {0}; + int32_t code = 0; + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + const char* table_name = "taosc_test_table1"; + sprintf(sql, "create table taosc_test_db.%s (ts TIMESTAMP, val INT)", table_name); + TAOS_RES* res = taos_query(taos, sql); + if (taos_errno(res) != 0) { + printf("error in table database %s, reason:%s\n", table_name, taos_errstr(res)); + } + ASSERT_TRUE(taos_errno(res) == 0); + taos_free_result(res); + taosSsleep(2); + + for (int i = 0; i < insertCounts; i++) { + char sql[128]; + sprintf(sql, "insert into taosc_test_db.%s values(now() + %ds, %d)", table_name, i, i); + res = taos_query(taos, sql); + ASSERT_TRUE(taos_errno(res) == 0); + taos_free_result(res); + } + + pUserParam = NULL; + void* tmpParam = pUserParam; + tsem_init(&query_sem, 0, 0); + sprintf(sql, "select * from taosc_test_db.%s;", table_name); + taos_query_a(taos, sql, queryCallback, pUserParam); + tsem_wait(&query_sem); + ASSERT_TRUE(pUserParam == tmpParam); + + ASSERT_EQ(getRecordCounts, insertCounts); + taos_close(taos); + + printf("taos_query_a test finished.\n"); +} + +TEST_F(taoscTest, taos_query_a_param_test) { + char sql[1024] = {0}; + int32_t code = 0; + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + int pArray[2] = {0, 1}; + pUserParam = NULL; + void* tmpParam = pUserParam; + getRecordCounts = 0; + const char* table_name = "taosc_test_table1"; + tsem_init(&query_sem, 0, 0); + sprintf(sql, "select * from taosc_test_db.%s;", table_name); + taos_query_a(taos, sql, queryCallback, pUserParam); + tsem_wait(&query_sem); + ASSERT_TRUE(pUserParam == tmpParam); + ASSERT_EQ(pArray[0], 0); + ASSERT_EQ(pArray[1], 1); + + ASSERT_EQ(getRecordCounts, insertCounts); + taos_close(taos); + + printf("taos_query_a_param test finished.\n"); +} + +TEST_F(taoscTest, taos_query_test) { + char sql[1024] = {0}; + int32_t code = 0; + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + const char* table_name = "taosc_test_table1"; + sprintf(sql, "select * from taosc_test_db.%s;", table_name); + TAOS_RES* res = taos_query(taos, sql); + ASSERT_TRUE(res != nullptr); + + getRecordCounts = 0; + TAOS_ROW row; + while ((row = taos_fetch_row(res))) { + getRecordCounts++; + } + ASSERT_EQ(getRecordCounts, insertCounts); + taos_free_result(res); + taos_close(taos); + + printf("taos_query test finished.\n"); +} + +void queryCallback2(void* param, void* res, int32_t code) { + ASSERT_TRUE(code == 0); + ASSERT_TRUE(param == pUserParam); + // After using taos_query_a to query, using taos_fetch_row in the callback will cause blocking. + // Reason: schProcessOnCbBegin SCH_LOCK_TASK(pTask) + /* TAOS_ROW row; + while ((row = taos_fetch_row(res))) { + getRecordCounts++; + } */ + tsem_post(&query_sem); + taos_free_result(res); +} + +TEST_F(taoscTest, taos_query_a_t2) { + char sql[1024] = {0}; + int32_t code = 0; + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + getRecordCounts = 0; + + const char* table_name = "taosc_test_table1"; + sprintf(sql, "select * from taosc_test_db.%s;", table_name); + + pUserParam = NULL; + tsem_init(&query_sem, 0, 0); + taos_query_a(taos, sql, queryCallback2, pUserParam); + tsem_timewait(&query_sem, 10 * 1000); + + ASSERT_NE(getRecordCounts, insertCounts); + taos_close(taos); + + printf("taos_query_a_t2 test finished.\n"); +} + +void queryCallbackStartFetchThread(void* param, void* res, int32_t code) { + printf("queryCallbackStartFetchThread start...\n"); + ASSERT_TRUE(code == 0); + void** tmp = (void**)param; + *tmp = res; + printf("queryCallbackStartFetchThread end. res:%p\n", res); + tsem_post(&query_sem); +} + +TEST_F(taoscTest, taos_query_a_fetch_row) { + char sql[1024] = {0}; + int32_t code = 0; + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_TRUE(taos != nullptr); + + getRecordCounts = 0; + + const char* table_name = "taosc_test_table1"; + sprintf(sql, "select * from taosc_test_db.%s;", table_name); + + tsem_init(&query_sem, 0, 0); + printf("taos_query_a_fetch_row query start...\n"); + TAOS_RES *res; + TAOS_RES **pres = &res; + taos_query_a(taos, sql, queryCallbackStartFetchThread, pres); + tsem_wait(&query_sem); + + getRecordCounts = 0; + TAOS_ROW row; + printf("taos_query_a_fetch_row taos_fetch_row start...\n"); + + while ((row = taos_fetch_row(*pres))) { + getRecordCounts++; + } + printf("taos_query_a_fetch_row taos_fetch_row end. %p record count:%d.\n", *pres, getRecordCounts); + taos_free_result(*pres); + + ASSERT_EQ(getRecordCounts, insertCounts); + taos_close(taos); + + printf("taos_query_a_fetch_row test finished.\n"); +} + diff --git a/tests/unit-test/test.sh b/tests/unit-test/test.sh index 4122597717..292767e00c 100755 --- a/tests/unit-test/test.sh +++ b/tests/unit-test/test.sh @@ -6,7 +6,7 @@ function usage() { echo -e "\t -h help" } -ent=0 +ent=1 while getopts "eh" opt; do case $opt in e) @@ -34,7 +34,14 @@ else cd ../../../debug fi -ctest -j8 +set -e + +pgrep taosd || taosd >> /dev/null 2>&1 & + +sleep 10 + +ctest -E "smlTest|funcTest|profileTest|sdbTest|showTest|geomTest|idxFstUtilUT|idxTest|idxUtilUT|idxFstUT|parserTest|plannerTest|transUT|transUtilUt" -j8 + ret=$? exit $ret diff --git a/utils/test/c/tmqSim.c b/utils/test/c/tmqSim.c index 14e30008fe..006bd516d0 100644 --- a/utils/test/c/tmqSim.c +++ b/utils/test/c/tmqSim.c @@ -906,6 +906,7 @@ void* consumeThreadFunc(void* param) { pPrint("tmq_commit() manual commit when consume end.\n"); /*tmq_commit(pInfo->tmq, NULL, 0);*/ tmq_commit_sync(pInfo->tmq, NULL); + tmq_commit_cb_print(pInfo->tmq, 0, pInfo); taosFprintfFile(g_fp, "tmq_commit() manual commit over.\n"); pPrint("tmq_commit() manual commit over.\n"); }