diff --git a/README.md b/README.md
index 05c1c075f0c3b3894c93d0aa2e126a9dc6340758..885f91cb4e43323805d6a0bd71bf4665258aa6ad 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,12 @@
[![Build status](https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true)](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201)
+
+[![Twitter Follow](https://img.shields.io/twitter/follow/tdenginedb?label=TDengine&style=social)](https://twitter.com/tdenginedb)
+[![YouTube Channel](https://img.shields.io/badge/Subscribe_@tdengine--white?logo=youtube&style=social)](https://www.youtube.com/@tdengine)
+[![Discord Community](https://img.shields.io/badge/Join_Discord--white?logo=discord&style=social)](https://discord.com/invite/VZdSuUg4pS)
+[![LinkedIn](https://img.shields.io/badge/Follow_LinkedIn--white?logo=linkedin&style=social)](https://www.linkedin.com/company/tdengine)
+[![StackOverflow](https://img.shields.io/badge/Ask_StackOverflow--white?logo=stackoverflow&style=social&logoColor=orange)](https://stackoverflow.com/questions/tagged/tdengine)
English | [简体中文](README-CN.md) | [TDengine Cloud](https://cloud.tdengine.com) | [Learn more about TSDB](https://tdengine.com/tsdb/)
diff --git a/cmake/cmake.platform b/cmake/cmake.platform
index a4bfcaf609cc98f43094dabd993b8e310b9b220f..61eb66f675bd12840d025b5d0ed43192120506b4 100644
--- a/cmake/cmake.platform
+++ b/cmake/cmake.platform
@@ -37,6 +37,21 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
SET(TD_LINUX_32 TRUE)
ENDIF ()
+ EXECUTE_PROCESS(COMMAND chmod 777 ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh)
+ EXECUTE_PROCESS(COMMAND readlink /bin/sh OUTPUT_VARIABLE SHELL_LINK)
+ MESSAGE(STATUS "The shell is: " ${SHELL_LINK})
+
+ IF (${SHELL_LINK} MATCHES "dash")
+ EXECUTE_PROCESS(COMMAND ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO)
+ ELSE ()
+ EXECUTE_PROCESS(COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO)
+ ENDIF ()
+ MESSAGE(STATUS "The current OS is " ${TD_OS_INFO})
+ IF (${TD_OS_INFO} MATCHES "Alpine")
+ SET(TD_ALPINE TRUE)
+ ADD_DEFINITIONS("-D_ALPINE")
+ ENDIF ()
+
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(TD_DARWIN TRUE)
diff --git a/cmake/cmake.version b/cmake/cmake.version
index a4c783b6c8cfa4c3c1bea4eb7f4ac40b165efe87..a30618157b94a8fb361aa20ae87af00f8a1c3852 100644
--- a/cmake/cmake.version
+++ b/cmake/cmake.version
@@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
- SET(TD_VER_NUMBER "3.0.2.4")
+ SET(TD_VER_NUMBER "3.0.2.5")
ENDIF ()
IF (DEFINED VERCOMPATIBLE)
diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in
index 13b247770ea7eef6b64209ca98787ff6d733bf85..8df50af03c38eae13b143d6a5af7608d045860bb 100644
--- a/cmake/taosadapter_CMakeLists.txt.in
+++ b/cmake/taosadapter_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
- GIT_TAG 213f8b3
+ GIT_TAG db6c843
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in
index 13a81f88eab42c64be7ea0cf759da21ddce7a456..05191138e549acc29cf8f60ab2772df105be8109 100644
--- a/cmake/taostools_CMakeLists.txt.in
+++ b/cmake/taostools_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
- GIT_TAG 0cd564a
+ GIT_TAG 22627d7
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in
index e79c6b799f0bfdf98e73d33188c12d355eb32708..b013d45911988ce38cd752766e862da3d461b1cd 100644
--- a/cmake/taosws_CMakeLists.txt.in
+++ b/cmake/taosws_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
- GIT_TAG f406d51
+ GIT_TAG main
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/docs/en/01-index.md b/docs/en/01-index.md
index 13552ea9dcfbae71a368cad9d55b4a0030ac266a..296cd968986d5dd7738d6c3b997901614f893763 100644
--- a/docs/en/01-index.md
+++ b/docs/en/01-index.md
@@ -1,6 +1,7 @@
---
title: TDengine Documentation
sidebar_label: Documentation Home
+description: This website contains the user manuals for TDengine, an open-source, cloud-native time-series database optimized for IoT, Connected Cars, and Industrial IoT.
slug: /
---
diff --git a/docs/en/02-intro/index.md b/docs/en/02-intro/index.md
index a60bfab2ccd30fb585d72ee14054029b1c176a66..95dd4324f145800c139272381d2a07a40a2b5ce9 100644
--- a/docs/en/02-intro/index.md
+++ b/docs/en/02-intro/index.md
@@ -1,5 +1,6 @@
---
title: Introduction
+description: This document introduces the major features, competitive advantages, typical use cases, and benchmarks of TDengine.
toc_max_heading_level: 2
---
diff --git a/docs/en/04-concept/index.md b/docs/en/04-concept/index.md
index 0b1b226c17100d56313b5480e26f437841afe8c7..771a061c310bd53c485394fe3a8897567b12e48b 100644
--- a/docs/en/04-concept/index.md
+++ b/docs/en/04-concept/index.md
@@ -1,5 +1,6 @@
---
title: Concepts
+description: This document describes the basic concepts of TDengine, including the supertable.
---
In order to explain the basic concepts and provide some sample code, the TDengine documentation smart meters as a typical time series use case. We assume the following: 1. Each smart meter collects three metrics i.e. current, voltage, and phase; 2. There are multiple smart meters; 3. Each meter has static attributes like location and group ID. Based on this, collected data will look similar to the following table:
diff --git a/docs/en/05-get-started/01-docker.md b/docs/en/05-get-started/01-docker.md
index ac273daba48d39bd0777ffdb30f431c6521d13b3..42e6861674434ad9800f69dcf00fe80a140e9bf7 100644
--- a/docs/en/05-get-started/01-docker.md
+++ b/docs/en/05-get-started/01-docker.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Docker
title: Quick Install on Docker
+sidebar_label: Docker
+description: This document describes how to install TDengine in a Docker container and perform queries and inserts.
---
This document describes how to install TDengine in a Docker container and perform queries and inserts.
diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md
index 54d2e046c214f2df8ecd5ff03b7d5108c701938d..a0c1d939831395da596ecf15247c46b5a5188a14 100644
--- a/docs/en/05-get-started/03-package.md
+++ b/docs/en/05-get-started/03-package.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Package
title: Quick Install from Package
+sidebar_label: Package
+description: This document describes how to install TDengine on Linux, Windows, and macOS and perform queries and inserts.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/05-get-started/index.md b/docs/en/05-get-started/index.md
index 12cfa22c69b1db8e82de4cb251ca3d8c67fc4546..66573a89cd6e181192132cc0b304f415fa25b89c 100644
--- a/docs/en/05-get-started/index.md
+++ b/docs/en/05-get-started/index.md
@@ -1,6 +1,6 @@
---
title: Get Started
-description: This article describes how to install TDengine and test its performance.
+description: This document describes how to install TDengine on various platforms.
---
import GitHubSVG from './github.svg'
diff --git a/docs/en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md
index 45bbaa2751a6ac6c04b4d6a7fcb00dd0fe03f638..913c24f1896e3c2af6614fc07e9319c6fb06783f 100644
--- a/docs/en/07-develop/01-connect/index.md
+++ b/docs/en/07-develop/01-connect/index.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Connect
title: Connect to TDengine
-description: "How to establish connections to TDengine and how to install and use TDengine connectors."
+sidebar_label: Connect
+description: This document describes how to establish connections to TDengine and how to install and use TDengine connectors.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/02-model/index.mdx b/docs/en/07-develop/02-model/index.mdx
index 19a239805f1492eae0c463f5a942378b83ecf6b8..db5a259cfe6f8cc1fec6c588ec9b31888334ca06 100644
--- a/docs/en/07-develop/02-model/index.mdx
+++ b/docs/en/07-develop/02-model/index.mdx
@@ -1,5 +1,6 @@
---
title: Data Model
+description: This document describes the data model of TDengine.
---
The data model employed by TDengine is similar to that of a relational database. You have to create databases and tables. You must design the data model based on your own business and application requirements. You should design the [STable](/concept/#super-table-stable) (an abbreviation for super table) schema to fit your data. This chapter will explain the big picture without getting into syntactical details.
diff --git a/docs/en/07-develop/03-insert-data/01-sql-writing.mdx b/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
index f2168645ff9e59d60e88c85f86e890945b9f336c..32ba53a0cb25b403dd93c2b8c758dc54cdcc0d15 100644
--- a/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
+++ b/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
@@ -1,5 +1,6 @@
---
title: Insert Using SQL
+description: This document describes how to insert data into TDengine using SQL.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx b/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx
index ffb969a8a6d0bc61e23fee44f245a24236db5b1b..89ca10b669d094a156f55439429e329308e71935 100644
--- a/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx
+++ b/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx
@@ -1,5 +1,6 @@
---
title: Write from Kafka
+description: This document describes how to insert data into TDengine using Kafka.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/30-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/30-influxdb-line.mdx
index fc5644850cbedcb91de2aebca29070dc3c021551..c559883d26c7ef5750f3ee1f828912f8d800c3a4 100644
--- a/docs/en/07-develop/03-insert-data/30-influxdb-line.mdx
+++ b/docs/en/07-develop/03-insert-data/30-influxdb-line.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: InfluxDB Line Protocol
title: InfluxDB Line Protocol
+sidebar_label: InfluxDB Line Protocol
+description: This document describes how to insert data into TDengine using the InfluxDB Line Protocol.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx
index 5d3f25dca96a0d41a4562aa067800607e8e04277..30bc3b87bf035f563e1a03508a90466e9288f89c 100644
--- a/docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx
+++ b/docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: OpenTSDB Line Protocol
title: OpenTSDB Line Protocol
+sidebar_label: OpenTSDB Line Protocol
+description: This document describes how to insert data into TDengine using the OpenTSDB Line Protocol.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx
index 214580c179b97f46f94096411c57bf0004dc68e3..e9db130241236e7224e5965c4c3c651ddab8cb00 100644
--- a/docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx
+++ b/docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: OpenTSDB JSON Protocol
title: OpenTSDB JSON Protocol
+sidebar_label: OpenTSDB JSON Protocol
+description: This document describes how to insert data into TDengine using the OpenTSDB JSON protocol.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/60-high-volume.md b/docs/en/07-develop/03-insert-data/60-high-volume.md
index 272a13881372b58a9a66c0d452cda54f9ee8c78c..d5afa8ef6ec120fa73854f5ca170504d7dd69b39 100644
--- a/docs/en/07-develop/03-insert-data/60-high-volume.md
+++ b/docs/en/07-develop/03-insert-data/60-high-volume.md
@@ -1,6 +1,7 @@
---
-sidebar_label: High Performance Writing
title: High Performance Writing
+sidebar_label: High Performance Writing
+description: This document describes how to achieve high performance when writing data into TDengine.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/03-insert-data/_py_kafka.mdx b/docs/en/07-develop/03-insert-data/_py_kafka.mdx
index dc43a0d415275189220287278547b015865e8d90..c71821dad129fe1a573e6f607eb591f81f928ae1 100644
--- a/docs/en/07-develop/03-insert-data/_py_kafka.mdx
+++ b/docs/en/07-develop/03-insert-data/_py_kafka.mdx
@@ -53,8 +53,69 @@ for p in ps:
In addition to python's built-in multithreading and multiprocessing library, we can also use the third-party library gunicorn.
-### Examples
+### examples
+
+
+kafka_example_perform
+
+`kafka_example_perform` is the entry point of the examples.
+
+```py
+{{#include docs/examples/python/kafka_example_perform.py}}
+```
+
+
+
+kafka_example_common
+
+`kafka_example_common` is the common code of the examples.
```py
-{{#include docs/examples/python/kafka_example.py}}
+{{#include docs/examples/python/kafka_example_common.py}}
```
+
+
+
+kafka_example_producer
+
+`kafka_example_producer` is `producer`, which is responsible for generating test data and sending it to kafka.
+
+```py
+{{#include docs/examples/python/kafka_example_producer.py}}
+```
+
+
+
+kafka_example_consumer
+
+`kafka_example_consumer` is `consumer`,which is responsible for consuming data from kafka and writing it to TDengine.
+
+```py
+{{#include docs/examples/python/kafka_example_consumer.py}}
+```
+
+
+### execute Python examples
+
+
+ execute Python examples
+
+ 1. install and start up `kafka`
+ 2. install python3 and pip
+ 3. install `taospy` by pip
+ 4. install `kafka-python` by pip
+ 5. execute this example
+
+ The entry point of this example is `kafka_example_perform.py`. For more information about usage, please use `--help` command.
+
+ ```
+ python3 kafka_example_perform.py --help
+ ```
+
+ For example, the following command is creating 100 sub-table and inserting 20000 data for each table and the kafka max poll is 100 and 1 thread and 1 process per thread.
+
+ ```
+ python3 kafka_example_perform.py -table-count=100 -table-items=20000 -max-poll=100 -threads=1 -processes=1
+ ```
+
+
diff --git a/docs/en/07-develop/03-insert-data/index.md b/docs/en/07-develop/03-insert-data/index.md
index 1a71e719a56448e4b535632e570ce8a04d2282bb..15f8f4ee9e9b24e6b511e6d29505c7b99fea3ae8 100644
--- a/docs/en/07-develop/03-insert-data/index.md
+++ b/docs/en/07-develop/03-insert-data/index.md
@@ -1,5 +1,6 @@
---
title: Insert Data
+description: This document describes how to insert data into TDengine.
---
TDengine supports multiple protocols of inserting data, including SQL, InfluxDB Line protocol, OpenTSDB Telnet protocol, and OpenTSDB JSON protocol. Data can be inserted row by row, or in batches. Data from one or more collection points can be inserted simultaneously. Data can be inserted with multiple threads, and out of order data and historical data can be inserted as well. InfluxDB Line protocol, OpenTSDB Telnet protocol and OpenTSDB JSON protocol are the 3 kinds of schemaless insert protocols supported by TDengine. It's not necessary to create STables and tables in advance if using schemaless protocols, and the schemas can be adjusted automatically based on the data being inserted.
diff --git a/docs/en/07-develop/04-query-data/index.mdx b/docs/en/07-develop/04-query-data/index.mdx
index 38dc98d1ff262c7f8ec4951297e6f42e436682c8..7e167bb4f342167c486403259985976357e44496 100644
--- a/docs/en/07-develop/04-query-data/index.mdx
+++ b/docs/en/07-develop/04-query-data/index.mdx
@@ -1,6 +1,6 @@
---
title: Query Data
-description: "This chapter introduces major query functionalities and how to perform sync and async query using connectors."
+description: This document describes how to query data in TDengine and how to perform synchronous and asynchronous queries using connectors.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/07-develop/06-stream.md b/docs/en/07-develop/06-stream.md
index 36f903ee9a4f2d210e63d0b79e702bc199f790ed..125173e60bae77bbbe782363ebd2103cf7e4b703 100644
--- a/docs/en/07-develop/06-stream.md
+++ b/docs/en/07-develop/06-stream.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Stream Processing
-description: "The TDengine stream processing engine combines data inserts, preprocessing, analytics, real-time computation, and alerting into a single component."
title: Stream Processing
+sidebar_label: Stream Processing
+description: This document describes the stream processing component of TDengine.
---
Raw time-series data is often cleaned and preprocessed before being permanently stored in a database. In a traditional time-series solution, this generally requires the deployment of stream processing systems such as Kafka or Flink. However, the complexity of such systems increases the cost of development and maintenance.
diff --git a/docs/en/07-develop/08-cache.md b/docs/en/07-develop/08-cache.md
index 82a4787016f608f8e32e89b1747443b7cd164551..6a6ca3e5947b6a3233f90e5e0a01417e6be3b19d 100644
--- a/docs/en/07-develop/08-cache.md
+++ b/docs/en/07-develop/08-cache.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Caching
title: Caching
-description: "This document describes the caching component of TDengine."
+sidebar_label: Caching
+description: This document describes the caching component of TDengine.
---
TDengine uses various kinds of caching techniques to efficiently write and query data. This document describes the caching component of TDengine.
diff --git a/docs/en/07-develop/09-udf.md b/docs/en/07-develop/09-udf.md
index 699b3ebe5f7cddaa6f56cb8027c784a5821a7a0d..553a7b932b013a1f4d2b5e4e291f71c28b64039f 100644
--- a/docs/en/07-develop/09-udf.md
+++ b/docs/en/07-develop/09-udf.md
@@ -1,7 +1,7 @@
---
-sidebar_label: UDF
title: User-Defined Functions (UDF)
-description: "You can define your own scalar and aggregate functions to expand the query capabilities of TDengine."
+sidebar_label: UDF
+description: This document describes how to create user-defined functions (UDF), your own scalar and aggregate functions that can expand the query capabilities of TDengine.
---
The built-in functions of TDengine may not be sufficient for the use cases of every application. In this case, you can define custom functions for use in TDengine queries. These are known as user-defined functions (UDF). A user-defined function takes one column of data or the result of a subquery as its input.
diff --git a/docs/en/07-develop/index.md b/docs/en/07-develop/index.md
index 34649d32a2f758fda2bd79afbbd8f3427b714353..8f80b82b970c576945eee6f972bd901d910614a9 100644
--- a/docs/en/07-develop/index.md
+++ b/docs/en/07-develop/index.md
@@ -1,5 +1,6 @@
---
title: Developer Guide
+description: This document describes how to use the various components of TDengine from a developer's perspective.
---
Before creating an application to process time-series data with TDengine, consider the following:
diff --git a/docs/en/10-deployment/01-deploy.md b/docs/en/10-deployment/01-deploy.md
index 5dfcd3108d8b10cf24cdd5c852c4225ced0f16b2..da00e21a7ec7c7a34c0a3ae60b2928bd3b036cc4 100644
--- a/docs/en/10-deployment/01-deploy.md
+++ b/docs/en/10-deployment/01-deploy.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Manual Deployment
title: Manual Deployment and Management
+sidebar_label: Manual Deployment
+description: This document describes how to deploy TDengine on a server.
---
## Prerequisites
diff --git a/docs/en/10-deployment/03-k8s.md b/docs/en/10-deployment/03-k8s.md
index b0aa6777130864404e97dc332cf0e5ce830bf8ed..49e61caafce6414a10c4bc1937ce13394a7da9eb 100644
--- a/docs/en/10-deployment/03-k8s.md
+++ b/docs/en/10-deployment/03-k8s.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Kubernetes
title: Deploying a TDengine Cluster in Kubernetes
+sidebar_label: Kubernetes
+description: This document describes how to deploy TDengine on Kubernetes.
---
TDengine is a cloud-native time-series database that can be deployed on Kubernetes. This document gives a step-by-step description of how you can use YAML files to create a TDengine cluster and introduces common operations for TDengine in a Kubernetes environment.
diff --git a/docs/en/10-deployment/05-helm.md b/docs/en/10-deployment/05-helm.md
index 90baa5f4459c6d9d01530d5e0c36477d79aa5ab9..aa617176693a576c8dbd37b83a70b1be3b983ef0 100644
--- a/docs/en/10-deployment/05-helm.md
+++ b/docs/en/10-deployment/05-helm.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Helm
title: Use Helm to deploy TDengine
+sidebar_label: Helm
+description: This document describes how to deploy TDengine on Kubernetes by using Helm.
---
Helm is a package manager for Kubernetes that can provide more capabilities in deploying on Kubernetes.
diff --git a/docs/en/10-deployment/index.md b/docs/en/10-deployment/index.md
index 7054a33e4a40222ed5eb9a15837990e3e7a81cff..865fbc2da57bb985dabc03a743c5e0f7186b98be 100644
--- a/docs/en/10-deployment/index.md
+++ b/docs/en/10-deployment/index.md
@@ -1,5 +1,6 @@
---
title: Deployment
+description: This document describes how to deploy a TDengine cluster on a server, on Kubernetes, and by using Helm.
---
TDengine has a native distributed design and provides the ability to scale out. A few nodes can form a TDengine cluster. If you need higher processing power, you just need to add more nodes into the cluster. TDengine uses virtual node technology to virtualize a node into multiple virtual nodes to achieve load balancing. At the same time, TDengine can group virtual nodes on different nodes into virtual node groups, and use the replication mechanism to ensure the high availability of the system. The cluster feature of TDengine is completely open source.
diff --git a/docs/en/12-taos-sql/01-data-type.md b/docs/en/12-taos-sql/01-data-type.md
index 60046629a4c6f89ccfe9b20adcbb2fdba2ffb261..641fd3cbb7c4e2937cc1756a41a522f6eb4b51aa 100644
--- a/docs/en/12-taos-sql/01-data-type.md
+++ b/docs/en/12-taos-sql/01-data-type.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Data Types
title: Data Types
-description: 'TDengine supports a variety of data types including timestamp, float, JSON and many others.'
+sidebar_label: Data Types
+description: This document describes the data types that TDengine supports.
---
## Timestamp
diff --git a/docs/en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md
index 059f124ea5b5f380cd72ba55a20b6cf3a80b035e..280d72697cd1fc72e754d48b56fa9a36bd8de40e 100644
--- a/docs/en/12-taos-sql/02-database.md
+++ b/docs/en/12-taos-sql/02-database.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Database
title: Database
-description: "create and drop database, show or change database parameters"
+sidebar_label: Database
+description: This document describes how to create and perform operations on databases.
---
## Create a Database
diff --git a/docs/en/12-taos-sql/03-table.md b/docs/en/12-taos-sql/03-table.md
index 6d12b8c73056d049997a244ed0ab788742094d65..f61d1f51471bf042aea79023bff4f74c43831eb8 100644
--- a/docs/en/12-taos-sql/03-table.md
+++ b/docs/en/12-taos-sql/03-table.md
@@ -1,5 +1,6 @@
---
title: Table
+description: This document describes how to create and perform operations on standard tables and subtables.
---
## Create Table
diff --git a/docs/en/12-taos-sql/04-stable.md b/docs/en/12-taos-sql/04-stable.md
index 8a7c713f8cad6d61c8b098583cc4e282b00d48cf..5b316d0d2460b497655e7f29acb897301b5b4769 100644
--- a/docs/en/12-taos-sql/04-stable.md
+++ b/docs/en/12-taos-sql/04-stable.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Supertable
title: Supertable
+sidebar_label: Supertable
+description: This document describes how to create and perform operations on supertables.
---
## Create a Supertable
diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md
index 9141211db5239cb6a035f4a01a831adf9f50aa77..c22357abfa1c9e2a4dece880c407cb4bbfdaa055 100644
--- a/docs/en/12-taos-sql/05-insert.md
+++ b/docs/en/12-taos-sql/05-insert.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Insert
title: Insert
+sidebar_label: Insert
+description: This document describes how to insert data into TDengine.
---
## Syntax
@@ -27,7 +28,7 @@ INSERT INTO tb_name [(field1_name, ...)] subquery
2. The precision of a timestamp depends on its format. The precision configured for the database affects only timestamps that are inserted as long integers (UNIX time). Timestamps inserted as date and time strings are not affected. As an example, the timestamp 2021-07-13 16:16:48 is equivalent to 1626164208 in UNIX time. This UNIX time is modified to 1626164208000 for databases with millisecond precision, 1626164208000000 for databases with microsecond precision, and 1626164208000000000 for databases with nanosecond precision.
3. If you want to insert multiple rows simultaneously, do not use the NOW function in the timestamp. Using the NOW function in this situation will cause multiple rows to have the same timestamp and prevent them from being stored correctly. This is because the NOW function obtains the current time on the client, and multiple instances of NOW in a single statement will return the same time.
- The earliest timestamp that you can use when inserting data is equal to the current time on the server minus the value of the KEEP parameter. The latest timestamp that you can use when inserting data is equal to the current time on the server plus the value of the DURATION parameter. You can configure the KEEP and DURATION parameters when you create a database. The default values are 3650 days for the KEEP parameter and 10 days for the DURATION parameter.
+ The earliest timestamp that you can use when inserting data is equal to the current time on the server minus the value of the KEEP parameter (You can configure the KEEP parameter when you create a database and the default value is 3650 days). The latest timestamp you can use when inserting data depends on the PRECISION parameter (You can configure the PRECISION parameter when you create a database, ms means milliseconds, us means microseconds, ns means nanoseconds, and the default value is milliseconds). If the timestamp precision is milliseconds or microseconds, the latest timestamp is the Unix epoch (January 1st, 1970 at 00:00:00.000 UTC) plus 1000 years, that is, January 1st, 2970 at 00:00:00.000 UTC; If the timestamp precision is nanoseconds, the latest timestamp is the Unix epoch plus 292 years, that is, January 1st, 2262 at 00:00:00.000000000 UTC.
**Syntax**
diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md
index ee06a7be2d3172210bf35302d5bffbf7a49adabc..3099e3a541861ad236135a5bef1255db7d4394b9 100644
--- a/docs/en/12-taos-sql/06-select.md
+++ b/docs/en/12-taos-sql/06-select.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Select
title: Select
+sidebar_label: Select
+description: This document describes how to query data in TDengine.
---
## Syntax
@@ -12,6 +13,7 @@ SELECT [DISTINCT] select_list
from_clause
[WHERE condition]
[partition_by_clause]
+ [interp_clause]
[window_clause]
[group_by_clause]
[order_by_clasue]
@@ -52,8 +54,11 @@ window_clause: {
| STATE_WINDOW(col)
| INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)]
+interp_clause:
+ RANGE(ts_val, ts_val), EVERY(every_val), FILL(fill_mod_and_val)
+
partition_by_clause:
- PARTITION BY expr [, expr] ...
+ PARTITION BY expr [, expr] ...
group_by_clause:
GROUP BY expr [, expr] ... HAVING condition
diff --git a/docs/en/12-taos-sql/08-delete-data.mdx b/docs/en/12-taos-sql/08-delete-data.mdx
index 999c467ad05b6d3e349e322141acfb02a49de5ff..f91a89a7ebe86a7699f5c9a3fd6d3bca200c1445 100644
--- a/docs/en/12-taos-sql/08-delete-data.mdx
+++ b/docs/en/12-taos-sql/08-delete-data.mdx
@@ -1,7 +1,7 @@
---
-sidebar_label: Delete Data
-description: "Delete data from table or Stable"
title: Delete Data
+sidebar_label: Delete Data
+description: This document describes how to delete data from TDengine.
---
TDengine provides the functionality of deleting data from a table or STable according to specified time range, it can be used to cleanup abnormal data generated due to device failure.
diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md
index 802eb259bf72687f9c75cdb34e3520040d3c9010..d2aca5c361f15cbc9815dc65de08cd668e6a2b76 100644
--- a/docs/en/12-taos-sql/10-function.md
+++ b/docs/en/12-taos-sql/10-function.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Functions
title: Functions
+sidebar_label: Functions
+description: This document describes the standard SQL functions available in TDengine.
toc_max_heading_level: 4
---
@@ -872,9 +873,9 @@ INTERP(expr)
- `INTERP` is used to get the value that matches the specified time slice from a column. If no such value exists an interpolation value will be returned based on `FILL` parameter.
- The input data of `INTERP` is the value of the specified column and a `where` clause can be used to filter the original data. If no `where` condition is specified then all original data is the input.
- `INTERP` must be used along with `RANGE`, `EVERY`, `FILL` keywords.
-- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified.
-- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. The parameter `EVERY` must be an integer, with no quotes, with a time unit of: b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), or w(week). For example, `EVERY(500a)` will interpolate every 500 milliseconds.
-- Interpolation is performed based on `FILL` parameter.
+- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1 <= timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified.
+- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY(time_unit)`. Starting from timestamp1, one interpolation is performed for every time interval specified `time_unit` parameter. The parameter `time_unit` must be an integer, with no quotes, with a time unit of: a(millisecond)), s(second), m(minute), h(hour), d(day), or w(week). For example, `EVERY(500a)` will interpolate every 500 milliseconds.
+- Interpolation is performed based on `FILL` parameter. For more information about FILL clause, see [FILL Clause](../distinguished/#fill-clause).
- `INTERP` can only be used to interpolate in single timeline. So it must be used with `partition by tbname` when it's used on a STable.
- Pseudocolumn `_irowts` can be used along with `INTERP` to return the timestamps associated with interpolation points(support after version 3.0.1.4).
- Pseudocolumn `_isfilled` can be used along with `INTERP` to indicate whether the results are original records or data points generated by interpolation algorithm(support after version 3.0.2.3).
diff --git a/docs/en/12-taos-sql/12-distinguished.md b/docs/en/12-taos-sql/12-distinguished.md
index 0763e85a53bc6021a2fe28d7df20f627d1b3fbe7..536fd8ffc3968996b8e31b5a2864fd730a7624a7 100644
--- a/docs/en/12-taos-sql/12-distinguished.md
+++ b/docs/en/12-taos-sql/12-distinguished.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Time-Series Extensions
title: Time-Series Extensions
+sidebar_label: Time-Series Extensions
+description: This document describes the extended functions specific to time-series data processing available in TDengine.
---
As a purpose-built database for storing and processing time-series data, TDengine provides time-series-specific extensions to standard SQL.
diff --git a/docs/en/12-taos-sql/13-tmq.md b/docs/en/12-taos-sql/13-tmq.md
index befab4f4f01e595564e93ffcfbb0723e13294af0..1a805c76fb8e51ad22dd4e8b090860a6e1730a24 100644
--- a/docs/en/12-taos-sql/13-tmq.md
+++ b/docs/en/12-taos-sql/13-tmq.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Data Subscription
title: Data Subscription
+sidebar_label: Data Subscription
+description: This document describes the SQL statements related to the data subscription component of TDengine.
---
The information in this document is related to the TDengine data subscription feature.
diff --git a/docs/en/12-taos-sql/14-stream.md b/docs/en/12-taos-sql/14-stream.md
index e70e962668d85ea6a84afd86657a7b26df90ccf4..b8f6c3a163e1c2fa37e437725652eabb1a71dbe6 100644
--- a/docs/en/12-taos-sql/14-stream.md
+++ b/docs/en/12-taos-sql/14-stream.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Stream Processing
title: Stream Processing
+sidebar_label: Stream Processing
+description: This document describes the SQL statements related to the stream processing component of TDengine.
---
Raw time-series data is often cleaned and preprocessed before being permanently stored in a database. Stream processing components like Kafka, Flink, and Spark are often deployed alongside a time-series database to handle these operations, increasing system complexity and maintenance costs.
diff --git a/docs/en/12-taos-sql/16-operators.md b/docs/en/12-taos-sql/16-operators.md
index c426e2879342e430c61c4f8133aa9f8186888941..32ad4e7075b6a510cb537016effb6064e6c51794 100644
--- a/docs/en/12-taos-sql/16-operators.md
+++ b/docs/en/12-taos-sql/16-operators.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Operators
title: Operators
+sidebar_label: Operators
+description: This document describes the SQL operators available in TDengine.
---
## Arithmetic Operators
diff --git a/docs/en/12-taos-sql/17-json.md b/docs/en/12-taos-sql/17-json.md
index 77f774303316b466a15226f548f84da69be8f92d..b2494e0cc1a1829d0389b2cf634e5d8575817f57 100644
--- a/docs/en/12-taos-sql/17-json.md
+++ b/docs/en/12-taos-sql/17-json.md
@@ -1,6 +1,7 @@
---
-sidebar_label: JSON Type
title: JSON Type
+sidebar_label: JSON Type
+description: This document describes the JSON data type in TDengine.
---
diff --git a/docs/en/12-taos-sql/18-escape.md b/docs/en/12-taos-sql/18-escape.md
index a2ae40de98be677e599e83a634952a39faeaafbf..85e4610e44f1a6f93e9727c32f8333cddf07ecc7 100644
--- a/docs/en/12-taos-sql/18-escape.md
+++ b/docs/en/12-taos-sql/18-escape.md
@@ -1,5 +1,6 @@
---
title: Escape Characters
+description: This document describes the usage of escape characters in TDengine.
---
## Escape Characters
diff --git a/docs/en/12-taos-sql/19-limit.md b/docs/en/12-taos-sql/19-limit.md
index f00ec90f5755d3d004a35b210f93560c6f719536..654fae7560d3c24df1353b87952a3868ca307418 100644
--- a/docs/en/12-taos-sql/19-limit.md
+++ b/docs/en/12-taos-sql/19-limit.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Name and Size Limits
title: Name and Size Limits
+sidebar_label: Name and Size Limits
+description: This document describes the name and size limits in TDengine.
---
## Naming Rules
diff --git a/docs/en/12-taos-sql/20-keywords.md b/docs/en/12-taos-sql/20-keywords.md
index 23f85947e30ae2876cf631124e6485c09f2ff8da..a2191c87ee17444d5341b8e97b33a954be84dc98 100644
--- a/docs/en/12-taos-sql/20-keywords.md
+++ b/docs/en/12-taos-sql/20-keywords.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Reserved Keywords
title: Reserved Keywords
+sidebar_label: Reserved Keywords
+description: This document describes the reserved keywords in TDengine that cannot be used in object names.
---
## Keyword List
diff --git a/docs/en/12-taos-sql/21-node.md b/docs/en/12-taos-sql/21-node.md
index a0d49ab208448fa9dd90ef63deb235ef051b0e19..8a5069e66f5111c3c362829cfd654f16a80b60c7 100644
--- a/docs/en/12-taos-sql/21-node.md
+++ b/docs/en/12-taos-sql/21-node.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Cluster
title: Cluster
+sidebar_label: Cluster
+description: This document describes the SQL statements related to cluster management in TDengine.
---
The physical entities that form TDengine clusters are known as data nodes (dnodes). Each dnode is a process running on the operating system of the physical machine. Dnodes can contain virtual nodes (vnodes), which store time-series data. Virtual nodes are formed into vgroups, which have 1 or 3 vnodes depending on the replica setting. If you want to enable replication on your cluster, it must contain at least three nodes. Dnodes can also contain management nodes (mnodes). Each cluster has up to three mnodes. Finally, dnodes can contain query nodes (qnodes), which compute time-series data, thus separating compute from storage. A single dnode can contain a vnode, qnode, and mnode.
diff --git a/docs/en/12-taos-sql/22-meta.md b/docs/en/12-taos-sql/22-meta.md
index 1cd759742a8714274712343a22cbf723cd9c3212..d2bc72f047a7e18c120a39e426caea70fd711018 100644
--- a/docs/en/12-taos-sql/22-meta.md
+++ b/docs/en/12-taos-sql/22-meta.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Metadata
title: Information_Schema Database
+sidebar_label: Metadata
+description: This document describes how to use the INFORMATION_SCHEMA database in TDengine.
---
TDengine includes a built-in database named `INFORMATION_SCHEMA` to provide access to database metadata, system information, and status information. This information includes database names, table names, and currently running SQL statements. All information related to TDengine maintenance is stored in this database. It contains several read-only tables. These tables are more accurately described as views, and they do not correspond to specific files. You can query these tables but cannot write data to them. The INFORMATION_SCHEMA database is intended to provide a unified method for SHOW commands to access data. However, using SELECT ... FROM INFORMATION_SCHEMA.tablename offers several advantages over SHOW commands:
diff --git a/docs/en/12-taos-sql/23-perf.md b/docs/en/12-taos-sql/23-perf.md
index 29cf3af6abfbbc06e42ae99c78f35f33a3c7c30a..fc369ec663cf9130bd7d1af650f1f47a1054fad6 100644
--- a/docs/en/12-taos-sql/23-perf.md
+++ b/docs/en/12-taos-sql/23-perf.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Statistics
title: Performance_Schema Database
+sidebar_label: Statistics
+description: This document describes how to use the PERFORMANCE_SCHEMA database in TDengine.
---
TDengine includes a built-in database named `PERFORMANCE_SCHEMA` to provide access to database performance statistics. This document introduces the tables of PERFORMANCE_SCHEMA and their structure.
diff --git a/docs/en/12-taos-sql/24-show.md b/docs/en/12-taos-sql/24-show.md
index f70d86570e5fe9cf4f9eb6e58dd1908c62adcc89..dc1db956a0db1eead3a6c729e51c140b5be30c37 100644
--- a/docs/en/12-taos-sql/24-show.md
+++ b/docs/en/12-taos-sql/24-show.md
@@ -1,6 +1,7 @@
---
-sidebar_label: SHOW Statement
title: SHOW Statement for Metadata
+sidebar_label: SHOW Statement
+description: This document describes how to use the SHOW statement in TDengine.
---
`SHOW` command can be used to get brief system information. To get details about metatadata, information, and status in the system, please use `select` to query the tables in database `INFORMATION_SCHEMA`.
diff --git a/docs/en/12-taos-sql/25-grant.md b/docs/en/12-taos-sql/25-grant.md
index f895567c621f123778c8a711a68357a889ca0098..8b4c4393523c90595c7dd5461fc2abc73fa44c93 100644
--- a/docs/en/12-taos-sql/25-grant.md
+++ b/docs/en/12-taos-sql/25-grant.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Access Control
title: User and Access Control
-description: Manage user and user's permission
+sidebar_label: Access Control
+description: This document describes how to manage users and permissions in TDengine.
---
This document describes how to manage permissions in TDengine.
diff --git a/docs/en/12-taos-sql/26-udf.md b/docs/en/12-taos-sql/26-udf.md
index 977f3bcc0844ad63e4d2fe0f28d9ca8f29c5cbd6..249fcd3b54aceee06139fd93acc25b8a5b6ba43d 100644
--- a/docs/en/12-taos-sql/26-udf.md
+++ b/docs/en/12-taos-sql/26-udf.md
@@ -1,6 +1,7 @@
---
-sidebar_label: User-Defined Functions
title: User-Defined Functions (UDF)
+sidebar_label: User-Defined Functions
+description: This document describes the SQL statements related to user-defined functions (UDF) in TDengine.
---
You can create user-defined functions and import them into TDengine.
diff --git a/docs/en/12-taos-sql/27-index.md b/docs/en/12-taos-sql/27-index.md
index 7d09bc43ab06932b82019923d4a8fda48cd99c97..7586e4af76983e785b2c6b3f03870a8bcd6df4a3 100644
--- a/docs/en/12-taos-sql/27-index.md
+++ b/docs/en/12-taos-sql/27-index.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Index
-title: Using Indices
+title: Indexing
+sidebar_label: Indexing
+description: This document describes the SQL statements related to indexing in TDengine.
---
TDengine supports SMA and FULLTEXT indexing.
diff --git a/docs/en/12-taos-sql/28-recovery.md b/docs/en/12-taos-sql/28-recovery.md
index e869ffc45ff7420836d91a2536d32ce6b08a0d82..b4da25ea0c3b4f2758c981ee5bd03985ef3f2754 100644
--- a/docs/en/12-taos-sql/28-recovery.md
+++ b/docs/en/12-taos-sql/28-recovery.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Error Recovery
title: Error Recovery
+sidebar_label: Error Recovery
+description: This document describes the SQL statements related to error recovery in TDengine.
---
In a complex environment, connections and query tasks may encounter errors or fail to return in a reasonable time. If this occurs, you can terminate the connection or task.
diff --git a/docs/en/12-taos-sql/29-changes.md b/docs/en/12-taos-sql/29-changes.md
index f288cd7545c1de25f6cf8b003e084ba3622524a7..341791d6755aa66fddd98561823ee0e5ac74ba3f 100644
--- a/docs/en/12-taos-sql/29-changes.md
+++ b/docs/en/12-taos-sql/29-changes.md
@@ -1,7 +1,7 @@
---
-sidebar_label: Changes in TDengine 3.0
title: Changes in TDengine 3.0
-description: "This document explains how TDengine SQL has changed in version 3.0."
+sidebar_label: Changes in TDengine 3.0
+description: This document describes how TDengine SQL has changed in version 3.0 compared with previous versions.
---
## Basic SQL Elements
diff --git a/docs/en/12-taos-sql/index.md b/docs/en/12-taos-sql/index.md
index a5ffc9dc8dce158eccc0fa0519f09ba346710c31..276f84f21bc8ab92d13f1975b298dbdcf25db249 100644
--- a/docs/en/12-taos-sql/index.md
+++ b/docs/en/12-taos-sql/index.md
@@ -1,6 +1,6 @@
---
title: TDengine SQL
-description: 'The syntax supported by TDengine SQL '
+description: This document describes the syntax and functions supported by TDengine SQL.
---
This section explains the syntax of SQL to perform operations on databases, tables and STables, insert data, select data and use functions. We also provide some tips that can be used in TDengine SQL. If you have previous experience with SQL this section will be fairly easy to understand. If you do not have previous experience with SQL, you'll come to appreciate the simplicity and power of SQL. TDengine SQL has been enhanced in version 3.0, and the query engine has been rearchitected. For information about how TDengine SQL has changed, see [Changes in TDengine 3.0](../taos-sql/changes).
diff --git a/docs/en/13-operation/01-pkg-install.md b/docs/en/13-operation/01-pkg-install.md
index d7713b943f5fe8fbd5e685b8ba03ff8cc8ed4e53..6e6c4aaebf7da8ed633cbb89233f9028f56d8302 100644
--- a/docs/en/13-operation/01-pkg-install.md
+++ b/docs/en/13-operation/01-pkg-install.md
@@ -1,6 +1,6 @@
---
title: Install and Uninstall
-description: Install, Uninstall, Start, Stop and Upgrade
+description: This document describes how to install, upgrade, and uninstall TDengine.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/13-operation/02-planning.mdx b/docs/en/13-operation/02-planning.mdx
index 2dffa7bb8747e21e4754740208eafed65d341217..37ef6aae26ce55046ead09bcfbe37a14213bad46 100644
--- a/docs/en/13-operation/02-planning.mdx
+++ b/docs/en/13-operation/02-planning.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: Resource Planning
title: Resource Planning
+sidebar_label: Resource Planning
+description: This document describes how to plan compute and storage resources for your TDengine cluster.
---
It is important to plan computing and storage resources if using TDengine to build an IoT, time-series or Big Data platform. How to plan the CPU, memory and disk resources required, will be described in this chapter.
diff --git a/docs/en/13-operation/03-tolerance.md b/docs/en/13-operation/03-tolerance.md
index 21a5a902822d7b85f555114a112686d4e35c64aa..4f33748e68a0b51be619fe7aa8cc3b2152c71bf2 100644
--- a/docs/en/13-operation/03-tolerance.md
+++ b/docs/en/13-operation/03-tolerance.md
@@ -1,5 +1,6 @@
---
title: Fault Tolerance and Disaster Recovery
+description: This document describes how TDengine provides fault tolerance and disaster recovery.
---
## Fault Tolerance
diff --git a/docs/en/13-operation/07-import.md b/docs/en/13-operation/07-import.md
index 8362cec1ab3072866018678b42a679d0c19b49de..e95824e927f4c65b427d0819d7bc968c52f5fbe5 100644
--- a/docs/en/13-operation/07-import.md
+++ b/docs/en/13-operation/07-import.md
@@ -1,5 +1,6 @@
---
title: Data Import
+description: This document describes how to import data into TDengine.
---
There are multiple ways of importing data provided by TDengine: import with script, import from data file, import using `taosdump`.
diff --git a/docs/en/13-operation/08-export.md b/docs/en/13-operation/08-export.md
index 5780de42faeaedbc1c985ad2aa2f52fe56c76971..bffda36e23741a7ff52394772c918fa7040ea047 100644
--- a/docs/en/13-operation/08-export.md
+++ b/docs/en/13-operation/08-export.md
@@ -1,5 +1,6 @@
---
title: Data Export
+description: This document describes how to export data from TDengine.
---
There are two ways of exporting data from a TDengine cluster:
diff --git a/docs/en/13-operation/10-monitor.md b/docs/en/13-operation/10-monitor.md
index 74a5564a2a7b82009e6b2406290a5c15afbf3c1d..346b874059a11c5608027b4ea6e2550765d64186 100644
--- a/docs/en/13-operation/10-monitor.md
+++ b/docs/en/13-operation/10-monitor.md
@@ -1,5 +1,6 @@
---
title: TDengine Monitoring
+description: This document describes how to monitor your TDengine cluster.
---
After TDengine is started, it automatically writes monitoring data including CPU, memory and disk usage, bandwidth, number of requests, disk I/O speed, slow queries, into a designated database at a predefined interval through taosKeeper. Additionally, some important system operations, like logon, create user, drop database, and alerts and warnings generated in TDengine are written into the `log` database too. A system operator can view the data in `log` database from TDengine CLI or from a web console.
diff --git a/docs/en/13-operation/17-diagnose.md b/docs/en/13-operation/17-diagnose.md
index fa202a23ea5b5d58eb0fc107045a9c27c7fa99ad..9d42b3ebbcfe0b87fa23bccaee12769d465fc24e 100644
--- a/docs/en/13-operation/17-diagnose.md
+++ b/docs/en/13-operation/17-diagnose.md
@@ -1,5 +1,6 @@
---
title: Problem Diagnostics
+description: This document describes how to diagnose issues with your TDengine cluster.
---
## Network Connection Diagnostics
diff --git a/docs/en/13-operation/index.md b/docs/en/13-operation/index.md
index c64749c40e26f091e4a25e0238827ebceff4b069..8b386dc19a1113a84016bf3d03dd847216eed930 100644
--- a/docs/en/13-operation/index.md
+++ b/docs/en/13-operation/index.md
@@ -1,5 +1,6 @@
---
title: Administration
+description: This document describes how to perform management operations on your TDengine cluster from an administrator's perspective.
---
This chapter is mainly written for system administrators. It covers download, install/uninstall, data import/export, system monitoring, user management, connection management, capacity planning and system optimization.
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 09e40b956f9a3b713335bec768fd1d5474f4bea1..b138d69bfc277401723e5b75b874b42914963f48 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
@@ -1,5 +1,6 @@
---
title: REST API
+description: This document describes the TDengine REST API.
---
To support the development of various types of applications and platforms, TDengine provides an API that conforms to REST principles; namely REST API. To minimize the learning cost, unlike REST APIs for other database engines, TDengine allows insertion of SQL commands in the BODY of an HTTP POST request, to operate the database.
diff --git a/docs/en/14-reference/03-connector/03-cpp.mdx b/docs/en/14-reference/03-connector/03-cpp.mdx
index 906d56ab158e20db4bafa9eb8375434568555184..3bd7b7f4c6ad0c2ca3cf5c05fa72d1b27f714653 100644
--- a/docs/en/14-reference/03-connector/03-cpp.mdx
+++ b/docs/en/14-reference/03-connector/03-cpp.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: C/C++
title: C/C++ Connector
+sidebar_label: C/C++
+description: This document describes the TDengine C/C++ connector.
---
C/C++ developers can use TDengine's client driver and the C/C++ connector, to develop their applications to connect to TDengine clusters for data writing, querying, and other functions. To use the C/C++ connector you must include the TDengine header file _taos.h_, which lists the function prototypes of the provided APIs. The application also needs to link to the corresponding dynamic libraries on the platform where it is located.
diff --git a/docs/en/14-reference/03-connector/04-java.mdx b/docs/en/14-reference/03-connector/04-java.mdx
index c37738b3f8ddba9879159e04573798dd61efa27e..61ce1660694aee4ded365cfbff0427ec48192348 100644
--- a/docs/en/14-reference/03-connector/04-java.mdx
+++ b/docs/en/14-reference/03-connector/04-java.mdx
@@ -1,8 +1,8 @@
---
-toc_max_heading_level: 4
-sidebar_label: Java
title: TDengine Java Connector
-description: The TDengine Java Connector is implemented on the standard JDBC API and provides native and REST connectors.
+sidebar_label: Java
+description: This document describes the TDengine Java Connector.
+toc_max_heading_level: 4
---
import Tabs from '@theme/Tabs';
diff --git a/docs/en/14-reference/03-connector/05-go.mdx b/docs/en/14-reference/03-connector/05-go.mdx
index 60407c0735bf9bcb42ae54bddcc9afa639a02fcc..da2f54708f550bc4ba9f35da81ad59a575bda169 100644
--- a/docs/en/14-reference/03-connector/05-go.mdx
+++ b/docs/en/14-reference/03-connector/05-go.mdx
@@ -1,7 +1,8 @@
---
-toc_max_heading_level: 4
-sidebar_label: Go
title: TDengine Go Connector
+sidebar_label: Go
+description: This document describes the TDengine Go connector.
+toc_max_heading_level: 4
---
import Tabs from '@theme/Tabs';
diff --git a/docs/en/14-reference/03-connector/06-rust.mdx b/docs/en/14-reference/03-connector/06-rust.mdx
index 4e2a7848dc87ac0522b6d5aa5855b5a0998dc789..6e848596107f3dd8a0e99b4bf8fe1dc9530021a4 100644
--- a/docs/en/14-reference/03-connector/06-rust.mdx
+++ b/docs/en/14-reference/03-connector/06-rust.mdx
@@ -1,7 +1,8 @@
---
-toc_max_heading_level: 4
-sidebar_label: Rust
title: TDengine Rust Connector
+sidebar_label: Rust
+description: This document describes the TDengine Rust connector.
+toc_max_heading_level: 4
---
import Tabs from '@theme/Tabs';
diff --git a/docs/en/14-reference/03-connector/07-python.mdx b/docs/en/14-reference/03-connector/07-python.mdx
index d593c3f133dafa3b5f8083577f8f0d4d75cb3d8b..146da268a8b7b4ebf799f3441efcd2d454afd65d 100644
--- a/docs/en/14-reference/03-connector/07-python.mdx
+++ b/docs/en/14-reference/03-connector/07-python.mdx
@@ -1,7 +1,7 @@
---
-sidebar_label: Python
title: TDengine Python Connector
-description: "taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. tasopy wraps both the native and REST interfaces of TDengine, corresponding to the two submodules of tasopy: taos and taosrest. In addition to wrapping the native and REST interfaces, taospy also provides a programming interface that conforms to the Python Data Access Specification (PEP 249), making it easy to integrate taospy with many third-party tools, such as SQLAlchemy and pandas."
+sidebar_label: Python
+description: This document describes taospy, the TDengine Python connector.
---
import Tabs from "@theme/Tabs";
diff --git a/docs/en/14-reference/03-connector/08-node.mdx b/docs/en/14-reference/03-connector/08-node.mdx
index a36cf0efc9432425ad16c4d8112cc813a8c528b9..83479f91dab38d072f53952464153190ad3eaa03 100644
--- a/docs/en/14-reference/03-connector/08-node.mdx
+++ b/docs/en/14-reference/03-connector/08-node.mdx
@@ -1,7 +1,8 @@
---
-toc_max_heading_level: 4
-sidebar_label: Node.js
title: TDengine Node.js Connector
+sidebar_label: Node.js
+description: This document describes the TDengine Node.js connector.
+toc_max_heading_level: 4
---
import Tabs from "@theme/Tabs";
@@ -59,9 +60,19 @@ Please refer to [version support list](/reference/connector#version-support)
- `python` (recommended for `v2.7` , `v3.x.x` currently not supported)
- `@tdengine/client` 3.0.0 supports Node.js LTS v10.9.0 or later and Node.js LTS v12.8.0 or later. Older versions may be incompatible.
- `make`
-- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or higher
+- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or later.
+
+
+
+- `python` (recommended for `v2.7` , `v3.x.x` currently not supported)
+- `@tdengine/client` 3.0.0 currently supports Node.js from v12.22.12, but only later versions of v12. Other versions may be incompatible.
+- `make`
+- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or later.
+
+
+
- Installation method 1
@@ -249,4 +260,4 @@ let cursor = conn.cursor();
## API Reference
-[API Reference](https://docs.taosdata.com/api/td2.0-connector/)
\ No newline at end of file
+[API Reference](https://docs.taosdata.com/api/td2.0-connector/)
diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx
index 756e948bd293477c37439b624bab9af86191e232..e984967fb7048bf4a89d5528be7f6c977820d255 100644
--- a/docs/en/14-reference/03-connector/09-csharp.mdx
+++ b/docs/en/14-reference/03-connector/09-csharp.mdx
@@ -1,7 +1,8 @@
---
-toc_max_heading_level: 4
-sidebar_label: C#
title: C# Connector
+sidebar_label: C#
+description: This document describes the TDengine C# connector.
+toc_max_heading_level: 4
---
import Tabs from '@theme/Tabs';
diff --git a/docs/en/14-reference/03-connector/10-php.mdx b/docs/en/14-reference/03-connector/10-php.mdx
index 87f8616f9ebac598285406eb404b7c2544950ee3..fd00d11239315bbab6e59d838d472d3496ff8342 100644
--- a/docs/en/14-reference/03-connector/10-php.mdx
+++ b/docs/en/14-reference/03-connector/10-php.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: PHP
title: PHP Connector
+sidebar_label: PHP
+description: This document describes the TDengine PHP connector.
---
`php-tdengine` is the TDengine PHP connector provided by TDengine community. In particular, it supports Swoole coroutine.
diff --git a/docs/en/14-reference/03-connector/index.mdx b/docs/en/14-reference/03-connector/index.mdx
index da3aae8309a9282a37597a3ac4bb623e6dfd1b79..2df73b8592c496ca1e3e715c86a9fbb83420f425 100644
--- a/docs/en/14-reference/03-connector/index.mdx
+++ b/docs/en/14-reference/03-connector/index.mdx
@@ -1,5 +1,6 @@
---
title: Connector
+description: This document describes the connectors that TDengine provides to interface with various programming languages.
---
TDengine provides a rich set of APIs (application development interface). To facilitate users to develop their applications quickly, TDengine supports connectors for multiple programming languages, including official connectors for C/C++, Java, Python, Go, Node.js, C#, and Rust. These connectors support connecting to TDengine clusters using both native interfaces (taosc) and REST interfaces (not supported in a few languages yet). Community developers have also contributed several unofficial connectors, such as the ADO.NET connector, the Lua connector, and the PHP connector.
diff --git a/docs/en/14-reference/04-taosadapter.md b/docs/en/14-reference/04-taosadapter.md
index 9eb6cb921391df3ce494fddaae8caa23cb0f4adc..c1ec97b647c228b7302391f768033792e236c79b 100644
--- a/docs/en/14-reference/04-taosadapter.md
+++ b/docs/en/14-reference/04-taosadapter.md
@@ -1,7 +1,7 @@
---
-title: "taosAdapter"
-description: "taosAdapter is a TDengine companion tool that acts as a bridge and adapter between TDengine clusters and applications. It provides an easy-to-use and efficient way to ingest data directly from data collection agent software such as Telegraf, StatsD, collectd, etc. It also provides an InfluxDB/OpenTSDB compatible data ingestion interface, allowing InfluxDB/OpenTSDB applications to be seamlessly ported to TDengine."
-sidebar_label: "taosAdapter"
+title: taosAdapter
+sidebar_label: taosAdapter
+description: This document describes how to use taosAdapter, a TDengine companion tool that acts as a bridge and adapter between TDengine clusters and applications.
---
import Prometheus from "./_prometheus.mdx"
diff --git a/docs/en/14-reference/05-taosbenchmark.md b/docs/en/14-reference/05-taosbenchmark.md
index 4017b12be923a9bcb5696c8b4b57c2d67b5c1378..9828d71ece98ca6de2f079f5599f2eed7fcea891 100644
--- a/docs/en/14-reference/05-taosbenchmark.md
+++ b/docs/en/14-reference/05-taosbenchmark.md
@@ -1,8 +1,8 @@
---
title: taosBenchmark
sidebar_label: taosBenchmark
+description: This document describes how to use taosBenchmark, a tool for testing the performance of TDengine.
toc_max_heading_level: 4
-description: "taosBenchmark (once called taosdemo ) is a tool for testing the performance of TDengine."
---
# Introduction
diff --git a/docs/en/14-reference/06-taosdump.md b/docs/en/14-reference/06-taosdump.md
index 9c63b4dc035b6a6a18f8e17f19782527eef88bca..dcfc068a3d64eb9f755f498b2b80d0a2b228842f 100644
--- a/docs/en/14-reference/06-taosdump.md
+++ b/docs/en/14-reference/06-taosdump.md
@@ -1,6 +1,6 @@
---
title: taosdump
-description: "taosdump is a tool that supports backing up data from a running TDengine cluster and restoring the backed up data to the same, or another running TDengine cluster."
+description: This document describes how to use taosdump, a tool for backing up and restoring the data in a TDengine cluster.
---
## Introduction
diff --git a/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp
index 942130d4fabf7944c7add10acb3bb42ca7f51e0f..a90477880ff3a2cb2068540b55b69e4bbdbd8d4c 100644
Binary files a/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp and b/docs/en/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp differ
diff --git a/docs/en/14-reference/07-tdinsight/index.md b/docs/en/14-reference/07-tdinsight/index.md
index d03c16a8bc25a39fb751ded4b5c12df4b69a8e4e..652d5ded0b3fed28961e92d4894fa090be393873 100644
--- a/docs/en/14-reference/07-tdinsight/index.md
+++ b/docs/en/14-reference/07-tdinsight/index.md
@@ -1,6 +1,7 @@
---
title: TDinsight - Grafana-based Zero-Dependency Monitoring Solution for TDengine
sidebar_label: TDinsight
+description: This document describes TDinsight, a monitoring solution for TDengine.
---
TDinsight is a solution for monitoring TDengine using the builtin native monitoring database and [Grafana].
@@ -325,11 +326,12 @@ Currently, only the number of logins per minute is reported.
Support monitoring taosAdapter request statistics and status details. Includes.
-1. **http_request_inflight**: number of real-time requests.
-2. **http_request_total**: number of total requests.
-3. **http_request_fail**: number of failed requets.
-4. **CPU Used**: CPU usage of taosAdapter.
-5. **Memory Used**: Memory usage of taosAdapter.
+1. **Http Request Total**: number of total requests.
+2. **Http Request Fail**: number of failed requests.
+3. **CPU Used**: CPU usage of taosAdapter.
+4. **Memory Used**: Memory usage of taosAdapter.
+5. **Http Request Inflight**: number of real-time requests.
+6. **Http Status Code**: taosAdapter http status code.
## Upgrade
diff --git a/docs/en/14-reference/08-taos-shell.md b/docs/en/14-reference/08-taos-shell.md
index 68e2f087658305ec408c50e27f4a87ef43b2c870..7833ac861fea5fb2dfd66ccc9ec2db8f0ddeff3f 100644
--- a/docs/en/14-reference/08-taos-shell.md
+++ b/docs/en/14-reference/08-taos-shell.md
@@ -1,7 +1,7 @@
---
title: TDengine Command Line Interface (CLI)
sidebar_label: Command Line Interface
-description: Instructions and tips for using the TDengine CLI
+description: This document describes how to use the TDengine CLI.
---
The TDengine command-line interface (hereafter referred to as `TDengine CLI`) is the simplest way for users to manipulate and interact with TDengine instances.
diff --git a/docs/en/14-reference/09-support-platform/index.md b/docs/en/14-reference/09-support-platform/index.md
index 061294f0160f5f07c7c032b4a7475f6b12c2efca..7dfa8ac93a9e91eb9238f7b56033a592c241079f 100644
--- a/docs/en/14-reference/09-support-platform/index.md
+++ b/docs/en/14-reference/09-support-platform/index.md
@@ -1,6 +1,6 @@
---
title: List of supported platforms
-description: "List of platforms supported by TDengine server, client, and connector"
+description: This document describes the supported platforms for the TDengine server, client, and connectors.
---
## List of supported platforms for TDengine server
diff --git a/docs/en/14-reference/11-docker/index.md b/docs/en/14-reference/11-docker/index.md
index 89987c456f14d243a4b59af5b15ae754225bbaf9..b9278c6961ec5f395f68795422bde682f9467f77 100644
--- a/docs/en/14-reference/11-docker/index.md
+++ b/docs/en/14-reference/11-docker/index.md
@@ -1,6 +1,6 @@
---
title: Deploying TDengine with Docker
-description: "This chapter focuses on starting the TDengine service in a container and accessing it."
+description: This chapter describes how to start and access TDengine in a Docker container.
---
This chapter describes how to start the TDengine service in a container and access it. Users can control the behavior of the service in the container by using environment variables on the docker run command-line or in the docker-compose file.
diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md
index 9e56a0b0bff931c3b10103c5d63f9134baf280a1..afa9f5a8aebe08d733b059a664467bc08d2c4aa6 100644
--- a/docs/en/14-reference/12-config/index.md
+++ b/docs/en/14-reference/12-config/index.md
@@ -1,6 +1,6 @@
---
title: Configuration Parameters
-description: "Configuration parameters for client and server in TDengine"
+description: This document describes the configuration parameters for the TDengine server and client.
---
## Configuration File on Server Side
@@ -162,11 +162,7 @@ The parameters described in this document by the effect that they have on the sy
| Meaning | Execution policy for query statements |
| Unit | None |
| Default | 1 |
-| Value Range | 1: Run queries on vnodes and not on qnodes
-
-2: Run subtasks without scan operators on qnodes and subtasks with scan operators on vnodes.
-
-3: Only run scan operators on vnodes; run all other operators on qnodes. |
+| Value Range | 1: Run queries on vnodes and not on qnodes; 2: Run subtasks without scan operators on qnodes and subtasks with scan operators on vnodes; 3: Only run scan operators on vnodes, and run all other operators on qnodes. |
### querySmaOptimize
@@ -176,11 +172,7 @@ The parameters described in this document by the effect that they have on the sy
| Meaning | SMA index optimization policy |
| Unit | None |
| Default Value | 0 |
-| Notes |
-
-0: Disable SMA indexing and perform all queries on non-indexed data.
-
-1: Enable SMA indexing and perform queries from suitable statements on precomputation results.|
+| Notes |0: Disable SMA indexing and perform all queries on non-indexed data; 1: Enable SMA indexing and perform queries from suitable statements on precomputation results.|
### countAlwaysReturnValue
diff --git a/docs/en/14-reference/12-directory.md b/docs/en/14-reference/12-directory.md
index 19b036418f18637bfd21fa286f24528c649d146d..651892c8b29447647d8edef12af58c469de951b1 100644
--- a/docs/en/14-reference/12-directory.md
+++ b/docs/en/14-reference/12-directory.md
@@ -1,6 +1,6 @@
---
title: File directory structure
-description: "TDengine installation directory description"
+description: This document describes the structure of the TDengine directory after installation.
---
After TDengine is installed, the following directories or files will be created in the system by default.
diff --git a/docs/en/14-reference/13-schemaless/13-schemaless.md b/docs/en/14-reference/13-schemaless/13-schemaless.md
index a97a54af02601ddc2dde43614ac7ba8a6c8d4009..caedd76df8e41b4246891f686d61ed61af671d7e 100644
--- a/docs/en/14-reference/13-schemaless/13-schemaless.md
+++ b/docs/en/14-reference/13-schemaless/13-schemaless.md
@@ -1,6 +1,6 @@
---
title: Schemaless Writing
-description: 'The Schemaless write method eliminates the need to create super tables/sub tables in advance and automatically creates the storage structure corresponding to the data, as it is written to the interface.'
+description: This document describes how to use the schemaless write component of TDengine.
---
In IoT applications, data is collected for many purposes such as intelligent control, business analysis, device monitoring and so on. Due to changes in business or functional requirements or changes in device hardware, the application logic and even the data collected may change. Schemaless writing automatically creates storage structures for your data as it is being written to TDengine, so that you do not need to create supertables in advance. When necessary, schemaless writing
diff --git a/docs/en/14-reference/14-taosKeeper.md b/docs/en/14-reference/14-taosKeeper.md
index 665bc75380d4f59666d792d074fb37c65c810264..0b4a1fbd60e1cb465ecb3e01f50e8c39aaa3497c 100644
--- a/docs/en/14-reference/14-taosKeeper.md
+++ b/docs/en/14-reference/14-taosKeeper.md
@@ -1,7 +1,7 @@
---
sidebar_label: taosKeeper
title: taosKeeper
-description: exports TDengine monitoring metrics.
+description: This document describes how to use taosKeeper, a tool for exporting TDengine monitoring metrics.
---
## Introduction
diff --git a/docs/en/14-reference/index.md b/docs/en/14-reference/index.md
index f3a64913d065d1d8e321ce7433c9d605ef70bd13..bc8ec6996538bf15bf4cb4d52aaa126ed11b5b72 100644
--- a/docs/en/14-reference/index.md
+++ b/docs/en/14-reference/index.md
@@ -1,5 +1,6 @@
---
title: Reference
+description: This document describes TDengine connectors and utilities.
---
This section describes the TDengine connectors and utilities.
diff --git a/docs/en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx
index ca32ce8afce30eaa6756f7b403685b989d824bbf..5a2942b14497401ef1a2cb8f31ad2773f6b828e3 100644
--- a/docs/en/20-third-party/01-grafana.mdx
+++ b/docs/en/20-third-party/01-grafana.mdx
@@ -1,6 +1,7 @@
---
-sidebar_label: Grafana
title: Grafana
+sidebar_label: Grafana
+description: This document describes how to integrate TDengine with Grafana.
---
import Tabs from "@theme/Tabs";
@@ -155,13 +156,13 @@ You can setup a zero-configuration stack for TDengine + Grafana by [docker-compo
services:
tdengine:
- image: tdengine/tdengine:2.6.0.2
+ image: tdengine/tdengine:3.0.2.4
environment:
TAOS_FQDN: tdengine
volumes:
- tdengine-data:/var/lib/taos/
grafana:
- image: grafana/grafana:8.5.6
+ image: grafana/grafana:9.3.6
volumes:
- ./tdengine.yml/:/etc/grafana/provisioning/tdengine.yml
- grafana-data:/var/lib/grafana
@@ -196,11 +197,18 @@ As shown above, select the `TDengine` data source in the `Query` and enter the c
- INPUT SQL: Enter the desired query (the results being two columns and multiple rows), such as `select _wstart, avg(mem_system) from log.dnodes_info where ts >= $from and ts < $to interval($interval)`. In this statement, $from, $to, and $interval are variables that Grafana replaces with the query time range and interval. In addition to the built-in variables, custom template variables are also supported.
- ALIAS BY: This allows you to set the current query alias.
- GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement.
+- Group by column name(s): `group by` or `partition by` columns name split by comma. By setting `Group by column name(s)`, it can show multi-dimension data if Sql is `group by` or `partition by`. Such as, it can show data by `dnode_ep` if sql is `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)` and `Group by column name(s)` is `dnode_ep`.
+- Format to: format legend for `group by` or `partition by`. Such as it can display series data by `dnode_ep` if sql is `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)` and `Group by column name(s)` is `dnode_ep` and `Format to` is `mem_system_{{dnode_ep}}`.
Follow the default prompt to query the average system memory usage for the specified interval on the server where the current TDengine deployment is located as follows.
![TDengine Database TDinsight plugin create dashboard 2](./grafana/create_dashboard2.webp)
+查询每台 TDengine 服务器指定间隔系统内存平均使用量如下.
+The example to query the average system memory usage for the specified interval on each server as follows.
+
+![TDengine Database TDinsight plugin create dashboard 2](./grafana/create_dashboard3.webp)
+
> For more information on how to use Grafana to create the appropriate monitoring interface and for more details on using Grafana, refer to the official Grafana [documentation](https://grafana.com/docs/).
### Importing the Dashboard
diff --git a/docs/en/20-third-party/02-prometheus.md b/docs/en/20-third-party/02-prometheus.md
index ef9b9cb637ffc8da2de6acdd853fa097cfbc0193..bfdd3d015e6fcfa484fdceea6f0bebc43049ed17 100644
--- a/docs/en/20-third-party/02-prometheus.md
+++ b/docs/en/20-third-party/02-prometheus.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Prometheus
title: Prometheus writing and reading
+sidebar_label: Prometheus
+description: This document describes how to integrate TDengine with Prometheus.
---
import Prometheus from "../14-reference/_prometheus.mdx"
diff --git a/docs/en/20-third-party/03-telegraf.md b/docs/en/20-third-party/03-telegraf.md
index 8f3cab0e57094a1d2fac5f54601489382ac3f9a1..7e99b84eab88614bf82da92a2db11ddf1be753bf 100644
--- a/docs/en/20-third-party/03-telegraf.md
+++ b/docs/en/20-third-party/03-telegraf.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Telegraf
title: Telegraf writing
+sidebar_label: Telegraf
+description: This document describes how to integrate TDengine with Telegraf.
---
import Telegraf from "../14-reference/_telegraf.mdx"
diff --git a/docs/en/20-third-party/05-collectd.md b/docs/en/20-third-party/05-collectd.md
index 5b52e3b7bc75c2d21ab5a6c08331030fe4e423f7..d8c8e7f81def389418d28d62486ef32afb5d996c 100644
--- a/docs/en/20-third-party/05-collectd.md
+++ b/docs/en/20-third-party/05-collectd.md
@@ -1,6 +1,7 @@
---
-sidebar_label: collectd
title: collectd writing
+sidebar_label: collectd
+description: This document describes how to integrate TDengine with collectd.
---
import CollectD from "../14-reference/_collectd.mdx"
diff --git a/docs/en/20-third-party/06-statsd.md b/docs/en/20-third-party/06-statsd.md
index b861a48ecd59fa1f2036c6c323d3fdee8a3ee44b..ea428e9cdb45992cdebd6be4713583b88990a67f 100644
--- a/docs/en/20-third-party/06-statsd.md
+++ b/docs/en/20-third-party/06-statsd.md
@@ -1,6 +1,7 @@
---
-sidebar_label: StatsD
title: StatsD Writing
+sidebar_label: StatsD
+description: This document describes how to integrate TDengine with StatsD.
---
import StatsD from "../14-reference/_statsd.mdx"
diff --git a/docs/en/20-third-party/07-icinga2.md b/docs/en/20-third-party/07-icinga2.md
index 167b6a4303f838c8c9945a95dac802a54bad3525..540aae8689bc0885ab4649be8fd07fec04dad829 100644
--- a/docs/en/20-third-party/07-icinga2.md
+++ b/docs/en/20-third-party/07-icinga2.md
@@ -1,6 +1,7 @@
---
-sidebar_label: icinga2
title: icinga2 writing
+sidebar_label: icinga2
+description: This document describes how to integrate TDengine with icinga2.
---
import Icinga2 from "../14-reference/_icinga2.mdx"
diff --git a/docs/en/20-third-party/08-tcollector.md b/docs/en/20-third-party/08-tcollector.md
index b604a2d7125851a8f2ec4965f755f5400d0613bf..f1c0ecd44deaea6172d8d9b1d4e6c2e5ee8ccabb 100644
--- a/docs/en/20-third-party/08-tcollector.md
+++ b/docs/en/20-third-party/08-tcollector.md
@@ -1,6 +1,7 @@
---
-sidebar_label: TCollector
title: TCollector writing
+sidebar_label: TCollector
+description: This document describes how to integrate TDengine with TCollector.
---
import TCollector from "../14-reference/_tcollector.mdx"
diff --git a/docs/en/20-third-party/09-emq-broker.md b/docs/en/20-third-party/09-emq-broker.md
index 2ead1bbaf40f06fec2a5cbf85e46fdfdcc5216df..10ce0174ed5d362a113acd7ade59741a10155657 100644
--- a/docs/en/20-third-party/09-emq-broker.md
+++ b/docs/en/20-third-party/09-emq-broker.md
@@ -1,6 +1,7 @@
---
-sidebar_label: EMQX Broker
title: EMQX Broker writing
+sidebar_label: EMQX Broker
+description: This document describes how to integrate TDengine with the EMQX broker.
---
MQTT is a popular IoT data transfer protocol. [EMQX](https://github.com/emqx/emqx) is an open-source MQTT Broker software. You can write MQTT data directly to TDengine without any code. You only need to setup "rules" in EMQX Dashboard to create a simple configuration. EMQX supports saving data to TDengine by sending data to a web service and provides a native TDengine driver for direct saving in the Enterprise Edition. Please refer to the [EMQX official documentation](https://www.emqx.io/docs/en/v4.4/rule/rule-engine.html) for details on how to use it.).
diff --git a/docs/en/20-third-party/10-hive-mq-broker.md b/docs/en/20-third-party/10-hive-mq-broker.md
index 828a62ac5b336766d5c3770cc42cd3a61cfd8d5d..6c5165596e04678db1dd32d16756133719fdb4b9 100644
--- a/docs/en/20-third-party/10-hive-mq-broker.md
+++ b/docs/en/20-third-party/10-hive-mq-broker.md
@@ -1,6 +1,7 @@
---
-sidebar_label: HiveMQ Broker
title: HiveMQ Broker Writing
+sidebar_label: HiveMQ Broker
+description: This document describes how to integrate TDengine with the HiveMQ broker.
---
[HiveMQ](https://www.hivemq.com/) is an MQTT broker that provides community and enterprise editions. HiveMQ is mainly for enterprise emerging machine-to-machine M2M communication and internal transport, meeting scalability, ease of management, and security features. HiveMQ provides an open-source plug-in development kit. MQTT data can be saved to TDengine via TDengine extension for HiveMQ. For more information, see [HiveMQ TDengine Extension](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README_EN.md).
diff --git a/docs/en/20-third-party/11-kafka.md b/docs/en/20-third-party/11-kafka.md
index 3e8f7c295d7b6ab81ecb678865ed3e4eff81b2c5..0998862b2d75b98fb65ff414d000535b0c8b7ea5 100644
--- a/docs/en/20-third-party/11-kafka.md
+++ b/docs/en/20-third-party/11-kafka.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Kafka
title: TDengine Kafka Connector Tutorial
+sidebar_label: Kafka
+description: This document describes how to integrate TDengine with Kafka.
---
TDengine Kafka Connector contains two plugins: TDengine Source Connector and TDengine Sink Connector. Users only need to provide a simple configuration file to synchronize the data of the specified topic in Kafka (batch or real-time) to TDengine or synchronize the data (batch or real-time) of the specified database in TDengine to Kafka.
diff --git a/docs/en/20-third-party/12-google-data-studio.md b/docs/en/20-third-party/12-google-data-studio.md
index fc94f98056bbeeeec88ca7ea12a4a6a7e6f15dc5..ea6431fa5a81b3b9e51fe04e8e404cf52e9c0ad9 100644
--- a/docs/en/20-third-party/12-google-data-studio.md
+++ b/docs/en/20-third-party/12-google-data-studio.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Google Data Studio
title: Use Google Data Studio to access TDengine
+sidebar_label: Google Data Studio
+description: This document describes how to integrate TDengine with Google Data Studio.
---
Data Studio is a powerful tool for reporting and visualization, offering a wide variety of charts and connectors and making it easy to generate reports based on predefined templates. Its ease of use and robust ecosystem have made it one of the first choices for people working in data analysis.
diff --git a/docs/en/20-third-party/13-Jupyter.md b/docs/en/20-third-party/13-Jupyter.md
index fbd7e530f0959740c53e48ce1d73d92ce0d6c5c5..1ac9df1da4c7756c4f186d456948ae65262e9d54 100644
--- a/docs/en/20-third-party/13-Jupyter.md
+++ b/docs/en/20-third-party/13-Jupyter.md
@@ -1,6 +1,7 @@
---
-sidebar_label: JupyterLab
title: Connect JupyterLab to TDengine
+sidebar_label: JupyterLab
+description: This document describes how to integrate TDengine with JupyterLab.
---
JupyterLab is the next generation of the ubiquitous Jupyter Notebook. In this note we show you how to install the TDengine Python connector to connect to TDengine in JupyterLab. You can then insert data and perform queries against the TDengine instance within JupyterLab.
diff --git a/docs/en/20-third-party/grafana/create_dashboard1.webp b/docs/en/20-third-party/grafana/create_dashboard1.webp
index 55eb388833e4df2a46f4d1cf6d346aa11429385d..df41d66d50e888555792ef34188a966c2e106a86 100644
Binary files a/docs/en/20-third-party/grafana/create_dashboard1.webp and b/docs/en/20-third-party/grafana/create_dashboard1.webp differ
diff --git a/docs/en/20-third-party/grafana/create_dashboard2.webp b/docs/en/20-third-party/grafana/create_dashboard2.webp
index bb40e407187718c52e9f617d8ebd3d25fd14b56b..ba50f5299605bd72ebfe1f3f5d1d62bdbc8939c9 100644
Binary files a/docs/en/20-third-party/grafana/create_dashboard2.webp and b/docs/en/20-third-party/grafana/create_dashboard2.webp differ
diff --git a/docs/en/20-third-party/grafana/create_dashboard3.webp b/docs/en/20-third-party/grafana/create_dashboard3.webp
new file mode 100644
index 0000000000000000000000000000000000000000..84f387f87bcc8e06fca90deabebd1d601c528ef1
Binary files /dev/null and b/docs/en/20-third-party/grafana/create_dashboard3.webp differ
diff --git a/docs/en/20-third-party/index.md b/docs/en/20-third-party/index.md
index 87bd9e075133d1182ee93d1c1c43617c766755b9..6fc8043eefef62d476e289195c8f38e385e020c4 100644
--- a/docs/en/20-third-party/index.md
+++ b/docs/en/20-third-party/index.md
@@ -1,5 +1,6 @@
---
title: Third Party Tools
+description: This document describes how to integrate TDengine with various third-party tools.
---
Since TDengine supports standard SQL commands, common database connector standards (e.g., JDBC), ORM, and other popular time-series database writing protocols (e.g., InfluxDB Line Protocol, OpenTSDB JSON, OpenTSDB Telnet, etc.), it is very easy to integrate TDengine with other third party tools. You only need to provide simple configuration, the integration can be done without a line of code.
diff --git a/docs/en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md
index 697ecb98a1c212dbdfef47a916fe1e288ea5508c..cef05dcc56793846fd36515121f6688f74999bbf 100644
--- a/docs/en/21-tdinternal/01-arch.md
+++ b/docs/en/21-tdinternal/01-arch.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Architecture
title: Architecture
+sidebar_label: Architecture
+description: This document describes the architecture of TDengine.
---
## Cluster and Primary Logic Unit
diff --git a/docs/en/21-tdinternal/03-high-availability.md b/docs/en/21-tdinternal/03-high-availability.md
index e2e1c6521efd59078e7dc9c9a1e5d8df3377d266..a0f6ca4ffe15ba5901709ffa3c6d64b8697fa93a 100644
--- a/docs/en/21-tdinternal/03-high-availability.md
+++ b/docs/en/21-tdinternal/03-high-availability.md
@@ -1,6 +1,7 @@
---
-sidebar_label: High Availability
title: High Availability
+sidebar_label: High Availability
+description: This document describes how TDengine implements high availability.
---
## High Availability of Vnode
diff --git a/docs/en/21-tdinternal/04-load-balance.md b/docs/en/21-tdinternal/04-load-balance.md
index 7648398059a2a422533d6d687336988d207c79a4..73da1c1dd65ffb3251c86ff936f5b5b26dc9d1cb 100644
--- a/docs/en/21-tdinternal/04-load-balance.md
+++ b/docs/en/21-tdinternal/04-load-balance.md
@@ -1,6 +1,7 @@
---
-sidebar_label: Load Balance
title: Load Balance
+sidebar_label: Load Balance
+description: This document describes how TDengine implements load balancing.
---
The load balance in TDengine is mainly about processing data series data. TDengine employes builtin hash algorithm to distribute all the tables, sub-tables and their data of a database across all the vgroups that belongs to the database. Each table or sub-table can only be handled by a single vgroup, while each vgroup can process multiple table or sub-table.
diff --git a/docs/en/21-tdinternal/index.md b/docs/en/21-tdinternal/index.md
index 999d6f89ff57164d6e0372620504c8ecc9de7c9b..4f0846754382767b4694ab1c54f8ae2d3340948c 100644
--- a/docs/en/21-tdinternal/index.md
+++ b/docs/en/21-tdinternal/index.md
@@ -1,5 +1,6 @@
---
title: TDengine Inside
+description: This document describes the internals of TDengine from an architectural perspective.
---
```mdx-code-block
diff --git a/docs/en/25-application/01-telegraf.md b/docs/en/25-application/01-telegraf.md
index 65fb08ee674cc9c952bbcfda57f0366fa129fdf2..e043aebcb64f6e3b26b1e79964c5875e3b64ee6f 100644
--- a/docs/en/25-application/01-telegraf.md
+++ b/docs/en/25-application/01-telegraf.md
@@ -1,6 +1,7 @@
---
-sidebar_label: TDengine + Telegraf + Grafana
title: Quickly Build IT DevOps Visualization System with TDengine + Telegraf + Grafana
+sidebar_label: TDengine + Telegraf + Grafana
+description: This document describes how to create an IT visualization system by integrating TDengine with Telegraf and Grafana.
---
## Background
diff --git a/docs/en/25-application/02-collectd.md b/docs/en/25-application/02-collectd.md
index 97412b230941435a08df12c859d63bca68b79ec9..6ac7253fc46c50d3efe698d508de8669c65bf5d9 100644
--- a/docs/en/25-application/02-collectd.md
+++ b/docs/en/25-application/02-collectd.md
@@ -1,6 +1,7 @@
---
-sidebar_label: TDengine + collectd/StatsD + Grafana
title: Quickly build an IT DevOps visualization system using TDengine + collectd/StatsD + Grafana
+sidebar_label: TDengine + collectd/StatsD + Grafana
+description: This document describes how to build an IT visualization system by integrating TDengine with Grafana and collectd or StatsD.
---
## Background
diff --git a/docs/en/25-application/03-immigrate.md b/docs/en/25-application/03-immigrate.md
index 1aabaa43e77660d72bca00d7d59cdee69b1a7c92..30d069e4e2be2498b3634ae02cc0fc444c886392 100644
--- a/docs/en/25-application/03-immigrate.md
+++ b/docs/en/25-application/03-immigrate.md
@@ -1,6 +1,7 @@
---
-sidebar_label: OpenTSDB Migration to TDengine
title: Best Practices for Migrating OpenTSDB Applications to TDengine
+sidebar_label: OpenTSDB Migration to TDengine
+description: This document describes the best practices for migrating an OpenTSDB application to TDengine.
---
As a distributed, scalable, distributed time-series database platform based on HBase, and thanks to its first-mover advantage, OpenTSDB is widely used for monitoring in DevOps. However, as new technologies like cloud computing, microservices, and containerization technology has developed rapidly, Enterprise-level services are becoming more and more diverse and the architecture is becoming more complex.
diff --git a/docs/en/25-application/index.md b/docs/en/25-application/index.md
index 5383a00c67c515dc65fd2ed1cac4b218710288b5..178fef47b64285efe732e53b316581ae4876a218 100644
--- a/docs/en/25-application/index.md
+++ b/docs/en/25-application/index.md
@@ -1,5 +1,6 @@
---
title: Application Practice
+description: This document describes some examples of building systems around TDengine.
---
```mdx-code-block
diff --git a/docs/en/27-train-faq/01-faq.md b/docs/en/27-train-faq/01-faq.md
index 7650e9736556d3b9887e0c2fc8f9e94091c58c2d..9e7f4f8e0d3d94f0016c0dcc6701c670fd7d32c8 100644
--- a/docs/en/27-train-faq/01-faq.md
+++ b/docs/en/27-train-faq/01-faq.md
@@ -1,5 +1,6 @@
---
title: Frequently Asked Questions
+description: This document describes the frequently asked questions about TDengine.
---
## Submit an Issue
diff --git a/docs/en/27-train-faq/index.md b/docs/en/27-train-faq/index.md
index 2cb87aab005b0ecc9275b6fe10e267487d38c336..cc55a41559a32fcb89b28a99705b59e07c22a81d 100644
--- a/docs/en/27-train-faq/index.md
+++ b/docs/en/27-train-faq/index.md
@@ -1,5 +1,6 @@
---
title: FAQ & Others
+description: This document describes common issues related with TDengine.
---
```mdx-code-block
diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md
index 83ea3eb5e6d3edd69d65774a9761324a8f77dcd9..0c5ccf3aef6a665b458adbe1a27788dafb535667 100644
--- a/docs/en/28-releases/01-tdengine.md
+++ b/docs/en/28-releases/01-tdengine.md
@@ -1,7 +1,7 @@
---
-sidebar_label: TDengine
title: TDengine Release History and Download Links
-description: TDengine release history, Release Notes and download links.
+sidebar_label: TDengine
+description: This document provides download links for all released versions of TDengine 3.0.
---
TDengine 3.x installation packages can be downloaded at the following links:
@@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
import Release from "/components/ReleaseV3";
+## 3.0.2.5
+
+
+
## 3.0.2.4
diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md
index 97fed654f2f25c782a036501c39204be5750d93e..29dd605c8cf53bd6c75a5d83a2f16f68d4c8e7b9 100644
--- a/docs/en/28-releases/02-tools.md
+++ b/docs/en/28-releases/02-tools.md
@@ -1,7 +1,7 @@
---
-sidebar_label: taosTools
title: taosTools Release History and Download Links
-description: taosTools release history, Release Notes, download links.
+sidebar_label: taosTools
+description: This document provides download links for all released versions of taosTools compatible with TDengine 3.0.
---
taosTools installation packages can be downloaded at the following links:
@@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat
import Release from "/components/ReleaseV3";
+## 2.4.3
+
+
+
## 2.4.2
diff --git a/docs/en/28-releases/index.md b/docs/en/28-releases/index.md
index c01c99cdce0190fb04f88d55a09e8cc406d4d8b0..d1f93c3b9b2cf297578953d9c262b60f3ad2a214 100644
--- a/docs/en/28-releases/index.md
+++ b/docs/en/28-releases/index.md
@@ -1,5 +1,6 @@
---
title: Releases
+description: This document describes TDengine products that have been released.
---
```mdx-code-block
diff --git a/docs/examples/csharp/wsConnect/wsConnect.csproj b/docs/examples/csharp/wsConnect/wsConnect.csproj
index 6d78be6e7a112475523d449b1ba308923bf13add..c7988b6e9c955f21d53a312e10b513403363936e 100644
--- a/docs/examples/csharp/wsConnect/wsConnect.csproj
+++ b/docs/examples/csharp/wsConnect/wsConnect.csproj
@@ -2,7 +2,7 @@
Exe
- net5.0
+ net6.0
diff --git a/docs/examples/csharp/wsInsert/wsInsert.csproj b/docs/examples/csharp/wsInsert/wsInsert.csproj
index 95bfbdea3df6d1f8047c082a31a43dad958edce0..5aa419b2c80bf303e84ff3f1a30a839ce9220663 100644
--- a/docs/examples/csharp/wsInsert/wsInsert.csproj
+++ b/docs/examples/csharp/wsInsert/wsInsert.csproj
@@ -2,7 +2,7 @@
Exe
- net5.0
+ net6.0
enable
diff --git a/docs/examples/csharp/wsQuery/wsQuery.csproj b/docs/examples/csharp/wsQuery/wsQuery.csproj
index e5c2cf767cf4a427d11a72298e932940706fb2f4..bcc7c19a59fdab1c8ad9d3098824239d645743e6 100644
--- a/docs/examples/csharp/wsQuery/wsQuery.csproj
+++ b/docs/examples/csharp/wsQuery/wsQuery.csproj
@@ -2,7 +2,7 @@
Exe
- net5.0
+ net6.0
enable
diff --git a/docs/examples/csharp/wsStmt/wsStmt.csproj b/docs/examples/csharp/wsStmt/wsStmt.csproj
index e5c2cf767cf4a427d11a72298e932940706fb2f4..bcc7c19a59fdab1c8ad9d3098824239d645743e6 100644
--- a/docs/examples/csharp/wsStmt/wsStmt.csproj
+++ b/docs/examples/csharp/wsStmt/wsStmt.csproj
@@ -2,7 +2,7 @@
Exe
- net5.0
+ net6.0
enable
diff --git a/docs/examples/node/restexample/connect.js b/docs/examples/node/restexample/connect.js
index bb027d4fe85f35e5a7047b1517caee00314e2153..f36472b4c09a952cffe4b8ab24d1d9aa9f15b3fe 100644
--- a/docs/examples/node/restexample/connect.js
+++ b/docs/examples/node/restexample/connect.js
@@ -3,18 +3,14 @@ const { options, connect } = require("@tdengine/rest");
async function test() {
options.path = "/rest/sql";
options.host = "localhost";
+ options.port = 6041;
let conn = connect(options);
let cursor = conn.cursor();
try {
let res = await cursor.query("SELECT server_version()");
- res.toString();
+ console.log("res.getResult()",res.getResult());
} catch (err) {
console.log(err);
}
}
test();
-
-// output:
-// server_version() |
-// ===================
-// 3.0.0.0 |
diff --git a/docs/examples/python/connection_usage_native_reference.py b/docs/examples/python/connection_usage_native_reference.py
index 8b754ec7226e8fd25dbdeb27b28faebdcf612049..0a23c5f95b9d0f113e861aae07255c46bb5ae0a5 100644
--- a/docs/examples/python/connection_usage_native_reference.py
+++ b/docs/examples/python/connection_usage_native_reference.py
@@ -42,4 +42,4 @@ print(data)
# ANCHOR_END: query
-conn.close()
+conn.close()
\ No newline at end of file
diff --git a/docs/examples/python/kafka_example.py b/docs/examples/python/kafka_example.py
deleted file mode 100644
index 43f9183f7e25b680827aef836363ef5f0549468b..0000000000000000000000000000000000000000
--- a/docs/examples/python/kafka_example.py
+++ /dev/null
@@ -1,241 +0,0 @@
-#! encoding = utf-8
-import json
-import time
-from json import JSONDecodeError
-from typing import Callable
-import logging
-from concurrent.futures import ThreadPoolExecutor, Future
-
-import taos
-from kafka import KafkaConsumer
-from kafka.consumer.fetcher import ConsumerRecord
-
-
-class Consumer(object):
- DEFAULT_CONFIGS = {
- 'kafka_brokers': 'localhost:9092',
- 'kafka_topic': 'python_kafka',
- 'kafka_group_id': 'taos',
- 'taos_host': 'localhost',
- 'taos_user': 'root',
- 'taos_password': 'taosdata',
- 'taos_database': 'power',
- 'taos_port': 6030,
- 'timezone': None,
- 'clean_after_testing': False,
- 'bath_consume': True,
- 'batch_size': 1000,
- 'async_model': True,
- 'workers': 10,
- 'testing': False
- }
-
- LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanDiego', 'California.SanJose',
- 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
- 'California.SantaClara', 'California.Cupertino']
-
- CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1'
- USE_DATABASE_SQL = 'use {}'
- DROP_TABLE_SQL = 'drop table if exists meters'
- DROP_DATABASE_SQL = 'drop database if exists {}'
- CREATE_STABLE_SQL = 'create stable meters (ts timestamp, current float, voltage int, phase float) ' \
- 'tags (location binary(64), groupId int)'
- CREATE_TABLE_SQL = 'create table if not exists {} using meters tags (\'{}\', {})'
- INSERT_SQL_HEADER = "insert into "
- INSERT_PART_SQL = 'power.{} values (\'{}\', {}, {}, {})'
-
- def __init__(self, **configs):
- self.config: dict = self.DEFAULT_CONFIGS
- self.config.update(configs)
- if not self.config.get('testing'):
- self.consumer = KafkaConsumer(
- self.config.get('kafka_topic'), # topic
- bootstrap_servers=self.config.get('kafka_brokers'),
- group_id=self.config.get('kafka_group_id'),
- )
- self.taos = taos.connect(
- host=self.config.get('taos_host'),
- user=self.config.get('taos_user'),
- password=self.config.get('taos_password'),
- port=self.config.get('taos_port'),
- timezone=self.config.get('timezone'),
- )
- if self.config.get('async_model'):
- self.pool = ThreadPoolExecutor(max_workers=self.config.get('workers'))
- self.tasks = []
- # tags and table mapping # key: {location}_{groupId} value:
- self.tag_table_mapping = {}
- i = 0
- for location in self.LOCATIONS:
- for j in range(1, 11):
- table_name = 'd{}'.format(i)
- self._cache_table(location=location, group_id=j, table_name=table_name)
- i += 1
-
- def init_env(self):
- # create database and table
- self.taos.execute(self.DROP_DATABASE_SQL.format(self.config.get('taos_database')))
- self.taos.execute(self.CREATE_DATABASE_SQL.format(self.config.get('taos_database')))
- self.taos.execute(self.USE_DATABASE_SQL.format(self.config.get('taos_database')))
- self.taos.execute(self.DROP_TABLE_SQL)
- self.taos.execute(self.CREATE_STABLE_SQL)
- for tags, table_name in self.tag_table_mapping.items():
- location, group_id = _get_location_and_group(tags)
- self.taos.execute(self.CREATE_TABLE_SQL.format(table_name, location, group_id))
-
- def consume(self):
- logging.warning('## start consumer topic-[%s]', self.config.get('kafka_topic'))
- try:
- if self.config.get('bath_consume'):
- self._run_batch(self._to_taos_batch)
- else:
- self._run(self._to_taos)
- except KeyboardInterrupt:
- logging.warning("## caught keyboard interrupt, stopping")
- finally:
- self.stop()
-
- def stop(self):
- # close consumer
- if self.consumer is not None:
- self.consumer.commit()
- self.consumer.close()
-
- # multi thread
- if self.config.get('async_model'):
- for task in self.tasks:
- while not task.done():
- pass
- if self.pool is not None:
- self.pool.shutdown()
-
- # clean data
- if self.config.get('clean_after_testing'):
- self.taos.execute(self.DROP_TABLE_SQL)
- self.taos.execute(self.DROP_DATABASE_SQL.format(self.config.get('taos_database')))
- # close taos
- if self.taos is not None:
- self.taos.close()
-
- def _run(self, f):
- for message in self.consumer:
- if self.config.get('async_model'):
- self.pool.submit(f(message))
- else:
- f(message)
-
- def _run_batch(self, f):
- while True:
- messages = self.consumer.poll(timeout_ms=500, max_records=self.config.get('batch_size'))
- if messages:
- if self.config.get('async_model'):
- self.pool.submit(f, messages.values())
- else:
- f(list(messages.values()))
- if not messages:
- time.sleep(0.1)
-
- def _to_taos(self, message: ConsumerRecord) -> bool:
- sql = self.INSERT_SQL_HEADER + self._build_sql(message.value)
- if len(sql) == 0: # decode error, skip
- return True
- logging.info('## insert sql %s', sql)
- return self.taos.execute(sql=sql) == 1
-
- def _to_taos_batch(self, messages):
- sql = self._build_sql_batch(messages=messages)
- if len(sql) == 0: # decode error, skip
- return
- self.taos.execute(sql=sql)
-
- def _build_sql(self, msg_value: str) -> str:
- try:
- data = json.loads(msg_value)
- except JSONDecodeError as e:
- logging.error('## decode message [%s] error ', msg_value, e)
- return ''
- location = data.get('location')
- group_id = data.get('groupId')
- ts = data.get('ts')
- current = data.get('current')
- voltage = data.get('voltage')
- phase = data.get('phase')
-
- table_name = self._get_table_name(location=location, group_id=group_id)
- return self.INSERT_PART_SQL.format(table_name, ts, current, voltage, phase)
-
- def _build_sql_batch(self, messages) -> str:
- sql_list = []
- for partition_messages in messages:
- for message in partition_messages:
- sql_list.append(self._build_sql(message.value))
-
- return self.INSERT_SQL_HEADER + ' '.join(sql_list)
-
- def _cache_table(self, location: str, group_id: int, table_name: str):
- self.tag_table_mapping[_tag_table_mapping_key(location=location, group_id=group_id)] = table_name
-
- def _get_table_name(self, location: str, group_id: int) -> str:
- return self.tag_table_mapping.get(_tag_table_mapping_key(location=location, group_id=group_id))
-
-
-def _tag_table_mapping_key(location: str, group_id: int):
- return '{}_{}'.format(location, group_id)
-
-
-def _get_location_and_group(key: str) -> (str, int):
- fields = key.split('_')
- return fields[0], fields[1]
-
-
-def test_to_taos(consumer: Consumer):
- msg = {
- 'location': 'California.SanFrancisco',
- 'groupId': 1,
- 'ts': '2022-12-06 15:13:38.643',
- 'current': 3.41,
- 'voltage': 105,
- 'phase': 0.02027,
- }
- record = ConsumerRecord(checksum=None, headers=None, offset=1, key=None, value=json.dumps(msg), partition=1,
- topic='test', serialized_key_size=None, serialized_header_size=None,
- serialized_value_size=None, timestamp=time.time(), timestamp_type=None)
- assert consumer._to_taos(message=record)
-
-
-def test_to_taos_batch(consumer: Consumer):
- records = [
- [
- ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
- value=json.dumps({'location': 'California.SanFrancisco',
- 'groupId': 1,
- 'ts': '2022-12-06 15:13:38.643',
- 'current': 3.41,
- 'voltage': 105,
- 'phase': 0.02027, }),
- partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
- serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
- ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
- value=json.dumps({'location': 'California.LosAngles',
- 'groupId': 2,
- 'ts': '2022-12-06 15:13:39.643',
- 'current': 3.41,
- 'voltage': 102,
- 'phase': 0.02027, }),
- partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
- serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
- ]
- ]
-
- consumer._to_taos_batch(messages=records)
-
-
-if __name__ == '__main__':
- consumer = Consumer(async_model=True, testing=True)
- # init env
- consumer.init_env()
- # consumer.consume()
- # test build sql
- # test build sql batch
- test_to_taos(consumer)
- test_to_taos_batch(consumer)
diff --git a/docs/examples/python/kafka_example_common.py b/docs/examples/python/kafka_example_common.py
new file mode 100644
index 0000000000000000000000000000000000000000..566748c94e2542aabe8265ed55c85e4b725d69bb
--- /dev/null
+++ b/docs/examples/python/kafka_example_common.py
@@ -0,0 +1,65 @@
+#! encoding = utf-8
+import taos
+
+LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanDiego', 'California.SanJose',
+ 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
+ 'California.SantaClara', 'California.Cupertino']
+
+CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1'
+USE_DATABASE_SQL = 'use {}'
+DROP_TABLE_SQL = 'drop table if exists meters'
+DROP_DATABASE_SQL = 'drop database if exists {}'
+CREATE_STABLE_SQL = 'create stable meters (ts timestamp, current float, voltage int, phase float) tags ' \
+ '(location binary(64), groupId int)'
+CREATE_TABLE_SQL = 'create table if not exists {} using meters tags (\'{}\', {})'
+
+
+def create_database_and_tables(host, port, user, password, db, table_count):
+ tags_tables = _init_tags_table_names(table_count=table_count)
+ conn = taos.connect(host=host, port=port, user=user, password=password)
+
+ conn.execute(DROP_DATABASE_SQL.format(db))
+ conn.execute(CREATE_DATABASE_SQL.format(db))
+ conn.execute(USE_DATABASE_SQL.format(db))
+ conn.execute(DROP_TABLE_SQL)
+ conn.execute(CREATE_STABLE_SQL)
+ for tags in tags_tables:
+ location, group_id = _get_location_and_group(tags)
+ tables = tags_tables[tags]
+ for table_name in tables:
+ conn.execute(CREATE_TABLE_SQL.format(table_name, location, group_id))
+ conn.close()
+
+
+def clean(host, port, user, password, db):
+ conn = taos.connect(host=host, port=port, user=user, password=password)
+ conn.execute(DROP_DATABASE_SQL.format(db))
+ conn.close()
+
+
+def _init_tags_table_names(table_count):
+ tags_table_names = {}
+ group_id = 0
+ for i in range(table_count):
+ table_name = 'd{}'.format(i)
+ location_idx = i % len(LOCATIONS)
+ location = LOCATIONS[location_idx]
+ if location_idx == 0:
+ group_id += 1
+ if group_id > 10:
+ group_id -= 10
+ key = _tag_table_mapping_key(location=location, group_id=group_id)
+ if key not in tags_table_names:
+ tags_table_names[key] = []
+ tags_table_names[key].append(table_name)
+
+ return tags_table_names
+
+
+def _tag_table_mapping_key(location, group_id):
+ return '{}_{}'.format(location, group_id)
+
+
+def _get_location_and_group(key):
+ fields = key.split('_')
+ return fields[0], fields[1]
diff --git a/docs/examples/python/kafka_example_consumer.py b/docs/examples/python/kafka_example_consumer.py
new file mode 100644
index 0000000000000000000000000000000000000000..e2d5cf535b3953a3c0ecec9e25cc615948162633
--- /dev/null
+++ b/docs/examples/python/kafka_example_consumer.py
@@ -0,0 +1,231 @@
+#! encoding = utf-8
+import json
+import logging
+import time
+from concurrent.futures import ThreadPoolExecutor, Future
+from json import JSONDecodeError
+from typing import Callable
+
+import taos
+from kafka import KafkaConsumer
+from kafka.consumer.fetcher import ConsumerRecord
+
+import kafka_example_common as common
+
+
+class Consumer(object):
+ DEFAULT_CONFIGS = {
+ 'kafka_brokers': 'localhost:9092', # kafka broker
+ 'kafka_topic': 'tdengine_kafka_practices',
+ 'kafka_group_id': 'taos',
+ 'taos_host': 'localhost', # TDengine host
+ 'taos_port': 6030, # TDengine port
+ 'taos_user': 'root', # TDengine user name
+ 'taos_password': 'taosdata', # TDengine password
+ 'taos_database': 'power', # TDengine database
+ 'message_type': 'json', # message format, 'json' or 'line'
+ 'clean_after_testing': False, # if drop database after testing
+ 'max_poll': 1000, # poll size for batch mode
+ 'workers': 10, # thread count for multi-threading
+ 'testing': False
+ }
+
+ INSERT_SQL_HEADER = "insert into "
+ INSERT_PART_SQL = '{} values (\'{}\', {}, {}, {})'
+
+ def __init__(self, **configs):
+ self.config = self.DEFAULT_CONFIGS
+ self.config.update(configs)
+
+ self.consumer = None
+ if not self.config.get('testing'):
+ self.consumer = KafkaConsumer(
+ self.config.get('kafka_topic'),
+ bootstrap_servers=self.config.get('kafka_brokers'),
+ group_id=self.config.get('kafka_group_id'),
+ )
+
+ self.conns = taos.connect(
+ host=self.config.get('taos_host'),
+ port=self.config.get('taos_port'),
+ user=self.config.get('taos_user'),
+ password=self.config.get('taos_password'),
+ db=self.config.get('taos_database'),
+ )
+ if self.config.get('workers') > 1:
+ self.pool = ThreadPoolExecutor(max_workers=self.config.get('workers'))
+ self.tasks = []
+ # tags and table mapping # key: {location}_{groupId} value:
+
+ def consume(self):
+ """
+
+ consume data from kafka and deal. Base on `message_type`, `bath_consume`, `insert_by_table`,
+ there are several deal function.
+ :return:
+ """
+ self.conns.execute(common.USE_DATABASE_SQL.format(self.config.get('taos_database')))
+ try:
+ if self.config.get('message_type') == 'line': # line
+ self._run(self._line_to_taos)
+ if self.config.get('message_type') == 'json': # json
+ self._run(self._json_to_taos)
+ except KeyboardInterrupt:
+ logging.warning("## caught keyboard interrupt, stopping")
+ finally:
+ self.stop()
+
+ def stop(self):
+ """
+
+ stop consuming
+ :return:
+ """
+ # close consumer
+ if self.consumer is not None:
+ self.consumer.commit()
+ self.consumer.close()
+
+ # multi thread
+ if self.config.get('workers') > 1:
+ if self.pool is not None:
+ self.pool.shutdown()
+ for task in self.tasks:
+ while not task.done():
+ time.sleep(0.01)
+
+ # clean data
+ if self.config.get('clean_after_testing'):
+ self.conns.execute(common.DROP_TABLE_SQL)
+ self.conns.execute(common.DROP_DATABASE_SQL.format(self.config.get('taos_database')))
+ # close taos
+ if self.conns is not None:
+ self.conns.close()
+
+ def _run(self, f):
+ """
+
+ run in batch consuming mode
+ :param f:
+ :return:
+ """
+ i = 0 # just for test.
+ while True:
+ messages = self.consumer.poll(timeout_ms=100, max_records=self.config.get('max_poll'))
+ if messages:
+ if self.config.get('workers') > 1:
+ self.pool.submit(f, messages.values())
+ else:
+ f(list(messages.values()))
+ if not messages:
+ i += 1 # just for test.
+ time.sleep(0.1)
+ if i > 3: # just for test.
+ logging.warning('## test over.') # just for test.
+ return # just for test.
+
+ def _json_to_taos(self, messages):
+ """
+
+ convert a batch of json data to sql, and insert into TDengine
+ :param messages:
+ :return:
+ """
+ sql = self._build_sql_from_json(messages=messages)
+ self.conns.execute(sql=sql)
+
+ def _line_to_taos(self, messages):
+ """
+
+ convert a batch of lines data to sql, and insert into TDengine
+ :param messages:
+ :return:
+ """
+ lines = []
+ for partition_messages in messages:
+ for message in partition_messages:
+ lines.append(message.value.decode())
+ sql = self.INSERT_SQL_HEADER + ' '.join(lines)
+ self.conns.execute(sql=sql)
+
+ def _build_single_sql_from_json(self, msg_value):
+ try:
+ data = json.loads(msg_value)
+ except JSONDecodeError as e:
+ logging.error('## decode message [%s] error ', msg_value, e)
+ return ''
+ # location = data.get('location')
+ # group_id = data.get('groupId')
+ ts = data.get('ts')
+ current = data.get('current')
+ voltage = data.get('voltage')
+ phase = data.get('phase')
+ table_name = data.get('table_name')
+
+ return self.INSERT_PART_SQL.format(table_name, ts, current, voltage, phase)
+
+ def _build_sql_from_json(self, messages):
+ sql_list = []
+ for partition_messages in messages:
+ for message in partition_messages:
+ sql_list.append(self._build_single_sql_from_json(message.value))
+ return self.INSERT_SQL_HEADER + ' '.join(sql_list)
+
+
+def test_json_to_taos(consumer: Consumer):
+ records = [
+ [
+ ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
+ value=json.dumps({'table_name': 'd0',
+ 'ts': '2022-12-06 15:13:38.643',
+ 'current': 3.41,
+ 'voltage': 105,
+ 'phase': 0.02027, }),
+ partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
+ serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
+ ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
+ value=json.dumps({'table_name': 'd1',
+ 'ts': '2022-12-06 15:13:39.643',
+ 'current': 3.41,
+ 'voltage': 102,
+ 'phase': 0.02027, }),
+ partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
+ serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
+ ]
+ ]
+
+ consumer._json_to_taos(messages=records)
+
+
+def test_line_to_taos(consumer: Consumer):
+ records = [
+ [
+ ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
+ value="d0 values('2023-01-01 00:00:00.001', 3.49, 109, 0.02737)".encode('utf-8'),
+ partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
+ serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
+ ConsumerRecord(checksum=None, headers=None, offset=1, key=None,
+ value="d1 values('2023-01-01 00:00:00.002', 6.19, 112, 0.09171)".encode('utf-8'),
+ partition=1, topic='test', serialized_key_size=None, serialized_header_size=None,
+ serialized_value_size=None, timestamp=time.time(), timestamp_type=None),
+ ]
+ ]
+ consumer._line_to_taos(messages=records)
+
+
+def consume(kafka_brokers, kafka_topic, kafka_group_id, taos_host, taos_port, taos_user,
+ taos_password, taos_database, message_type, max_poll, workers):
+ c = Consumer(kafka_brokers=kafka_brokers, kafka_topic=kafka_topic, kafka_group_id=kafka_group_id,
+ taos_host=taos_host, taos_port=taos_port, taos_user=taos_user, taos_password=taos_password,
+ taos_database=taos_database, message_type=message_type, max_poll=max_poll, workers=workers)
+ c.consume()
+
+
+if __name__ == '__main__':
+ consumer = Consumer(testing=True)
+ common.create_database_and_tables(host='localhost', port=6030, user='root', password='taosdata', db='py_kafka_test',
+ table_count=10)
+ consumer.conns.execute(common.USE_DATABASE_SQL.format('py_kafka_test'))
+ test_json_to_taos(consumer)
+ test_line_to_taos(consumer)
+ common.clean(host='localhost', port=6030, user='root', password='taosdata', db='py_kafka_test')
diff --git a/docs/examples/python/kafka_example_perform.py b/docs/examples/python/kafka_example_perform.py
new file mode 100644
index 0000000000000000000000000000000000000000..23ae4b48c8fc8139b85cd41b041953e8f55f12b4
--- /dev/null
+++ b/docs/examples/python/kafka_example_perform.py
@@ -0,0 +1,103 @@
+#! encoding=utf-8
+
+import argparse
+import logging
+import multiprocessing
+import time
+from multiprocessing import pool
+
+import kafka_example_common as common
+import kafka_example_consumer as consumer
+import kafka_example_producer as producer
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-kafka-broker', type=str, default='localhost:9092',
+ help='kafka borker host. default is `localhost:9200`')
+ parser.add_argument('-kafka-topic', type=str, default='tdengine-kafka-practices',
+ help='kafka topic. default is `tdengine-kafka-practices`')
+ parser.add_argument('-kafka-group', type=str, default='kafka_practices',
+ help='kafka consumer group. default is `kafka_practices`')
+ parser.add_argument('-taos-host', type=str, default='localhost',
+ help='TDengine host. default is `localhost`')
+ parser.add_argument('-taos-port', type=int, default=6030, help='TDengine port. default is 6030')
+ parser.add_argument('-taos-user', type=str, default='root', help='TDengine username, default is `root`')
+ parser.add_argument('-taos-password', type=str, default='taosdata', help='TDengine password, default is `taosdata`')
+ parser.add_argument('-taos-db', type=str, default='tdengine_kafka_practices',
+ help='TDengine db name, default is `tdengine_kafka_practices`')
+ parser.add_argument('-table-count', type=int, default=100, help='TDengine sub-table count, default is 100')
+ parser.add_argument('-table-items', type=int, default=1000, help='items in per sub-tables, default is 1000')
+ parser.add_argument('-message-type', type=str, default='line',
+ help='kafka message type. `line` or `json`. default is `line`')
+ parser.add_argument('-max-poll', type=int, default=1000, help='max poll for kafka consumer')
+ parser.add_argument('-threads', type=int, default=10, help='thread count for deal message')
+ parser.add_argument('-processes', type=int, default=1, help='process count')
+
+ args = parser.parse_args()
+ total = args.table_count * args.table_items
+
+ logging.warning("## start to prepare testing data...")
+ prepare_data_start = time.time()
+ producer.produce_total(100, args.kafka_broker, args.kafka_topic, args.message_type, total, args.table_count)
+ prepare_data_end = time.time()
+ logging.warning("## prepare testing data finished! spend-[%s]", prepare_data_end - prepare_data_start)
+
+ logging.warning("## start to create database and tables ...")
+ create_db_start = time.time()
+ # create database and table
+ common.create_database_and_tables(host=args.taos_host, port=args.taos_port, user=args.taos_user,
+ password=args.taos_password, db=args.taos_db, table_count=args.table_count)
+ create_db_end = time.time()
+ logging.warning("## create database and tables finished! spend [%s]", create_db_end - create_db_start)
+
+ processes = args.processes
+
+ logging.warning("## start to consume data and insert into TDengine...")
+ consume_start = time.time()
+ if processes > 1: # multiprocess
+ multiprocessing.set_start_method("spawn")
+ pool = pool.Pool(processes)
+
+ consume_start = time.time()
+ for _ in range(processes):
+ pool.apply_async(func=consumer.consume, args=(
+ args.kafka_broker, args.kafka_topic, args.kafka_group, args.taos_host, args.taos_port, args.taos_user,
+ args.taos_password, args.taos_db, args.message_type, args.max_poll, args.threads))
+ pool.close()
+ pool.join()
+ else:
+ consume_start = time.time()
+ consumer.consume(kafka_brokers=args.kafka_broker, kafka_topic=args.kafka_topic, kafka_group_id=args.kafka_group,
+ taos_host=args.taos_host, taos_port=args.taos_port, taos_user=args.taos_user,
+ taos_password=args.taos_password, taos_database=args.taos_db, message_type=args.message_type,
+ max_poll=args.max_poll, workers=args.threads)
+ consume_end = time.time()
+ logging.warning("## consume data and insert into TDengine over! spend-[%s]", consume_end - consume_start)
+
+ # print report
+ logging.warning(
+ "\n#######################\n"
+ " Prepare data \n"
+ "#######################\n"
+ "# data_type # %s \n"
+ "# total # %s \n"
+ "# spend # %s s\n"
+ "#######################\n"
+ " Create database \n"
+ "#######################\n"
+ "# stable # 1 \n"
+ "# sub-table # 100 \n"
+ "# spend # %s s \n"
+ "#######################\n"
+ " Consume \n"
+ "#######################\n"
+ "# data_type # %s \n"
+ "# threads # %s \n"
+ "# processes # %s \n"
+ "# total_count # %s \n"
+ "# spend # %s s\n"
+ "# per_second # %s \n"
+ "#######################\n",
+ args.message_type, total, prepare_data_end - prepare_data_start, create_db_end - create_db_start,
+ args.message_type, args.threads, processes, total, consume_end - consume_start,
+ total / (consume_end - consume_start))
diff --git a/docs/examples/python/kafka_example_producer.py b/docs/examples/python/kafka_example_producer.py
new file mode 100644
index 0000000000000000000000000000000000000000..51468c7e37ab3400bece69fa58e126a789ef9860
--- /dev/null
+++ b/docs/examples/python/kafka_example_producer.py
@@ -0,0 +1,97 @@
+#! encoding = utf-8
+import json
+import random
+import threading
+from concurrent.futures import ThreadPoolExecutor, Future
+from datetime import datetime
+
+from kafka import KafkaProducer
+
+locations = ['California.SanFrancisco', 'California.LosAngles', 'California.SanDiego', 'California.SanJose',
+ 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale',
+ 'California.SantaClara', 'California.Cupertino']
+
+producers: list[KafkaProducer] = []
+
+lock = threading.Lock()
+start = 1640966400
+
+
+def produce_total(workers, broker, topic, message_type, total, table_count):
+ if len(producers) == 0:
+ lock.acquire()
+ if len(producers) == 0:
+ _init_kafka_producers(broker=broker, count=10)
+ lock.release()
+ pool = ThreadPoolExecutor(max_workers=workers)
+ futures = []
+ for _ in range(0, workers):
+ futures.append(pool.submit(_produce_total, topic, message_type, int(total / workers), table_count))
+ pool.shutdown()
+ for f in futures:
+ f.result()
+ _close_kafka_producers()
+
+
+def _produce_total(topic, message_type, total, table_count):
+ producer = _get_kafka_producer()
+ for _ in range(total):
+ message = _get_fake_date(message_type=message_type, table_count=table_count)
+ producer.send(topic=topic, value=message.encode(encoding='utf-8'))
+
+
+def _init_kafka_producers(broker, count):
+ for _ in range(count):
+ p = KafkaProducer(bootstrap_servers=broker, batch_size=64 * 1024, linger_ms=300, acks=0)
+ producers.append(p)
+
+
+def _close_kafka_producers():
+ for p in producers:
+ p.close()
+
+
+def _get_kafka_producer():
+ return producers[random.randint(0, len(producers) - 1)]
+
+
+def _get_fake_date(table_count, message_type='json'):
+ if message_type == 'json':
+ return _get_json_message(table_count=table_count)
+ if message_type == 'line':
+ return _get_line_message(table_count=table_count)
+ return ''
+
+
+def _get_json_message(table_count):
+ return json.dumps({
+ 'ts': _get_timestamp(),
+ 'current': random.randint(0, 1000) / 100,
+ 'voltage': random.randint(105, 115),
+ 'phase': random.randint(0, 32000) / 100000,
+ 'location': random.choice(locations),
+ 'groupId': random.randint(1, 10),
+ 'table_name': _random_table_name(table_count)
+ })
+
+
+def _get_line_message(table_count):
+ return "{} values('{}', {}, {}, {})".format(
+ _random_table_name(table_count), # table
+ _get_timestamp(), # ts
+ random.randint(0, 1000) / 100, # current
+ random.randint(105, 115), # voltage
+ random.randint(0, 32000) / 100000, # phase
+ )
+
+
+def _random_table_name(table_count):
+ return 'd{}'.format(random.randint(0, table_count - 1))
+
+
+def _get_timestamp():
+ global start
+ lock.acquire(blocking=True)
+ start += 0.001
+ lock.release()
+ return datetime.fromtimestamp(start).strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
diff --git a/docs/zh/07-develop/03-insert-data/_py_kafka.mdx b/docs/zh/07-develop/03-insert-data/_py_kafka.mdx
index cd7edf557d4ae41df0f55f4456fe405515132e51..d656325674aae33c3bd222fddeb5efb776593d59 100644
--- a/docs/zh/07-develop/03-insert-data/_py_kafka.mdx
+++ b/docs/zh/07-develop/03-insert-data/_py_kafka.mdx
@@ -55,6 +55,70 @@ for p in ps:
### 完整示例
+
+kafka_example_perform
+
+`kafka_example_perform` 是示例程序的入口
+
+```py
+{{#include docs/examples/python/kafka_example_perform.py}}
+```
+
+
+
+kafka_example_common
+
+`kafka_example_common` 是示例程序的公共代码
+
```py
-{{#include docs/examples/python/kafka_example.py}}
+{{#include docs/examples/python/kafka_example_common.py}}
```
+
+
+
+kafka_example_producer
+
+`kafka_example_producer` 是示例程序的 producer 代码,负责生成并发送测试数据到 kafka
+
+```py
+{{#include docs/examples/python/kafka_example_producer.py}}
+```
+
+
+
+kafka_example_consumer
+
+`kafka_example_consumer` 是示例程序的 consumer 代码,负责从 kafka 消费数据,并写入到 TDengine
+
+```py
+{{#include docs/examples/python/kafka_example_consumer.py}}
+```
+
+
+### 执行步骤
+
+
+ 执行 Python 示例程序
+
+ 1. 安装并启动 kafka
+
+ 2. python 环境准备
+ - 安装 python3
+ - 安装 taospy
+ - 安装 kafka-python
+
+ 3. 执行示例程序
+
+ 程序的执行入口是 `kafka_example_perform.py`,获取程序完整的执行参数,请执行 help 命令。
+
+ ```
+ python3 kafka_example_perform.py --help
+ ```
+
+ 以下为创建 100 个子表,每个子表 20000 条数据,kafka max poll 为 100,一个进程,每个进程一个处理线程的程序执行命令
+
+ ```
+ python3 kafka_example_perform.py -table-count=100 -table-items=20000 -max-poll=100 -threads=1 -processes=1
+ ```
+
+
diff --git a/docs/zh/08-connector/35-node.mdx b/docs/zh/08-connector/35-node.mdx
index 35c28e3b9fc52698b813e65191732d3dd84c336e..f2aff41da2da7967410256550d3cfca30c31423b 100644
--- a/docs/zh/08-connector/35-node.mdx
+++ b/docs/zh/08-connector/35-node.mdx
@@ -62,6 +62,16 @@ REST 连接器支持所有能运行 Node.js 的平台。
- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本
+
+
+
+- `python` (建议`v2.7` , `v3.x.x` 目前还不支持)
+- `@tdengine/client` 3.0.0 目前是只支持 Node.js v12.22.12 或 v12 的更高版本;其他版本可能存在包兼容性的问题
+- `make`
+- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本
+
+
+
- 安装方法 1
diff --git a/docs/zh/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md
index fc35da863676943e152d5c113b70e5b5bd6b566e..b0a84af6dc551379e4e095c21a3c4593717c5aad 100644
--- a/docs/zh/12-taos-sql/02-database.md
+++ b/docs/zh/12-taos-sql/02-database.md
@@ -142,7 +142,7 @@ SHOW DATABASES;
### 显示一个数据库的创建语句
```
-SHOW CREATE DATABASE db_name;
+SHOW CREATE DATABASE db_name \G;
```
常用于数据库迁移。对一个已经存在的数据库,返回其创建语句;在另一个集群中执行该语句,就能得到一个设置完全相同的 Database。
@@ -150,7 +150,7 @@ SHOW CREATE DATABASE db_name;
### 查看数据库参数
```sql
-SELECT * FROM INFORMATION_SCHEMA.INS_DATABASES WHERE NAME='DBNAME' \G;
+SELECT * FROM INFORMATION_SCHEMA.INS_DATABASES WHERE NAME='db_name' \G;
```
会列出指定数据库的配置参数,并且每行只显示一个参数。
@@ -177,4 +177,4 @@ REDISTRIBUTE VGROUP vgroup_no DNODE dnode_id1 [DNODE dnode_id2] [DNODE dnode_id3
BALANCE VGROUP
```
-自动调整集群所有vgroup中的vnode分布,相当于在vnode级别对集群进行数据的负载均衡操作。
\ No newline at end of file
+自动调整集群所有vgroup中的vnode分布,相当于在vnode级别对集群进行数据的负载均衡操作。
diff --git a/docs/zh/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md
index 045abcde95e04cb4009dea9de597339c25fe36b0..5687c7e740766ad7a3fbea03ff42ce3137bb140e 100644
--- a/docs/zh/12-taos-sql/03-table.md
+++ b/docs/zh/12-taos-sql/03-table.md
@@ -57,7 +57,7 @@ table_option: {
3. MAX_DELAY:用于控制推送计算结果的最大延迟,默认值为 interval 的值(但不能超过最大值),最小单位毫秒,范围为 1 毫秒到 15 分钟,多个以逗号分隔。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。只可用于超级表,且只有当数据库使用了 RETENTIONS 参数时,才可以使用此表参数。
4. ROLLUP:Rollup 指定的聚合函数,提供基于多层级的降采样聚合结果。只可用于超级表。只有当数据库使用了 RETENTIONS 参数时,才可以使用此表参数。作用于超级表除 TS 列外的其它所有列,但是只能定义一个聚合函数。 聚合函数支持 avg, sum, min, max, last, first。
5. SMA:Small Materialized Aggregates,提供基于数据块的自定义预计算功能。预计算类型包括 MAX、MIN 和 SUM。可用于超级表/普通表。
-6. TTL:Time to Live,是用户用来指定表的生命周期的参数。如果创建表时指定了这个参数,当该表的存在时间超过 TTL 指定的时间后,TDengine 自动删除该表。这个 TTL 的时间只是一个大概时间,系统不保证到了时间一定会将其删除,而只保证存在这样一个机制且最终一定会删除。TTL 单位是天,默认为 0,表示不限制,到期时间为表创建时间加上 TTL 时间。
+6. TTL:Time to Live,是用户用来指定表的生命周期的参数。如果创建表时指定了这个参数,当该表的存在时间超过 TTL 指定的时间后,TDengine 自动删除该表。这个 TTL 的时间只是一个大概时间,系统不保证到了时间一定会将其删除,而只保证存在这样一个机制且最终一定会删除。TTL 单位是天,默认为 0,表示不限制,到期时间为表创建时间加上 TTL 时间。TTL 与数据库 KEEP 参数没有关联,如果 KEEP 比 TTL 小,在表被删除之前数据也可能已经被删除。
## 创建子表
diff --git a/docs/zh/12-taos-sql/05-insert.md b/docs/zh/12-taos-sql/05-insert.md
index ccb8f40b21f7f0082f7bf420643e88a618d83f0e..b72754b15437a081b89056fca3a76030cac62363 100644
--- a/docs/zh/12-taos-sql/05-insert.md
+++ b/docs/zh/12-taos-sql/05-insert.md
@@ -28,7 +28,7 @@ INSERT INTO tb_name [(field1_name, ...)] subquery
2. 时间戳不同的格式语法会有不同的精度影响。字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响。例如,时间戳"2021-07-13 16:16:48"的 UNIX 秒数为 1626164208。则其在毫秒精度下需要写作 1626164208000,在微秒精度设置下就需要写为 1626164208000000,纳秒精度设置下需要写为 1626164208000000000。
3. 一次插入多行数据时,不要把首列的时间戳的值都写 NOW。否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的客户端执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。
- 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 KEEP 值(数据保留的天数)。允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 DURATION 值(数据文件存储数据的时间跨度,单位为天)。KEEP 和 DURATION 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。
+ 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 KEEP 值(数据保留的天数, 可以在创建数据库时指定,缺省值是 3650 天)。允许插入的最新记录的时间戳,取决于数据库的 PRECISION 值(时间戳精度, 可以在创建数据库时指定, ms 表示毫秒,us 表示微秒,ns 表示纳秒,默认毫秒):如果是毫秒或微秒, 取值为 1970 年 1 月 1 日 00:00:00.000 UTC 加上 1000 年, 即 2970 年 1 月 1 日 00:00:00.000 UTC; 如果是纳秒, 取值为 1970 年 1 月 1 日 00:00:00.000000000 UTC 加上 292 年, 即 2262 年 1 月 1 日 00:00:00.000000000 UTC。
**语法说明**
diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md
index 8244c0f27a271347938e8b55cd5d0f4938df0ea7..dcc085b3bd714116455badbdc268c41b717b818f 100644
--- a/docs/zh/12-taos-sql/06-select.md
+++ b/docs/zh/12-taos-sql/06-select.md
@@ -13,6 +13,7 @@ SELECT [DISTINCT] select_list
from_clause
[WHERE condition]
[partition_by_clause]
+ [interp_clause]
[window_clause]
[group_by_clause]
[order_by_clasue]
@@ -53,8 +54,11 @@ window_clause: {
| STATE_WINDOW(col)
| INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)]
+interp_clause:
+ RANGE(ts_val, ts_val), EVERY(every_val), FILL(fill_mod_and_val)
+
partition_by_clause:
- PARTITION BY expr [, expr] ...
+ PARTITION BY expr [, expr] ...
group_by_clause:
GROUP BY expr [, expr] ... HAVING condition
diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md
index 81fdb46f25a609f829401509aa87fb6c29350f90..b21d9c25dd38c602a44234897085dfdadd977065 100644
--- a/docs/zh/12-taos-sql/10-function.md
+++ b/docs/zh/12-taos-sql/10-function.md
@@ -875,9 +875,9 @@ INTERP(expr)
- INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。
- INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。
- INTERP 需要同时与 RANGE,EVERY 和 FILL 关键字一起使用。
-- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。
-- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。
-- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。
+- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1 <= timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。
+- INTERP 根据 EVERY(time_unit) 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(time_unit 值)进行插值,time_unit 可取值时间单位:1a(毫秒),1s(秒),1m(分),1h(小时),1d(天),1w(周)。例如 EVERY(500a) 将对于指定数据每500毫秒间隔进行一次插值.
+- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。关于 FILL 子句如何使用请参考 [FILL 子句](../distinguished/#fill-子句)
- INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 partition by tbname 一起使用。
- INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.1.4版本以后支持)。
- INTERP 可以与伪列 _isfilled 一起使用,显示返回结果是否为原始记录或插值算法产生的数据(3.0.2.3版本以后支持)。
diff --git a/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp
index 942130d4fabf7944c7add10acb3bb42ca7f51e0f..a90477880ff3a2cb2068540b55b69e4bbdbd8d4c 100644
Binary files a/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp and b/docs/zh/14-reference/07-tdinsight/assets/TDinsight-8-taosadapter.webp differ
diff --git a/docs/zh/14-reference/07-tdinsight/index.mdx b/docs/zh/14-reference/07-tdinsight/index.mdx
index 7f4c46a636ace97c6b04849d1b9805fcfc92da82..8ec11378ee7e96f8bea26cd8c7b79dcfe2557c12 100644
--- a/docs/zh/14-reference/07-tdinsight/index.mdx
+++ b/docs/zh/14-reference/07-tdinsight/index.mdx
@@ -345,11 +345,12 @@ TDinsight 仪表盘旨在提供 TDengine 相关资源的使用情况和状态,
支持监控 taosAdapter 请求统计和状态详情。包括:
-1. **http_request_inflight**: 即时处理请求数
-2. **http_request_total**: 请求总数。
-3. **http_request_fail**: 请求总数。
-4. **CPU Used**: taosAdapter CPU 使用情况。
-5. **Memory Used**: taosAdapter 内存使用情况。
+1. **Http Request Total**: 请求总数。
+2. **Http Request Fail**: 请求总数。
+3. **CPU Used**: taosAdapter CPU 使用情况。
+4. **Memory Used**: taosAdapter 内存使用情况。
+5. **Http Request Inflight**: 即时处理请求数。
+6. **Http Status Code**: taosAdapter http 状态码。
## 升级
diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md
index 503f6927648ce77eedc6c2a5d160a0d997bf00d7..28b409de30a40c9997c0b91d8f50bf3277c149c1 100644
--- a/docs/zh/14-reference/12-config/index.md
+++ b/docs/zh/14-reference/12-config/index.md
@@ -162,11 +162,7 @@ taos --dump-config
| 含义 | 查询语句的执行策略 |
| 单位 | 无 |
| 缺省值 | 1 |
-| 补充说明 | 1: 只使用 vnode,不使用 qnode |
-
-2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行
-
-3: vnode 只运行扫描算子,其余算子均在 qnode 执行 |
+| 补充说明 | 1: 只使用 vnode,不使用 qnode; 2: 没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行; 3: vnode 只运行扫描算子,其余算子均在 qnode 执行 |
### querySmaOptimize
@@ -176,11 +172,7 @@ taos --dump-config
| 含义 | sma index 的优化策略 |
| 单位 | 无 |
| 缺省值 | 0 |
-| 补充说明 |
-
-0: 表示不使用 sma index,永远从原始数据进行查询
-
-1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询 |
+| 补充说明 |0: 表示不使用 sma index,永远从原始数据进行查询; 1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询 |
### maxNumOfDistinctRes
@@ -389,7 +381,7 @@ charset 的有效值是 UTF-8。
| 属性 | 说明 |
| -------- | -------------------------------------------- |
| 适用范围 | 服务端和客户端均适用 |
-| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 |
+| 含义 | 当日志文件夹所在磁盘可用空间大小小于该值时,停止写日志 |
| 单位 | GB |
| 缺省值 | 1.0 |
diff --git a/docs/zh/20-third-party/01-grafana.mdx b/docs/zh/20-third-party/01-grafana.mdx
index d5cfe847cada26a102b634573e7f4e2492adf60b..5927dc4fcacc0b947e3a4c44778d9d5979bfc196 100644
--- a/docs/zh/20-third-party/01-grafana.mdx
+++ b/docs/zh/20-third-party/01-grafana.mdx
@@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource
或者从 [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) 或 [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) 下载 .zip 文件到本地并解压到 Grafana 插件目录。命令行下载示例如下:
```bash
-GF_VERSION=3.2.7
+GF_VERSION=3.2.9
# from GitHub
wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip
# from Grafana
@@ -156,13 +156,13 @@ docker run -d \
services:
tdengine:
- image: tdengine/tdengine:2.6.0.2
+ image: tdengine/tdengine:3.0.2.4
environment:
TAOS_FQDN: tdengine
volumes:
- tdengine-data:/var/lib/taos/
grafana:
- image: grafana/grafana:8.5.6
+ image: grafana/grafana:9.3.6
volumes:
- ./tdengine.yml/:/etc/grafana/provisioning/tdengine.yml
- grafana-data:/var/lib/grafana
@@ -197,11 +197,17 @@ docker run -d \
- INPUT SQL:输入要查询的语句(该 SQL 语句的结果集应为两列多行),例如:`select _wstart, avg(mem_system) from log.dnodes_info where ts >= $from and ts < $to interval($interval)` ,其中,from、to 和 interval 为 TDengine 插件的内置变量,表示从 Grafana 插件面板获取的查询范围和时间间隔。除了内置变量外,`也支持可以使用自定义模板变量`。
- ALIAS BY:可设置当前查询别名。
- GENERATE SQL: 点击该按钮会自动替换相应变量,并生成最终执行的语句。
+- Group by column name(s): **半角**逗号分隔的 `group by` 或 `partition by` 列名。如果是 `group by` or `partition by` 查询语句,设置 `Group by` 列,可以展示多维数据。例如:INPUT SQL 为 `select _wstart as ts, avg(mem_system), dnode_ep from log.dnodes_info where ts>=$from and ts<=$to partition by dnode_ep interval($interval)`,设置 Group by 列名为 `dnode_ep`,可以按 `dnode_ep` 展示数据。
+- Format to: Group by 或 Partition by 场景下多维数据 legend 格式化格式。例如上述 INPUT SQL,将 Format to 设置为 `mem_system_{{dnode_ep}}`,展示的 legend 名字为格式化的列名。
按照默认提示查询当前 TDengine 部署所在服务器指定间隔系统内存平均使用量如下:
![TDengine Database Grafana plugin create dashboard](./create_dashboard2.webp)
+查询每台 TDengine 服务器指定间隔系统内存平均使用量如下:
+
+![TDengine Database Grafana plugin create dashboard](./create_dashboard3.webp)
+
> 关于如何使用 Grafana 创建相应的监测界面以及更多有关使用 Grafana 的信息,请参考 Grafana 官方的[文档](https://grafana.com/docs/)。
### 导入 Dashboard
diff --git a/docs/zh/20-third-party/create_dashboard1.webp b/docs/zh/20-third-party/create_dashboard1.webp
index 55eb388833e4df2a46f4d1cf6d346aa11429385d..df41d66d50e888555792ef34188a966c2e106a86 100644
Binary files a/docs/zh/20-third-party/create_dashboard1.webp and b/docs/zh/20-third-party/create_dashboard1.webp differ
diff --git a/docs/zh/20-third-party/create_dashboard2.webp b/docs/zh/20-third-party/create_dashboard2.webp
index bb40e407187718c52e9f617d8ebd3d25fd14b56b..ba50f5299605bd72ebfe1f3f5d1d62bdbc8939c9 100644
Binary files a/docs/zh/20-third-party/create_dashboard2.webp and b/docs/zh/20-third-party/create_dashboard2.webp differ
diff --git a/docs/zh/20-third-party/create_dashboard3.webp b/docs/zh/20-third-party/create_dashboard3.webp
new file mode 100644
index 0000000000000000000000000000000000000000..84f387f87bcc8e06fca90deabebd1d601c528ef1
Binary files /dev/null and b/docs/zh/20-third-party/create_dashboard3.webp differ
diff --git a/docs/zh/27-train-faq/01-faq.md b/docs/zh/27-train-faq/01-faq.md
index c6ecbe471a5c0863bac80ed6edfa6abd1e13c010..b0006196301c8a5dfa06842f9f49f77ece7f7507 100644
--- a/docs/zh/27-train-faq/01-faq.md
+++ b/docs/zh/27-train-faq/01-faq.md
@@ -243,8 +243,8 @@ sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
```
launchctl limit maxfiles
```
-### 19 建库时提示Out of dnode
-该提示是创建db的vnode数量不够了,需要的vnode不能超过了dnode中vnode的上限。因为系统默认是一个dnode中有cpu核数两倍的vnode,也可以通过配置文件中的参数supportVnodes控制。
-正常调大taos.cfg种这个supportVnodes参数即可。
+### 20 建库时提示 Out of dnodes
+该提示是创建 db 的 vnode 数量不够了,需要的 vnode 不能超过了 dnode 中 vnode 的上限。因为系统默认是一个 dnode 中有 CPU 核数两倍的 vnode,也可以通过配置文件中的参数 supportVnodes 控制。
+正常调大 taos.cfg 中 supportVnodes 参数即可。
diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md
index 2ec1e6cc5434d640efdfce6d29f73a605137cd51..cf7bf831642a879d8eb94e4afddef803930c2673 100644
--- a/docs/zh/28-releases/01-tdengine.md
+++ b/docs/zh/28-releases/01-tdengine.md
@@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
import Release from "/components/ReleaseV3";
+## 3.0.2.5
+
+
+
## 3.0.2.4
diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md
index 421cbd39e3462c9290b70970afede034598a8c2e..5f277b48734cbfa3775be07cb50541f6a0946ff5 100644
--- a/docs/zh/28-releases/02-tools.md
+++ b/docs/zh/28-releases/02-tools.md
@@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下:
import Release from "/components/ReleaseV3";
+## 2.4.3
+
+
+
## 2.4.2
diff --git a/examples/JDBC/readme.md b/examples/JDBC/readme.md
index c7d7875308d248c1abef8d47bc69a69e91374dbb..c5588a5b255970b1e509abc5b0a8410dcbf52a43 100644
--- a/examples/JDBC/readme.md
+++ b/examples/JDBC/readme.md
@@ -10,4 +10,4 @@
| 6 | taosdemo | This is an internal tool for testing Our JDBC-JNI, JDBC-RESTful, RESTful interfaces |
-more detail: https://docs.taosdata.com/reference/connector/java/
\ No newline at end of file
+more detail: https://docs.taosdata.com/connector/java/
diff --git a/examples/nodejs/node-example-raw.js b/examples/nodejs/node-example-raw.js
deleted file mode 100644
index 058a50c4c3f0f7d44da4bdcc4fc54b81d7e1bc38..0000000000000000000000000000000000000000
--- a/examples/nodejs/node-example-raw.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/* This example is to show how to use the td-connector through the cursor only and is a bit more raw.
- * No promises, object wrappers around data, functions that prettify the data, or anything.
- * The cursor will generally use callback functions over promises, and return and store the raw data from the C Interface.
- * It is advised to use the td-connector through the cursor and the TaosQuery class amongst other higher level APIs.
-*/
-
-// Get the td-connector package
-const taos = require('td2.0-connector');
-
-/* We will connect to TDengine by passing an object comprised of connection options to taos.connect and store the
- * connection to the variable conn
- */
-/*
- * Connection Options
- * host: the host to connect to
- * user: the use to login as
- * password: the password for the above user to login
- * config: the location of the taos.cfg file, by default it is in /etc/taos
- * port: the port we connect through
- */
-var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0});
-
-// Initialize our TDengineCursor, which we use to interact with TDengine
-var c1 = conn.cursor();
-
-// c1.execute(query) will execute the query
-// Let's create a database named db
-try {
- c1.execute('create database if not exists db;');
-}
-catch(err) {
- conn.close();
- throw err;
-}
-
-// Now we will use database db
-try {
- c1.execute('use db;');
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's create a table called weather
-// which stores some weather data like humidity, AQI (air quality index), temperature, and some notes as text
-try {
- c1.execute('create table if not exists weather (ts timestamp, humidity smallint, aqi int, temperature float, notes binary(30));');
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's get the description of the table weather
-try {
- c1.execute('describe db.weather');
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// To get results, we run the function c1.fetchall()
-// It only returns the query results as an array of result rows, but also stores the latest results in c1.data
-try {
- var tableDesc = c1.fetchall(); // The description variable here is equal to c1.data;
- console.log(tableDesc);
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's try to insert some random generated data to test with
-
-let stime = new Date();
-let interval = 1000;
-
-// Timestamps must be in the form of "YYYY-MM-DD HH:MM:SS.MMM" if they are in milliseconds
-// "YYYY-MM-DD HH:MM:SS.MMMMMM" if they are in microseconds
-// Thus, we create the following function to convert a javascript Date object to the correct formatting
-function convertDateToTS(date) {
- let tsArr = date.toISOString().split("T")
- return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length-1) + "\"";
-}
-
-try {
- for (let i = 0; i < 10000; i++) {
- stime.setMilliseconds(stime.getMilliseconds() + interval);
- let insertData = [convertDateToTS(stime),
- parseInt(Math.random()*100),
- parseInt(Math.random()*300),
- parseFloat(Math.random()*10 + 30),
- "\"random note!\""];
- c1.execute('insert into db.weather values(' + insertData.join(',') + ' );');
- }
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Now let's look at our newly inserted data
-var retrievedData;
-try {
- c1.execute('select * from db.weather;')
- retrievedData = c1.fetchall();
-
- // c1.fields stores the names of each column retrieved
- console.log(c1.fields);
- console.log(retrievedData);
- // timestamps retrieved are always JS Date Objects
- // Numbers are numbers, big ints are big ints, and strings are strings
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's try running some basic functions
-try {
- c1.execute('select count(*), avg(temperature), max(temperature), min(temperature), stddev(temperature) from db.weather;')
- c1.fetchall();
- console.log(c1.fields);
- console.log(c1.data);
-}
-catch(err) {
- conn.close();
- throw err;
-}
-
-conn.close();
-
-// Feel free to fork this repository or copy this code and start developing your own apps and backends with NodeJS and TDengine!
diff --git a/examples/nodejs/node-example.js b/examples/nodejs/node-example.js
deleted file mode 100644
index bfdd9e49a08fc1d6c20f3bdafbb84a500986b9fd..0000000000000000000000000000000000000000
--- a/examples/nodejs/node-example.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/* This example is to show the preferred way to use the td-connector */
-/* To run, enter node path/to/node-example.js */
-// Get the td-connector package
-const taos = require('td2.0-connector');
-
-/* We will connect to TDengine by passing an object comprised of connection options to taos.connect and store the
- * connection to the variable conn
- */
-/*
- * Connection Options
- * host: the host to connect to
- * user: the use to login as
- * password: the password for the above user to login
- * config: the location of the taos.cfg file, by default it is in /etc/taos
- * port: the port we connect through
- */
-var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0});
-
-// Initialize our TDengineCursor, which we use to interact with TDengine
-var c1 = conn.cursor();
-
-// c1.query(query) will return a TaosQuery object, of which then we can execute. The execute function then returns a promise
-// Let's create a database named db
-try {
- c1.execute('create database if not exists db;');
- //var query = c1.query('create database if not exists db;');
- //query.execute();
-}
-catch(err) {
- conn.close();
- throw err;
-}
-
-// Now we will use database db. As this query won't return any results,
-// we can simplify the code and directly use the c1.execute() function. No need for a TaosQuery object to wrap around the query
-try {
- c1.execute('use db;');
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's create a table called weather
-// which stores some weather data like humidity, AQI (air quality index), temperature, and some notes as text
-// We can also immedietely execute a TaosQuery object by passing true as the secodn argument
-// This will then return a promise that we can then attach a callback function to
-try {
- var promise = c1.query('create table if not exists weather (ts timestamp, humidity smallint, aqi int, temperature float, notes binary(30));', true);
- promise.then(function(){
- console.log("Table created!");
- }).catch(function() {
- console.log("Table couldn't be created.")
- });
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's get the description of the table weather
-// When using a TaosQuery object and then executing it, upon success it returns a TaosResult object, which is a wrapper around the
-// retrieved data and allows us to easily access data and manipulate or display it.
-try {
- c1.query('describe db.weather;').execute().then(function(result){
- // Result is an instance of TaosResult and has the function pretty() which instantly logs a prettified version to the console
- result.pretty();
- });
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-
-Date.prototype.Format = function(fmt){
- var o = {
- 'M+': this.getMonth() + 1,
- 'd+': this.getDate(),
- 'H+': this.getHours(),
- 'm+': this.getMinutes(),
- 's+': this.getSeconds(),
- 'S+': this.getMilliseconds()
- };
- if (/(y+)/.test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
- }
- for (var k in o) {
- if (new RegExp('(' + k + ')').test(fmt)) {
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(String(o[k]).length)));
- }
- }
- return fmt;
-}
-
-
-// Let's try to insert some random generated data to test with
-// We will use the bind function of the TaosQuery object to easily bind values to question marks in the query
-// For Timestamps, a normal Datetime object or TaosTimestamp or milliseconds can be passed in through the bind function
-let stime = new Date();
-let interval = 1000;
-try {
- for (let i = 0; i < 1000; i++) {
- stime.setMilliseconds(stime.getMilliseconds() + interval);
-
- //console.log(stime.Format('yyyy-MM-dd HH:mm:ss.SSS'));
-
- let insertData = [stime,
- parseInt(Math.random()*100),
- parseInt(Math.random()*300),
- parseFloat(Math.random()*10 + 30),
- "Note"];
- //c1.execute('insert into db.weather values(' + insertData.join(',') + ' );');
-
- //var query = c1.query('insert into db.weather values(?, ?, ?, ?, ?);').bind(insertData);
- //query.execute();
- c1.execute('insert into db.weather values(\"'+stime.Format('yyyy-MM-dd HH:mm:ss.SSS')+'\",'+parseInt(Math.random() * 100)+','+parseInt(Math.random() * 300)+','+parseFloat(Math.random()*10 + 30)+',"Note");');
- }
-}catch (err) {
- conn.close();
- throw err;
-}
-
-// Now let's look at our newly inserted data
-var retrievedData;
-try {
- c1.query('select * from db.weather limit 5 offset 100;', true).then(function(result){
- //result.pretty();
- console.log('=========>'+JSON.stringify(result));
- // Neat!
- });
-
-}
-catch (err) {
- conn.close();
- throw err;
-}
-
-// Let's try running some basic functions
-try {
- c1.query('select count(*), avg(temperature), max(temperature), min(temperature), stddev(temperature) from db.weather;', true)
- .then(function(result) {
- result.pretty();
- })
-}
-catch(err) {
- conn.close();
- throw err;
-}
-
-conn.close();
-
-// Feel free to fork this repository or copy this code and start developing your own apps and backends with NodeJS and TDengine!
diff --git a/examples/nodejs/nodejsChecker.js b/examples/nodejs/nodejsChecker.js
index e634a54ea1c56310bae7d38188590a0d7862f953..58b27dad67ba578b3b53194d3de73373991c2240 100644
--- a/examples/nodejs/nodejsChecker.js
+++ b/examples/nodejs/nodejsChecker.js
@@ -1,29 +1,27 @@
-const taos = require('td2.0-connector');
-//const taos = require('../../../src/connector/nodejs/');
-
+const taos = require("@tdengine/client");
var host = null;
var port = 6030;
for(var i = 2; i < global.process.argv.length; i++){
- var key = global.process.argv[i].split("=")[0];
- var value = global.process.argv[i].split("=")[1];
-
- if("host" == key){
- host = value;
- }
- if("port" == key){
- port = value;
- }
+ var key = global.process.argv[i].split("=")[0];
+ var value = global.process.argv[i].split("=")[1];
+
+ if("host" == key){
+ host = value;
+ }
+ if("port" == key){
+ port = value;
+ }
}
if(host == null){
- console.log("Usage: node nodejsChecker.js host= port=");
- process.exit(0);
+ console.log("Usage: node nodejsChecker.js host= port=");
+ process.exit(0);
}
// establish connection
var conn = taos.connect({host:host, user:"root", password:"taosdata",port:port});
-var cursor = conn.cursor();
+var cursor = conn.cursor();
// create database
executeSql("create database if not exists test", 0);
// use db
@@ -40,22 +38,22 @@ executeQuery("select * from test.weather");
conn.close();
function executeQuery(sql){
- var start = new Date().getTime();
- var promise = cursor.query(sql, true);
- var end = new Date().getTime();
- promise.then(function(result){
- printSql(sql, result != null,(end - start));
- result.pretty();
- });
+ var start = new Date().getTime();
+ var promise = cursor.query(sql, true);
+ var end = new Date().getTime();
+ promise.then(function(result){
+ printSql(sql, result != null,(end - start));
+ result.pretty();
+ });
}
function executeSql(sql, affectRows){
- var start = new Date().getTime();
- var promise = cursor.execute(sql);
- var end = new Date().getTime();
- printSql(sql, promise == affectRows, (end - start));
+ var start = new Date().getTime();
+ var promise = cursor.execute(sql);
+ var end = new Date().getTime();
+ printSql(sql, promise == affectRows, (end - start));
}
function printSql(sql, succeed, cost){
- console.log("[ "+(succeed ? "OK" : "ERROR!")+" ] time cost: " + cost + " ms, execute statement ====> " + sql);
-}
+ console.log("[ "+(succeed ? "OK" : "ERROR!")+" ] time cost: " + cost + " ms, execute statement ====> " + sql);
+}
\ No newline at end of file
diff --git a/examples/nodejs/test1970.js b/examples/nodejs/test1970.js
deleted file mode 100644
index 5177a7371e9a07fa7b548936ff038c1f2a29bc1f..0000000000000000000000000000000000000000
--- a/examples/nodejs/test1970.js
+++ /dev/null
@@ -1,125 +0,0 @@
-const taos = require('td2.0-connector');
-var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0})
-var c1 = conn.cursor(); // Initializing a new cursor
-
-let stime = new Date();
-let interval = 1000;
-
-function convertDateToTS(date) {
- let tsArr = date.toISOString().split("T")
- return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\"";
-}
-
-function R(l, r) {
- return Math.random() * (r - l) - r;
-}
-
-function randomBool() {
- if (Math.random() < 0.5) {
- return true;
- }
- return false;
-}
-
-// Initialize
-const dbname = "nodejs_1970_db";
-const tbname = "t1";
-
-let dropDB = "drop database if exists " + dbname
-console.log(dropDB);//asdasdasd
-c1.execute(dropDB);///asdasd
-
-let createDB = "create database " + dbname + " keep 36500"
-console.log(createDB);
-c1.execute(createDB);
-
-let useTbl = "use " + dbname
-console.log(useTbl)
-c1.execute(useTbl);
-
-let createTbl = "create table if not exists " + tbname + "(ts timestamp,id int)"
-console.log(createTbl);
-c1.execute(createTbl);
-
-//1969-12-31 23:59:59.999
-//1970-01-01 00:00:00.000
-//1970-01-01 07:59:59.999
-//1970-01-01 08:00:00.000a
-//1628928479484 2021-08-14 08:07:59.484
-let sql1 = "insert into " + dbname + "." + tbname + " values('1969-12-31 23:59:59.999',1)"
-console.log(sql1);
-c1.execute(sql1);
-
-let sql2 = "insert into " + dbname + "." + tbname + " values('1970-01-01 00:00:00.000',2)"
-console.log(sql2);
-c1.execute(sql2);
-
-let sql3 = "insert into " + dbname + "." + tbname + " values('1970-01-01 07:59:59.999',3)"
-console.log(sql3);
-c1.execute(sql3);
-
-let sql4 = "insert into " + dbname + "." + tbname + " values('1970-01-01 08:00:00.000',4)"
-console.log(sql4);
-c1.execute(sql4);
-
-let sql5 = "insert into " + dbname + "." + tbname + " values('2021-08-14 08:07:59.484',5)"
-console.log(sql5);
-c1.execute(sql5);
-
-// Select
-let query1 = "select * from " + dbname + "." + tbname
-console.log(query1);
-c1.execute(query1);
-
-var d = c1.fetchall();
-console.log(c1.fields);
-for (let i = 0; i < d.length; i++)
- console.log(d[i][0].valueOf());
-
-//initialize
-let initSql1 = "drop table if exists " + tbname
-console.log(initSql1);
-c1.execute(initSql1);
-
-console.log(createTbl);
-c1.execute(createTbl);
-c1.execute(useTbl)
-
-//-28800001 1969-12-31 23:59:59.999
-//-28800000 1970-01-01 00:00:00.000
-//-1 1970-01-01 07:59:59.999
-//0 1970-01-01 08:00:00.00
-//1628928479484 2021-08-14 08:07:59.484
-let sql11 = "insert into " + dbname + "." + tbname + " values(-28800001,11)";
-console.log(sql11);
-c1.execute(sql11);
-
-let sql12 = "insert into " + dbname + "." + tbname + " values(-28800000,12)"
-console.log(sql12);
-c1.execute(sql12);
-
-let sql13 = "insert into " + dbname + "." + tbname + " values(-1,13)"
-console.log(sql13);
-c1.execute(sql13);
-
-let sql14 = "insert into " + dbname + "." + tbname + " values(0,14)"
-console.log(sql14);
-c1.execute(sql14);
-
-let sql15 = "insert into " + dbname + "." + tbname + " values(1628928479484,15)"
-console.log(sql15);
-c1.execute(sql15);
-
-// Select
-console.log(query1);
-c1.execute(query1);
-
-var d = c1.fetchall();
-console.log(c1.fields);
-for (let i = 0; i < d.length; i++)
- console.log(d[i][0].valueOf());
-
-setTimeout(function () {
- conn.close();
-}, 2000);
-
diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h
index e0aacbfec9db8804b4003417689f404b78549afb..d7a62f5402defb95da6a4217254e14dbbc6de56c 100644
--- a/include/common/tdataformat.h
+++ b/include/common/tdataformat.h
@@ -109,7 +109,7 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
void tRowDestroy(SRow *pRow);
void tRowSort(SArray *aRowP);
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
-int32_t tRowAppendToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData);
+int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
// SRowIter ================================
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
@@ -137,6 +137,7 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn)
void tColDataClear(SColData *pColData);
void tColDataDeepClear(SColData *pColData);
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
+int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward);
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
uint8_t tColDataGetBitValue(const SColData *pColData, int32_t iVal);
int32_t tColDataCopy(SColData *pColDataFrom, SColData *pColData, xMallocFn xMalloc, void *arg);
@@ -146,9 +147,9 @@ extern void (*tColDataCalcSMA[])(SColData *pColData, int64_t *sum, int64_t *max,
int32_t tColDataAddValueByBind(SColData *pColData, TAOS_MULTI_BIND *pBind);
void tColDataSortMerge(SArray *colDataArr);
-//for raw block
-int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes,
- int32_t nRows, char* lengthOrbitmap, char *data);
+// for raw block
+int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap,
+ char *data);
// for encode/decode
int32_t tPutColData(uint8_t *pBuf, SColData *pColData);
int32_t tGetColData(uint8_t *pBuf, SColData *pColData);
@@ -200,6 +201,9 @@ struct SColData {
int16_t cid;
int8_t type;
int8_t smaOn;
+ int32_t numOfNone; // # of none
+ int32_t numOfNull; // # of null
+ int32_t numOfValue; // # of vale
int32_t nVal;
uint8_t flag;
uint8_t *pBitMap;
@@ -261,7 +265,13 @@ struct STag {
// STSchema ================================
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version);
-void tDestroyTSchema(STSchema *pTSchema);
+#define tDestroyTSchema(pTSchema) \
+ do { \
+ if (pTSchema) { \
+ taosMemoryFree(pTSchema); \
+ pTSchema = NULL; \
+ } \
+ } while (0)
#endif
diff --git a/include/common/tmsg.h b/include/common/tmsg.h
index caf67ee3a99cf054a7b6add325fbd1af7b5e8b3f..a82364f347629936b51619b8feda45984fd16e7c 100644
--- a/include/common/tmsg.h
+++ b/include/common/tmsg.h
@@ -58,7 +58,7 @@ extern int32_t tMsgDict[];
#define TMSG_INFO(TYPE) \
((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || (TYPE) < TDMT_SCH_MAX_MSG || \
(TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG) || \
- (TYPE) < TDMT_VND_STREAM_MSG || (TYPE) < TDMT_VND_TMQ_MSG \
+ (TYPE) < TDMT_VND_STREAM_MSG || (TYPE) < TDMT_VND_TMQ_MSG || (TYPE) < TDMT_VND_TMQ_MAX_MSG \
? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \
: 0
@@ -145,12 +145,14 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9
#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10
-#define TSDB_FILL_NONE 0
-#define TSDB_FILL_NULL 1
-#define TSDB_FILL_SET_VALUE 2
-#define TSDB_FILL_LINEAR 3
-#define TSDB_FILL_PREV 4
-#define TSDB_FILL_NEXT 5
+#define TSDB_FILL_NONE 0
+#define TSDB_FILL_NULL 1
+#define TSDB_FILL_NULL_F 2
+#define TSDB_FILL_SET_VALUE 3
+#define TSDB_FILL_SET_VALUE_F 4
+#define TSDB_FILL_LINEAR 5
+#define TSDB_FILL_PREV 6
+#define TSDB_FILL_NEXT 7
#define TSDB_ALTER_USER_PASSWD 0x1
#define TSDB_ALTER_USER_SUPERUSER 0x2
@@ -1241,7 +1243,7 @@ int32_t tDeserializeSDropVnodeReq(void* buf, int32_t bufLen, SDropVnodeReq* pReq
typedef struct {
int64_t dbUid;
char db[TSDB_DB_FNAME_LEN];
- int64_t reserved[8];
+ int64_t compactStartTime;
} SCompactVnodeReq;
int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq);
@@ -1279,6 +1281,25 @@ typedef struct {
int32_t tSerializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
int32_t tDeserializeSAlterVnodeReplicaReq(void* buf, int32_t bufLen, SAlterVnodeReplicaReq* pReq);
+typedef struct {
+ int32_t vgId;
+ int8_t disable;
+} SDisableVnodeWriteReq;
+
+int32_t tSerializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
+int32_t tDeserializeSDisableVnodeWriteReq(void* buf, int32_t bufLen, SDisableVnodeWriteReq* pReq);
+
+typedef struct {
+ int32_t srcVgId;
+ int32_t dstVgId;
+ uint32_t hashBegin;
+ uint32_t hashEnd;
+ int64_t reserved;
+} SAlterVnodeHashRangeReq;
+
+int32_t tSerializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
+int32_t tDeserializeSAlterVnodeHashRangeReq(void* buf, int32_t bufLen, SAlterVnodeHashRangeReq* pReq);
+
typedef struct {
SMsgHead header;
char dbFName[TSDB_DB_FNAME_LEN];
@@ -1762,6 +1783,7 @@ typedef struct {
#define STREAM_FILL_HISTORY_ON 1
#define STREAM_FILL_HISTORY_OFF 0
#define STREAM_DEFAULT_FILL_HISTORY STREAM_FILL_HISTORY_OFF
+#define STREAM_DEFAULT_IGNORE_UPDATE 0
#define STREAM_CREATE_STABLE_TRUE 1
#define STREAM_CREATE_STABLE_FALSE 0
@@ -1790,7 +1812,8 @@ typedef struct {
// 3.0.2.3
int8_t createStb;
uint64_t targetStbUid;
- SArray* fillNullCols; // array of SColLocation
+ SArray* fillNullCols; // array of SColLocation
+ int8_t igUpdate;
} SCMCreateStreamReq;
typedef struct {
diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h
index 7833bdf1393c72b988b1553d691e7d8936b14603..44ee26ef240ddc5f133c08d3076e068d876e7268 100644
--- a/include/common/tmsgdef.h
+++ b/include/common/tmsgdef.h
@@ -220,6 +220,7 @@ enum {
TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "vnode-drop-ttl-stb", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_VND_TRIM, "vnode-trim", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_VND_COMMIT, "vnode-commit", NULL, NULL)
+ TD_DEF_MSG_TYPE(TDMT_VND_DISABLE_WRITE, "vnode-disable-write", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_VND_MAX_MSG, "vnd-max", NULL, NULL)
TD_NEW_MSG_SEG(TDMT_SCH_MSG)
diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h
index 597371d9d1a50fce133f8a78c16a72d031119978..ada3fd20e8ce693a7fcd9a331d24b968fe1852c4 100644
--- a/include/common/ttokendef.h
+++ b/include/common/ttokendef.h
@@ -16,331 +16,333 @@
#ifndef _TD_COMMON_TOKEN_H_
#define _TD_COMMON_TOKEN_H_
-#define TK_OR 1
-#define TK_AND 2
-#define TK_UNION 3
-#define TK_ALL 4
-#define TK_MINUS 5
-#define TK_EXCEPT 6
-#define TK_INTERSECT 7
-#define TK_NK_BITAND 8
-#define TK_NK_BITOR 9
-#define TK_NK_LSHIFT 10
-#define TK_NK_RSHIFT 11
-#define TK_NK_PLUS 12
-#define TK_NK_MINUS 13
-#define TK_NK_STAR 14
-#define TK_NK_SLASH 15
-#define TK_NK_REM 16
-#define TK_NK_CONCAT 17
-#define TK_CREATE 18
-#define TK_ACCOUNT 19
-#define TK_NK_ID 20
-#define TK_PASS 21
-#define TK_NK_STRING 22
-#define TK_ALTER 23
-#define TK_PPS 24
-#define TK_TSERIES 25
-#define TK_STORAGE 26
-#define TK_STREAMS 27
-#define TK_QTIME 28
-#define TK_DBS 29
-#define TK_USERS 30
-#define TK_CONNS 31
-#define TK_STATE 32
-#define TK_USER 33
-#define TK_ENABLE 34
-#define TK_NK_INTEGER 35
-#define TK_SYSINFO 36
-#define TK_DROP 37
-#define TK_GRANT 38
-#define TK_ON 39
-#define TK_TO 40
-#define TK_REVOKE 41
-#define TK_FROM 42
-#define TK_SUBSCRIBE 43
-#define TK_NK_COMMA 44
-#define TK_READ 45
-#define TK_WRITE 46
-#define TK_NK_DOT 47
-#define TK_DNODE 48
-#define TK_PORT 49
-#define TK_DNODES 50
-#define TK_NK_IPTOKEN 51
-#define TK_FORCE 52
-#define TK_LOCAL 53
-#define TK_QNODE 54
-#define TK_BNODE 55
-#define TK_SNODE 56
-#define TK_MNODE 57
-#define TK_DATABASE 58
-#define TK_USE 59
-#define TK_FLUSH 60
-#define TK_TRIM 61
-#define TK_IF 62
-#define TK_NOT 63
-#define TK_EXISTS 64
-#define TK_BUFFER 65
-#define TK_CACHEMODEL 66
-#define TK_CACHESIZE 67
-#define TK_COMP 68
-#define TK_DURATION 69
-#define TK_NK_VARIABLE 70
-#define TK_MAXROWS 71
-#define TK_MINROWS 72
-#define TK_KEEP 73
-#define TK_PAGES 74
-#define TK_PAGESIZE 75
-#define TK_TSDB_PAGESIZE 76
-#define TK_PRECISION 77
-#define TK_REPLICA 78
-#define TK_VGROUPS 79
-#define TK_SINGLE_STABLE 80
-#define TK_RETENTIONS 81
-#define TK_SCHEMALESS 82
-#define TK_WAL_LEVEL 83
-#define TK_WAL_FSYNC_PERIOD 84
-#define TK_WAL_RETENTION_PERIOD 85
-#define TK_WAL_RETENTION_SIZE 86
-#define TK_WAL_ROLL_PERIOD 87
-#define TK_WAL_SEGMENT_SIZE 88
-#define TK_STT_TRIGGER 89
-#define TK_TABLE_PREFIX 90
-#define TK_TABLE_SUFFIX 91
-#define TK_NK_COLON 92
-#define TK_MAX_SPEED 93
-#define TK_TABLE 94
-#define TK_NK_LP 95
-#define TK_NK_RP 96
-#define TK_STABLE 97
-#define TK_ADD 98
-#define TK_COLUMN 99
-#define TK_MODIFY 100
-#define TK_RENAME 101
-#define TK_TAG 102
-#define TK_SET 103
-#define TK_NK_EQ 104
-#define TK_USING 105
-#define TK_TAGS 106
-#define TK_COMMENT 107
-#define TK_BOOL 108
-#define TK_TINYINT 109
-#define TK_SMALLINT 110
-#define TK_INT 111
-#define TK_INTEGER 112
-#define TK_BIGINT 113
-#define TK_FLOAT 114
-#define TK_DOUBLE 115
-#define TK_BINARY 116
-#define TK_TIMESTAMP 117
-#define TK_NCHAR 118
-#define TK_UNSIGNED 119
-#define TK_JSON 120
-#define TK_VARCHAR 121
-#define TK_MEDIUMBLOB 122
-#define TK_BLOB 123
-#define TK_VARBINARY 124
-#define TK_DECIMAL 125
-#define TK_MAX_DELAY 126
-#define TK_WATERMARK 127
-#define TK_ROLLUP 128
-#define TK_TTL 129
-#define TK_SMA 130
-#define TK_DELETE_MARK 131
-#define TK_FIRST 132
-#define TK_LAST 133
-#define TK_SHOW 134
-#define TK_PRIVILEGES 135
-#define TK_DATABASES 136
-#define TK_TABLES 137
-#define TK_STABLES 138
-#define TK_MNODES 139
-#define TK_QNODES 140
-#define TK_FUNCTIONS 141
-#define TK_INDEXES 142
-#define TK_ACCOUNTS 143
-#define TK_APPS 144
-#define TK_CONNECTIONS 145
-#define TK_LICENCES 146
-#define TK_GRANTS 147
-#define TK_QUERIES 148
-#define TK_SCORES 149
-#define TK_TOPICS 150
-#define TK_VARIABLES 151
-#define TK_CLUSTER 152
-#define TK_BNODES 153
-#define TK_SNODES 154
-#define TK_TRANSACTIONS 155
-#define TK_DISTRIBUTED 156
-#define TK_CONSUMERS 157
-#define TK_SUBSCRIPTIONS 158
-#define TK_VNODES 159
-#define TK_ALIVE 160
-#define TK_LIKE 161
-#define TK_TBNAME 162
-#define TK_QTAGS 163
-#define TK_AS 164
-#define TK_INDEX 165
-#define TK_FUNCTION 166
-#define TK_INTERVAL 167
-#define TK_COUNT 168
-#define TK_LAST_ROW 169
-#define TK_TOPIC 170
-#define TK_WITH 171
-#define TK_META 172
-#define TK_CONSUMER 173
-#define TK_GROUP 174
-#define TK_DESC 175
-#define TK_DESCRIBE 176
-#define TK_RESET 177
-#define TK_QUERY 178
-#define TK_CACHE 179
-#define TK_EXPLAIN 180
-#define TK_ANALYZE 181
-#define TK_VERBOSE 182
-#define TK_NK_BOOL 183
-#define TK_RATIO 184
-#define TK_NK_FLOAT 185
-#define TK_OUTPUTTYPE 186
-#define TK_AGGREGATE 187
-#define TK_BUFSIZE 188
-#define TK_STREAM 189
-#define TK_INTO 190
-#define TK_TRIGGER 191
-#define TK_AT_ONCE 192
-#define TK_WINDOW_CLOSE 193
-#define TK_IGNORE 194
-#define TK_EXPIRED 195
-#define TK_FILL_HISTORY 196
-#define TK_SUBTABLE 197
-#define TK_KILL 198
-#define TK_CONNECTION 199
-#define TK_TRANSACTION 200
-#define TK_BALANCE 201
-#define TK_VGROUP 202
-#define TK_MERGE 203
-#define TK_REDISTRIBUTE 204
-#define TK_SPLIT 205
-#define TK_DELETE 206
-#define TK_INSERT 207
-#define TK_NULL 208
-#define TK_NK_QUESTION 209
-#define TK_NK_ARROW 210
-#define TK_ROWTS 211
-#define TK_QSTART 212
-#define TK_QEND 213
-#define TK_QDURATION 214
-#define TK_WSTART 215
-#define TK_WEND 216
-#define TK_WDURATION 217
-#define TK_IROWTS 218
-#define TK_ISFILLED 219
-#define TK_CAST 220
-#define TK_NOW 221
-#define TK_TODAY 222
-#define TK_TIMEZONE 223
-#define TK_CLIENT_VERSION 224
-#define TK_SERVER_VERSION 225
-#define TK_SERVER_STATUS 226
-#define TK_CURRENT_USER 227
-#define TK_CASE 228
-#define TK_END 229
-#define TK_WHEN 230
-#define TK_THEN 231
-#define TK_ELSE 232
-#define TK_BETWEEN 233
-#define TK_IS 234
-#define TK_NK_LT 235
-#define TK_NK_GT 236
-#define TK_NK_LE 237
-#define TK_NK_GE 238
-#define TK_NK_NE 239
-#define TK_MATCH 240
-#define TK_NMATCH 241
-#define TK_CONTAINS 242
-#define TK_IN 243
-#define TK_JOIN 244
-#define TK_INNER 245
-#define TK_SELECT 246
-#define TK_DISTINCT 247
-#define TK_WHERE 248
-#define TK_PARTITION 249
-#define TK_BY 250
-#define TK_SESSION 251
-#define TK_STATE_WINDOW 252
-#define TK_EVENT_WINDOW 253
-#define TK_START 254
-#define TK_SLIDING 255
-#define TK_FILL 256
-#define TK_VALUE 257
-#define TK_NONE 258
-#define TK_PREV 259
-#define TK_LINEAR 260
-#define TK_NEXT 261
-#define TK_HAVING 262
-#define TK_RANGE 263
-#define TK_EVERY 264
-#define TK_ORDER 265
-#define TK_SLIMIT 266
-#define TK_SOFFSET 267
-#define TK_LIMIT 268
-#define TK_OFFSET 269
-#define TK_ASC 270
-#define TK_NULLS 271
-#define TK_ABORT 272
-#define TK_AFTER 273
-#define TK_ATTACH 274
-#define TK_BEFORE 275
-#define TK_BEGIN 276
-#define TK_BITAND 277
-#define TK_BITNOT 278
-#define TK_BITOR 279
-#define TK_BLOCKS 280
-#define TK_CHANGE 281
-#define TK_COMMA 282
-#define TK_COMPACT 283
-#define TK_CONCAT 284
-#define TK_CONFLICT 285
-#define TK_COPY 286
-#define TK_DEFERRED 287
-#define TK_DELIMITERS 288
-#define TK_DETACH 289
-#define TK_DIVIDE 290
-#define TK_DOT 291
-#define TK_EACH 292
-#define TK_FAIL 293
-#define TK_FILE 294
-#define TK_FOR 295
-#define TK_GLOB 296
-#define TK_ID 297
-#define TK_IMMEDIATE 298
-#define TK_IMPORT 299
-#define TK_INITIALLY 300
-#define TK_INSTEAD 301
-#define TK_ISNULL 302
-#define TK_KEY 303
-#define TK_MODULES 304
-#define TK_NK_BITNOT 305
-#define TK_NK_SEMI 306
-#define TK_NOTNULL 307
-#define TK_OF 308
-#define TK_PLUS 309
-#define TK_PRIVILEGE 310
-#define TK_RAISE 311
-#define TK_REPLACE 312
-#define TK_RESTRICT 313
-#define TK_ROW 314
-#define TK_SEMI 315
-#define TK_STAR 316
-#define TK_STATEMENT 317
-#define TK_STRICT 318
-#define TK_STRING 319
-#define TK_TIMES 320
-#define TK_UPDATE 321
-#define TK_VALUES 322
-#define TK_VARIABLE 323
-#define TK_VIEW 324
-#define TK_WAL 325
+#define TK_OR 1
+#define TK_AND 2
+#define TK_UNION 3
+#define TK_ALL 4
+#define TK_MINUS 5
+#define TK_EXCEPT 6
+#define TK_INTERSECT 7
+#define TK_NK_BITAND 8
+#define TK_NK_BITOR 9
+#define TK_NK_LSHIFT 10
+#define TK_NK_RSHIFT 11
+#define TK_NK_PLUS 12
+#define TK_NK_MINUS 13
+#define TK_NK_STAR 14
+#define TK_NK_SLASH 15
+#define TK_NK_REM 16
+#define TK_NK_CONCAT 17
+#define TK_CREATE 18
+#define TK_ACCOUNT 19
+#define TK_NK_ID 20
+#define TK_PASS 21
+#define TK_NK_STRING 22
+#define TK_ALTER 23
+#define TK_PPS 24
+#define TK_TSERIES 25
+#define TK_STORAGE 26
+#define TK_STREAMS 27
+#define TK_QTIME 28
+#define TK_DBS 29
+#define TK_USERS 30
+#define TK_CONNS 31
+#define TK_STATE 32
+#define TK_USER 33
+#define TK_ENABLE 34
+#define TK_NK_INTEGER 35
+#define TK_SYSINFO 36
+#define TK_DROP 37
+#define TK_GRANT 38
+#define TK_ON 39
+#define TK_TO 40
+#define TK_REVOKE 41
+#define TK_FROM 42
+#define TK_SUBSCRIBE 43
+#define TK_NK_COMMA 44
+#define TK_READ 45
+#define TK_WRITE 46
+#define TK_NK_DOT 47
+#define TK_DNODE 48
+#define TK_PORT 49
+#define TK_DNODES 50
+#define TK_NK_IPTOKEN 51
+#define TK_FORCE 52
+#define TK_LOCAL 53
+#define TK_QNODE 54
+#define TK_BNODE 55
+#define TK_SNODE 56
+#define TK_MNODE 57
+#define TK_DATABASE 58
+#define TK_USE 59
+#define TK_FLUSH 60
+#define TK_TRIM 61
+#define TK_COMPACT 62
+#define TK_IF 63
+#define TK_NOT 64
+#define TK_EXISTS 65
+#define TK_BUFFER 66
+#define TK_CACHEMODEL 67
+#define TK_CACHESIZE 68
+#define TK_COMP 69
+#define TK_DURATION 70
+#define TK_NK_VARIABLE 71
+#define TK_MAXROWS 72
+#define TK_MINROWS 73
+#define TK_KEEP 74
+#define TK_PAGES 75
+#define TK_PAGESIZE 76
+#define TK_TSDB_PAGESIZE 77
+#define TK_PRECISION 78
+#define TK_REPLICA 79
+#define TK_VGROUPS 80
+#define TK_SINGLE_STABLE 81
+#define TK_RETENTIONS 82
+#define TK_SCHEMALESS 83
+#define TK_WAL_LEVEL 84
+#define TK_WAL_FSYNC_PERIOD 85
+#define TK_WAL_RETENTION_PERIOD 86
+#define TK_WAL_RETENTION_SIZE 87
+#define TK_WAL_ROLL_PERIOD 88
+#define TK_WAL_SEGMENT_SIZE 89
+#define TK_STT_TRIGGER 90
+#define TK_TABLE_PREFIX 91
+#define TK_TABLE_SUFFIX 92
+#define TK_NK_COLON 93
+#define TK_MAX_SPEED 94
+#define TK_TABLE 95
+#define TK_NK_LP 96
+#define TK_NK_RP 97
+#define TK_STABLE 98
+#define TK_ADD 99
+#define TK_COLUMN 100
+#define TK_MODIFY 101
+#define TK_RENAME 102
+#define TK_TAG 103
+#define TK_SET 104
+#define TK_NK_EQ 105
+#define TK_USING 106
+#define TK_TAGS 107
+#define TK_COMMENT 108
+#define TK_BOOL 109
+#define TK_TINYINT 110
+#define TK_SMALLINT 111
+#define TK_INT 112
+#define TK_INTEGER 113
+#define TK_BIGINT 114
+#define TK_FLOAT 115
+#define TK_DOUBLE 116
+#define TK_BINARY 117
+#define TK_TIMESTAMP 118
+#define TK_NCHAR 119
+#define TK_UNSIGNED 120
+#define TK_JSON 121
+#define TK_VARCHAR 122
+#define TK_MEDIUMBLOB 123
+#define TK_BLOB 124
+#define TK_VARBINARY 125
+#define TK_DECIMAL 126
+#define TK_MAX_DELAY 127
+#define TK_WATERMARK 128
+#define TK_ROLLUP 129
+#define TK_TTL 130
+#define TK_SMA 131
+#define TK_DELETE_MARK 132
+#define TK_FIRST 133
+#define TK_LAST 134
+#define TK_SHOW 135
+#define TK_PRIVILEGES 136
+#define TK_DATABASES 137
+#define TK_TABLES 138
+#define TK_STABLES 139
+#define TK_MNODES 140
+#define TK_QNODES 141
+#define TK_FUNCTIONS 142
+#define TK_INDEXES 143
+#define TK_ACCOUNTS 144
+#define TK_APPS 145
+#define TK_CONNECTIONS 146
+#define TK_LICENCES 147
+#define TK_GRANTS 148
+#define TK_QUERIES 149
+#define TK_SCORES 150
+#define TK_TOPICS 151
+#define TK_VARIABLES 152
+#define TK_CLUSTER 153
+#define TK_BNODES 154
+#define TK_SNODES 155
+#define TK_TRANSACTIONS 156
+#define TK_DISTRIBUTED 157
+#define TK_CONSUMERS 158
+#define TK_SUBSCRIPTIONS 159
+#define TK_VNODES 160
+#define TK_ALIVE 161
+#define TK_LIKE 162
+#define TK_TBNAME 163
+#define TK_QTAGS 164
+#define TK_AS 165
+#define TK_INDEX 166
+#define TK_FUNCTION 167
+#define TK_INTERVAL 168
+#define TK_COUNT 169
+#define TK_LAST_ROW 170
+#define TK_TOPIC 171
+#define TK_WITH 172
+#define TK_META 173
+#define TK_CONSUMER 174
+#define TK_GROUP 175
+#define TK_DESC 176
+#define TK_DESCRIBE 177
+#define TK_RESET 178
+#define TK_QUERY 179
+#define TK_CACHE 180
+#define TK_EXPLAIN 181
+#define TK_ANALYZE 182
+#define TK_VERBOSE 183
+#define TK_NK_BOOL 184
+#define TK_RATIO 185
+#define TK_NK_FLOAT 186
+#define TK_OUTPUTTYPE 187
+#define TK_AGGREGATE 188
+#define TK_BUFSIZE 189
+#define TK_STREAM 190
+#define TK_INTO 191
+#define TK_TRIGGER 192
+#define TK_AT_ONCE 193
+#define TK_WINDOW_CLOSE 194
+#define TK_IGNORE 195
+#define TK_EXPIRED 196
+#define TK_FILL_HISTORY 197
+#define TK_UPDATE 198
+#define TK_SUBTABLE 199
+#define TK_KILL 200
+#define TK_CONNECTION 201
+#define TK_TRANSACTION 202
+#define TK_BALANCE 203
+#define TK_VGROUP 204
+#define TK_MERGE 205
+#define TK_REDISTRIBUTE 206
+#define TK_SPLIT 207
+#define TK_DELETE 208
+#define TK_INSERT 209
+#define TK_NULL 210
+#define TK_NK_QUESTION 211
+#define TK_NK_ARROW 212
+#define TK_ROWTS 213
+#define TK_QSTART 214
+#define TK_QEND 215
+#define TK_QDURATION 216
+#define TK_WSTART 217
+#define TK_WEND 218
+#define TK_WDURATION 219
+#define TK_IROWTS 220
+#define TK_ISFILLED 221
+#define TK_CAST 222
+#define TK_NOW 223
+#define TK_TODAY 224
+#define TK_TIMEZONE 225
+#define TK_CLIENT_VERSION 226
+#define TK_SERVER_VERSION 227
+#define TK_SERVER_STATUS 228
+#define TK_CURRENT_USER 229
+#define TK_CASE 230
+#define TK_END 231
+#define TK_WHEN 232
+#define TK_THEN 233
+#define TK_ELSE 234
+#define TK_BETWEEN 235
+#define TK_IS 236
+#define TK_NK_LT 237
+#define TK_NK_GT 238
+#define TK_NK_LE 239
+#define TK_NK_GE 240
+#define TK_NK_NE 241
+#define TK_MATCH 242
+#define TK_NMATCH 243
+#define TK_CONTAINS 244
+#define TK_IN 245
+#define TK_JOIN 246
+#define TK_INNER 247
+#define TK_SELECT 248
+#define TK_DISTINCT 249
+#define TK_WHERE 250
+#define TK_PARTITION 251
+#define TK_BY 252
+#define TK_SESSION 253
+#define TK_STATE_WINDOW 254
+#define TK_EVENT_WINDOW 255
+#define TK_START 256
+#define TK_SLIDING 257
+#define TK_FILL 258
+#define TK_VALUE 259
+#define TK_VALUE_F 260
+#define TK_NONE 261
+#define TK_PREV 262
+#define TK_NULL_F 263
+#define TK_LINEAR 264
+#define TK_NEXT 265
+#define TK_HAVING 266
+#define TK_RANGE 267
+#define TK_EVERY 268
+#define TK_ORDER 269
+#define TK_SLIMIT 270
+#define TK_SOFFSET 271
+#define TK_LIMIT 272
+#define TK_OFFSET 273
+#define TK_ASC 274
+#define TK_NULLS 275
+#define TK_ABORT 276
+#define TK_AFTER 277
+#define TK_ATTACH 278
+#define TK_BEFORE 279
+#define TK_BEGIN 280
+#define TK_BITAND 281
+#define TK_BITNOT 282
+#define TK_BITOR 283
+#define TK_BLOCKS 284
+#define TK_CHANGE 285
+#define TK_COMMA 286
+#define TK_CONCAT 287
+#define TK_CONFLICT 288
+#define TK_COPY 289
+#define TK_DEFERRED 290
+#define TK_DELIMITERS 291
+#define TK_DETACH 292
+#define TK_DIVIDE 293
+#define TK_DOT 294
+#define TK_EACH 295
+#define TK_FAIL 296
+#define TK_FILE 297
+#define TK_FOR 298
+#define TK_GLOB 299
+#define TK_ID 300
+#define TK_IMMEDIATE 301
+#define TK_IMPORT 302
+#define TK_INITIALLY 303
+#define TK_INSTEAD 304
+#define TK_ISNULL 305
+#define TK_KEY 306
+#define TK_MODULES 307
+#define TK_NK_BITNOT 308
+#define TK_NK_SEMI 309
+#define TK_NOTNULL 310
+#define TK_OF 311
+#define TK_PLUS 312
+#define TK_PRIVILEGE 313
+#define TK_RAISE 314
+#define TK_REPLACE 315
+#define TK_RESTRICT 316
+#define TK_ROW 317
+#define TK_SEMI 318
+#define TK_STAR 319
+#define TK_STATEMENT 320
+#define TK_STRICT 321
+#define TK_STRING 322
+#define TK_TIMES 323
+#define TK_VALUES 324
+#define TK_VARIABLE 325
+#define TK_VIEW 326
+#define TK_WAL 327
#define TK_NK_SPACE 600
#define TK_NK_COMMENT 601
diff --git a/include/libs/cache/cache.h b/include/libs/cache/cache.h
deleted file mode 100644
index 6a2587ee9674668861d050ee734987125674e643..0000000000000000000000000000000000000000
--- a/include/libs/cache/cache.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef _TD_CACHE_H_
-#define _TD_CACHE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_TD_CACHE_H_*/
\ No newline at end of file
diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h
index e98e341f15fdce600e5efa54a824b2ae29b8568e..7b65c06b85f990b87c0c819f1d7627d8f28e8cc0 100644
--- a/include/libs/function/functionMgt.h
+++ b/include/libs/function/functionMgt.h
@@ -219,6 +219,7 @@ bool fmIsKeepOrderFunc(int32_t funcId);
bool fmIsCumulativeFunc(int32_t funcId);
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
bool fmIsGroupKeyFunc(int32_t funcId);
+bool fmIsBlockDistFunc(int32_t funcId);
void getLastCacheDataType(SDataType* pType);
diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h
index d77f2b62332ee071747676145b5dcba0b4e48371..164fbf018cd39e0c7869ca95b9ba877e9488e1e4 100644
--- a/include/libs/nodes/cmdnodes.h
+++ b/include/libs/nodes/cmdnodes.h
@@ -124,6 +124,11 @@ typedef struct STrimDatabaseStmt {
int32_t maxSpeed;
} STrimDatabaseStmt;
+typedef struct SCompactDatabaseStmt {
+ ENodeType type;
+ char dbName[TSDB_DB_NAME_LEN];
+} SCompactDatabaseStmt;
+
typedef struct STableOptions {
ENodeType type;
bool commentNull;
@@ -395,6 +400,7 @@ typedef struct SStreamOptions {
SNode* pDeleteMark;
int8_t fillHistory;
int8_t ignoreExpired;
+ int8_t ignoreUpdate;
} SStreamOptions;
typedef struct SCreateStreamStmt {
diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h
index 24b436ec994f903cd09c4c6bd918c813b192254d..a2e4c76adccc91d5a1f8689643f3d7a93089eba0 100644
--- a/include/libs/nodes/nodes.h
+++ b/include/libs/nodes/nodes.h
@@ -155,7 +155,7 @@ typedef enum ENodeType {
QUERY_NODE_EXPLAIN_STMT,
QUERY_NODE_DESCRIBE_STMT,
QUERY_NODE_RESET_QUERY_CACHE_STMT,
- QUERY_NODE_COMPACT_STMT,
+ QUERY_NODE_COMPACT_DATABASE_STMT,
QUERY_NODE_CREATE_FUNCTION_STMT,
QUERY_NODE_DROP_FUNCTION_STMT,
QUERY_NODE_CREATE_STREAM_STMT,
diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h
index 3602225789f5d2b5586e592646763e8f651f9dcf..ad4b59714cbcd83f80a4ad260004310e0740b94f 100644
--- a/include/libs/nodes/plannodes.h
+++ b/include/libs/nodes/plannodes.h
@@ -93,6 +93,7 @@ typedef struct SScanLogicNode {
int64_t watermark;
int64_t deleteMark;
int8_t igExpired;
+ int8_t igCheckUpdate;
SArray* pSmaIndexes;
SNodeList* pGroupTags;
bool groupSort;
@@ -224,6 +225,7 @@ typedef struct SWindowLogicNode {
int64_t watermark;
int64_t deleteMark;
int8_t igExpired;
+ int8_t igCheckUpdate;
EWindowAlgorithm windowAlgo;
EOrder inputTsOrder;
EOrder outputTsOrder;
@@ -364,6 +366,7 @@ typedef struct STableScanPhysiNode {
int64_t watermark;
int8_t igExpired;
bool assignBlockUid;
+ int8_t igCheckUpdate;
} STableScanPhysiNode;
typedef STableScanPhysiNode STableSeqScanPhysiNode;
@@ -562,6 +565,7 @@ typedef struct SQueryInserterNode {
char tableName[TSDB_TABLE_NAME_LEN];
int32_t vgId;
SEpSet epSet;
+ bool explain;
} SQueryInserterNode;
typedef struct SDataDeleterNode {
diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h
index 2d143912474cb9ef769d2db915f24f110d37b1a2..1a9700907effa002ce4b2acf69196eb08fd7e6d9 100644
--- a/include/libs/nodes/querynodes.h
+++ b/include/libs/nodes/querynodes.h
@@ -233,8 +233,10 @@ typedef struct SEventWindowNode {
typedef enum EFillMode {
FILL_MODE_NONE = 1,
FILL_MODE_VALUE,
+ FILL_MODE_VALUE_F,
FILL_MODE_PREV,
FILL_MODE_NULL,
+ FILL_MODE_NULL_F,
FILL_MODE_LINEAR,
FILL_MODE_NEXT
} EFillMode;
diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h
index 8f227459735f8c43f74b760b16b4b133c883c95b..558203052f1e7241f1b315bb87e8710b5526db63 100644
--- a/include/libs/parser/parser.h
+++ b/include/libs/parser/parser.h
@@ -86,10 +86,11 @@ void qCleanupKeywordsTable();
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash);
int32_t qResetStmtDataBlock(STableDataCxt* block, bool keepBuf);
int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool reset);
-int32_t qRebuildStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, uint64_t uid, uint64_t suid, int32_t vgId, bool rebuildCreateTb);
+int32_t qRebuildStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, uint64_t uid, uint64_t suid, int32_t vgId,
+ bool rebuildCreateTb);
void qDestroyStmtDataBlock(STableDataCxt* pBlock);
STableMeta* qGetTableMetaInDataBlock(STableDataCxt* pDataBlock);
-int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData **pData);
+int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData);
int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx);
int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery);
@@ -104,18 +105,18 @@ void destroyBoundColumnInfo(void* pBoundInfo);
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
int32_t msgBufLen);
-void qDestroyBoundColInfo(void* pInfo);
+void qDestroyBoundColInfo(void* pInfo);
-SQuery* smlInitHandle();
-int32_t smlBuildRow(STableDataCxt* pTableCxt);
-int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void *kv, int32_t index);
+SQuery* smlInitHandle();
+int32_t smlBuildRow(STableDataCxt* pTableCxt);
+int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* kv, int32_t index);
STableDataCxt* smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta);
-int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols, STableMeta* pTableMeta,
- char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl, char* msgBuf, int16_t msgBufLen);
+int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols,
+ STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
+ char* msgBuf, int16_t msgBufLen);
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
-
-int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD *fields, int numFields);
+int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD *fields, int numFields, bool needChangeLength);
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h
index f7bd68393e67b6c5a92587bc3fad56a20891b4fd..41c0e98084a95f34d3ef6fffb094d47c6a9976dc 100644
--- a/include/libs/planner/planner.h
+++ b/include/libs/planner/planner.h
@@ -36,6 +36,7 @@ typedef struct SPlanContext {
int64_t watermark;
int64_t deleteMark;
int8_t igExpired;
+ int8_t igCheckUpdate;
char* pMsg;
int32_t msgLen;
const char* pUser;
diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h
index 3af75e0eaf443e7887dacd6a3056be4241ec5c9b..cbf1d60e35ac1c4187ddb0a5d8cc366714cbaec3 100644
--- a/include/libs/tfs/tfs.h
+++ b/include/libs/tfs/tfs.h
@@ -150,7 +150,7 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname);
* @param nrname The rel name of new file.
* @return int32_t 0 for success, -1 for failure.
*/
-int32_t tfsRename(STfs *pTfs, char *orname, char *nrname);
+int32_t tfsRename(STfs *pTfs, const char *orname, const char *nrname);
/**
* @brief Init file object in tfs.
diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h
index a1ae1e429dd5dbb18f6521b263576e7096482327..1eed342f8ca496006fc5fa00150cad4cc5dea9a6 100644
--- a/include/libs/wal/wal.h
+++ b/include/libs/wal/wal.h
@@ -191,6 +191,7 @@ int32_t walApplyVer(SWal *, int64_t ver);
// read
SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond);
void walCloseReader(SWalReader *pRead);
+void walReadReset(SWalReader *pReader);
int32_t walReadVer(SWalReader *pRead, int64_t ver);
int32_t walReadSeekVer(SWalReader *pRead, int64_t ver);
int32_t walNextValidMsg(SWalReader *pRead);
@@ -201,6 +202,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead);
int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead);
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead);
+SWalRef *walRefFirstVer(SWal *, SWalRef *);
SWalRef *walRefCommittedVer(SWal *);
SWalRef *walOpenRef(SWal *);
diff --git a/include/os/os.h b/include/os/os.h
index 809b814491e99724561af2356fe1128cfc86dc16..309a977ff6b7e6d500d93cba0ee487cc7befbd9e 100644
--- a/include/os/os.h
+++ b/include/os/os.h
@@ -27,7 +27,11 @@ extern "C" {
#if !defined(WINDOWS)
#include
+
+#if !defined(_ALPINE)
#include
+#endif
+
#include
#include
#include
diff --git a/include/os/osFile.h b/include/os/osFile.h
index ae77e0f27a26adf679f72be92c235e61b6ed0655..0e930027066dbd3f5a0e90810a8a3f5c134637b6 100644
--- a/include/os/osFile.h
+++ b/include/os/osFile.h
@@ -110,6 +110,8 @@ bool taosValidFile(TdFilePtr pFile);
int32_t taosGetErrorFile(TdFilePtr pFile);
+int32_t taosCompressFile(char *srcFileName, char *destFileName);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h
index dbe4d6801e42fa04a9b9da0f2d3f864d0b75f94d..a8ccb67bfb1bb345150a2d7ee90d776e7b251aa3 100644
--- a/include/os/osSysinfo.h
+++ b/include/os/osSysinfo.h
@@ -60,6 +60,13 @@ void taosSetCoreDump(bool enable);
#endif // WINDOWS
+#if defined(_ALPINE)
+
+#define _UTSNAME_LENGTH 65
+#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
+
+#endif
+
typedef struct {
char sysname[_UTSNAME_MACHINE_LENGTH];
char nodename[_UTSNAME_MACHINE_LENGTH];
diff --git a/include/os/osSystem.h b/include/os/osSystem.h
index 5154c56e4b5b48fb1a85e2dd620b3b3338902478..ba9f137b40edb2b4eacd2369004e1bd74bdd7361 100644
--- a/include/os/osSystem.h
+++ b/include/os/osSystem.h
@@ -16,6 +16,11 @@
#ifndef _TD_OS_SYSTEM_H_
#define _TD_OS_SYSTEM_H_
+#ifdef _ALPINE
+#define UNW_LOCAL_ONLY
+#include
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -29,46 +34,124 @@ extern "C" {
#define tcgetattr TCGETATTR_FUNC_TAOS_FORBID
#endif
-typedef struct TdCmd* TdCmdPtr;
+typedef struct TdCmd *TdCmdPtr;
+
+TdCmdPtr taosOpenCmd(const char *cmd);
+
+int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf);
+
+int64_t taosGetLineCmd(TdCmdPtr pCmd, char **__restrict ptrBuf);
+
+int32_t taosEOFCmd(TdCmdPtr pCmd);
-TdCmdPtr taosOpenCmd(const char* cmd);
-int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf);
-int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf);
-int32_t taosEOFCmd(TdCmdPtr pCmd);
-int64_t taosCloseCmd(TdCmdPtr* ppCmd);
+int64_t taosCloseCmd(TdCmdPtr *ppCmd);
-void* taosLoadDll(const char* filename);
-void* taosLoadSym(void* handle, char* name);
-void taosCloseDll(void* handle);
+void *taosLoadDll(const char *filename);
+
+void *taosLoadSym(void *handle, char *name);
+
+void taosCloseDll(void *handle);
int32_t taosSetConsoleEcho(bool on);
-void taosSetTerminalMode();
+
+void taosSetTerminalMode();
+
int32_t taosGetOldTerminalMode();
-void taosResetTerminalMode();
+
+void taosResetTerminalMode();
#define STACKSIZE 100
-#if !defined(WINDOWS)
-#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \
- void* array[STACKSIZE]; \
- int32_t size = backtrace(array, STACKSIZE); \
- char** strings = backtrace_symbols(array, size); \
- int32_t offset = 0; \
- if (strings != NULL) { \
- offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
- for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
- offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, strings[i]); \
- } \
- } \
- \
- taosMemoryFree(strings); \
-}
+#if defined(_ALPINE)
+#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \
+ { \
+ unw_cursor_t cursor; \
+ unw_context_t context; \
+ \
+ unw_getcontext(&context); \
+ unw_init_local(&cursor, &context); \
+ \
+ char *array[STACKSIZE]; \
+ int32_t size = 0; \
+ int32_t ignores = ignoreNum; \
+ int32_t offset = 0; \
+ while (unw_step(&cursor) > 0 && size < STACKSIZE) { \
+ unw_word_t offset, pc; \
+ char fname[64]; \
+ unw_get_reg(&cursor, UNW_REG_IP, &pc); \
+ fname[0] = '\0'; \
+ (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); \
+ size += 1; \
+ array[size] = (char *)taosMemoryMalloc(sizeof(char) * STACKSIZE + 1); \
+ snprintf(array[size], STACKSIZE, "0x%lx : (%s+0x%lx) [0x%lx]\n", (long)pc, fname, (long)offset, (long)pc); \
+ } \
+ if (ignoreNum < size && size > 0) { \
+ offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
+ for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
+ offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
+ array[i]); \
+ } \
+ } \
+ for (int i = 0; i < size; i++) { \
+ taosMemoryFree(array[i]); \
+ } \
+ }
+
+#define taosPrintTrace(flags, level, dflag, ignoreNum) \
+ { \
+ unw_cursor_t cursor; \
+ unw_context_t context; \
+ \
+ unw_getcontext(&context); \
+ unw_init_local(&cursor, &context); \
+ \
+ char *array[STACKSIZE]; \
+ int32_t size = 0; \
+ while (unw_step(&cursor) > 0 && size < STACKSIZE) { \
+ unw_word_t offset, pc; \
+ char fname[64]; \
+ unw_get_reg(&cursor, UNW_REG_IP, &pc); \
+ fname[0] = '\0'; \
+ (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); \
+ size += 1; \
+ array[size] = (char *)taosMemoryMalloc(sizeof(char) * STACKSIZE + 1); \
+ snprintf(array[size], STACKSIZE, "frame:%d, 0x%lx : (%s+0x%lx) [0x%lx]\n", size, (long)pc, fname, (long)offset, \
+ (long)pc); \
+ } \
+ if (ignoreNum < size && size > 0) { \
+ taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \
+ for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
+ taosPrintLog(flags, level, dflag, "frame:%d, %s", (ignoreNum > 0) ? i - ignoreNum : i, array[i]); \
+ } \
+ } \
+ for (int i = 0; i < size; i++) { \
+ taosMemoryFree(array[i]); \
+ } \
+ }
+
+#elif !defined(WINDOWS)
+#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \
+ { \
+ void *array[STACKSIZE]; \
+ int32_t size = backtrace(array, STACKSIZE); \
+ char **strings = backtrace_symbols(array, size); \
+ int32_t offset = 0; \
+ if (strings != NULL) { \
+ offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \
+ for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
+ offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \
+ strings[i]); \
+ } \
+ } \
+ \
+ taosMemoryFree(strings); \
+ }
#define taosPrintTrace(flags, level, dflag, ignoreNum) \
{ \
- void* array[STACKSIZE]; \
- int32_t size = backtrace(array, STACKSIZE); \
- char** strings = backtrace_symbols(array, size); \
+ void *array[STACKSIZE]; \
+ int32_t size = backtrace(array, STACKSIZE); \
+ char **strings = backtrace_symbols(array, size); \
if (strings != NULL) { \
taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
@@ -80,65 +163,70 @@ void taosResetTerminalMode();
}
#else
-#include
#include
+#include
-#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \
- unsigned int i; \
- void* stack[STACKSIZE]; \
- unsigned short frames; \
- SYMBOL_INFO* symbol; \
- HANDLE process; \
- int32_t offset = 0; \
- \
- process = GetCurrentProcess(); \
- \
- SymInitialize(process, NULL, TRUE); \
- \
- frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
- symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
- if (symbol != NULL) { \
- symbol->MaxNameLen = 255; \
- symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
- \
- if (frames > 0) { \
- offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
- for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
- SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
- offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \
- } \
- } \
- free(symbol); \
- } \
+#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \
+ { \
+ unsigned int i; \
+ void *stack[STACKSIZE]; \
+ unsigned short frames; \
+ SYMBOL_INFO *symbol; \
+ HANDLE process; \
+ int32_t offset = 0; \
+ \
+ process = GetCurrentProcess(); \
+ \
+ SymInitialize(process, NULL, TRUE); \
+ \
+ frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
+ symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
+ if (symbol != NULL) { \
+ symbol->MaxNameLen = 255; \
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
+ \
+ if (frames > 0) { \
+ offset = \
+ snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
+ for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
+ SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
+ offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", \
+ (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \
+ } \
+ } \
+ free(symbol); \
+ } \
}
-#define taosPrintTrace(flags, level, dflag, ignoreNum) \
+#define taosPrintTrace(flags, level, dflag, ignoreNum) \
{ \
- unsigned int i; \
- void* stack[STACKSIZE]; \
- unsigned short frames; \
- SYMBOL_INFO* symbol; \
- HANDLE process; \
- \
- process = GetCurrentProcess(); \
- \
- SymInitialize(process, NULL, TRUE); \
- \
- frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
- symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
- if (symbol != NULL) { \
- symbol->MaxNameLen = 255; \
- symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
- \
- if (frames > 0) { \
- taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
- for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
- SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
- taosPrintLog(flags, level, dflag, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \
- } \
- } \
- free(symbol); \
- } \
+ unsigned int i; \
+ void *stack[STACKSIZE]; \
+ unsigned short frames; \
+ SYMBOL_INFO *symbol; \
+ HANDLE process; \
+ \
+ process = GetCurrentProcess(); \
+ \
+ SymInitialize(process, NULL, TRUE); \
+ \
+ frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
+ symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
+ if (symbol != NULL) { \
+ symbol->MaxNameLen = 255; \
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
+ \
+ if (frames > 0) { \
+ taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", \
+ (ignoreNum > 0) ? frames - ignoreNum : frames); \
+ for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
+ SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \
+ taosPrintLog(flags, level, dflag, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, \
+ symbol->Name, symbol->Address); \
+ } \
+ } \
+ free(symbol); \
+ } \
}
#endif
diff --git a/include/os/osThread.h b/include/os/osThread.h
index 916d463733373c2512ab77a7e6931cede98966af..aa0dc066c60bb7e218f249bb06505c43c7d2845c 100644
--- a/include/os/osThread.h
+++ b/include/os/osThread.h
@@ -22,7 +22,7 @@
extern "C" {
#endif
-#ifndef WINDOWS
+#if !defined(WINDOWS) && !defined(_ALPINE)
#ifndef __USE_XOPEN2K
#define TD_USE_SPINLOCK_AS_MUTEX
typedef pthread_mutex_t pthread_spinlock_t;
@@ -100,7 +100,11 @@ typedef pthread_key_t TdThreadKey;
#define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID
#define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID
+
+#if !defined(_ALPINE)
#define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID
+#endif
+
#define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID
#define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID
diff --git a/include/util/taoserror.h b/include/util/taoserror.h
index 7bcf3201dad4898b8af5802d53020e7fdfd4fe1f..e27e8e2d38f36c682abc9ba74acc9eb7aa0535eb 100644
--- a/include/util/taoserror.h
+++ b/include/util/taoserror.h
@@ -111,6 +111,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x012A)
#define TSDB_CODE_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x012B)
#define TSDB_CODE_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x012C)
+#define TSDB_CODE_MSG_ENCODE_ERROR TAOS_DEF_ERROR_CODE(0, 0x012D)
#define TSDB_CODE_APP_IS_STARTING TAOS_DEF_ERROR_CODE(0, 0x0130) //
#define TSDB_CODE_APP_IS_STOPPING TAOS_DEF_ERROR_CODE(0, 0x0131) //
@@ -357,6 +358,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3)
#define TSDB_CODE_MND_STREAM_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x03F4)
#define TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB TAOS_DEF_ERROR_CODE(0, 0x03F5)
+#define TSDB_CODE_MND_TOO_MANY_STREAMS TAOS_DEF_ERROR_CODE(0, 0x03F6)
// mnode-sma
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
diff --git a/include/util/trbtree.h b/include/util/trbtree.h
index 7c93c8dd8d65f2c4947019f370c0933e6ad81ee0..e2264194401bee65a22f0301f0339cb76a8d7356 100644
--- a/include/util/trbtree.h
+++ b/include/util/trbtree.h
@@ -33,9 +33,12 @@ typedef int32_t (*tRBTreeCmprFn)(const SRBTreeNode *, const SRBTreeNode *);
#define tRBTreeMax(T) ((T)->max == ((T)->NIL) ? NULL : (T)->max)
void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn);
+void tRBTreeClear(SRBTree *pTree);
SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z);
void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z);
SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey);
+SRBTreeNode *tRBTreeDropMin(SRBTree *pTree);
+SRBTreeNode *tRBTreeDropMax(SRBTree *pTree);
SRBTreeNode *tRBTreeGet(SRBTree *pTree, const SRBTreeNode *pKeyNode);
// SRBTreeIter =============================================
diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh
index 7f95ca3d72000acd97259d934097153be91943cf..5aeff0e2fac3cde9e381a33719f5ab25722e16f5 100755
--- a/packaging/tools/install.sh
+++ b/packaging/tools/install.sh
@@ -35,6 +35,20 @@ dumpName="taosdump"
demoName="taosdemo"
xname="taosx"
+clientName2="taos"
+serverName2="taosd"
+productName2="TDengine"
+emailName2="taosdata.com"
+
+benchmarkName2="${clientName2}Benchmark"
+dumpName2="${clientName2}dump"
+uninstallScript2="rm${clientName2}"
+
+historyFile="${clientName2}_history"
+logDir="/var/log/${clientName2}"
+configDir="/etc/${clientName2}"
+installDir="/usr/local/${clientName}"
+
data_dir=${dataDir}
log_dir=${logDir}
cfg_install_dir=${configDir}
@@ -210,13 +224,20 @@ function install_bin() {
[ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || :
[ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -s ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || :
[ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || :
- [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || :
- [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
+ [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || :
+ [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
[ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
[ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -s ${install_main_dir}/bin/${xname} ${bin_link_dir}/${xname} || :
[ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
+
+ if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || :
+ [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName2} || :
+ [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName2} || :
+ [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || :
+ fi
}
function install_lib() {
@@ -518,7 +539,7 @@ function install_config() {
local_fqdn_check
echo
- echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName}:6030) of an existing ${productName} cluster node to join${NC}"
+ echo -e -n "${GREEN}Enter FQDN:port (like h1.${emailName2}:6030) of an existing ${productName2} cluster node to join${NC}"
echo
echo -e -n "${GREEN}OR leave it blank to build one${NC}:"
read firstEp
@@ -655,6 +676,9 @@ function clean_service_on_systemd() {
fi
${csudo}systemctl disable tarbitratord &>/dev/null || echo &>/dev/null
${csudo}rm -f ${tarbitratord_service_config}
+ # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ # ${csudo}rm -f ${service_config_dir}/${serverName2}.service
+ # fi
}
function install_service_on_systemd() {
@@ -663,6 +687,13 @@ function install_service_on_systemd() {
[ -f ${script_dir}/cfg/${serverName}.service ] &&
${csudo}cp ${script_dir}/cfg/${serverName}.service \
${service_config_dir}/ || :
+
+ # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ # [ -f ${script_dir}/cfg/${serverName}.service ] &&
+ # ${csudo}cp ${script_dir}/cfg/${serverName}.service \
+ # ${service_config_dir}/${serverName2}.service || :
+ # fi
+
${csudo}systemctl daemon-reload
${csudo}systemctl enable ${serverName}
@@ -787,13 +818,13 @@ function updateProduct() {
if echo $osinfo | grep -qwi "centos"; then
rpm -q tdengine 2>&1 > /dev/null && rpm_erase tdengine ||:
elif echo $osinfo | grep -qwi "ubuntu"; then
- dpkg -l tdengine 2>&1 > /dev/null && deb_erase tdengine ||:
+ dpkg -l tdengine 2>&1 | grep ii > /dev/null && deb_erase tdengine ||:
fi
tar -zxf ${tarName}
install_jemalloc
- echo -e "${GREEN}Start to update ${productName}...${NC}"
+ echo -e "${GREEN}Start to update ${productName2}...${NC}"
# Stop the service if running
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
if ((${service_mod} == 0)); then
@@ -830,25 +861,25 @@ function updateProduct() {
echo
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}"
[ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \
- echo -e "${GREEN_DARK}To configure Taos Adapter ${NC}: edit ${configDir}/taosadapter.toml"
+ echo -e "${GREEN_DARK}To configure Adapter ${NC}: edit ${configDir}/taosadapter.toml"
if ((${service_mod} == 0)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
[ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \
- echo -e "${GREEN_DARK}To start Taos Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}"
+ echo -e "${GREEN_DARK}To start Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}"
elif ((${service_mod} == 1)); then
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
[ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \
- echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}"
+ echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}service taosadapter start${NC}"
else
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}"
[ -f ${installDir}/bin/taosadapter ] && \
- echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
+ echo -e "${GREEN_DARK}To start ${clientName} Adapter ${NC}: taosadapter &${NC}"
fi
if [ ${openresty_work} = 'true' ]; then
- echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}"
+ echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell OR from ${GREEN_UNDERLINE}http://127.0.0.1:${web_port}${NC}"
else
- echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName} -h $serverFqdn${NC} in shell${NC}"
+ echo -e "${GREEN_DARK}To access ${productName2} ${NC}: use ${GREEN_UNDERLINE}${clientName2} -h $serverFqdn${NC} in shell${NC}"
fi
if ((${prompt_force} == 1)); then
@@ -856,13 +887,13 @@ function updateProduct() {
echo -e "${RED}Please run '${serverName} --force-keep-file' at first time for the exist ${productName} $exist_version!${NC}"
fi
echo
- echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
+ echo -e "\033[44;32;1m${productName2} is updated successfully!${NC}"
else
install_bin
install_config
echo
- echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}"
+ echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}"
fi
rm -rf $(tar -tf ${tarName} | grep -v "^\./$")
@@ -876,7 +907,7 @@ function installProduct() {
fi
tar -zxf ${tarName}
- echo -e "${GREEN}Start to install ${productName}...${NC}"
+ echo -e "${GREEN}Start to install ${productName2}...${NC}"
install_main_path
@@ -965,7 +996,7 @@ serverFqdn=$(hostname)
if [ "$verType" == "server" ]; then
# Check default 2.x data file.
if [ -x ${data_dir}/dnode/dnodeCfg.json ]; then
- echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of tdengine 2.x, please clear it before installing!\033[0m"
+ echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m"
else
# Install server and client
if [ -x ${bin_dir}/${serverName} ]; then
diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh
index f7d677c9821ed685750dcd50e2823f9abda4ef42..1543c59297d663f0579d53f5c9778385cbef3ba8 100755
--- a/packaging/tools/install_client.sh
+++ b/packaging/tools/install_client.sh
@@ -23,6 +23,16 @@ osType=Linux
pagMode=full
verMode=edge
+clientName2="taos"
+serverName2="taosd"
+productName2="TDengine"
+emailName2="taosdata.com"
+
+benchmarkName2="${clientName2}Benchmark"
+dumpName2="${clientName2}dump"
+demoName2="${clientName2}demo"
+uninstallScript2="rm${clientName2}"
+
if [ "$osType" != "Darwin" ]; then
script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory
@@ -112,6 +122,15 @@ function install_bin() {
fi
[ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript} || :
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
+
+ if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ #Make link
+ [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || :
+ if [ "$osType" != "Darwin" ]; then
+ [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/${demoName2} || :
+ fi
+ [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript2} || :
+ fi
}
function clean_lib() {
@@ -263,9 +282,9 @@ function update_TDengine() {
exit 1
fi
tar -zxf ${tarName}
- echo -e "${GREEN}Start to update ${productName} client...${NC}"
+ echo -e "${GREEN}Start to update ${productName2} client...${NC}"
# Stop the client shell if running
- if ps aux | grep -v grep | grep ${clientName} &> /dev/null; then
+ if ps aux | grep -v grep | grep ${clientName2} &> /dev/null; then
kill_client
sleep 1
fi
@@ -284,7 +303,7 @@ function update_TDengine() {
install_config
echo
- echo -e "\033[44;32;1m${productName} client is updated successfully!${NC}"
+ echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}"
rm -rf $(tar -tf ${tarName})
}
@@ -296,7 +315,7 @@ function install_TDengine() {
exit 1
fi
tar -zxf ${tarName}
- echo -e "${GREEN}Start to install ${productName} client...${NC}"
+ echo -e "${GREEN}Start to install ${productName2} client...${NC}"
install_main_path
install_log
@@ -311,7 +330,7 @@ function install_TDengine() {
install_config
echo
- echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}"
+ echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}"
rm -rf $(tar -tf ${tarName})
}
@@ -321,7 +340,7 @@ function install_TDengine() {
# Install or updata client and client
# if server is already install, don't install client
if [ -e ${bin_dir}/${serverName} ]; then
- echo -e "\033[44;32;1mThere are already installed ${productName} server, so don't need install client!${NC}"
+ echo -e "\033[44;32;1mThere are already installed ${productName2} server, so don't need install client!${NC}"
exit 0
fi
diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat
index bf7418ad7935cb33f4a9d765e6c319d86383db69..f5ed1cdf666c2442f10b9d45320f4a93a6cdfa6f 100644
--- a/packaging/tools/make_install.bat
+++ b/packaging/tools/make_install.bat
@@ -2,12 +2,20 @@
for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
-goto %1
+if "%1" NEQ "" goto %1
+
:needAdmin
if exist C:\\TDengine\\data\\dnode\\dnodeCfg.json (
echo The default data directory C:/TDengine/data contains old data of tdengine 2.x, please clear it before installing!
)
+
+rem // stop and delete service
+mshta vbscript:createobject("shell.application").shellexecute("%~s0",":stop_delete","","runas",1)(window.close)
+echo This might take a few moment to accomplish deleting service taosd/taosadapter ...
+call :check_svc taosd
+call :check_svc taosadapter
+
set source_dir=%2
set source_dir=%source_dir:/=\\%
set binary_dir=%3
@@ -87,7 +95,6 @@ if %Enterprise% == TRUE (
copy %binary_dir%\\build\\bin\\taosd.exe %target_dir% > nul
copy %binary_dir%\\build\\bin\\udfd.exe %target_dir% > nul
-
if exist %binary_dir%\\build\\bin\\taosadapter.exe (
copy %binary_dir%\\build\\bin\\taosadapter.exe %target_dir% > nul
)
@@ -107,22 +114,23 @@ goto :eof
:hasAdmin
-sc query "taosd" && sc stop taosd && sc delete taosd
-sc query "taosadapter" && sc stop taosadapter && sc delete taosd
+call :stop_delete
+call :check_svc taosd
+call :check_svc taosadapter
copy /y C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 > nul
if exist C:\\TDengine\\driver\\taosws.dll (
copy /y C:\\TDengine\\driver\\taosws.dll C:\\Windows\\System32 > nul
)
-sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND
-sc query "taosadapter" >nul || sc create "taosadapter" binPath= "C:\\TDengine\\taosadapter.exe" start= DEMAND
+rem // create services
+sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND
+sc create "taosadapter" binPath= "C:\\TDengine\\taosadapter.exe" start= DEMAND
set "env=HKLM\System\CurrentControlSet\Control\Session Manager\Environment"
for /f "tokens=2*" %%I in ('reg query "%env%" /v Path ^| findstr /i "\"') do (
- rem // make addition persistent through reboots
- reg add "%env%" /f /v Path /t REG_EXPAND_SZ /d "%%J;C:\TDengine"
+ call :append_if_not_exists %%J
rem // apply change to the current process
for %%a in ("%%J;C:\TDengine") do path %%~a
@@ -132,3 +140,36 @@ rem // use setx to set a temporary throwaway value to trigger a WM_SETTINGCHANGE
rem // applies change to new console windows without requiring a reboot
(setx /m foo bar & reg delete "%env%" /f /v foo) >NUL 2>NUL
+goto :end
+
+:append_if_not_exists
+set "_origin_paths=%*"
+set "_paths=%*"
+set "_found=0"
+:loop
+for /f "tokens=1* delims=;" %%x in ("%_paths%") do (
+ if "%%x" EQU "C:\TDengine" (
+ set "_found=1"
+ ) else (
+ set "_paths=%%y"
+ goto :loop
+ )
+)
+if "%_found%" == "0" (
+ rem // make addition persistent through reboots
+ reg add "%env%" /f /v Path /t REG_EXPAND_SZ /d "%_origin_paths%;C:\TDengine"
+)
+exit /B 0
+
+:stop_delete
+sc stop taosd
+sc delete taosd
+sc stop taosadapter
+sc delete taosadapter
+exit /B 0
+
+:check_svc
+sc query %1 >nul 2>nul && goto :check_svc %1
+exit /B 0
+
+:end
diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh
index 9034fd85f5cee9841ebdbe8907e7256c87b6601f..cb99f67e705d1ce6e802e50b99fdbc411006020e 100755
--- a/packaging/tools/make_install.sh
+++ b/packaging/tools/make_install.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# This file is used to install TAOS time-series database on linux systems. The operating system
# is required to use systemd to manage services at boot
@@ -340,7 +340,7 @@ function install_lib() {
#install_avro lib64
if [ "$osType" != "Darwin" ]; then
- ${csudo}ldconfig
+ ${csudo}ldconfig /etc/ld.so.conf.d
fi
}
diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh
index db28de8decada6593abf5600bd8cf86cfe7d0984..208bfc183c91bba96be689fe6a475a5ae6e38649 100755
--- a/packaging/tools/makeclient.sh
+++ b/packaging/tools/makeclient.sh
@@ -13,7 +13,13 @@ osType=$5
verMode=$6
verType=$7
pagMode=$8
-dbName=$9
+#comVersion=$9
+dbName=$10
+
+productName2="${11}"
+#serverName2="${12}d"
+clientName2="${12}"
+# cusEmail2=${13}
productName="TDengine"
clientName="taos"
@@ -38,15 +44,21 @@ release_dir="${top_dir}/release"
#package_name='linux'
if [ "$verMode" == "cluster" ]; then
- install_dir="${release_dir}/${productName}-enterprise-client-${version}"
+ install_dir="${release_dir}/${productName2}-enterprise-client-${version}"
elif [ "$verMode" == "cloud" ]; then
- install_dir="${release_dir}/${productName}-cloud-client-${version}"
+ install_dir="${release_dir}/${productName2}-cloud-client-${version}"
else
- install_dir="${release_dir}/${productName}-client-${version}"
+ install_dir="${release_dir}/${productName2}-client-${version}"
fi
# Directories and files.
+if [ "$verMode" == "cluster" ]; then
+ sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh
+ sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh
+ sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh
+fi
+
if [ "$osType" != "Darwin" ]; then
if [ "$pagMode" == "lite" ]; then
strip ${build_dir}/bin/${clientName}
@@ -131,22 +143,28 @@ fi
cd ${curr_dir}
cp ${install_files} ${install_dir}
+cp ${install_dir}/install_client.sh install_client_temp.sh
if [ "$osType" == "Darwin" ]; then
- sed 's/osType=Linux/osType=Darwin/g' ${install_dir}/install_client.sh >>install_client_temp.sh
+ sed -i 's/osType=Linux/osType=Darwin/g' install_client_temp.sh
mv install_client_temp.sh ${install_dir}/install_client.sh
fi
if [ "$verMode" == "cluster" ]; then
- sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install_client.sh >>install_client_temp.sh
+ sed -i 's/verMode=edge/verMode=cluster/g' install_client_temp.sh
+ sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_client_temp.sh
+ sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_client_temp.sh
+ sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_client_temp.sh
+ sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_client_temp.sh
+
mv install_client_temp.sh ${install_dir}/install_client.sh
fi
if [ "$verMode" == "cloud" ]; then
- sed 's/verMode=edge/verMode=cloud/g' ${install_dir}/install_client.sh >>install_client_temp.sh
+ sed -i 's/verMode=edge/verMode=cloud/g' install_client_temp.sh
mv install_client_temp.sh ${install_dir}/install_client.sh
fi
if [ "$pagMode" == "lite" ]; then
- sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install_client.sh >>install_client_temp.sh
+ sed -i 's/pagMode=full/pagMode=lite/g' install_client_temp.sh
mv install_client_temp.sh ${install_dir}/install_client.sh
fi
chmod a+x ${install_dir}/install_client.sh
diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh
index 0ee548242f2a69b025dddb46381d8d8c1d30d799..0a34d81b7fa0000ad8924c3968ae897a6f7f43f3 100755
--- a/packaging/tools/makepkg.sh
+++ b/packaging/tools/makepkg.sh
@@ -16,6 +16,10 @@ verType=$7
pagMode=$8
versionComp=$9
dbName=${10}
+productName2="${11}"
+serverName2="${12}d"
+clientName2="${12}"
+cusEmail2="${13}"
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/../..)"
@@ -38,11 +42,11 @@ release_dir="${top_dir}/release"
#package_name='linux'
if [ "$verMode" == "cluster" ]; then
- install_dir="${release_dir}/${productName}-enterprise-server-${version}"
+ install_dir="${release_dir}/${productName2}-enterprise-server-${version}"
elif [ "$verMode" == "cloud" ]; then
- install_dir="${release_dir}/${productName}-cloud-server-${version}"
+ install_dir="${release_dir}/${productName2}-cloud-server-${version}"
else
- install_dir="${release_dir}/${productName}-server-${version}"
+ install_dir="${release_dir}/${productName2}-server-${version}"
fi
if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
@@ -50,11 +54,11 @@ if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then
[ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0"
taostools_ver=$(git tag |grep -v taos | sort | tail -1)
- taostools_install_dir="${release_dir}/${clientName}Tools-${taostools_ver}"
+ taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}"
cd ${curr_dir}
else
- taostools_install_dir="${release_dir}/${clientName}Tools-${version}"
+ taostools_install_dir="${release_dir}/${clientName2}Tools-${version}"
fi
# Directories and files
@@ -225,6 +229,10 @@ fi
if [ "$verMode" == "cluster" ]; then
sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh
+ sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh
+ sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh
+ sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh
+ sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" remove_temp.sh
mv remove_temp.sh ${install_dir}/bin/remove.sh
fi
if [ "$verMode" == "cloud" ]; then
@@ -247,16 +255,21 @@ fi
cd ${curr_dir}
cp ${install_files} ${install_dir}
+cp ${install_dir}/install.sh install_temp.sh
if [ "$verMode" == "cluster" ]; then
- sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install.sh >>install_temp.sh
+ sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh
+ sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh
+ sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh
+ sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh
+ sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_temp.sh
mv install_temp.sh ${install_dir}/install.sh
fi
if [ "$verMode" == "cloud" ]; then
- sed 's/verMode=edge/verMode=cloud/g' ${install_dir}/install.sh >>install_temp.sh
+ sed -i 's/verMode=edge/verMode=cloud/g' install_temp.sh
mv install_temp.sh ${install_dir}/install.sh
fi
if [ "$pagMode" == "lite" ]; then
- sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install.sh >>install_temp.sh
+ sed -i 's/pagMode=full/pagMode=lite/g' install_temp.sh
mv install_temp.sh ${install_dir}/install.sh
fi
chmod a+x ${install_dir}/install.sh
diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh
index 8e5630ec2f7bc89d739486efdec7fc55acb2b046..9c50c4582db01fab94bb82f1556c3a94df741b1d 100755
--- a/packaging/tools/remove.sh
+++ b/packaging/tools/remove.sh
@@ -36,6 +36,16 @@ clientName="taos"
uninstallScript="rmtaos"
productName="TDengine"
+serverName2="taosd"
+clientName2="taos"
+productName2="TDengine"
+
+benchmarkName2="${clientName2}Benchmark"
+dumpName2="${clientName2}dump"
+uninstallScript2="rm${clientName2}"
+
+installDir="/usr/local/${clientName}"
+
#install main path
install_main_dir=${installDir}
data_link_dir=${installDir}/data
@@ -107,6 +117,15 @@ function clean_bin() {
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
${csudo}rm -f ${bin_link_dir}/set_core || :
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
+ ${csudo}rm -f ${bin_link_dir}/taoskeeper || :
+ ${csudo}rm -f ${bin_link_dir}/taosx || :
+
+ if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ ${csudo}rm -f ${bin_link_dir}/${clientName2} || :
+ ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || :
+ ${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
+ ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
+ fi
}
function clean_local_bin() {
@@ -147,7 +166,7 @@ function clean_log() {
function clean_service_on_systemd() {
taosd_service_config="${service_config_dir}/${taos_service_name}.service"
if systemctl is-active --quiet ${taos_service_name}; then
- echo "${productName} ${serverName} is running, stopping it..."
+ echo "${productName2} ${serverName2} is running, stopping it..."
${csudo}systemctl stop ${taos_service_name} &>/dev/null || echo &>/dev/null
fi
${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null
@@ -155,7 +174,7 @@ function clean_service_on_systemd() {
taosadapter_service_config="${service_config_dir}/taosadapter.service"
if systemctl is-active --quiet ${taosadapter_service_name}; then
- echo "${productName} taosAdapter is running, stopping it..."
+ echo "${productName2} ${clientName2}Adapter is running, stopping it..."
${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
fi
${csudo}systemctl disable ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
@@ -163,7 +182,7 @@ function clean_service_on_systemd() {
tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service"
if systemctl is-active --quiet ${tarbitrator_service_name}; then
- echo "${productName} tarbitrator is running, stopping it..."
+ echo "${productName2} tarbitrator is running, stopping it..."
${csudo}systemctl stop ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
fi
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
@@ -172,12 +191,12 @@ function clean_service_on_systemd() {
function clean_service_on_sysvinit() {
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
- echo "${productName} ${serverName} is running, stopping it..."
+ echo "${productName2} ${serverName2} is running, stopping it..."
${csudo}service ${serverName} stop || :
fi
if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then
- echo "${productName} tarbitrator is running, stopping it..."
+ echo "${productName2} tarbitrator is running, stopping it..."
${csudo}service tarbitratord stop || :
fi
@@ -272,5 +291,5 @@ if [ "$osType" = "Darwin" ]; then
${csudo}rm -rf /Applications/TDengine.app
fi
-echo -e "${GREEN}${productName} is removed successfully!${NC}"
+echo -e "${GREEN}${productName2} is removed successfully!${NC}"
echo
diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh
index 7ab7fa85998284e0dcb4cd158eb8599806fd7470..10a0fb5e02a7fbc10b05765d4036e76b0bd1e4c8 100755
--- a/packaging/tools/remove_client.sh
+++ b/packaging/tools/remove_client.sh
@@ -12,6 +12,15 @@ installDir="/usr/local/taos"
clientName="taos"
uninstallScript="rmtaos"
+clientName2="taos"
+productName2="TDengine"
+
+benchmarkName2="${clientName}Benchmark"
+dumpName2="${clientName}dump"
+uninstallScript2="rm${clientName}"
+
+installDir="/usr/local/${clientName}"
+
#install main path
install_main_dir=${installDir}
@@ -40,6 +49,12 @@ function clean_bin() {
${csudo}rm -f ${bin_link_dir}/taosdump || :
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
${csudo}rm -f ${bin_link_dir}/set_core || :
+
+ if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
+ ${csudo}rm -f ${bin_link_dir}/${clientName2} || :
+ ${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
+ ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
+ fi
}
function clean_lib() {
@@ -82,5 +97,5 @@ clean_config
${csudo}rm -rf ${install_main_dir}
-echo -e "${GREEN}TDengine client is removed successfully!${NC}"
+echo -e "${GREEN}${productName2} client is removed successfully!${NC}"
echo
diff --git a/packaging/tools/tdengine.iss b/packaging/tools/tdengine.iss
index 3a22c737743872528887616b83b3ec58329e8795..91c6ad1c66bd1556cc90a9eb4c264859756fdf2f 100644
--- a/packaging/tools/tdengine.iss
+++ b/packaging/tools/tdengine.iss
@@ -18,7 +18,6 @@
#define MyAppDLLName "\driver\*.dll"
;#define MyAppVersion "3.0"
;#define MyAppInstallName "TDengine"
-;#define MyAppInstallName "TDengine"
[Setup]
VersionInfoVersion={#MyAppVersion}
AppId={{A0F7A93C-79C4-485D-B2B8-F0D03DF42FAB}
@@ -59,11 +58,14 @@ Source: {#MyAppSourceDir}{#MyAppDriverName}; DestDir: "{app}\driver"; Flags: igN
Source: {#MyAppSourceDir}{#MyAppIncludeName}; DestDir: "{app}\include"; Flags: igNoreversion recursesubdirs createallsubdirs
Source: {#MyAppSourceDir}{#MyAppExeName}; DestDir: "{app}"; Excludes: {#MyAppExcludeSource} ; Flags: igNoreversion recursesubdirs createallsubdirs
Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNoreversion recursesubdirs createallsubdirs
+Source: {#MyAppSourceDir}\taos.exe; DestDir: "{app}"; DestName: "{#CusPrompt}.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs
+Source: {#MyAppSourceDir}\taosBenchmark.exe; DestDir: "{app}"; DestName: "{#CusPrompt}Benchmark.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs
+Source: {#MyAppSourceDir}\taosdump.exe; DestDir: "{app}"; DestName: "{#CusPrompt}dump.EXE"; Flags: igNoreversion recursesubdirs createallsubdirs
[run]
-Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\TDengine\\taosd.exe --win_service""" ; Flags: runhidden
-Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe""" ; Flags: runhidden
+Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\{#CusName}\\taosd.exe --win_service""" ; Flags: runhidden
+Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\{#CusName}\\taosadapter.exe""" ; Flags: runhidden
[UninstallRun]
RunOnceId: "stoptaosd"; Filename: {sys}\sc.exe; Parameters: "stop taosd" ; Flags: runhidden
@@ -73,8 +75,8 @@ RunOnceId: "deltaosadapter"; Filename: {sys}\sc.exe; Parameters: "delete taosada
[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
- ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\TDengine"; \
- Check: NeedsAddPath('C:\TDengine')
+ ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};C:\{#CusName}"; \
+ Check: NeedsAddPath('C:\{#CusName}')
[Code]
function NeedsAddPath(Param: string): boolean;
@@ -104,11 +106,11 @@ Name: "desktopicon";Description: "{cm:CreateDesktopIcon}"; GroupDescription:"{cm
[Icons]
Name:"{group}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; IconFilename: "{app}\include\{#MyAppIco}"
-Name:"{group}\Open TDengine Directory"; Filename: "{app}\"
+Name:"{group}\Open {#CusName} Directory"; Filename: "{app}\"
Name:"{group}\Taosdemo"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taosdemo.exe" ; IconFilename: "{app}\include\{#MyAppIco}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" ; IconFilename: "{app}\include\{#MyAppIco}"
Name:"{commondesktop}\Taos Shell"; Filename: "{app}\include\{#MyAppTaosExeName}" ; Parameters: "taos.exe" ; Tasks: desktopicon; WorkingDir: "{app}" ; IconFilename: "{app}\include\{#MyAppIco}"
[Messages]
-ConfirmUninstall=Do you really want to uninstall TDengine from your computer?%n%nPress [Y] to completely delete %1 and all its components;%nPress [N] to keep the software on your computer.
+ConfirmUninstall=Do you really want to uninstall {#CusName} from your computer?%n%nPress [Y] to completely delete %1 and all its components;%nPress [N] to keep the software on your computer.
diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt
index 0c445c7fbfa01b6432259bd20e7e481966aee7a7..d0cfd38fb97789543357396590afc30dc3f8ef9a 100644
--- a/source/client/CMakeLists.txt
+++ b/source/client/CMakeLists.txt
@@ -62,4 +62,4 @@ target_link_libraries(
if(${BUILD_TEST})
ADD_SUBDIRECTORY(test)
-endif(${BUILD_TEST})
\ No newline at end of file
+endif(${BUILD_TEST})
diff --git a/source/client/inc/clientSml.h b/source/client/inc/clientSml.h
index 311260e3fb1eec8b6a1118bb88cf3180ba5e68de..3dcba673bfa843823561e565ddbe58586d82b774 100644
--- a/source/client/inc/clientSml.h
+++ b/source/client/inc/clientSml.h
@@ -99,6 +99,7 @@ typedef struct {
char *tags;
char *cols;
char *timestamp;
+ char *measureTag;
int32_t measureLen;
int32_t measureTagsLen;
@@ -114,7 +115,7 @@ typedef struct {
int32_t sTableNameLen;
char childTableName[TSDB_TABLE_NAME_LEN];
uint64_t uid;
- void *key; // for openTsdb
+// void *key; // for openTsdb
SArray *tags;
@@ -166,8 +167,8 @@ typedef struct {
int32_t ttl;
int32_t uid; // used for automatic create child table
- NodeList *childTables;
- NodeList *superTables;
+ SHashObj *childTables;
+ SHashObj *superTables;
SHashObj *pVgHash;
STscObj *taos;
diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c
index fbab1ee08b847544c3711d73697636f502c2ce25..2b79fc7388099875a06692a805e3ab5b7c872e4d 100644
--- a/source/client/src/clientEnv.c
+++ b/source/client/src/clientEnv.c
@@ -23,12 +23,12 @@
#include "scheduler.h"
#include "tcache.h"
#include "tglobal.h"
+#include "thttp.h"
#include "tmsg.h"
#include "tref.h"
#include "trpc.h"
#include "tsched.h"
#include "ttime.h"
-#include "thttp.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
@@ -65,7 +65,7 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
static void deregisterRequest(SRequestObj *pRequest) {
const static int64_t SLOW_QUERY_INTERVAL = 3000000L; // todo configurable
- if(pRequest == NULL){
+ if (pRequest == NULL) {
tscError("pRequest == NULL");
return;
}
@@ -380,9 +380,9 @@ void doDestroyRequest(void *p) {
}
if (pRequest->syncQuery) {
- if (pRequest->body.param){
- tsem_destroy(&((SSyncQueryParam*)pRequest->body.param)->sem);
- }
+ if (pRequest->body.param) {
+ tsem_destroy(&((SSyncQueryParam *)pRequest->body.param)->sem);
+ }
taosMemoryFree(pRequest->body.param);
}
@@ -406,20 +406,20 @@ static void *tscCrashReportThreadFp(void *param) {
setThreadName("client-crashReport");
char filepath[PATH_MAX] = {0};
snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
- char *pMsg = NULL;
- int64_t msgLen = 0;
+ char *pMsg = NULL;
+ int64_t msgLen = 0;
TdFilePtr pFile = NULL;
- bool truncateFile = false;
- int32_t sleepTime = 200;
- int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
- int32_t loopTimes = reportPeriodNum;
+ bool truncateFile = false;
+ int32_t sleepTime = 200;
+ int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
+ int32_t loopTimes = reportPeriodNum;
#ifdef WINDOWS
if (taosCheckCurrentInDll()) {
atexit(crashReportThreadFuncUnexpectedStopped);
}
#endif
-
+
while (1) {
if (clientStop) break;
if (loopTimes++ < reportPeriodNum) {
@@ -449,12 +449,12 @@ static void *tscCrashReportThreadFp(void *param) {
pMsg = NULL;
continue;
}
-
+
if (pFile) {
taosReleaseCrashLogFile(pFile, truncateFile);
truncateFile = false;
}
-
+
taosMsleep(sleepTime);
loopTimes = 0;
}
@@ -467,11 +467,11 @@ int32_t tscCrashReportInit() {
if (!tsEnableCrashReport) {
return 0;
}
-
+
TdThreadAttr thAttr;
taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
- TdThread crashReportThread;
+ TdThread crashReportThread;
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
tscError("failed to create crashReport thread since %s", strerror(errno));
return -1;
@@ -496,26 +496,24 @@ void tscStopCrashReport() {
}
}
-
void tscWriteCrashInfo(int signum, void *sigInfo, void *context) {
- char *pMsg = NULL;
+ char *pMsg = NULL;
const char *flags = "UTL FATAL ";
ELogLevel level = DEBUG_FATAL;
int32_t dflag = 255;
- int64_t msgLen= -1;
+ int64_t msgLen = -1;
if (tsEnableCrashReport) {
if (taosGenCrashJsonMsg(signum, &pMsg, lastClusterId, appInfo.startTime)) {
taosPrintLog(flags, level, dflag, "failed to generate crash json msg");
} else {
- msgLen = strlen(pMsg);
+ msgLen = strlen(pMsg);
}
}
taosLogCrashInfo("taos", pMsg, msgLen, signum, sigInfo);
}
-
void taos_init_imp(void) {
// In the APIs of other program language, taos_cleanup is not available yet.
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
@@ -570,7 +568,7 @@ void taos_init_imp(void) {
taosThreadMutexInit(&appInfo.mutex, NULL);
tscCrashReportInit();
-
+
tscDebug("client is initialized successfully");
}
@@ -621,6 +619,9 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
tscError("failed to set cfg:%s to %s since %s", pItem->name, str, terrstr());
} else {
tscInfo("set cfg:%s to %s", pItem->name, str);
+ if (TSDB_OPTION_SHELL_ACTIVITY_TIMER == option || TSDB_OPTION_USE_ADAPTER == option) {
+ code = taosSetCfg(pCfg, pItem->name);
+ }
}
return code;
diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c
index 2c53fe40800badfd17d308d4aca094729edf1d3d..f63a2ebde039cfedc7472d7a67faa621dd06a375 100644
--- a/source/client/src/clientImpl.c
+++ b/source/client/src/clientImpl.c
@@ -138,6 +138,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
p->mgmtEp = epSet;
taosThreadMutexInit(&p->qnodeMutex, NULL);
p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores / 2);
+ if (p->pTransporter == NULL) {
+ taosThreadMutexUnlock(&appInfo.mutex);
+ taosMemoryFreeClear(key);
+ taosMemoryFree(p);
+ return NULL;
+ }
p->pAppHbMgr = appHbMgrInit(p, key);
if (NULL == p->pAppHbMgr) {
destroyAppInst(p);
@@ -1386,8 +1392,6 @@ int32_t doProcessMsgFromServer(void* param) {
tscError("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self,
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId);
}
-
- taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId);
}
}
@@ -1407,6 +1411,11 @@ int32_t doProcessMsgFromServer(void* param) {
}
pSendInfo->fp(pSendInfo->param, &buf, pMsg->code);
+
+ if (pTscObj) {
+ taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId);
+ }
+
rpcFreeCont(pMsg->pCont);
destroySendMsgInfo(pSendInfo);
@@ -1444,6 +1453,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
tscError("failed to sched msg to tsc, tsc ready to quit");
rpcFreeCont(pMsg->pCont);
taosMemoryFree(arg->pEpset);
+ destroySendMsgInfo(pMsg->info.ahandle);
taosMemoryFree(arg);
}
}
diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c
index 72a00ef471fa0010efc7666c00b2a5e020509ab2..70cdd291e44a355aeded4ab038e673d34b3277d8 100644
--- a/source/client/src/clientRawBlockWrite.c
+++ b/source/client/src/clientRawBlockWrite.c
@@ -25,6 +25,8 @@
#include "tref.h"
#include "ttimer.h"
+static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); }
+
static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id,
int8_t t) {
char* string = NULL;
@@ -690,7 +692,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
pReq.numOfColumns = req.schemaRow.nCols;
pReq.numOfTags = req.schemaTag.nCols;
pReq.commentLen = -1;
- pReq.suid = req.suid;
+ pReq.suid = processSuid(req.suid, pRequest->pDb);
pReq.source = TD_REQ_FROM_TAOX;
pReq.igExists = true;
@@ -762,7 +764,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
// build drop stable
pReq.igNotExists = true;
pReq.source = TD_REQ_FROM_TAOX;
- pReq.suid = req.suid;
+ pReq.suid = processSuid(req.suid, pRequest->pDb);
STscObj* pTscObj = pRequest->pTscObj;
SName tableName = {0};
@@ -880,6 +882,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
if (pCreateReq->type == TSDB_CHILD_TABLE) {
STableMeta* pTableMeta = NULL;
SName sName = {0};
+ pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb);
toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.stbName, &sName);
code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta);
if (code != TSDB_CODE_SUCCESS) {
@@ -1017,6 +1020,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
pDropReq = req.pReqs + iReq;
pDropReq->igNotExists = true;
+ pDropReq->suid = processSuid(pDropReq->suid, pRequest->pDb);
SVgroupInfo pInfo = {0};
SName pName = {0};
@@ -1126,7 +1130,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
TAOS_RES* res = taos_query(taos, sql);
SRequestObj* pRequest = (SRequestObj*)res;
code = pRequest->code;
- if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
+ if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_PAR_GET_META_ERROR) {
code = TSDB_CODE_SUCCESS;
}
taos_free_result(res);
@@ -1307,7 +1311,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
- code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields);
+ code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false);
if (code != TSDB_CODE_SUCCESS) {
uError("WriteRaw:rawBlockBindData failed");
goto end;
@@ -1387,7 +1391,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData));
- code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0);
+ code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, NULL, 0, false);
if (code != TSDB_CODE_SUCCESS) {
uError("WriteRaw:rawBlockBindData failed");
goto end;
@@ -1505,7 +1509,18 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
}
- code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, NULL, NULL, 0);
+ SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
+ TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
+ if (fields == NULL) {
+ goto end;
+ }
+ for (int i = 0; i < pSW->nCols; i++) {
+ fields[i].type = pSW->pSchema[i].type;
+ fields[i].bytes = pSW->pSchema[i].bytes;
+ tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
+ }
+ code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, NULL, fields, pSW->nCols, true);
+ taosMemoryFree(fields);
if (code != TSDB_CODE_SUCCESS) {
uError("WriteRaw:rawBlockBindData failed");
goto end;
@@ -1515,7 +1530,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
code = smlBuildOutput(pQuery, pVgHash);
if (code != TSDB_CODE_SUCCESS) {
uError("smlBuildOutput failed");
- return code;
+ goto end;
}
launchQueryImpl(pRequest, pQuery, true, NULL);
@@ -1538,6 +1553,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
SMqTaosxRspObj rspObj = {0};
SDecoder decoder = {0};
STableMeta* pTableMeta = NULL;
+ SVCreateTbReq* pCreateReqDst = NULL;
terrno = TSDB_CODE_SUCCESS;
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
@@ -1605,17 +1621,17 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
strcpy(pName.tname, tbName);
// find schema data info
- SVCreateTbReq pCreateReq = {0};
-
for (int j = 0; j < rspObj.rsp.createTableNum; j++) {
void** dataTmp = taosArrayGet(rspObj.rsp.createTableReq, j);
int32_t* lenTmp = taosArrayGet(rspObj.rsp.createTableLen, j);
- SDecoder decoderTmp = {0};
+ SDecoder decoderTmp = {0};
+ SVCreateTbReq pCreateReq = {0};
tDecoderInit(&decoderTmp, *dataTmp, *lenTmp);
- memset(&pCreateReq, 0, sizeof(SVCreateTbReq));
if (tDecodeSVCreateTbReq(&decoderTmp, &pCreateReq) < 0) {
tDecoderClear(&decoderTmp);
+ uError("WriteRaw: tDecodeSVCreateTbReq error");
+ code = TSDB_CODE_TMQ_INVALID_MSG;
goto end;
}
@@ -1625,13 +1641,18 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
goto end;
}
if (strcmp(tbName, pCreateReq.name) == 0) {
- strcpy(pName.tname, pCreateReq.ctb.stbName);
+ cloneSVreateTbReq(&pCreateReq, &pCreateReqDst);
tDecoderClear(&decoderTmp);
break;
}
tDecoderClear(&decoderTmp);
}
+ if (pCreateReqDst) {
+ strcpy(pName.tname, pCreateReqDst->ctb.stbName);
+ } else {
+ strcpy(pName.tname, tbName);
+ }
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName);
@@ -1650,16 +1671,38 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
goto end;
}
+ if (pCreateReqDst) {
+ pTableMeta->vgId = vg.vgId;
+ pTableMeta->uid = pCreateReqDst->uid;
+ }
void* hData = taosHashGet(pVgHash, &vg.vgId, sizeof(vg.vgId));
if (hData == NULL) {
taosHashPut(pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
}
- code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, &pCreateReq, NULL, 0);
+ SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(rspObj.rsp.blockSchema, rspObj.resIter);
+ TAOS_FIELD* fields = taosMemoryCalloc(pSW->nCols, sizeof(TAOS_FIELD));
+ if (fields == NULL) {
+ goto end;
+ }
+ for (int i = 0; i < pSW->nCols; i++) {
+ fields[i].type = pSW->pSchema[i].type;
+ fields[i].bytes = pSW->pSchema[i].bytes;
+ tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
+ }
+ code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, pCreateReqDst, fields, pSW->nCols, true);
+ taosMemoryFree(fields);
if (code != TSDB_CODE_SUCCESS) {
uError("WriteRaw:rawBlockBindData failed");
goto end;
}
+ pCreateReqDst = NULL;
+ }
+
+ code = smlBuildOutput(pQuery, pVgHash);
+ if (code != TSDB_CODE_SUCCESS) {
+ uError("smlBuildOutput failed");
+ goto end;
}
launchQueryImpl(pRequest, pQuery, true, NULL);
@@ -1672,6 +1715,10 @@ end:
destroyRequest(pRequest);
taosHashCleanup(pVgHash);
taosMemoryFreeClear(pTableMeta);
+ if (pCreateReqDst) {
+ tdDestroySVCreateTbReq(pCreateReqDst);
+ taosMemoryFree(pCreateReqDst);
+ }
return code;
}
diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c
index e21fcd64b8bf33bfa474e44d618813b12bc5f25d..60002425f75d0c138ba2d61af6179cb74df9e5e2 100644
--- a/source/client/src/clientSml.c
+++ b/source/client/src/clientSml.c
@@ -759,13 +759,13 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
conn.requestObjRefId = info->pRequest->self;
conn.mgmtEps = getEpSet_s(&info->taos->pAppInfo->mgmtEp);
- NodeList *tmp = info->superTables;
+ SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL);
while (tmp) {
- SSmlSTableMeta *sTableData = (SSmlSTableMeta *)tmp->data.value;
+ SSmlSTableMeta *sTableData = *tmp;
bool needCheckMeta = false; // for multi thread
- size_t superTableLen = (size_t)tmp->data.keyLen;
- const void *superTable = tmp->data.key;
+ size_t superTableLen = 0;
+ void *superTable = taosHashGetKey(tmp, &superTableLen);
memset(pName.tname, 0, TSDB_TABLE_NAME_LEN);
memcpy(pName.tname, superTable, superTableLen);
@@ -914,7 +914,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
sTableData->tableMeta = pTableMeta;
- tmp = tmp->next;
+ tmp = (SSmlSTableMeta **)taosHashIterate(info->superTables, tmp);
}
return 0;
@@ -1017,11 +1017,11 @@ void smlDestroyTableInfo(SSmlHandle *info, SSmlTableInfo *tag) {
taosHashCleanup(kvHash);
}
- if (info->parseJsonByLib) {
- SSmlLineInfo *key = (SSmlLineInfo *)(tag->key);
- if (key != NULL) taosMemoryFree(key->tags);
- }
- taosMemoryFree(tag->key);
+ // if (info->parseJsonByLib) {
+ // SSmlLineInfo *key = (SSmlLineInfo *)(tag->key);
+ // if (key != NULL) taosMemoryFree(key->tags);
+ // }
+ // taosMemoryFree(tag->key);
taosArrayDestroy(tag->cols);
taosArrayDestroy(tag->tags);
taosMemoryFree(tag);
@@ -1042,29 +1042,23 @@ void smlDestroyInfo(SSmlHandle *info) {
qDestroyQuery(info->pQuery);
// destroy info->childTables
- NodeList *tmp = info->childTables;
- while (tmp) {
- if (tmp->data.used) {
- smlDestroyTableInfo(info, (SSmlTableInfo *)tmp->data.value);
- }
- NodeList *t = tmp->next;
- taosMemoryFree(tmp);
- tmp = t;
+ SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL);
+ while (oneTable) {
+ smlDestroyTableInfo(info, *oneTable);
+ oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable);
}
// destroy info->superTables
- tmp = info->superTables;
- while (tmp) {
- if (tmp->data.used) {
- smlDestroySTableMeta((SSmlSTableMeta *)tmp->data.value);
- }
- NodeList *t = tmp->next;
- taosMemoryFree(tmp);
- tmp = t;
+ SSmlSTableMeta **oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL);
+ while (oneSTable) {
+ smlDestroySTableMeta(*oneSTable);
+ oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, oneSTable);
}
// destroy info->pVgHash
taosHashCleanup(info->pVgHash);
+ taosHashCleanup(info->childTables);
+ taosHashCleanup(info->superTables);
for (int i = 0; i < taosArrayGetSize(info->tagJsonArray); i++) {
cJSON *tags = (cJSON *)taosArrayGetP(info->tagJsonArray, i);
@@ -1088,6 +1082,7 @@ void smlDestroyInfo(SSmlHandle *info) {
if (info->parseJsonByLib) {
taosMemoryFree(info->lines[i].tags);
}
+ if (info->lines[i].measureTagsLen != 0) taosMemoryFree(info->lines[i].measureTag);
}
taosMemoryFree(info->lines);
}
@@ -1112,6 +1107,9 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
}
info->pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
+ info->childTables = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
+ info->superTables = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
+
info->id = smlGenId();
info->pQuery = smlInitHandle();
info->dataFormat = true;
@@ -1122,7 +1120,7 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) {
info->maxTagKVs = taosArrayInit(8, sizeof(SSmlKv));
info->preLineColKV = taosArrayInit(8, sizeof(SSmlKv));
- if (NULL == info->pVgHash) {
+ if (NULL == info->pVgHash || NULL == info->childTables || NULL == info->superTables) {
uError("create SSmlHandle failed");
goto cleanup;
}
@@ -1156,11 +1154,13 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
SSmlLineInfo *elements = info->lines + i;
SSmlTableInfo *tinfo = NULL;
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
- tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements->measure, elements->measureTagsLen, NULL);
+ tinfo = *(SSmlTableInfo **)taosHashGet(info->childTables, elements->measure, elements->measureTagsLen);
} else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
- tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet);
+ tinfo = *(SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag,
+ elements->measureLen + elements->tagsLen);
} else {
- tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet);
+ tinfo = *(SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag,
+ elements->measureLen + elements->tagsLen);
}
if (tinfo == NULL) {
@@ -1184,12 +1184,12 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
return ret;
}
- SSmlSTableMeta *tableMeta =
- (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
+ SSmlSTableMeta **tableMeta =
+ (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
if (tableMeta) { // update meta
- ret = smlUpdateMeta(tableMeta->colHash, tableMeta->cols, elements->colArray, false, &info->msgBuf);
+ ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, elements->colArray, false, &info->msgBuf);
if (ret == TSDB_CODE_SUCCESS) {
- ret = smlUpdateMeta(tableMeta->tagHash, tableMeta->tags, tinfo->tags, true, &info->msgBuf);
+ ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, tinfo->tags, true, &info->msgBuf);
}
if (ret != TSDB_CODE_SUCCESS) {
uError("SML:0x%" PRIx64 " smlUpdateMeta failed", info->id);
@@ -1205,7 +1205,7 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
SSmlSTableMeta *meta = smlBuildSTableMeta(info->dataFormat);
smlInsertMeta(meta->tagHash, meta->tags, tinfo->tags);
smlInsertMeta(meta->colHash, meta->cols, elements->colArray);
- nodeListSet(&info->superTables, elements->measure, elements->measureLen, meta, NULL);
+ taosHashPut(info->superTables, elements->measure, elements->measureLen, &meta, POINTER_BYTES);
}
}
@@ -1215,9 +1215,9 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
static int32_t smlInsertData(SSmlHandle *info) {
int32_t code = TSDB_CODE_SUCCESS;
- NodeList *tmp = info->childTables;
- while (tmp) {
- SSmlTableInfo *tableData = (SSmlTableInfo *)tmp->data.value;
+ SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL);
+ while (oneTable) {
+ SSmlTableInfo *tableData = *oneTable;
SName pName = {TSDB_TABLE_NAME_T, info->taos->acctId, {0}, {0}};
tstrncpy(pName.dbname, info->pRequest->pDb, sizeof(pName.dbname));
@@ -1237,25 +1237,25 @@ static int32_t smlInsertData(SSmlHandle *info) {
}
taosHashPut(info->pVgHash, (const char *)&vg.vgId, sizeof(vg.vgId), (char *)&vg, sizeof(vg));
- SSmlSTableMeta *pMeta =
- (SSmlSTableMeta *)nodeListGet(info->superTables, tableData->sTableName, tableData->sTableNameLen, NULL);
- if (unlikely(NULL == pMeta || NULL == pMeta->tableMeta)) {
+ SSmlSTableMeta **pMeta =
+ (SSmlSTableMeta **)taosHashGet(info->superTables, tableData->sTableName, tableData->sTableNameLen);
+ if (unlikely(NULL == pMeta || NULL == (*pMeta)->tableMeta)) {
uError("SML:0x%" PRIx64 " NULL == pMeta. table name: %s", info->id, tableData->childTableName);
return TSDB_CODE_SML_INTERNAL_ERROR;
}
// use tablemeta of stable to save vgid and uid of child table
- pMeta->tableMeta->vgId = vg.vgId;
- pMeta->tableMeta->uid = tableData->uid; // one table merge data block together according uid
+ (*pMeta)->tableMeta->vgId = vg.vgId;
+ (*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid
- code = smlBindData(info->pQuery, info->dataFormat, tableData->tags, pMeta->cols, tableData->cols, pMeta->tableMeta,
- tableData->childTableName, tableData->sTableName, tableData->sTableNameLen, info->ttl,
- info->msgBuf.buf, info->msgBuf.len);
+ code = smlBindData(info->pQuery, info->dataFormat, tableData->tags, (*pMeta)->cols, tableData->cols,
+ (*pMeta)->tableMeta, tableData->childTableName, tableData->sTableName, tableData->sTableNameLen,
+ info->ttl, info->msgBuf.buf, info->msgBuf.len);
if (code != TSDB_CODE_SUCCESS) {
uError("SML:0x%" PRIx64 " smlBindData failed", info->id);
return code;
}
- tmp = tmp->next;
+ oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable);
}
code = smlBuildOutput(info->pQuery, info->pVgHash);
@@ -1288,25 +1288,22 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
int32_t smlClearForRerun(SSmlHandle *info) {
info->reRun = false;
// clear info->childTables
- NodeList *pList = info->childTables;
- while (pList) {
- if (pList->data.used) {
- smlDestroyTableInfo(info, (SSmlTableInfo *)pList->data.value);
- pList->data.used = false;
- }
- pList = pList->next;
+ SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL);
+ while (oneTable) {
+ smlDestroyTableInfo(info, *oneTable);
+ oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, oneTable);
}
// clear info->superTables
- pList = info->superTables;
- while (pList) {
- if (pList->data.used) {
- smlDestroySTableMeta((SSmlSTableMeta *)pList->data.value);
- pList->data.used = false;
- }
- pList = pList->next;
+ SSmlSTableMeta **oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, NULL);
+ while (oneSTable) {
+ smlDestroySTableMeta(*oneSTable);
+ oneSTable = (SSmlSTableMeta **)taosHashIterate(info->superTables, oneSTable);
}
+ taosHashClear(info->childTables);
+ taosHashClear(info->superTables);
+
if (!info->dataFormat) {
if (unlikely(info->lines != NULL)) {
uError("SML:0x%" PRIx64 " info->lines != NULL", info->id);
@@ -1375,6 +1372,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char
if (info->dataFormat) {
SSmlLineInfo element = {0};
code = smlParseTelnetString(info, (char *)tmp, (char *)tmp + len, &element);
+ if (element.measureTagsLen != 0) taosMemoryFree(element.measureTag);
} else {
code = smlParseTelnetString(info, (char *)tmp, (char *)tmp + len, info->lines + i);
}
@@ -1418,15 +1416,15 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL
}
info->cost.lineNum = info->lineNum;
- info->cost.numOfSTables = nodeListSize(info->superTables);
- info->cost.numOfCTables = nodeListSize(info->childTables);
+ info->cost.numOfSTables = taosHashGetSize(info->superTables);
+ info->cost.numOfCTables = taosHashGetSize(info->childTables);
info->cost.schemaTime = taosGetTimestampUs();
do {
code = smlModifyDBSchemas(info);
if (code == 0) break;
- } while (retryNum++ < nodeListSize(info->superTables) * MAX_RETRY_TIMES);
+ } while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES);
if (code != 0) {
uError("SML:0x%" PRIx64 " smlModifyDBSchemas error : %s", info->id, tstrerror(code));
@@ -1504,7 +1502,7 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
request->code = code;
info->cost.endTime = taosGetTimestampUs();
info->cost.code = code;
- // smlPrintStatisticInfo(info);
+ smlPrintStatisticInfo(info);
end:
smlDestroyInfo(info);
diff --git a/source/client/src/clientSmlJson.c b/source/client/src/clientSmlJson.c
index db1ca5a4217aaed2f4469df14aecbf283b1fcfbc..a437fd238c11471ed465b2d7ab4049a0f284e5a8 100644
--- a/source/client/src/clientSmlJson.c
+++ b/source/client/src/clientSmlJson.c
@@ -256,7 +256,7 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){
if(unlikely(index >= OTD_JSON_FIELDS_NUM)) {
uError("index >= %d, %s", OTD_JSON_FIELDS_NUM, *start)
- break;
+ return -1;
}
char *sTmp = *start;
@@ -275,6 +275,7 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset){
}
if(unlikely(isInQuote && *(*start) == '"')){
element->measureLen = (*start) - element->measure;
+ (*start)++;
break;
}
(*start)++;
@@ -384,7 +385,7 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
if(unlikely(index >= OTD_JSON_FIELDS_NUM)) {
uError("index >= %d, %s", OTD_JSON_FIELDS_NUM, *start)
- break;
+ return -1;
}
if((*start)[1] == 'm'){
@@ -393,6 +394,7 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
while(*(*start)){
if(unlikely(*(*start) == '"')){
element->measureLen = (*start) - element->measure;
+ (*start)++;
break;
}
(*start)++;
@@ -406,15 +408,14 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
element->timestampLen = tmp - (*start);
*start = tmp;
}
- continue;
- }
-
- while(*(*start)){
- if(unlikely(*(*start) == ',' || *(*start) == '}' || (*(*start)) <= 32)){
- element->timestampLen = (*start) - element->timestamp;
- break;
+ }else{
+ while(*(*start)){
+ if(unlikely(*(*start) == ',' || *(*start) == '}' || (*(*start)) <= 32)){
+ element->timestampLen = (*start) - element->timestamp;
+ break;
+ }
+ (*start)++;
}
- (*start)++;
}
}else if((*start)[1] == 'v'){
(*start) += offset[index++];
@@ -425,14 +426,14 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
element->colsLen = tmp - (*start);
*start = tmp;
}
- continue;
- }
- while(*(*start)){
- if(unlikely( *(*start) == ',' || *(*start) == '}' || (*(*start)) <= 32)){
- element->colsLen = (*start) - element->cols;
- break;
+ }else{
+ while(*(*start)){
+ if(unlikely( *(*start) == ',' || *(*start) == '}' || (*(*start)) <= 32)){
+ element->colsLen = (*start) - element->cols;
+ break;
+ }
+ (*start)++;
}
- (*start)++;
}
}else if((*start)[1] == 't' && (*start)[2] == 'a'){
(*start) += offset[index++];
@@ -442,7 +443,6 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset){
element->tagsLen = tmp - (*start);
*start = tmp;
}
- continue;
}
if(*(*start) == '}'){
(*start)++;
@@ -694,9 +694,9 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
SArray *superKV = NULL;
if(info->dataFormat){
if(unlikely(!isSameMeasure)){
- SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
-
- if(unlikely(sMeta == NULL)){
+ SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
+ SSmlSTableMeta *sMeta = NULL;
+ if(unlikely(tmp == NULL)){
STableMeta * pTableMeta = smlGetMeta(info, elements->measure, elements->measureLen);
if(pTableMeta == NULL){
info->dataFormat = false;
@@ -705,10 +705,11 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
}
sMeta = smlBuildSTableMeta(info->dataFormat);
sMeta->tableMeta = pTableMeta;
- nodeListSet(&info->superTables, elements->measure, elements->measureLen, sMeta, NULL);
+ taosHashPut(info->superTables, elements->measure, elements->measureLen, &sMeta, POINTER_BYTES);
+ tmp = &sMeta;
}
- info->currSTableMeta = sMeta->tableMeta;
- superKV = sMeta->tags;
+ info->currSTableMeta = (*tmp)->tableMeta;
+ superKV = (*tmp)->tags;
if(unlikely(taosArrayGetSize(superKV) == 0)){
isSuperKVInit = false;
@@ -761,13 +762,13 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt);
if(unlikely(kv.length > maxKV->length)){
maxKV->length = kv.length;
- SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
+ SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
if(unlikely(NULL == tableMeta)){
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
return TSDB_CODE_SML_INTERNAL_ERROR;
}
- SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
+ SSmlKv *oldKV = (SSmlKv *)taosArrayGet((*tableMeta)->tags, cnt);
oldKV->length = kv.length;
info->needModifySchema = true;
}
@@ -808,8 +809,14 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
cnt++;
}
- SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet);
- if (unlikely(tinfo == NULL)) {
+ elements->measureTag = (char*)taosMemoryMalloc(elements->measureLen + elements->tagsLen);
+ memcpy(elements->measureTag, elements->measure, elements->measureLen);
+ memcpy(elements->measureTag + elements->measureLen, elements->tags, elements->tagsLen);
+ elements->measureTagsLen = elements->measureLen + elements->tagsLen;
+
+ SSmlTableInfo **tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, elements->measureLen + elements->tagsLen);
+ SSmlTableInfo *tinfo = NULL;
+ if (unlikely(tmp == NULL)) {
tinfo = smlBuildTableInfo(1, elements->measure, elements->measureLen);
if (unlikely(!tinfo)) {
return TSDB_CODE_OUT_OF_MEMORY;
@@ -828,17 +835,18 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
}
}
- SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
- *key = *elements;
- if(info->parseJsonByLib){
- key->tags = taosMemoryMalloc(elements->tagsLen + 1);
- memcpy(key->tags, elements->tags, elements->tagsLen);
- key->tags[elements->tagsLen] = 0;
- }
- tinfo->key = key;
- nodeListSet(&info->childTables, key, POINTER_BYTES, tinfo, is_same_child_table_telnet);
+// SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
+// *key = *elements;
+// if(info->parseJsonByLib){
+// key->tags = taosMemoryMalloc(elements->tagsLen + 1);
+// memcpy(key->tags, elements->tags, elements->tagsLen);
+// key->tags[elements->tagsLen] = 0;
+// }
+// tinfo->key = key;
+ taosHashPut(info->childTables, elements->measureTag, elements->measureLen + elements->tagsLen, &tinfo, POINTER_BYTES);
+ tmp = &tinfo;
}
- if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx;
+ if (info->dataFormat) info->currTableDataCtx = (*tmp)->tableDataCtx;
return ret;
}
@@ -1011,6 +1019,8 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
elements->tags = NULL;
return ret;
}
+ }else{
+ elements->measureTag = info->preLine.measureTag;
}
if(needFree){
@@ -1189,6 +1199,8 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id);
return ret;
}
+ }else{
+ elements->measureTag = info->preLine.measureTag;
}
if(unlikely(info->reRun)){
@@ -1259,6 +1271,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
if(info->dataFormat) {
SSmlLineInfo element = {0};
ret = smlParseJSONString(info, &dataPointStart, &element);
+ if(element.measureTagsLen != 0) taosMemoryFree(element.measureTag);
}else{
if(cnt >= payloadNum){
payloadNum = payloadNum << 1;
@@ -1269,6 +1282,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
}
}
ret = smlParseJSONString(info, &dataPointStart, info->lines + cnt);
+ if((info->lines + cnt)->measure == NULL) break;
}
if (unlikely(ret != TSDB_CODE_SUCCESS)) {
uError("SML:0x%" PRIx64 " Invalid JSON Payload 1:%s", info->id, payload);
diff --git a/source/client/src/clientSmlLine.c b/source/client/src/clientSmlLine.c
index 890245f53d5f7cbf52613ca7804da3c43e9543f8..e1fd8c2a81724ffae00ee045b57797274d02d70e 100644
--- a/source/client/src/clientSmlLine.c
+++ b/source/client/src/clientSmlLine.c
@@ -148,9 +148,9 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
SArray *superKV = NULL;
if(info->dataFormat){
if(unlikely(!isSameMeasure)){
- SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
-
- if(unlikely(sMeta == NULL)){
+ SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashGet(info->superTables, currElement->measure, currElement->measureLen);
+ SSmlSTableMeta *sMeta = NULL;
+ if(unlikely(tmp == NULL)){
STableMeta * pTableMeta = smlGetMeta(info, currElement->measure, currElement->measureLen);
if(pTableMeta == NULL){
info->dataFormat = false;
@@ -159,10 +159,11 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
sMeta = smlBuildSTableMeta(info->dataFormat);
sMeta->tableMeta = pTableMeta;
- nodeListSet(&info->superTables, currElement->measure, currElement->measureLen, sMeta, NULL);
+ taosHashPut(info->superTables, currElement->measure, currElement->measureLen, &sMeta, POINTER_BYTES);
+ tmp = &sMeta;
}
- info->currSTableMeta = sMeta->tableMeta;
- superKV = sMeta->tags;
+ info->currSTableMeta = (*tmp)->tableMeta;
+ superKV = (*tmp)->tags;
if(unlikely(taosArrayGetSize(superKV) == 0)){
isSuperKVInit = false;
@@ -258,13 +259,13 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt);
if(unlikely(kv.length > maxKV->length)){
maxKV->length = kv.length;
- SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
+ SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, currElement->measure, currElement->measureLen);
if(unlikely(NULL == tableMeta)){
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
return TSDB_CODE_SML_INTERNAL_ERROR;
}
- SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
+ SSmlKv *oldKV = (SSmlKv *)taosArrayGet((*tableMeta)->tags, cnt);
oldKV->length = kv.length;
info->needModifySchema = true;
}
@@ -310,7 +311,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
(*sql)++;
}
- void* oneTable = nodeListGet(info->childTables, currElement->measure, currElement->measureTagsLen, NULL);
+ void* oneTable = taosHashGet(info->childTables, currElement->measure, currElement->measureTagsLen);
if ((oneTable != NULL)) {
return TSDB_CODE_SUCCESS;
}
@@ -332,7 +333,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
}
- nodeListSet(&info->childTables, currElement->measure, currElement->measureTagsLen, tinfo, NULL);
+ taosHashPut(info->childTables, currElement->measure, currElement->measureTagsLen, &tinfo, POINTER_BYTES);
return TSDB_CODE_SUCCESS;
}
@@ -345,18 +346,18 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
SArray *superKV = NULL;
if(info->dataFormat){
if(unlikely(!isSameCTable)){
- SSmlTableInfo *oneTable = (SSmlTableInfo *)nodeListGet(info->childTables, currElement->measure, currElement->measureTagsLen, NULL);
+ SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashGet(info->childTables, currElement->measure, currElement->measureTagsLen);
if (unlikely(oneTable == NULL)) {
smlBuildInvalidDataMsg(&info->msgBuf, "child table should inside", currElement->measure);
return TSDB_CODE_SML_INVALID_DATA;
}
- info->currTableDataCtx = oneTable->tableDataCtx;
+ info->currTableDataCtx = (*oneTable)->tableDataCtx;
}
if(unlikely(!isSameMeasure)){
- SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
-
- if(unlikely(sMeta == NULL)){
+ SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashGet(info->superTables, currElement->measure, currElement->measureLen);
+ SSmlSTableMeta *sMeta = NULL;
+ if(unlikely(tmp == NULL)){
STableMeta * pTableMeta = smlGetMeta(info, currElement->measure, currElement->measureLen);
if(pTableMeta == NULL){
info->dataFormat = false;
@@ -365,10 +366,11 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
}
sMeta = smlBuildSTableMeta(info->dataFormat);
sMeta->tableMeta = pTableMeta;
- nodeListSet(&info->superTables, currElement->measure, currElement->measureLen, sMeta, NULL);
+ taosHashPut(info->superTables, currElement->measure, currElement->measureLen, &sMeta, POINTER_BYTES);
+ tmp = &sMeta;
}
- info->currSTableMeta = sMeta->tableMeta;
- superKV = sMeta->cols;
+ info->currSTableMeta = (*tmp)->tableMeta;
+ superKV = (*tmp)->cols;
if(unlikely(taosArrayGetSize(superKV) == 0)){
isSuperKVInit = false;
}
@@ -487,13 +489,13 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd,
if(unlikely(IS_VAR_DATA_TYPE(kv.type) && kv.length > maxKV->length)){
maxKV->length = kv.length;
- SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, currElement->measure, currElement->measureLen, NULL);
+ SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, currElement->measure, currElement->measureLen);
if(unlikely(NULL == tableMeta)){
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
return TSDB_CODE_SML_INTERNAL_ERROR;
}
- SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->cols, cnt);
+ SSmlKv *oldKV = (SSmlKv *)taosArrayGet((*tableMeta)->cols, cnt);
oldKV->length = kv.length;
info->needModifySchema = true;
}
diff --git a/source/client/src/clientSmlTelnet.c b/source/client/src/clientSmlTelnet.c
index d43ab6c9f97ca7d1c4523f03ff2bb9c73556fc4b..7f669ffead9cb2545809776f6100a8d1a83bdb51 100644
--- a/source/client/src/clientSmlTelnet.c
+++ b/source/client/src/clientSmlTelnet.c
@@ -71,6 +71,7 @@ static void smlParseTelnetElement(char **sql, char *sqlEnd, char **data, int32_t
static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SSmlLineInfo *elements, SSmlMsgBuf *msg) {
if(is_same_child_table_telnet(elements, &info->preLine) == 0){
+ elements->measureTag = info->preLine.measureTag;
return TSDB_CODE_SUCCESS;
}
@@ -83,9 +84,9 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
SArray *superKV = NULL;
if(info->dataFormat){
if(!isSameMeasure){
- SSmlSTableMeta *sMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
-
- if(unlikely(sMeta == NULL)){
+ SSmlSTableMeta **tmp = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
+ SSmlSTableMeta *sMeta = NULL;
+ if(unlikely(tmp == NULL)){
STableMeta * pTableMeta = smlGetMeta(info, elements->measure, elements->measureLen);
if(pTableMeta == NULL){
info->dataFormat = false;
@@ -94,10 +95,11 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
sMeta = smlBuildSTableMeta(info->dataFormat);
sMeta->tableMeta = pTableMeta;
- nodeListSet(&info->superTables, elements->measure, elements->measureLen, sMeta, NULL);
+ taosHashPut(info->superTables, elements->measure, elements->measureLen, &sMeta, POINTER_BYTES);
+ tmp = &sMeta;
}
- info->currSTableMeta = sMeta->tableMeta;
- superKV = sMeta->tags;
+ info->currSTableMeta = (*tmp)->tableMeta;
+ superKV = (*tmp)->tags;
if(unlikely(taosArrayGetSize(superKV) == 0)){
isSuperKVInit = false;
@@ -183,13 +185,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
SSmlKv *maxKV = (SSmlKv *)taosArrayGet(maxKVs, cnt);
if(unlikely(kv.length > maxKV->length)){
maxKV->length = kv.length;
- SSmlSTableMeta *tableMeta = (SSmlSTableMeta *)nodeListGet(info->superTables, elements->measure, elements->measureLen, NULL);
+ SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen);
if(unlikely(NULL == tableMeta)){
uError("SML:0x%" PRIx64 " NULL == tableMeta", info->id);
return TSDB_CODE_SML_INTERNAL_ERROR;
}
- SSmlKv *oldKV = (SSmlKv *)taosArrayGet(tableMeta->tags, cnt);
+ SSmlKv *oldKV = (SSmlKv *)taosArrayGet((*tableMeta)->tags, cnt);
oldKV->length = kv.length;
info->needModifySchema = true;
}
@@ -229,8 +231,15 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
taosArrayPush(preLineKV, &kv);
cnt++;
}
- SSmlTableInfo *tinfo = (SSmlTableInfo *)nodeListGet(info->childTables, elements, POINTER_BYTES, is_same_child_table_telnet);
- if (unlikely(tinfo == NULL)) {
+
+ elements->measureTag = (char*)taosMemoryMalloc(elements->measureLen + elements->tagsLen);
+ memcpy(elements->measureTag, elements->measure, elements->measureLen);
+ memcpy(elements->measureTag + elements->measureLen, elements->tags, elements->tagsLen);
+ elements->measureTagsLen = elements->measureLen + elements->tagsLen;
+
+ SSmlTableInfo **tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, elements->measureLen + elements->tagsLen);
+ SSmlTableInfo *tinfo = NULL;
+ if (unlikely(tmp == NULL)) {
tinfo = smlBuildTableInfo(1, elements->measure, elements->measureLen);
if (!tinfo) {
return TSDB_CODE_OUT_OF_MEMORY;
@@ -249,12 +258,13 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
}
}
- SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
- *key = *elements;
- tinfo->key = key;
- nodeListSet(&info->childTables, key, POINTER_BYTES, tinfo, is_same_child_table_telnet);
+// SSmlLineInfo *key = (SSmlLineInfo *)taosMemoryMalloc(sizeof(SSmlLineInfo));
+// *key = *elements;
+// tinfo->key = key;
+ taosHashPut(info->childTables, elements->measureTag, elements->measureLen + elements->tagsLen, &tinfo, POINTER_BYTES);
+ tmp = &tinfo;
}
- if (info->dataFormat) info->currTableDataCtx = tinfo->tableDataCtx;
+ if (info->dataFormat) info->currTableDataCtx = (*tmp)->tableDataCtx;
return TSDB_CODE_SUCCESS;
}
diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c
index f5b65371a7c90393b72ee059afb8060f1b373891..3ed157efef1fc84b58cfe4d566965123108047cd 100644
--- a/source/client/src/clientStmt.c
+++ b/source/client/src/clientStmt.c
@@ -393,7 +393,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
if (NULL == pStmt->sql.pTableCache || taosHashGetSize(pStmt->sql.pTableCache) <= 0) {
if (pStmt->bInfo.inExecCache) {
- if(ASSERT(taosHashGetSize(pStmt->exec.pBlockHash) == 1)){
+ if (ASSERT(taosHashGetSize(pStmt->exec.pBlockHash) == 1)) {
tscError("stmtGetFromCache error");
return TSDB_CODE_TSC_STMT_CACHE_ERROR;
}
diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c
index 01c99c6e9ed16048a715839dc4ccb18ca04c3852..96f18e5fb6c84c6a0d91f0a86003025b40e510e5 100644
--- a/source/client/src/clientTmq.c
+++ b/source/client/src/clientTmq.c
@@ -1885,9 +1885,6 @@ int32_t tmq_consumer_close(tmq_t* tmq) {
}
tmq_list_destroy(lst);
-
- /*return rsp;*/
- return 0;
}
taosRemoveRef(tmqMgmt.rsetId, tmq->refId);
return 0;
diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp
index 82202b8820212fddfe401c769b77003fde2982fc..a75411a8540c3eeb73e8a56bd392e46a84d66eee 100644
--- a/source/client/test/clientTests.cpp
+++ b/source/client/test/clientTests.cpp
@@ -112,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) {
}
taos_free_result(pRes);
- for(int32_t i = 0; i < 20; i += 20) {
+ for(int32_t i = 0; i < 2000; i += 20) {
char sql[1024] = {0};
sprintf(sql,
"insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
@@ -692,6 +692,7 @@ TEST(testCase, insert_test) {
taos_free_result(pRes);
taos_close(pConn);
}
+#endif
TEST(testCase, projection_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
@@ -725,7 +726,7 @@ TEST(testCase, projection_query_tables) {
}
taos_free_result(pRes);
- for (int32_t i = 0; i < 200000; ++i) {
+ for (int32_t i = 0; i < 2; ++i) {
printf("create table :%d\n", i);
createNewTable(pConn, i);
}
@@ -751,6 +752,7 @@ TEST(testCase, projection_query_tables) {
taos_close(pConn);
}
+#if 0
TEST(testCase, tsbs_perf_test) {
TdThread qid[20] = {0};
@@ -760,8 +762,6 @@ TEST(testCase, tsbs_perf_test) {
getchar();
}
-#endif
-
TEST(testCase, projection_query_stables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
@@ -790,7 +790,6 @@ TEST(testCase, projection_query_stables) {
taos_close(pConn);
}
-#if 0
TEST(testCase, agg_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
@@ -831,7 +830,7 @@ TEST(testCase, async_api_test) {
ASSERT_NE(pConn, nullptr);
taos_query(pConn, "use abc1");
-#if 0
+
TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')");
if (taos_errno(pRes) != 0) {
printf("failed, reason:%s\n", taos_errstr(pRes));
@@ -854,7 +853,6 @@ TEST(testCase, async_api_test) {
printf("%s\n", str);
memset(str, 0, sizeof(str));
}
-#endif
taos_query_a(pConn, "select count(*) from tu", queryCallback, pConn);
getchar();
diff --git a/source/common/src/systable.c b/source/common/src/systable.c
index 8791a81bbe7fbed021c13b772892f11ca109a41d..0e185fa1c0923ccb167dc9fc3e1a0d23f42291f6 100644
--- a/source/common/src/systable.c
+++ b/source/common/src/systable.c
@@ -230,6 +230,7 @@ static const SSysDbTableSchema vgroupsSchema[] = {
{.name = "v4_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
+ // {.name = "compact_start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
};
static const SSysDbTableSchema smaSchema[] = {
diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c
index 9b5b32cf695ff6d38ff09fe9eb778dbb2679a43c..2d4c571d31c95c9b5d641121e8364774f4c82d36 100644
--- a/source/common/src/tdatablock.c
+++ b/source/common/src/tdatablock.c
@@ -1431,6 +1431,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
pBlock->info.rows = 0;
pBlock->info.capacity = 0;
pBlock->info.rowSize = 0;
+ pBlock->info.id = pDataBlock->info.id;
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
for (int32_t i = 0; i < numOfCols; ++i) {
@@ -2483,6 +2484,7 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
data += colSizes[col];
colSizes[col] = htonl(colSizes[col]);
+// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type, htonl(colSizes[col]), colSizes[col]);
}
*actualLen = dataLen;
diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c
index 5e001a96872306d9369d388f8823a2baecdbf04f..7c0de3d6f0ca67754f3c62fb5102a4d3837feedc 100644
--- a/source/common/src/tdataformat.c
+++ b/source/common/src/tdataformat.c
@@ -21,6 +21,7 @@
#include "tlog.h"
static int32_t (*tColDataAppendValueImpl[8][3])(SColData *pColData, uint8_t *pData, uint32_t nData);
+static int32_t (*tColDataUpdateValueImpl[8][3])(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward);
// SBuffer ================================
void tBufferDestroy(SBuffer *pBuffer) {
@@ -850,19 +851,19 @@ _exit:
return &pIter->cv;
}
-static int32_t tRowAppendNoneToColData(SColData *aColData, int32_t nColData) {
+static int32_t tRowNoneUpsertColData(SColData *aColData, int32_t nColData, int32_t flag) {
int32_t code = 0;
+ if (flag) return code;
+
for (int32_t iColData = 0; iColData < nColData; iColData++) {
- SColData *pColData = &aColData[iColData];
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ code = tColDataAppendValueImpl[aColData[iColData].flag][CV_FLAG_NONE](&aColData[iColData], NULL, 0);
+ if (code) return code;
}
-_exit:
return code;
}
-static int32_t tRowAppendNullToColData(SColData *aColData, int32_t nColData, STSchema *pSchema) {
+static int32_t tRowNullUpsertColData(SColData *aColData, int32_t nColData, STSchema *pSchema, int32_t flag) {
int32_t code = 0;
int32_t iColData = 0;
@@ -873,21 +874,23 @@ static int32_t tRowAppendNullToColData(SColData *aColData, int32_t nColData, STS
while (pColData) {
if (pTColumn) {
if (pTColumn->colId == pColData->cid) { // NULL
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ if (flag == 0) {
+ code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ } else {
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0, flag > 0);
+ }
if (code) goto _exit;
+
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
pTColumn = (++iTColumn < pSchema->numOfCols) ? &pSchema->columns[iTColumn] : NULL;
} else if (pTColumn->colId > pColData->cid) { // NONE
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
} else {
pTColumn = (++iTColumn < pSchema->numOfCols) ? &pSchema->columns[iTColumn] : NULL;
}
- } else {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
-
+ } else { // NONE
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
}
}
@@ -895,7 +898,8 @@ static int32_t tRowAppendNullToColData(SColData *aColData, int32_t nColData, STS
_exit:
return code;
}
-static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData) {
+static int32_t tRowTupleUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData,
+ int32_t flag) {
int32_t code = 0;
int32_t iColData = 0;
@@ -955,11 +959,15 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
}
if (bv == BIT_FLG_NONE) {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0)))
+ goto _exit;
goto _continue;
} else if (bv == BIT_FLG_NULL) {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ if (flag == 0) {
+ code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ } else {
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0, flag > 0);
+ }
if (code) goto _exit;
goto _continue;
}
@@ -969,11 +977,20 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
uint8_t *pData = pv + *(int32_t *)(pf + pTColumn->offset);
uint32_t nData;
pData += tGetU32v(pData, &nData);
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData);
+ if (flag == 0) {
+ code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData);
+ } else {
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData, flag > 0);
+ }
if (code) goto _exit;
} else {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pf + pTColumn->offset,
- TYPE_BYTES[pColData->type]);
+ if (flag == 0) {
+ code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pf + pTColumn->offset,
+ TYPE_BYTES[pColData->type]);
+ } else {
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pf + pTColumn->offset,
+ TYPE_BYTES[pColData->type], flag > 0);
+ }
if (code) goto _exit;
}
@@ -981,17 +998,13 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
pTColumn = (++iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
} else if (pTColumn->colId > pColData->cid) { // NONE
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
-
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
} else {
pTColumn = (++iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
}
} else {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
-
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
}
}
@@ -999,7 +1012,7 @@ static int32_t tRowAppendTupleToColData(SRow *pRow, STSchema *pTSchema, SColData
_exit:
return code;
}
-static int32_t tRowAppendKVToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData) {
+static int32_t tRowKVUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag) {
int32_t code = 0;
SKVIdx *pKVIdx = (SKVIdx *)pRow->data;
@@ -1040,18 +1053,25 @@ static int32_t tRowAppendKVToColData(SRow *pRow, STSchema *pTSchema, SColData *a
if (TABS(cid) == pTColumn->colId) {
if (cid < 0) {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ if (flag == 0) {
+ code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0);
+ } else {
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0, flag > 0);
+ }
if (code) goto _exit;
} else {
+ uint32_t nData;
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
- uint32_t nData;
pData += tGetU32v(pData, &nData);
+ } else {
+ nData = 0;
+ }
+ if (flag == 0) {
code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData);
- if (code) goto _exit;
} else {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, 0);
- if (code) goto _exit;
+ code = tColDataUpdateValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, pData, nData, flag > 0);
}
+ if (code) goto _exit;
}
iCol++;
goto _continue;
@@ -1062,22 +1082,19 @@ static int32_t tRowAppendKVToColData(SRow *pRow, STSchema *pTSchema, SColData *a
}
}
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
_continue:
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
pTColumn = (++iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
} else if (pTColumn->colId > pColData->cid) {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
} else {
pTColumn = (++iTColumn < pTSchema->numOfCols) ? &pTSchema->columns[iTColumn] : NULL;
}
} else {
- code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0);
- if (code) goto _exit;
+ if (flag == 0 && (code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0))) goto _exit;
pColData = (++iColData < nColData) ? &aColData[iColData] : NULL;
}
}
@@ -1085,30 +1102,23 @@ static int32_t tRowAppendKVToColData(SRow *pRow, STSchema *pTSchema, SColData *a
_exit:
return code;
}
-int32_t tRowAppendToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData) {
+/* flag > 0: forward update
+ * flag == 0: append
+ * flag < 0: backward update
+ */
+int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag) {
ASSERT(pRow->sver == pTSchema->version);
ASSERT(nColData > 0);
- int32_t code = 0;
-
if (pRow->flag == HAS_NONE) {
- code = tRowAppendNoneToColData(aColData, nColData);
- goto _exit;
+ return tRowNoneUpsertColData(aColData, nColData, flag);
} else if (pRow->flag == HAS_NULL) {
- code = tRowAppendNullToColData(aColData, nColData, pTSchema);
- goto _exit;
+ return tRowNullUpsertColData(aColData, nColData, pTSchema, flag);
+ } else if (pRow->flag >> 4) { // KV row
+ return tRowKVUpsertColData(pRow, pTSchema, aColData, nColData, flag);
+ } else { // TUPLE row
+ return tRowTupleUpsertColData(pRow, pTSchema, aColData, nColData, flag);
}
-
- if (pRow->flag >> 4) { // KV row
- code = tRowAppendKVToColData(pRow, pTSchema, aColData, nColData);
- if (code) goto _exit;
- } else {
- code = tRowAppendTupleToColData(pRow, pTSchema, aColData, nColData);
- if (code) goto _exit;
- }
-
-_exit:
- return code;
}
// STag ========================================
@@ -1532,10 +1542,6 @@ STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) {
return pTSchema;
}
-void tDestroyTSchema(STSchema *pTSchema) {
- if (pTSchema) taosMemoryFree(pTSchema);
-}
-
// SColData ========================================
void tColDataDestroy(void *ph) {
SColData *pColData = (SColData *)ph;
@@ -1553,6 +1559,9 @@ void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
}
void tColDataClear(SColData *pColData) {
+ pColData->numOfNone = 0;
+ pColData->numOfNull = 0;
+ pColData->numOfValue = 0;
pColData->nVal = 0;
pColData->flag = 0;
pColData->nData = 0;
@@ -1598,15 +1607,18 @@ _exit:
}
static FORCE_INLINE int32_t tColDataAppendValue00(SColData *pColData, uint8_t *pData, uint32_t nData) {
pColData->flag = HAS_VALUE;
+ pColData->numOfValue++;
return tColDataPutValue(pColData, pData, nData);
}
static FORCE_INLINE int32_t tColDataAppendValue01(SColData *pColData, uint8_t *pData, uint32_t nData) {
pColData->flag = HAS_NONE;
+ pColData->numOfNone++;
pColData->nVal++;
return 0;
}
static FORCE_INLINE int32_t tColDataAppendValue02(SColData *pColData, uint8_t *pData, uint32_t nData) {
pColData->flag = HAS_NULL;
+ pColData->numOfNull++;
pColData->nVal++;
return 0;
}
@@ -1621,6 +1633,7 @@ static FORCE_INLINE int32_t tColDataAppendValue10(SColData *pColData, uint8_t *p
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
pColData->flag |= HAS_VALUE;
+ pColData->numOfValue++;
if (pColData->nVal) {
if (IS_VAR_DATA_TYPE(pColData->type)) {
@@ -1640,6 +1653,7 @@ static FORCE_INLINE int32_t tColDataAppendValue10(SColData *pColData, uint8_t *p
}
static FORCE_INLINE int32_t tColDataAppendValue11(SColData *pColData, uint8_t *pData, uint32_t nData) {
pColData->nVal++;
+ pColData->numOfNone++;
return 0;
}
static FORCE_INLINE int32_t tColDataAppendValue12(SColData *pColData, uint8_t *pData, uint32_t nData) {
@@ -1653,6 +1667,7 @@ static FORCE_INLINE int32_t tColDataAppendValue12(SColData *pColData, uint8_t *p
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
pColData->flag |= HAS_NULL;
+ pColData->numOfNull++;
pColData->nVal++;
return code;
@@ -1668,6 +1683,7 @@ static FORCE_INLINE int32_t tColDataAppendValue20(SColData *pColData, uint8_t *p
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
pColData->flag |= HAS_VALUE;
+ pColData->numOfValue++;
if (pColData->nVal) {
if (IS_VAR_DATA_TYPE(pColData->type)) {
@@ -1696,18 +1712,21 @@ static FORCE_INLINE int32_t tColDataAppendValue21(SColData *pColData, uint8_t *p
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 0);
pColData->flag |= HAS_NONE;
+ pColData->numOfNone++;
pColData->nVal++;
return code;
}
static FORCE_INLINE int32_t tColDataAppendValue22(SColData *pColData, uint8_t *pData, uint32_t nData) {
pColData->nVal++;
+ pColData->numOfNull++;
return 0;
}
static FORCE_INLINE int32_t tColDataAppendValue30(SColData *pColData, uint8_t *pData, uint32_t nData) {
int32_t code = 0;
pColData->flag |= HAS_VALUE;
+ pColData->numOfValue++;
uint8_t *pBitMap = NULL;
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
@@ -1744,6 +1763,7 @@ static FORCE_INLINE int32_t tColDataAppendValue31(SColData *pColData, uint8_t *p
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 0);
+ pColData->numOfNone++;
pColData->nVal++;
return code;
@@ -1755,15 +1775,20 @@ static FORCE_INLINE int32_t tColDataAppendValue32(SColData *pColData, uint8_t *p
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
+ pColData->numOfNull++;
pColData->nVal++;
return code;
}
-#define tColDataAppendValue40 tColDataPutValue
+static FORCE_INLINE int32_t tColDataAppendValue40(SColData *pColData, uint8_t *pData, uint32_t nData) {
+ pColData->numOfValue++;
+ return tColDataPutValue(pColData, pData, nData);
+}
static FORCE_INLINE int32_t tColDataAppendValue41(SColData *pColData, uint8_t *pData, uint32_t nData) {
int32_t code = 0;
pColData->flag |= HAS_NONE;
+ pColData->numOfNone++;
int32_t nBit = BIT1_SIZE(pColData->nVal + 1);
code = tRealloc(&pColData->pBitMap, nBit);
@@ -1778,6 +1803,7 @@ static FORCE_INLINE int32_t tColDataAppendValue42(SColData *pColData, uint8_t *p
int32_t code = 0;
pColData->flag |= HAS_NULL;
+ pColData->numOfNull++;
int32_t nBit = BIT1_SIZE(pColData->nVal + 1);
code = tRealloc(&pColData->pBitMap, nBit);
@@ -1795,6 +1821,7 @@ static FORCE_INLINE int32_t tColDataAppendValue50(SColData *pColData, uint8_t *p
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
+ pColData->numOfValue++;
return tColDataPutValue(pColData, pData, nData);
}
@@ -1805,6 +1832,7 @@ static FORCE_INLINE int32_t tColDataAppendValue51(SColData *pColData, uint8_t *p
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 0);
+ pColData->numOfNone++;
return tColDataPutValue(pColData, NULL, 0);
}
@@ -1812,6 +1840,7 @@ static FORCE_INLINE int32_t tColDataAppendValue52(SColData *pColData, uint8_t *p
int32_t code = 0;
pColData->flag |= HAS_NULL;
+ pColData->numOfNull++;
uint8_t *pBitMap = NULL;
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
@@ -1833,6 +1862,7 @@ static FORCE_INLINE int32_t tColDataAppendValue60(SColData *pColData, uint8_t *p
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 1);
+ pColData->numOfValue++;
return tColDataPutValue(pColData, pData, nData);
}
@@ -1840,6 +1870,7 @@ static FORCE_INLINE int32_t tColDataAppendValue61(SColData *pColData, uint8_t *p
int32_t code = 0;
pColData->flag |= HAS_NONE;
+ pColData->numOfNone++;
uint8_t *pBitMap = NULL;
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
@@ -1861,6 +1892,7 @@ static FORCE_INLINE int32_t tColDataAppendValue62(SColData *pColData, uint8_t *p
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
if (code) return code;
SET_BIT1_EX(pColData->pBitMap, pColData->nVal, 0);
+ pColData->numOfNull++;
return tColDataPutValue(pColData, NULL, 0);
}
@@ -1870,6 +1902,7 @@ static FORCE_INLINE int32_t tColDataAppendValue70(SColData *pColData, uint8_t *p
code = tRealloc(&pColData->pBitMap, BIT2_SIZE(pColData->nVal + 1));
if (code) return code;
SET_BIT2_EX(pColData->pBitMap, pColData->nVal, 2);
+ pColData->numOfValue++;
return tColDataPutValue(pColData, pData, nData);
}
@@ -1879,6 +1912,7 @@ static FORCE_INLINE int32_t tColDataAppendValue71(SColData *pColData, uint8_t *p
code = tRealloc(&pColData->pBitMap, BIT2_SIZE(pColData->nVal + 1));
if (code) return code;
SET_BIT2_EX(pColData->pBitMap, pColData->nVal, 0);
+ pColData->numOfNone++;
return tColDataPutValue(pColData, NULL, 0);
}
@@ -1888,6 +1922,7 @@ static FORCE_INLINE int32_t tColDataAppendValue72(SColData *pColData, uint8_t *p
code = tRealloc(&pColData->pBitMap, BIT2_SIZE(pColData->nVal + 1));
if (code) return code;
SET_BIT2_EX(pColData->pBitMap, pColData->nVal, 1);
+ pColData->numOfNull++;
return tColDataPutValue(pColData, NULL, 0);
}
@@ -1900,6 +1935,8 @@ static int32_t (*tColDataAppendValueImpl[8][3])(SColData *pColData, uint8_t *pDa
{tColDataAppendValue50, tColDataAppendValue51, tColDataAppendValue52}, // HAS_VALUE|HAS_NONE
{tColDataAppendValue60, tColDataAppendValue61, tColDataAppendValue62}, // HAS_VALUE|HAS_NULL
{tColDataAppendValue70, tColDataAppendValue71, tColDataAppendValue72}, // HAS_VALUE|HAS_NULL|HAS_NONE
+
+ // VALUE NONE NULL
};
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal) {
ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->type);
@@ -1908,6 +1945,282 @@ int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal) {
pColVal->value.nData);
}
+static FORCE_INLINE int32_t tColDataUpdateValue10(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue10(pColData, pData, nData);
+ } else {
+ pColData->flag = 0;
+ return tColDataAppendValue00(pColData, pData, nData);
+ }
+}
+static FORCE_INLINE int32_t tColDataUpdateValue12(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue12(pColData, pData, nData);
+ } else {
+ pColData->flag = 0;
+ return tColDataAppendValue02(pColData, pData, nData);
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue20(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (forward) {
+ pColData->numOfNull--;
+ pColData->nVal--;
+ if (pColData->numOfNull) {
+ return tColDataAppendValue20(pColData, pData, nData);
+ } else {
+ pColData->flag = 0;
+ return tColDataAppendValue00(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue30(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ uint8_t bv = GET_BIT1(pColData->pBitMap, pColData->nVal - 1);
+ if (bv == 0) { // NONE == > VALUE
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue30(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_NULL;
+ return tColDataAppendValue20(pColData, pData, nData);
+ }
+ } else if (forward) { // NULL == > VALUE
+ pColData->numOfNull--;
+ pColData->nVal--;
+ if (pColData->numOfNull) {
+ return tColDataAppendValue30(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_NONE;
+ return tColDataAppendValue10(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue32(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (GET_BIT1(pColData->pBitMap, pColData->nVal - 1) == 0) { // NONE ==> NULL
+ pColData->numOfNone--;
+ pColData->numOfNull++;
+ if (pColData->numOfNone) {
+ SET_BIT1(pColData->pBitMap, pColData->nVal - 1, 1);
+ } else {
+ pColData->flag = HAS_NULL;
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue40(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (forward) {
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue40(pColData, pData, nData);
+ } else {
+ pColData->flag = 0;
+ return tColDataAppendValue00(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue42(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (forward) {
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue42(pColData, pData, nData);
+ } else {
+ pColData->flag = 0;
+ return tColDataAppendValue02(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue50(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ uint8_t bv = GET_BIT1(pColData->pBitMap, pColData->nVal - 1);
+ if (bv == 0) { // NONE ==> VALUE
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue50(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_VALUE;
+ return tColDataAppendValue40(pColData, pData, nData);
+ }
+ } else if (forward) { // VALUE ==> VALUE
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue50(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_NONE;
+ return tColDataAppendValue10(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue52(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ uint8_t bv = GET_BIT1(pColData->pBitMap, pColData->nVal - 1);
+ if (bv == 0) { // NONE ==> NULL
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue52(pColData, pData, nData);
+ } else {
+ pColData->flag &= ~HAS_NONE;
+ return tColDataAppendValue42(pColData, pData, nData);
+ }
+ } else if (forward) { // VALUE ==> NULL
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue52(pColData, pData, nData);
+ } else {
+ pColData->flag &= ~HAS_VALUE;
+ return tColDataAppendValue12(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue60(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (forward) {
+ if (GET_BIT1(pColData->pBitMap, pColData->nVal - 1) == 0) { // NULL ==> VALUE
+ pColData->numOfNull--;
+ pColData->nVal--;
+ if (pColData->numOfNull) {
+ return tColDataAppendValue60(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_VALUE;
+ return tColDataAppendValue40(pColData, pData, nData);
+ }
+ } else { // VALUE ==> VALUE
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue60(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_NULL;
+ return tColDataAppendValue20(pColData, pData, nData);
+ }
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue62(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ if (forward && (GET_BIT1(pColData->pBitMap, pColData->nVal - 1) == 1)) { // VALUE ==> NULL
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue62(pColData, pData, nData);
+ } else {
+ pColData->flag = HAS_NULL;
+ return tColDataAppendValue20(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static FORCE_INLINE int32_t tColDataUpdateValue70(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ int32_t code = 0;
+
+ uint8_t bv = GET_BIT2(pColData->pBitMap, pColData->nVal - 1);
+ if (bv == 0) { // NONE ==> VALUE
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue70(pColData, pData, nData);
+ } else {
+ for (int32_t iVal = 0; iVal < pColData->nVal; ++iVal) {
+ SET_BIT1(pColData->pBitMap, iVal, GET_BIT2(pColData->pBitMap, iVal) - 1);
+ }
+ pColData->flag &= ~HAS_NONE;
+ return tColDataAppendValue60(pColData, pData, nData);
+ }
+ } else if (bv == 1) { // NULL ==> VALUE
+ if (forward) {
+ pColData->numOfNull--;
+ pColData->nVal--;
+ if (pColData->numOfNull) {
+ return tColDataAppendValue70(pColData, pData, nData);
+ } else {
+ for (int32_t iVal = 0; iVal < pColData->nVal; ++iVal) {
+ SET_BIT1(pColData->pBitMap, iVal, GET_BIT2(pColData->pBitMap, iVal) ? 1 : 0);
+ }
+ pColData->flag &= ~HAS_NULL;
+ return tColDataAppendValue50(pColData, pData, nData);
+ }
+ }
+ } else if (bv == 2) { // VALUE ==> VALUE
+ if (forward) {
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue70(pColData, pData, nData);
+ } else {
+ return tColDataPutValue(pColData, pData, nData);
+ }
+ }
+ } else {
+ ASSERT(0);
+ }
+ return 0;
+}
+static int32_t tColDataUpdateValue72(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) {
+ uint8_t bv = GET_BIT2(pColData->pBitMap, pColData->nVal - 1);
+ ASSERT(bv < 3);
+ if (bv == 0) { // NONE ==> NULL
+ pColData->numOfNone--;
+ pColData->nVal--;
+ if (pColData->numOfNone) {
+ return tColDataAppendValue72(pColData, pData, nData);
+ } else {
+ for (int32_t iVal = 0; iVal < pColData->nVal; ++iVal) {
+ SET_BIT1(pColData->pBitMap, iVal, GET_BIT2(pColData->pBitMap, iVal) - 1);
+ }
+ pColData->flag &= ~HAS_NONE;
+ return tColDataAppendValue62(pColData, pData, nData);
+ }
+ } else if (bv == 2 && forward) { // VALUE ==> NULL
+ pColData->numOfValue--;
+ pColData->nVal--;
+ if (pColData->numOfValue) {
+ return tColDataAppendValue72(pColData, pData, nData);
+ } else {
+ for (int32_t iVal = 0; iVal < pColData->nVal; ++iVal) {
+ SET_BIT1(pColData->pBitMap, iVal, GET_BIT2(pColData->pBitMap, iVal));
+ }
+ pColData->flag &= ~HAS_VALUE;
+ return tColDataAppendValue32(pColData, pData, nData);
+ }
+ }
+ return 0;
+}
+static int32_t (*tColDataUpdateValueImpl[8][3])(SColData *pColData, uint8_t *pData, uint32_t nData, bool forward) = {
+ {NULL, NULL, NULL}, // 0
+ {tColDataUpdateValue10, NULL, tColDataUpdateValue12}, // HAS_NONE
+ {tColDataUpdateValue20, NULL, NULL}, // HAS_NULL
+ {tColDataUpdateValue30, NULL, tColDataUpdateValue32}, // HAS_NULL|HAS_NONE
+ {tColDataUpdateValue40, NULL, tColDataUpdateValue42}, // HAS_VALUE
+ {tColDataUpdateValue50, NULL, tColDataUpdateValue52}, // HAS_VALUE|HAS_NONE
+ {tColDataUpdateValue60, NULL, tColDataUpdateValue62}, // HAS_VALUE|HAS_NULL
+ {tColDataUpdateValue70, NULL, tColDataUpdateValue72}, // HAS_VALUE|HAS_NULL|HAS_NONE
+
+ // VALUE NONE NULL
+};
+int32_t tColDataUpdateValue(SColData *pColData, SColVal *pColVal, bool forward) {
+ ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->type);
+ ASSERT(pColData->nVal > 0);
+
+ if (tColDataUpdateValueImpl[pColData->flag][pColVal->flag] == NULL) return 0;
+
+ return tColDataUpdateValueImpl[pColData->flag][pColVal->flag](
+ pColData, IS_VAR_DATA_TYPE(pColData->type) ? pColVal->value.pData : (uint8_t *)&pColVal->value.val,
+ pColVal->value.nData, forward);
+}
+
static FORCE_INLINE void tColDataGetValue1(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_NONE
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
}
diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c
index a9ff9a1e8b054adafde820653ede70868e9a7c46..d08110becd0e7a163c5564aa809a6d650030e356 100644
--- a/source/common/src/tglobal.c
+++ b/source/common/src/tglobal.c
@@ -76,19 +76,19 @@ bool tsEnableTelem = true;
int32_t tsTelemInterval = 43200;
char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com";
uint16_t tsTelemPort = 80;
-char* tsTelemUri = "/report";
+char *tsTelemUri = "/report";
-bool tsEnableCrashReport = true;
-char* tsClientCrashReportUri = "/ccrashreport";
-char* tsSvrCrashReportUri = "/dcrashreport";
+bool tsEnableCrashReport = true;
+char *tsClientCrashReportUri = "/ccrashreport";
+char *tsSvrCrashReportUri = "/dcrashreport";
// schemaless
char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null";
char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value.
// If set to empty system will generate table name using MD5 hash.
// true means that the name and order of cols in each line are the same(only for influx protocol)
-//bool tsSmlDataFormat = false;
-//int32_t tsSmlBatchSize = 10000;
+// bool tsSmlDataFormat = false;
+// int32_t tsSmlBatchSize = 10000;
// query
int32_t tsQueryPolicy = 1;
@@ -210,9 +210,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
int32_t taosSetTfsCfg(SConfig *pCfg);
#endif
-struct SConfig *taosGetCfg() {
- return tsCfg;
-}
+struct SConfig *taosGetCfg() { return tsCfg; }
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
char *apolloUrl) {
@@ -319,8 +317,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if (cfgAddBool(pCfg, "keepColumnName", tsKeepColumnName, true) != 0) return -1;
if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1;
if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1;
-// if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
-// if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
+ // if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1;
+ // if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1;
if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1;
if (cfgAddInt32(pCfg, "maxRetryWaitTime", tsMaxRetryWaitTime, 0, 86400000, 0) != 0) return -1;
if (cfgAddBool(pCfg, "useAdapter", tsUseAdapter, true) != 0) return -1;
@@ -353,7 +351,9 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1;
if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1;
+#if !defined(_ALPINE)
if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1;
+#endif
if (cfgAddInt32(pCfg, "pageSizeKB", tsPageSizeKB, 0, INT64_MAX, 1) != 0) return -1;
if (cfgAddInt64(pCfg, "totalMemoryKB", tsTotalMemoryKB, 0, INT64_MAX, 1) != 0) return -1;
if (cfgAddString(pCfg, "os sysname", info.sysname, 1) != 0) return -1;
@@ -662,9 +662,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN);
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
-// tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
+ // tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
-// tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
+ // tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32;
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
@@ -1048,10 +1048,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN);
} else if (strcasecmp("smlTagName", name) == 0) {
tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN);
-// } else if (strcasecmp("smlDataFormat", name) == 0) {
-// tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
-// } else if (strcasecmp("smlBatchSize", name) == 0) {
-// tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
+ // } else if (strcasecmp("smlDataFormat", name) == 0) {
+ // tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval;
+ // } else if (strcasecmp("smlBatchSize", name) == 0) {
+ // tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32;
} else if (strcasecmp("shellActivityTimer", name) == 0) {
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
} else if (strcasecmp("supportVnodes", name) == 0) {
@@ -1121,6 +1121,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
} else if (strcasecmp("uDebugFlag", name) == 0) {
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
+ } else if (strcasecmp("useAdapter", name) == 0) {
+ tsUseAdapter = cfgGetItem(pCfg, "useAdapter")->bval;
}
break;
}
diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c
index 95f74da8034eb70fff4c09802e55e6f754b79323..2ceeeefa5f7c0a1170bbcba26ef815384429dbde 100644
--- a/source/common/src/tmsg.c
+++ b/source/common/src/tmsg.c
@@ -3992,9 +3992,7 @@ int32_t tSerializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq *
if (tStartEncode(&encoder) < 0) return -1;
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
- for (int32_t i = 0; i < 8; ++i) {
- if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
- }
+ if (tEncodeI64(&encoder, pReq->compactStartTime) < 0) return -1;
tEndEncode(&encoder);
int32_t tlen = encoder.pos;
@@ -4009,9 +4007,7 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
if (tStartDecode(&decoder) < 0) return -1;
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
- for (int32_t i = 0; i < 8; ++i) {
- if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
- }
+ if (tDecodeI64(&decoder, &pReq->compactStartTime) < 0) return -1;
tEndDecode(&decoder);
tDecoderClear(&decoder);
@@ -4118,6 +4114,68 @@ int32_t tDeserializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnode
return 0;
}
+int32_t tSerializeSDisableVnodeWriteReq(void *buf, int32_t bufLen, SDisableVnodeWriteReq *pReq) {
+ SEncoder encoder = {0};
+ tEncoderInit(&encoder, buf, bufLen);
+
+ if (tStartEncode(&encoder) < 0) return -1;
+ if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1;
+ if (tEncodeI8(&encoder, pReq->disable) < 0) return -1;
+
+ tEndEncode(&encoder);
+
+ int32_t tlen = encoder.pos;
+ tEncoderClear(&encoder);
+ return tlen;
+}
+
+int32_t tDeserializeSDisableVnodeWriteReq(void *buf, int32_t bufLen, SDisableVnodeWriteReq *pReq) {
+ SDecoder decoder = {0};
+ tDecoderInit(&decoder, buf, bufLen);
+
+ if (tStartDecode(&decoder) < 0) return -1;
+ if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1;
+ if (tDecodeI8(&decoder, &pReq->disable) < 0) return -1;
+
+ tEndDecode(&decoder);
+ tDecoderClear(&decoder);
+ return 0;
+}
+
+int32_t tSerializeSAlterVnodeHashRangeReq(void *buf, int32_t bufLen, SAlterVnodeHashRangeReq *pReq) {
+ SEncoder encoder = {0};
+ tEncoderInit(&encoder, buf, bufLen);
+
+ if (tStartEncode(&encoder) < 0) return -1;
+ if (tEncodeI32(&encoder, pReq->srcVgId) < 0) return -1;
+ if (tEncodeI32(&encoder, pReq->dstVgId) < 0) return -1;
+ if (tEncodeI32(&encoder, pReq->hashBegin) < 0) return -1;
+ if (tEncodeI32(&encoder, pReq->hashEnd) < 0) return -1;
+ if (tEncodeI64(&encoder, pReq->reserved) < 0) return -1;
+
+ tEndEncode(&encoder);
+
+ int32_t tlen = encoder.pos;
+ tEncoderClear(&encoder);
+ return tlen;
+}
+
+int32_t tDeserializeSAlterVnodeHashRangeReq(void *buf, int32_t bufLen, SAlterVnodeHashRangeReq *pReq) {
+ SDecoder decoder = {0};
+ tDecoderInit(&decoder, buf, bufLen);
+
+ if (tStartDecode(&decoder) < 0) return -1;
+ if (tDecodeI32(&decoder, &pReq->srcVgId) < 0) return -1;
+ if (tDecodeI32(&decoder, &pReq->dstVgId) < 0) return -1;
+ if (tDecodeI32(&decoder, &pReq->hashBegin) < 0) return -1;
+ if (tDecodeI32(&decoder, &pReq->hashEnd) < 0) return -1;
+ if (tDecodeI64(&decoder, &pReq->reserved) < 0) return -1;
+
+ tEndDecode(&decoder);
+ tDecoderClear(&decoder);
+ return 0;
+}
+
int32_t tSerializeSKillQueryReq(void *buf, int32_t bufLen, SKillQueryReq *pReq) {
SEncoder encoder = {0};
tEncoderInit(&encoder, buf, bufLen);
@@ -5427,6 +5485,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
if (tEncodeCStr(&encoder, pField->name) < 0) return -1;
}
+
if (tEncodeI8(&encoder, pReq->createStb) < 0) return -1;
if (tEncodeU64(&encoder, pReq->targetStbUid) < 0) return -1;
if (tEncodeI32(&encoder, taosArrayGetSize(pReq->fillNullCols)) < 0) return -1;
@@ -5436,6 +5495,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
if (tEncodeI16(&encoder, pCol->colId) < 0) return -1;
if (tEncodeI8(&encoder, pCol->type) < 0) return -1;
}
+ if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1;
tEndEncode(&encoder);
@@ -5519,6 +5579,8 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
}
}
+ if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1;
+
tEndDecode(&decoder);
tDecoderClear(&decoder);
diff --git a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
index ff32cbcb08b2c743644df3b077408dfd4878e999..600a1f6829e11a1d38ffa262e7d360687c67b90d 100644
--- a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
+++ b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
@@ -48,7 +48,7 @@ int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t dmProcessGrantReq(SRpcMsg *pMsg);
+int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg);
// dmWorker.c
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c
index 76c8e09b70a31c8e9168809dea69bc1a1a3e5478..0d3b423771267cc567a4cfc95f2b550c508342d3 100644
--- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c
+++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c
@@ -234,7 +234,7 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
code = dmProcessRetrieve(pMgmt, pMsg);
break;
case TDMT_MND_GRANT:
- code = dmProcessGrantReq(pMsg);
+ code = dmProcessGrantReq(&pMgmt->pData->clusterId, pMsg);
break;
default:
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
index 16fe6c1b91f8a7788ad4a48993b337fe6bc7b160..7d11bc70827dbc6bdb1cf5d07acf24028ddb3a3c 100644
--- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
@@ -167,6 +167,7 @@ SArray *mmGetMsgHandles() {
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
+ if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SUBSCRIBE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
@@ -181,6 +182,7 @@ SArray *mmGetMsgHandles() {
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
+ if (dmSetMgmtHandle(pArray, TDMT_VND_DISABLE_WRITE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
index 095857825d3e02753a9be3a257af54815dabc973..b0810d528f761d6362b27a818636d52e8421429c 100644
--- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
@@ -49,7 +49,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
pMsg->info.node = pMgmt->pMnode;
const STraceId *trace = &pMsg->info.traceId;
- dGTrace("msg:%p, get from mnode queue", pMsg);
+ dGTrace("msg:%p, get from mnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
int32_t code = mndProcessRpcMsg(pMsg);
diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
index 6e724f4d4322c3aee7a143b1cffaa4cae155d3e7..e3fa2964b74b697cd507a9fddcb27a848010e2e1 100644
--- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
@@ -54,6 +54,7 @@ typedef struct {
int32_t vgVersion;
int32_t refCount;
int8_t dropped;
+ int8_t disable;
char *path;
SVnode *pImpl;
SMultiWorker pWriteW;
@@ -80,13 +81,15 @@ typedef struct {
SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId);
void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl);
-void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
+void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal);
// vmHandle.c
SArray *vmGetMsgHandles();
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
-int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
+int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
+int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
+int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
// vmFile.c
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
index 47772acbdce512a73f24977edb08ad62e0ccef79..2d6a4954e9694f0c284da38a8b4bb82622d797a7 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
@@ -281,7 +281,94 @@ _OVER:
return code;
}
-int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
+int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
+ SDisableVnodeWriteReq req = {0};
+ if (tDeserializeSDisableVnodeWriteReq(pMsg->pCont, pMsg->contLen, &req) != 0) {
+ terrno = TSDB_CODE_INVALID_MSG;
+ return -1;
+ }
+
+ dInfo("vgId:%d, vnode write disable:%d", req.vgId, req.disable);
+
+ SVnodeObj *pVnode = vmAcquireVnode(pMgmt, req.vgId);
+ if (pVnode == NULL) {
+ dError("vgId:%d, failed to disable write since %s", req.vgId, terrstr());
+ terrno = TSDB_CODE_VND_NOT_EXIST;
+ return -1;
+ }
+
+ pVnode->disable = req.disable;
+ vmReleaseVnode(pMgmt, pVnode);
+ return 0;
+}
+
+int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
+ SAlterVnodeHashRangeReq req = {0};
+ if (tDeserializeSAlterVnodeHashRangeReq(pMsg->pCont, pMsg->contLen, &req) != 0) {
+ terrno = TSDB_CODE_INVALID_MSG;
+ return -1;
+ }
+
+ int32_t srcVgId = req.srcVgId;
+ int32_t dstVgId = req.dstVgId;
+ dInfo("vgId:%d, start to alter vnode hashrange:[%u, %u], dstVgId:%d", req.srcVgId, req.hashBegin, req.hashEnd,
+ req.dstVgId);
+
+ SVnodeObj *pVnode = vmAcquireVnode(pMgmt, srcVgId);
+ if (pVnode == NULL) {
+ dError("vgId:%d, failed to alter hashrange since %s", srcVgId, terrstr());
+ terrno = TSDB_CODE_VND_NOT_EXIST;
+ return -1;
+ }
+
+ SWrapperCfg wrapperCfg = {
+ .dropped = pVnode->dropped,
+ .vgId = dstVgId,
+ .vgVersion = pVnode->vgVersion,
+ };
+ tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
+
+ dInfo("vgId:%d, close vnode", srcVgId);
+ vmCloseVnode(pMgmt, pVnode, true);
+
+ char srcPath[TSDB_FILENAME_LEN] = {0};
+ char dstPath[TSDB_FILENAME_LEN] = {0};
+ snprintf(srcPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, srcVgId);
+ snprintf(dstPath, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, dstVgId);
+
+ dInfo("vgId:%d, alter vnode hashrange at %s", srcVgId, srcPath);
+ if (vnodeAlterHashRange(srcPath, dstPath, &req, pMgmt->pTfs) < 0) {
+ dError("vgId:%d, failed to alter vnode hashrange since %s", srcVgId, terrstr());
+ return -1;
+ }
+
+ dInfo("vgId:%d, open vnode", dstVgId);
+ SVnode *pImpl = vnodeOpen(dstPath, pMgmt->pTfs, pMgmt->msgCb);
+ if (pImpl == NULL) {
+ dError("vgId:%d, failed to open vnode at %s since %s", dstVgId, dstPath, terrstr());
+ return -1;
+ }
+
+ if (vmOpenVnode(pMgmt, &wrapperCfg, pImpl) != 0) {
+ dError("vgId:%d, failed to open vnode mgmt since %s", dstVgId, terrstr());
+ return -1;
+ }
+
+ if (vnodeStart(pImpl) != 0) {
+ dError("vgId:%d, failed to start sync since %s", dstVgId, terrstr());
+ return -1;
+ }
+
+ if (vmWriteVnodeListToFile(pMgmt) != 0) {
+ dError("vgId:%d, failed to write vnode list since %s", dstVgId, terrstr());
+ return -1;
+ }
+
+ dInfo("vgId:%d, vnode hashrange is altered", dstVgId);
+ return 0;
+}
+
+int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
SAlterVnodeReplicaReq alterReq = {0};
if (tDeserializeSAlterVnodeReplicaReq(pMsg->pCont, pMsg->contLen, &alterReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG;
@@ -289,16 +376,16 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
int32_t vgId = alterReq.vgId;
- dInfo("vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d", alterReq.vgId, alterReq.replica,
- alterReq.selfIndex, alterReq.strict);
+ dInfo("vgId:%d, start to alter vnode replica:%d selfIndex:%d strict:%d", vgId, alterReq.replica, alterReq.selfIndex,
+ alterReq.strict);
for (int32_t i = 0; i < alterReq.replica; ++i) {
SReplica *pReplica = &alterReq.replicas[i];
- dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", alterReq.vgId, i, pReplica->fqdn, pReplica->port, pReplica->port);
+ dInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", vgId, i, pReplica->fqdn, pReplica->port, pReplica->port);
}
if (alterReq.replica <= 0 || alterReq.selfIndex < 0 || alterReq.selfIndex >= alterReq.replica) {
terrno = TSDB_CODE_INVALID_MSG;
- dError("vgId:%d, failed to alter replica since invalid msg", alterReq.vgId);
+ dError("vgId:%d, failed to alter replica since invalid msg", vgId);
return -1;
}
@@ -306,7 +393,7 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
if (pReplica->id != pMgmt->pData->dnodeId || pReplica->port != tsServerPort ||
strcmp(pReplica->fqdn, tsLocalFqdn) != 0) {
terrno = TSDB_CODE_INVALID_MSG;
- dError("vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode", alterReq.vgId, pReplica->id, pReplica->fqdn,
+ dError("vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode", vgId, pReplica->id, pReplica->fqdn,
pReplica->port);
return -1;
}
@@ -325,18 +412,18 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
.vgVersion = pVnode->vgVersion,
};
tstrncpy(wrapperCfg.path, pVnode->path, sizeof(wrapperCfg.path));
- vmCloseVnode(pMgmt, pVnode);
+ vmCloseVnode(pMgmt, pVnode, false);
char path[TSDB_FILENAME_LEN] = {0};
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vgId);
dInfo("vgId:%d, start to alter vnode replica at %s", vgId, path);
- if (vnodeAlter(path, &alterReq, pMgmt->pTfs) < 0) {
+ if (vnodeAlterReplica(path, &alterReq, pMgmt->pTfs) < 0) {
dError("vgId:%d, failed to alter vnode at %s since %s", vgId, path, terrstr());
return -1;
}
- dInfo("vgId:%d, start to open vnode", vgId);
+ dInfo("vgId:%d, close vnode", vgId);
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, pMgmt->msgCb);
if (pImpl == NULL) {
dError("vgId:%d, failed to open vnode at %s since %s", vgId, path, terrstr());
@@ -387,7 +474,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return -1;
}
- vmCloseVnode(pMgmt, pVnode);
+ vmCloseVnode(pMgmt, pVnode, false);
vmWriteVnodeListToFile(pMgmt);
dInfo("vgId:%d, is dropped", vgId);
@@ -451,7 +538,8 @@ SArray *vmGetMsgHandles() {
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
- if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
+ if (dmSetMgmtHandle(pArray, TDMT_VND_DISABLE_WRITE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
+ if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_VND_TRIM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c
index 99ba9b9b3bcc1e0efe9d1a1bb987e01c89786374..8049db9c7851086b72c86454379b85c559e72d24 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c
@@ -76,11 +76,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
return code;
}
-void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
+void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) {
char path[TSDB_FILENAME_LEN] = {0};
- vnodeProposeCommitOnNeed(pVnode->pImpl);
-
taosThreadRwlockWrlock(&pMgmt->lock);
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
taosThreadRwlockUnlock(&pMgmt->lock);
@@ -124,10 +122,26 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
vnodePostClose(pVnode->pImpl);
vmFreeQueue(pMgmt, pVnode);
+
+ if (commitAndRemoveWal) {
+ dInfo("vgId:%d, commit data", pVnode->vgId);
+ vnodeSyncCommit(pVnode->pImpl);
+ vnodeBegin(pVnode->pImpl);
+ dInfo("vgId:%d, commit data finished", pVnode->vgId);
+ }
+
vnodeClose(pVnode->pImpl);
pVnode->pImpl = NULL;
dInfo("vgId:%d, vnode is closed", pVnode->vgId);
+ if (commitAndRemoveWal) {
+ char path[TSDB_FILENAME_LEN] = {0};
+ snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d%swal", TD_DIRSEP, pVnode->vgId, TD_DIRSEP);
+ dInfo("vgId:%d, remove all wals, path:%s", pVnode->vgId, path);
+ tfsRmdir(pMgmt->pTfs, path);
+ tfsMkdir(pMgmt->pTfs, path);
+ }
+
if (pVnode->dropped) {
dInfo("vgId:%d, vnode is destroyed, dropped:%d", pVnode->vgId, pVnode->dropped);
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pVnode->vgId);
@@ -257,7 +271,7 @@ static void *vmCloseVnodeInThread(void *param) {
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
tmsgReportStartup("vnode-close", stepDesc);
- vmCloseVnode(pMgmt, pVnode);
+ vmCloseVnode(pMgmt, pVnode, false);
}
dInfo("thread:%d, numOfVnodes:%d is closed", pThread->threadIndex, pThread->vnodeNum);
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
index cd29b115508ccfcd51d9c130c4847b2ef265dba5..027b9b7d48ce2a88791e9ab4d3ab189ff287e811 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
@@ -41,7 +41,13 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
code = vmProcessDropVnodeReq(pMgmt, pMsg);
break;
case TDMT_VND_ALTER_REPLICA:
- code = vmProcessAlterVnodeReq(pMgmt, pMsg);
+ code = vmProcessAlterVnodeReplicaReq(pMgmt, pMsg);
+ break;
+ case TDMT_VND_DISABLE_WRITE:
+ code = vmProcessDisableVnodeWriteReq(pMgmt, pMsg);
+ break;
+ case TDMT_VND_ALTER_HASHRANGE:
+ code = vmProcessAlterHashRangeReq(pMgmt, pMsg);
break;
default:
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
@@ -51,7 +57,7 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
if (IsReq(pMsg)) {
if (code != 0) {
if (terrno != 0) code = terrno;
- dGError("msg:%p, failed to process since %s", pMsg, terrstr(code));
+ dGError("msg:%p, failed to process since %s, type:%s", pMsg, terrstr(code), TMSG_INFO(pMsg->msgType));
}
vmSendRsp(pMsg, code);
}
@@ -191,14 +197,21 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
terrno = TSDB_CODE_NO_DISKSPACE;
code = terrno;
dError("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
- } else if ((pMsg->msgType == TDMT_VND_SUBMIT) && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
+ break;
+ }
+ if (pMsg->msgType == TDMT_VND_SUBMIT && (grantCheck(TSDB_GRANT_STORAGE) != TSDB_CODE_SUCCESS)) {
terrno = TSDB_CODE_VND_NO_WRITE_AUTH;
code = terrno;
dDebug("vgId:%d, msg:%p put into vnode-write queue failed since %s", pVnode->vgId, pMsg, terrstr(code));
- } else {
- dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg);
- taosWriteQitem(pVnode->pWriteW.queue, pMsg);
+ break;
+ }
+ if (pMsg->msgType != TDMT_VND_ALTER_CONFIRM && pVnode->disable) {
+ dDebug("vgId:%d, msg:%p put into vnode-write queue failed since its disable", pVnode->vgId, pMsg);
+ terrno = TSDB_CODE_VND_STOPPED;
+ break;
}
+ dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg);
+ taosWriteQitem(pVnode->pWriteW.queue, pMsg);
break;
case SYNC_QUEUE:
dGTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg);
diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c
index dcb63f65246cfc103790c2e46b2ca4c8bd4beafe..d2b9618c604196a43f31a8dafccc450ef3152c10 100644
--- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c
+++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c
@@ -39,7 +39,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pMsg->msgType)];
if (msgFp == NULL) {
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
- dGError("msg:%p, not processed since no handler", pMsg);
+ dGError("msg:%p, not processed since no handler, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
return -1;
}
diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h
index cea0a43b61bf53cd1bcc47cae52000295e80fd90..9edfd9bf3b2e35c30639ad69ee84e3b1446271e3 100644
--- a/source/dnode/mnode/impl/inc/mndDb.h
+++ b/source/dnode/mnode/impl/inc/mndDb.h
@@ -30,6 +30,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
+SSdbRaw *mndDbActionEncode(SDbObj *pDb);
const char *mndGetDbStr(const char *src);
#ifdef __cplusplus
diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h
index 1cbd9bfb66b92b63dd2a01285b609eed671805f7..6ff1dc576e8d527ae8923b09802ba93eb65f6619 100644
--- a/source/dnode/mnode/impl/inc/mndDef.h
+++ b/source/dnode/mnode/impl/inc/mndDef.h
@@ -328,6 +328,7 @@ typedef struct {
SDbCfg cfg;
SRWLatch lock;
int64_t stateTs;
+ int64_t compactStartTime;
} SDbObj;
typedef struct {
@@ -649,6 +650,7 @@ typedef struct {
int64_t checkpointFreq; // ms
int64_t currentTick; // do not serialize
int64_t deleteMark;
+ int8_t igCheckUpdate;
} SStreamObj;
int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj);
diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h
index 07066d2251235d325aa9f64f2751c8248e8c7e54..d6e5d322baf28dbad41d0ea13124e1ec21588f0b 100644
--- a/source/dnode/mnode/impl/inc/mndTrans.h
+++ b/source/dnode/mnode/impl/inc/mndTrans.h
@@ -81,7 +81,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
void mndTransPullup(SMnode *pMnode);
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
-void mndTransExecute(SMnode *pMnode, STrans *pTrans);
+void mndTransExecute(SMnode *pMnode, STrans *pTrans, bool isLeader);
int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, const char *dbname);
#ifdef __cplusplus
diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h
index 765d4fd33da9fa52266a89e8fc57d247c6494a96..51eb24f40235e21a811ef48a172c75ba09b4f396 100644
--- a/source/dnode/mnode/impl/inc/mndVgroup.h
+++ b/source/dnode/mnode/impl/inc/mndVgroup.h
@@ -43,6 +43,7 @@ int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVg
int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnodeId, bool force);
int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup,
SArray *pArray);
+int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs);
void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c
index eeb4249217bbc08780939b10a2d7fb4b467226c3..eb4fc3cdad556d5af934c8e8f850dd21974d1ae2 100644
--- a/source/dnode/mnode/impl/src/mndConsumer.c
+++ b/source/dnode/mnode/impl/src/mndConsumer.c
@@ -839,10 +839,14 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
char *addedTopic = strdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0));
// not exist in current topic
-#if 0
+
+ bool existing = false;
+#if 1
for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->currentTopics); i++) {
char *topic = taosArrayGetP(pOldConsumer->currentTopics, i);
- A(strcmp(topic, addedTopic) != 0);
+ if (strcmp(topic, addedTopic) == 0) {
+ existing = true;
+ }
}
#endif
@@ -857,8 +861,10 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
}
// add to current topic
- taosArrayPush(pOldConsumer->currentTopics, &addedTopic);
- taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString);
+ if (!existing) {
+ taosArrayPush(pOldConsumer->currentTopics, &addedTopic);
+ taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString);
+ }
// set status
if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) {
diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c
index bdfda14a32772644a476b6ad6cbdc7d0e3989795..1943ab0b0f81a36bf48160266705b62b63a248d8 100644
--- a/source/dnode/mnode/impl/src/mndDb.c
+++ b/source/dnode/mnode/impl/src/mndDb.c
@@ -30,9 +30,8 @@
#include "systable.h"
#define DB_VER_NUMBER 1
-#define DB_RESERVE_SIZE 54
+#define DB_RESERVE_SIZE 46
-static SSdbRaw *mndDbActionEncode(SDbObj *pDb);
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb);
@@ -74,7 +73,7 @@ int32_t mndInitDb(SMnode *pMnode) {
void mndCleanupDb(SMnode *pMnode) {}
-static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
+SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
int32_t size = sizeof(SDbObj) + pDb->cfg.numOfRetensions * sizeof(SRetention) + DB_RESERVE_SIZE;
@@ -127,6 +126,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashPrefix, _OVER)
SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashSuffix, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.tsdbPageSize, _OVER)
+ SDB_SET_INT64(pRaw, dataPos, pDb->compactStartTime, _OVER)
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
@@ -216,6 +216,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashPrefix, _OVER)
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.tsdbPageSize, _OVER)
+ SDB_GET_INT64(pRaw, dataPos, &pDb->compactStartTime, _OVER)
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
taosInitRWLatch(&pDb->lock);
@@ -259,6 +260,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
pOld->updateTime = pNew->updateTime;
pOld->cfgVersion = pNew->cfgVersion;
pOld->vgVersion = pNew->vgVersion;
+ pOld->cfg.numOfVgroups = pNew->cfg.numOfVgroups;
pOld->cfg.buffer = pNew->cfg.buffer;
pOld->cfg.pageSize = pNew->cfg.pageSize;
pOld->cfg.pages = pNew->cfg.pages;
@@ -274,6 +276,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
pOld->cfg.replications = pNew->cfg.replications;
pOld->cfg.sstTrigger = pNew->cfg.sstTrigger;
pOld->cfg.tsdbPageSize = pNew->cfg.tsdbPageSize;
+ pOld->compactStartTime = pNew->compactStartTime;
taosWUnLockLatch(&pOld->lock);
return 0;
}
@@ -1378,7 +1381,63 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
return 0;
}
-static int32_t mndCompactDb(SMnode *pMnode, SDbObj *pDb) { return 0; }
+static int32_t mndSetCompactDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, int64_t compactTs) {
+ SDbObj dbObj = {0};
+ memcpy(&dbObj, pDb, sizeof(SDbObj));
+ dbObj.compactStartTime = compactTs;
+
+ SSdbRaw *pCommitRaw = mndDbActionEncode(&dbObj);
+ if (pCommitRaw == NULL) return -1;
+ if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) {
+ sdbFreeRaw(pCommitRaw);
+ return -1;
+ }
+
+ (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
+ return 0;
+}
+
+static int32_t mndSetCompactDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, int64_t compactTs) {
+ SSdb *pSdb = pMnode->pSdb;
+ void *pIter = NULL;
+
+ while (1) {
+ SVgObj *pVgroup = NULL;
+ pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
+ if (pIter == NULL) break;
+
+ if (mndVgroupInDb(pVgroup, pDb->uid)) {
+ if (mndBuildCompactVgroupAction(pMnode, pTrans, pDb, pVgroup, compactTs) != 0) {
+ sdbCancelFetch(pSdb, pIter);
+ sdbRelease(pSdb, pVgroup);
+ return -1;
+ }
+ }
+
+ sdbRelease(pSdb, pVgroup);
+ }
+
+ return 0;
+}
+
+static int32_t mndCompactDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
+ int64_t compactTs = taosGetTimestampMs();
+ int32_t code = -1;
+ STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "compact-db");
+ if (pTrans == NULL) goto _OVER;
+
+ mInfo("trans:%d, used to compact db:%s", pTrans->id, pDb->name);
+ mndTransSetDbName(pTrans, pDb->name, NULL);
+ if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER;
+ if (mndSetCompactDbCommitLogs(pMnode, pTrans, pDb, compactTs) != 0) goto _OVER;
+ if (mndSetCompactDbRedoActions(pMnode, pTrans, pDb, compactTs) != 0) goto _OVER;
+ if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
+ code = 0;
+
+_OVER:
+ mndTransDrop(pTrans);
+ return code;
+}
static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
@@ -1402,10 +1461,11 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
goto _OVER;
}
- code = mndCompactDb(pMnode, pDb);
+ code = mndCompactDb(pMnode, pReq, pDb);
+ if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
_OVER:
- if (code != 0) {
+ if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("db:%s, failed to process compact db req since %s", compactReq.db, terrstr());
}
diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c
index 8983d73c7078d09ec82cefc7d54592f9457330ef..da2ad158e3b3902f6b6c24fc7c4277d510ba9298 100644
--- a/source/dnode/mnode/impl/src/mndDef.c
+++ b/source/dnode/mnode/impl/src/mndDef.c
@@ -78,6 +78,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
// 3.0.20
if (tEncodeI64(pEncoder, pObj->checkpointFreq) < 0) return -1;
+ if (tEncodeI8(pEncoder, pObj->igCheckUpdate) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
@@ -145,6 +146,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) {
// 3.0.20
if (sver >= 2) {
if (tDecodeI64(pDecoder, &pObj->checkpointFreq) < 0) return -1;
+ if (tDecodeI8(pDecoder, &pObj->igCheckUpdate) < 0) return -1;
}
tEndDecode(pDecoder);
return 0;
@@ -493,7 +495,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
tlen += tEncodeSMqConsumerEp(buf, pConsumerEp);
cnt++;
}
- if(cnt != sz) return -1;
+ if (cnt != sz) return -1;
tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp);
tlen += taosEncodeString(buf, pSub->dbName);
return tlen;
diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c
index 396de7eed33102d24979653cdd05d27507641c96..42851bd16aa3f3f2351eaf35dbcfb570fe8e9492 100644
--- a/source/dnode/mnode/impl/src/mndGrant.c
+++ b/source/dnode/mnode/impl/src/mndGrant.c
@@ -129,7 +129,7 @@ void grantParseParameter() { mError("can't parsed parameter k"); }
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
void grantAdd(EGrantType grant, uint64_t value) {}
void grantRestore(EGrantType grant, uint64_t value) {}
-int32_t dmProcessGrantReq(SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
+int32_t dmProcessGrantReq(void* pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; }
#endif
diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c
index 854535c82f72bf5ca4c3340355980ecad07ff7df..c3f37d86e3f814992780a29442c77ea91dacf77d 100644
--- a/source/dnode/mnode/impl/src/mndMain.c
+++ b/source/dnode/mnode/impl/src/mndMain.c
@@ -669,9 +669,9 @@ _OVER:
mGDebug(
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
- "role:%s, redirect numOfEps:%d inUse:%d",
+ "role:%s, redirect numOfEps:%d inUse:%d, type:%s",
pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored,
- syncStr(state.restored), epSet.numOfEps, epSet.inUse);
+ syncStr(state.restored), epSet.numOfEps, epSet.inUse, TMSG_INFO(pMsg->msgType));
if (epSet.numOfEps <= 0) return -1;
diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c
index c243e83a15333c877434c07ed961c1ce2f5af9e2..6dedeaf8f31eb8ca466d3602fd3da88a42c3ddb3 100644
--- a/source/dnode/mnode/impl/src/mndStb.c
+++ b/source/dnode/mnode/impl/src/mndStb.c
@@ -41,6 +41,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq);
static int32_t mndProcessCreateStbReq(SRpcMsg *pReq);
static int32_t mndProcessAlterStbReq(SRpcMsg *pReq);
static int32_t mndProcessDropStbReq(SRpcMsg *pReq);
+static int32_t mndProcessDropTtltbReq(SRpcMsg *pReq);
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
@@ -65,6 +66,7 @@ int32_t mndInitStb(SMnode *pMnode) {
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessAlterStbReq);
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessDropStbReq);
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp);
+ mndSetMsgHandle(pMnode, TDMT_VND_DROP_TTL_TABLE_RSP, mndProcessDropTtltbReq);
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp);
mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp);
mndSetMsgHandle(pMnode, TDMT_MND_TABLE_META, mndProcessTableMetaReq);
@@ -971,9 +973,8 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
code = 0;
goto _OVER;
} else if (pStb->uid != createReq.suid) {
- mError("stb:%s, already exist while create, input suid:%" PRId64 " not match with exist suid:%" PRId64,
- createReq.name, createReq.suid, pStb->uid);
- terrno = TSDB_CODE_MND_STABLE_UID_NOT_MATCH;
+ mInfo("stb:%s, alter table does not need to be done, because table is deleted", createReq.name);
+ code = 0;
goto _OVER;
} else if (createReq.tagVer > 0 || createReq.colVer > 0) {
int32_t tagDelta = createReq.tagVer - pStb->tagVer;
@@ -2181,6 +2182,10 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
return 0;
}
+static int32_t mndProcessDropTtltbReq(SRpcMsg *pRsp) {
+ return 0;
+}
+
static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
int32_t code = -1;
diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c
index 6b54a36a6fc3b4135fb19f1bbe40ee13cdecf7c5..bf9168ac8f5df00d47f8675354de27fdd078db8b 100644
--- a/source/dnode/mnode/impl/src/mndStream.c
+++ b/source/dnode/mnode/impl/src/mndStream.c
@@ -31,6 +31,8 @@
#define MND_STREAM_VER_NUMBER 2
#define MND_STREAM_RESERVE_SIZE 64
+#define MND_STREAM_MAX_NUM 10
+
static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream);
@@ -295,6 +297,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
pObj->triggerParam = pCreate->maxDelay;
pObj->watermark = pCreate->watermark;
pObj->fillHistory = pCreate->fillHistory;
+ pObj->igCheckUpdate = pCreate->igUpdate;
memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN);
SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB);
@@ -377,6 +380,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
.triggerType = pObj->trigger == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : pObj->trigger,
.watermark = pObj->watermark,
.igExpired = pObj->igExpired,
+ .igCheckUpdate = pObj->igCheckUpdate,
};
// using ast and param to build physical plan
@@ -666,6 +670,35 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto _OVER;
}
+ {
+ int32_t numOfStream = 0;
+
+ SStreamObj *pStream = NULL;
+ void *pIter = NULL;
+
+ while (1) {
+ pIter = sdbFetch(pMnode->pSdb, SDB_STREAM, pIter, (void **)&pStream);
+ if (pIter == NULL) {
+ if (numOfStream > MND_STREAM_MAX_NUM) {
+ mError("too many streams, no more than 10 for each database");
+ terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
+ goto _OVER;
+ }
+ break;
+ }
+
+ if (pStream->sourceDbUid == streamObj.sourceDbUid) {
+ ++numOfStream;
+ }
+ sdbRelease(pMnode->pSdb, pStream);
+ if (numOfStream > MND_STREAM_MAX_NUM) {
+ mError("too many streams, no more than 10 for each database");
+ terrno = TSDB_CODE_MND_TOO_MANY_STREAMS;
+ goto _OVER;
+ }
+ }
+ }
+
pDb = mndAcquireDb(pMnode, streamObj.sourceDb);
if (pDb->cfg.replications != 1) {
mError("stream source db must have only 1 replica, but %s has %d", pDb->name, pDb->cfg.replications);
diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c
index 7dc09124039a48ad742ec641cf626b4ff3bbf3b9..f618b8afaea6642f723534934dfe175079738c67 100644
--- a/source/dnode/mnode/impl/src/mndSync.c
+++ b/source/dnode/mnode/impl/src/mndSync.c
@@ -85,7 +85,11 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
pRaw, pMgmt->transSec, pMgmt->transSeq);
if (pMeta->code == 0) {
- sdbWriteWithoutFree(pMnode->pSdb, pRaw);
+ int32_t code = sdbWriteWithoutFree(pMnode->pSdb, pRaw);
+ if (code != 0) {
+ mError("trans:%d, failed to write to sdb since %s", transId, terrstr());
+ return 0;
+ }
sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex);
}
@@ -110,8 +114,9 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
taosThreadMutexUnlock(&pMgmt->lock);
STrans *pTrans = mndAcquireTrans(pMnode, transId);
if (pTrans != NULL) {
- mInfo("trans:%d, execute in mnode which not leader or sync timeout", transId);
- mndTransExecute(pMnode, pTrans);
+ mInfo("trans:%d, execute in mnode which not leader or sync timeout, createTime:%" PRId64 " saved trans:%d",
+ transId, pTrans->createdTime, pMgmt->transId);
+ mndTransExecute(pMnode, pTrans, false);
mndReleaseTrans(pMnode, pTrans);
// sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
} else {
@@ -368,7 +373,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
taosThreadMutexLock(&pMgmt->lock);
pMgmt->errCode = 0;
- if (pMgmt->transId != 0) {
+ if (pMgmt->transId != 0 /* && pMgmt->transId != transId*/) {
mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId);
taosThreadMutexUnlock(&pMgmt->lock);
rpcFreeCont(req.pCont);
diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c
index dfcd55bcba7ca6a46a79cac2351df18a135218db..6bb286cd6f379aea8d39f9b88e0f110698474ebb 100644
--- a/source/dnode/mnode/impl/src/mndTrans.c
+++ b/source/dnode/mnode/impl/src/mndTrans.c
@@ -572,8 +572,20 @@ static void mndTransUpdateActions(SArray *pOldArray, SArray *pNewArray) {
}
static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) {
- mTrace("trans:%d, perform update action, old row:%p stage:%s, new row:%p stage:%s", pOld->id, pOld,
- mndTransStr(pOld->stage), pNew, mndTransStr(pNew->stage));
+ mTrace("trans:%d, perform update action, old row:%p stage:%s create:%" PRId64 ", new row:%p stage:%s create:%" PRId64,
+ pOld->id, pOld, mndTransStr(pOld->stage), pOld->createdTime, pNew, mndTransStr(pNew->stage),
+ pNew->createdTime);
+
+ if (pOld->createdTime != pNew->createdTime) {
+ mError("trans:%d, failed to perform update action since createTime not match, old row:%p stage:%s create:%" PRId64
+ ", new row:%p stage:%s create:%" PRId64,
+ pOld->id, pOld, mndTransStr(pOld->stage), pOld->createdTime, pNew, mndTransStr(pNew->stage),
+ pNew->createdTime);
+ // only occured while sync timeout
+ terrno = TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT;
+ return -1;
+ }
+
mndTransUpdateActions(pOld->redoActions, pNew->redoActions);
mndTransUpdateActions(pOld->undoActions, pNew->undoActions);
mndTransUpdateActions(pOld->commitActions, pNew->commitActions);
@@ -779,16 +791,18 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
}
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
- mInfo("trans:%d, sync to other mnodes, stage:%s", pTrans->id, mndTransStr(pTrans->stage));
+ mInfo("trans:%d, sync to other mnodes, stage:%s createTime:%" PRId64, pTrans->id, mndTransStr(pTrans->stage),
+ pTrans->createdTime);
int32_t code = mndSyncPropose(pMnode, pRaw, pTrans->id);
if (code != 0) {
- mError("trans:%d, failed to sync, errno:%s code:%s", pTrans->id, terrstr(), tstrerror(code));
+ mError("trans:%d, failed to sync, errno:%s code:%s createTime:%" PRId64 " saved trans:%d", pTrans->id, terrstr(),
+ tstrerror(code), pTrans->createdTime, pMnode->syncMgmt.transId);
sdbFreeRaw(pRaw);
return -1;
}
sdbFreeRaw(pRaw);
- mInfo("trans:%d, sync finished", pTrans->id);
+ mInfo("trans:%d, sync finished, createTime:%" PRId64, pTrans->id, pTrans->createdTime);
return 0;
}
@@ -891,7 +905,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
pTrans->rpcRsp = NULL;
pTrans->rpcRspLen = 0;
- mndTransExecute(pMnode, pNew);
+ mndTransExecute(pMnode, pNew, true);
mndReleaseTrans(pMnode, pNew);
return 0;
}
@@ -1054,7 +1068,7 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage),
action, pRsp->code, pAction->acceptableCode, pAction->retryCode);
- mndTransExecute(pMnode, pTrans);
+ mndTransExecute(pMnode, pTrans, true);
_OVER:
mndReleaseTrans(pMnode, pTrans);
@@ -1483,15 +1497,17 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) {
mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr());
}
- mInfo("trans:%d, execute finished, code:0x%x, failedTimes:%d", pTrans->id, pTrans->code, pTrans->failedTimes);
+ mInfo("trans:%d, execute finished, code:0x%x, failedTimes:%d createTime:%" PRId64, pTrans->id, pTrans->code,
+ pTrans->failedTimes, pTrans->createdTime);
return continueExec;
}
-void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
+void mndTransExecute(SMnode *pMnode, STrans *pTrans, bool isLeader) {
bool continueExec = true;
while (continueExec) {
- mInfo("trans:%d, continue to execute, stage:%s", pTrans->id, mndTransStr(pTrans->stage));
+ mInfo("trans:%d, continue to execute, stage:%s createTime:%" PRId64 " leader:%d", pTrans->id,
+ mndTransStr(pTrans->stage), pTrans->createdTime, isLeader);
pTrans->lastExecTime = taosGetTimestampMs();
switch (pTrans->stage) {
case TRN_STAGE_PREPARE:
@@ -1501,13 +1517,23 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
continueExec = mndTransPerformRedoActionStage(pMnode, pTrans);
break;
case TRN_STAGE_COMMIT:
- continueExec = mndTransPerformCommitStage(pMnode, pTrans);
+ if (isLeader) {
+ continueExec = mndTransPerformCommitStage(pMnode, pTrans);
+ } else {
+ mInfo("trans:%d, can not commit since not leader", pTrans->id);
+ continueExec = false;
+ }
break;
case TRN_STAGE_COMMIT_ACTION:
continueExec = mndTransPerformCommitActionStage(pMnode, pTrans);
break;
case TRN_STAGE_ROLLBACK:
- continueExec = mndTransPerformRollbackStage(pMnode, pTrans);
+ if (isLeader) {
+ continueExec = mndTransPerformRollbackStage(pMnode, pTrans);
+ } else {
+ mInfo("trans:%d, can not rollback since not leader", pTrans->id);
+ continueExec = false;
+ }
break;
case TRN_STAGE_UNDO_ACTION:
continueExec = mndTransPerformUndoActionStage(pMnode, pTrans);
@@ -1550,7 +1576,7 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
pAction->errCode = 0;
}
- mndTransExecute(pMnode, pTrans);
+ mndTransExecute(pMnode, pTrans, true);
return 0;
}
@@ -1608,7 +1634,7 @@ void mndTransPullup(SMnode *pMnode) {
int32_t *pTransId = taosArrayGet(pArray, i);
STrans *pTrans = mndAcquireTrans(pMnode, *pTransId);
if (pTrans != NULL) {
- mndTransExecute(pMnode, pTrans);
+ mndTransExecute(pMnode, pTrans, true);
}
mndReleaseTrans(pMnode, pTrans);
}
diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c
index 54ea9e7b2437b303088fcdd9d003eb1aa19af8e5..171916b63756402037fed985133a098008289bc2 100644
--- a/source/dnode/mnode/impl/src/mndVgroup.c
+++ b/source/dnode/mnode/impl/src/mndVgroup.c
@@ -59,6 +59,7 @@ int32_t mndInitVgroup(SMnode *pMnode) {
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_HASHRANGE_RSP, mndTransProcessRsp);
mndSetMsgHandle(pMnode, TDMT_DND_DROP_VNODE_RSP, mndTransProcessRsp);
mndSetMsgHandle(pMnode, TDMT_VND_COMPACT_RSP, mndTransProcessRsp);
+ mndSetMsgHandle(pMnode, TDMT_VND_DISABLE_WRITE_RSP, mndTransProcessRsp);
mndSetMsgHandle(pMnode, TDMT_MND_REDISTRIBUTE_VGROUP, mndProcessRedistributeVgroupMsg);
mndSetMsgHandle(pMnode, TDMT_MND_SPLIT_VGROUP, mndProcessSplitVgroupMsg);
@@ -355,9 +356,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
SReplica *pReplica = &alterReq.replicas[v];
SVnodeGid *pVgid = &pVgroup->vnodeGid[v];
SDnodeObj *pVgidDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
- if (pVgidDnode == NULL) {
- return NULL;
- }
+ if (pVgidDnode == NULL) return NULL;
pReplica->id = pVgidDnode->id;
pReplica->port = pVgidDnode->port;
@@ -397,6 +396,57 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
return pReq;
}
+static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t vgId, int32_t *pContLen) {
+ SDisableVnodeWriteReq disableReq = {
+ .vgId = vgId,
+ .disable = 1,
+ };
+
+ mInfo("vgId:%d, build disable vnode write req", vgId);
+ int32_t contLen = tSerializeSDisableVnodeWriteReq(NULL, 0, &disableReq);
+ if (contLen < 0) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
+
+ void *pReq = taosMemoryMalloc(contLen);
+ if (pReq == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
+
+ tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq);
+ *pContLen = contLen;
+ return pReq;
+}
+
+static void *mndBuildAlterVnodeHashRangeReq(SMnode *pMnode, SVgObj *pVgroup, int32_t dstVgId, int32_t *pContLen) {
+ SAlterVnodeHashRangeReq alterReq = {
+ .srcVgId = pVgroup->vgId,
+ .dstVgId = dstVgId,
+ .hashBegin = pVgroup->hashBegin,
+ .hashEnd = pVgroup->hashEnd,
+ };
+
+ mInfo("vgId:%d, build alter vnode hashrange req, dstVgId:%d, hashrange:[%u, %u]", pVgroup->vgId, dstVgId,
+ pVgroup->hashBegin, pVgroup->hashEnd);
+ int32_t contLen = tSerializeSAlterVnodeHashRangeReq(NULL, 0, &alterReq);
+ if (contLen < 0) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
+
+ void *pReq = taosMemoryMalloc(contLen);
+ if (pReq == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
+
+ tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq);
+ *pContLen = contLen;
+ return pReq;
+}
+
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
SDropVnodeReq dropReq = {0};
dropReq.dnodeId = pDnode->id;
@@ -478,7 +528,12 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
return pArray;
}
-static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; }
+static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) {
+ if (*dnode1Id == *dnode2Id) {
+ return 0;
+ }
+ return *dnode1Id > *dnode2Id ? 1 : -1;
+}
static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float ratio) {
float totalDnodes = pDnode->numOfVnodes + (float)pDnode->numOfOtherNodes * ratio + additionDnodes;
@@ -486,9 +541,12 @@ static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float r
}
static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
- float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9);
- float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9);
- return d1Score >= d2Score ? 1 : 0;
+ float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9);
+ float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9);
+ if (d1Score == d2Score) {
+ return 0;
+ }
+ return d1Score > d2Score ? 1 : -1;
}
void mndSortVnodeGid(SVgObj *pVgroup) {
@@ -746,6 +804,13 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false);
+ // pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
+ // if (pDb == NULL || pDb->compactStartTime <= 0) {
+ // colDataAppendNULL(pColInfo, numOfRows);
+ // } else {
+ // colDataAppend(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false);
+ // }
+
numOfRows++;
sdbRelease(pSdb, pVgroup);
}
@@ -1029,6 +1094,7 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
STransAction action = {0};
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
+ mInfo("vgId:%d, build alter vnode confirm req", pVgroup->vgId);
int32_t contLen = sizeof(SMsgHead);
SMsgHead *pHead = taosMemoryMalloc(contLen);
if (pHead == NULL) {
@@ -1053,7 +1119,25 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
return 0;
}
-int32_t mndAddAlterVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) { return 0; }
+static int32_t mndAddAlterVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans, SVgObj *pVgroup, int32_t dstVgId) {
+ STransAction action = {0};
+ action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
+
+ int32_t contLen = 0;
+ void *pReq = mndBuildAlterVnodeHashRangeReq(pMnode, pVgroup, dstVgId, &contLen);
+ if (pReq == NULL) return -1;
+
+ action.pCont = pReq;
+ action.contLen = contLen;
+ action.msgType = TDMT_VND_ALTER_HASHRANGE;
+
+ if (mndTransAppendRedoAction(pTrans, &action) != 0) {
+ taosMemoryFree(pReq);
+ return -1;
+ }
+
+ return 0;
+}
int32_t mndAddAlterVnodeConfigAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
STransAction action = {0};
@@ -1099,6 +1183,31 @@ int32_t mndAddAlterVnodeReplicaAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
return 0;
}
+static int32_t mndAddDisableVnodeWriteAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
+ int32_t dnodeId) {
+ SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId);
+ if (pDnode == NULL) return -1;
+
+ STransAction action = {0};
+ action.epSet = mndGetDnodeEpset(pDnode);
+ mndReleaseDnode(pMnode, pDnode);
+
+ int32_t contLen = 0;
+ void *pReq = mndBuildDisableVnodeWriteReq(pMnode, pDb, pVgroup->vgId, &contLen);
+ if (pReq == NULL) return -1;
+
+ action.pCont = pReq;
+ action.contLen = contLen;
+ action.msgType = TDMT_VND_DISABLE_WRITE;
+
+ if (mndTransAppendRedoAction(pTrans, &action) != 0) {
+ taosMemoryFree(pReq);
+ return -1;
+ }
+
+ return 0;
+}
+
int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
bool isRedo) {
STransAction action = {0};
@@ -1763,9 +1872,11 @@ static int32_t mndAddAdjustVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans,
}
static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup) {
- int32_t code = -1;
- STrans *pTrans = NULL;
- SArray *pArray = mndBuildDnodesArray(pMnode, 0);
+ int32_t code = -1;
+ STrans *pTrans = NULL;
+ SSdbRaw *pRaw = NULL;
+ SDbObj dbObj = {0};
+ SArray *pArray = mndBuildDnodesArray(pMnode, 0);
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup");
if (pTrans == NULL) goto _OVER;
@@ -1784,23 +1895,20 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
if (mndAddVnodeToVgroup(pMnode, pTrans, &newVg1, pArray) != 0) goto _OVER;
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[0].dnodeId) != 0) goto _OVER;
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg1, &newVg1.vnodeGid[1]) != 0) goto _OVER;
- if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
} else if (newVg1.replica == 3) {
SVnodeGid del1 = {0};
if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVg1, pArray, &del1) != 0) goto _OVER;
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg1, &del1, true) != 0) goto _OVER;
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[0].dnodeId) != 0) goto _OVER;
if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[1].dnodeId) != 0) goto _OVER;
- if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
} else {
goto _OVER;
}
- mInfo("vgId:%d, vgroup info after adjust replica, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg1.vgId,
- newVg1.replica, newVg1.hashBegin, newVg1.hashEnd, newVg1.vnodeGid[0].dnodeId);
for (int32_t i = 0; i < newVg1.replica; ++i) {
- mInfo("vgId:%d, vnode:%d dnode:%d", newVg1.vgId, i, newVg1.vnodeGid[i].dnodeId);
+ if (mndAddDisableVnodeWriteAction(pMnode, pTrans, pDb, &newVg1, newVg1.vnodeGid[i].dnodeId) != 0) goto _OVER;
}
+ if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
SVgObj newVg2 = {0};
memcpy(&newVg2, &newVg1, sizeof(SVgObj));
@@ -1813,15 +1921,25 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
memcpy(&newVg2.vnodeGid[0], &newVg2.vnodeGid[1], sizeof(SVnodeGid));
memset(&newVg2.vnodeGid[1], 0, sizeof(SVnodeGid));
- mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg1.vgId,
- newVg1.replica, newVg1.hashBegin, newVg1.hashEnd, newVg1.vnodeGid[0].dnodeId);
- mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg2.vgId,
- newVg2.replica, newVg2.hashBegin, newVg2.hashEnd, newVg2.vnodeGid[0].dnodeId);
+ mInfo("vgId:%d, vgroup info after split, replica:%d hashrange:[%u, %u] vnode:0 dnode:%d", newVg1.vgId, newVg1.replica,
+ newVg1.hashBegin, newVg1.hashEnd, newVg1.vnodeGid[0].dnodeId);
+ for (int32_t i = 0; i < newVg1.replica; ++i) {
+ mInfo("vgId:%d, vnode:%d dnode:%d", newVg1.vgId, i, newVg1.vnodeGid[i].dnodeId);
+ }
+ mInfo("vgId:%d, vgroup info after split, replica:%d hashrange:[%u, %u] vnode:0 dnode:%d", newVg2.vgId, newVg2.replica,
+ newVg2.hashBegin, newVg2.hashEnd, newVg2.vnodeGid[0].dnodeId);
+ for (int32_t i = 0; i < newVg1.replica; ++i) {
+ mInfo("vgId:%d, vnode:%d dnode:%d", newVg2.vgId, i, newVg2.vnodeGid[i].dnodeId);
+ }
+
+ int32_t maxVgId = sdbGetMaxId(pMnode->pSdb, SDB_VGROUP);
+ if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, &newVg1, maxVgId) != 0) goto _OVER;
+ newVg1.vgId = maxVgId;
- if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER;
- if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg2) != 0) goto _OVER;
+ maxVgId++;
+ if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, &newVg2, maxVgId) != 0) goto _OVER;
+ newVg2.vgId = maxVgId;
-#if 0
// adjust vgroup replica
if (pDb->cfg.replications != newVg1.replica) {
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER;
@@ -1829,38 +1947,38 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
if (pDb->cfg.replications != newVg2.replica) {
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray) != 0) goto _OVER;
}
-#endif
- {
- SSdbRaw *pRaw = mndVgroupActionEncode(&newVg1);
- if (pRaw == NULL) return -1;
- if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
- sdbFreeRaw(pRaw);
- return -1;
- }
- (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
- }
+ pRaw = mndVgroupActionEncode(&newVg1);
+ if (pRaw == NULL) goto _OVER;
+ if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
+ (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
+ pRaw = NULL;
- {
- SSdbRaw *pRaw = mndVgroupActionEncode(&newVg2);
- if (pRaw == NULL) return -1;
- if (mndTransAppendCommitlog(pTrans, pRaw) != 0) {
- sdbFreeRaw(pRaw);
- return -1;
- }
- (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
- }
+ pRaw = mndVgroupActionEncode(&newVg2);
+ if (pRaw == NULL) goto _OVER;
+ if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
+ (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
+ pRaw = NULL;
- mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg1.vgId,
- newVg1.replica, newVg1.hashBegin, newVg1.hashEnd, newVg1.vnodeGid[0].dnodeId);
- for (int32_t i = 0; i < newVg1.replica; ++i) {
- mInfo("vgId:%d, vnode:%d dnode:%d", newVg1.vgId, i, newVg1.vnodeGid[i].dnodeId);
- }
- mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg2.vgId,
- newVg2.replica, newVg2.hashBegin, newVg2.hashEnd, newVg2.vnodeGid[0].dnodeId);
- for (int32_t i = 0; i < newVg1.replica; ++i) {
- mInfo("vgId:%d, vnode:%d dnode:%d", newVg2.vgId, i, newVg2.vnodeGid[i].dnodeId);
- }
+ pRaw = mndVgroupActionEncode(pVgroup);
+ if (pRaw == NULL) goto _OVER;
+ if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
+ (void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
+ pRaw = NULL;
+
+ memcpy(&dbObj, pDb, sizeof(SDbObj));
+ if (dbObj.cfg.pRetensions != NULL) {
+ dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
+ if (dbObj.cfg.pRetensions == NULL) goto _OVER;
+ }
+ dbObj.vgVersion++;
+ dbObj.updateTime = taosGetTimestampMs();
+ dbObj.cfg.numOfVgroups++;
+ pRaw = mndDbActionEncode(&dbObj);
+ if (pRaw == NULL) goto _OVER;
+ if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
+ (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
+ pRaw = NULL;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
code = 0;
@@ -1868,22 +1986,29 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
_OVER:
taosArrayDestroy(pArray);
mndTransDrop(pTrans);
+ sdbFreeRaw(pRaw);
+ taosArrayDestroy(dbObj.cfg.pRetensions);
return code;
}
static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
int32_t code = -1;
- int32_t vgId = 2;
SVgObj *pVgroup = NULL;
SDbObj *pDb = NULL;
- mInfo("vgId:%d, start to split", vgId);
+ SSplitVgroupReq req = {0};
+ if (tDeserializeSSplitVgroupReq(pReq->pCont, pReq->contLen, &req) != 0) {
+ terrno = TSDB_CODE_INVALID_MSG;
+ goto _OVER;
+ }
+
+ mInfo("vgId:%d, start to split", req.vgId);
if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_SPLIT_VGROUP) != 0) {
goto _OVER;
}
- pVgroup = mndAcquireVgroup(pMnode, vgId);
+ pVgroup = mndAcquireVgroup(pMnode, req.vgId);
if (pVgroup == NULL) goto _OVER;
pDb = mndAcquireDb(pMnode, pVgroup->dbName);
@@ -2083,3 +2208,59 @@ _OVER:
}
bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid) { return !pVgroup->isTsma && pVgroup->dbUid == dbUid; }
+
+static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen,
+ int64_t compactTs) {
+ SCompactVnodeReq compactReq = {0};
+ compactReq.dbUid = pDb->uid;
+ compactReq.compactStartTime = compactTs;
+ tstrncpy(compactReq.db, pDb->name, TSDB_DB_FNAME_LEN);
+
+ mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId);
+ int32_t contLen = tSerializeSCompactVnodeReq(NULL, 0, &compactReq);
+ 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);
+
+ tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq);
+ *pContLen = contLen;
+ return pReq;
+}
+
+static int32_t mndAddCompactVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup,
+ int64_t compactTs) {
+ STransAction action = {0};
+ action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
+
+ int32_t contLen = 0;
+ void *pReq = mndBuildCompactVnodeReq(pMnode, pDb, pVgroup, &contLen, compactTs);
+ if (pReq == NULL) return -1;
+
+ action.pCont = pReq;
+ action.contLen = contLen;
+ action.msgType = TDMT_VND_COMPACT;
+
+ if (mndTransAppendRedoAction(pTrans, &action) != 0) {
+ taosMemoryFree(pReq);
+ return -1;
+ }
+
+ return 0;
+}
+
+int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs) {
+ if (mndAddCompactVnodeAction(pMnode, pTrans, pDb, pVgroup, compactTs) != 0) return -1;
+ return 0;
+}
\ No newline at end of file
diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c
index 860db20fa87e225f43e33e7b25f728a13f65846a..1d2f4da26b8150c7d92344d091421afd151adcde 100644
--- a/source/dnode/snode/src/snode.c
+++ b/source/dnode/snode/src/snode.c
@@ -93,6 +93,8 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t ver) {
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
ASSERT(pTask->exec.executor);
+ streamSetupTrigger(pTask);
+
return 0;
}
diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt
index 1f7a059ffc30623ddbdc442a9cbeb770afb57fff..ea7046886e5e383ca30a009253ea983d70ba264a 100644
--- a/source/dnode/vnode/CMakeLists.txt
+++ b/source/dnode/vnode/CMakeLists.txt
@@ -14,6 +14,7 @@ target_sources(
"src/vnd/vnodeSvr.c"
"src/vnd/vnodeSync.c"
"src/vnd/vnodeSnapshot.c"
+ "src/vnd/vnodeCompact.c"
# meta
"src/meta/metaOpen.c"
@@ -53,6 +54,7 @@ target_sources(
"src/tsdb/tsdbDiskData.c"
"src/tsdb/tsdbCompact.c"
"src/tsdb/tsdbMergeTree.c"
+ "src/tsdb/tsdbDataIter.c"
# tq
"src/tq/tq.c"
diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h
index 7d368c76c55d61af9305acb23d180cefdc936396..680cbbf92937124074775735a92fe0728f7b1d1c 100644
--- a/source/dnode/vnode/inc/vnode.h
+++ b/source/dnode/vnode/inc/vnode.h
@@ -50,13 +50,16 @@ extern const SVnodeCfg vnodeCfgDefault;
int32_t vnodeInit(int32_t nthreads);
void vnodeCleanup();
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
-int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
+int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
+int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnodeHashRangeReq *pReq, STfs *pTfs);
void vnodeDestroy(const char *path, STfs *pTfs);
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
void vnodePreClose(SVnode *pVnode);
void vnodePostClose(SVnode *pVnode);
void vnodeSyncCheckTimeout(SVnode *pVnode);
void vnodeClose(SVnode *pVnode);
+int32_t vnodeSyncCommit(SVnode *pVnode);
+int32_t vnodeBegin(SVnode* pVnode);
int32_t vnodeStart(SVnode *pVnode);
void vnodeStop(SVnode *pVnode);
@@ -178,7 +181,6 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL
void tsdbReaderClose(STsdbReader *pReader);
bool tsdbNextDataBlock(STsdbReader *pReader);
-void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave);
void tsdbReleaseDataBlock(STsdbReader *pReader);
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
@@ -268,8 +270,8 @@ int32_t tqReaderSetSubmitReq2(STqReader *pReader, void *msgStr, int32_t msgLen,
// int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver);
bool tqNextDataBlock2(STqReader *pReader);
bool tqNextDataBlockFilterOut2(STqReader *pReader, SHashObj *filterOutUids);
-int32_t tqRetrieveDataBlock2(SSDataBlock *pBlock, STqReader *pReader);
-int32_t tqRetrieveTaosxBlock2(STqReader *pReader, SArray *blocks, SArray *schemas);
+int32_t tqRetrieveDataBlock2(SSDataBlock *pBlock, STqReader *pReader, SSubmitTbData** pSubmitTbDataRet);
+int32_t tqRetrieveTaosxBlock2(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData** pSubmitTbDataRet);
// int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
// int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas);
diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h
index 007207562380f1e29ca7309025bf774dff27e333..c3e8d7ef1dacd2d0c7aaf143f09d3a9de88eec2e 100644
--- a/source/dnode/vnode/src/inc/sma.h
+++ b/source/dnode/vnode/src/inc/sma.h
@@ -209,6 +209,8 @@ static FORCE_INLINE void tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
smaDebug("vgId:%d, unref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref);
}
+int32_t smaPreClose(SSma *pSma);
+
// rsma
void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
int32_t tdRSmaFSOpen(SSma *pSma, int64_t version, int8_t rollback);
diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h
index 8c8775548d21702a31d4adc7e9d7f1c6aa30fa4c..5e97e75025fb9314cfc0b0e35a95bea528eaa9d1 100644
--- a/source/dnode/vnode/src/inc/tsdb.h
+++ b/source/dnode/vnode/src/inc/tsdb.h
@@ -69,6 +69,8 @@ typedef struct SDiskCol SDiskCol;
typedef struct SDiskData SDiskData;
typedef struct SDiskDataBuilder SDiskDataBuilder;
typedef struct SBlkInfo SBlkInfo;
+typedef struct STsdbDataIter2 STsdbDataIter2;
+typedef struct STsdbFilterInfo STsdbFilterInfo;
#define TSDBROW_ROW_FMT ((int8_t)0x0)
#define TSDBROW_COL_FMT ((int8_t)0x1)
@@ -163,6 +165,8 @@ void tBlockDataDestroy(SBlockData *pBlockData);
int32_t tBlockDataInit(SBlockData *pBlockData, TABLEID *pId, STSchema *pTSchema, int16_t *aCid, int32_t nCid);
void tBlockDataReset(SBlockData *pBlockData);
int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid);
+int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid);
+int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid);
void tBlockDataClear(SBlockData *pBlockData);
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData);
int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut, int32_t *szOut, uint8_t *aBuf[],
@@ -206,6 +210,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
uint8_t **ppBuf);
int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, int32_t nVal, SColData *pColData,
uint8_t **ppBuf);
+int32_t tRowInfoCmprFn(const void *p1, const void *p2);
// tsdbMemTable ==============================================================================================
// SMemTable
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
@@ -276,6 +281,7 @@ int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *m
int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk);
int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pBlock, SArray *aColumnDataAgg);
int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pBlock, SBlockData *pBlockData);
+int32_t tsdbReadDataBlockEx(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData);
int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData);
int32_t tsdbReadSttBlockEx(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData);
// SDelFWriter
@@ -307,6 +313,26 @@ int32_t tDiskDataBuilderInit(SDiskDataBuilder *pBuilder, STSchema *pTSchema, TAB
int32_t tDiskDataBuilderClear(SDiskDataBuilder *pBuilder);
int32_t tDiskDataAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTSchema, TABLEID *pId);
int32_t tGnrtDiskData(SDiskDataBuilder *pBuilder, const SDiskData **ppDiskData, const SBlkInfo **ppBlkInfo);
+// tsdbDataIter.c ==============================================================================================
+#define TSDB_MEM_TABLE_DATA_ITER 0
+#define TSDB_DATA_FILE_DATA_ITER 1
+#define TSDB_STT_FILE_DATA_ITER 2
+#define TSDB_TOMB_FILE_DATA_ITER 3
+
+#define TSDB_FILTER_FLAG_BY_VERSION 0x1
+#define TSDB_FILTER_FLAG_BY_TABLEID 0x2
+
+#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2 *)(((char *)pNode) - offsetof(STsdbDataIter2, rbtn)))
+/* open */
+int32_t tsdbOpenDataFileDataIter(SDataFReader *pReader, STsdbDataIter2 **ppIter);
+int32_t tsdbOpenSttFileDataIter(SDataFReader *pReader, int32_t iStt, STsdbDataIter2 **ppIter);
+int32_t tsdbOpenTombFileDataIter(SDelFReader *pReader, STsdbDataIter2 **ppIter);
+/* close */
+void tsdbCloseDataIter2(STsdbDataIter2 *pIter);
+/* cmpr */
+int32_t tsdbDataIterCmprFn(const SRBTreeNode *pNode1, const SRBTreeNode *pNode2);
+/* next */
+int32_t tsdbDataIterNext2(STsdbDataIter2 *pIter, STsdbFilterInfo *pFilterInfo);
// structs =======================
struct STsdbFS {
@@ -324,6 +350,8 @@ struct STsdb {
STsdbFS fs;
SLRUCache *lruCache;
TdThreadMutex lruMutex;
+ SLRUCache *biCache;
+ TdThreadMutex biMutex;
};
struct TSDBKEY {
@@ -641,6 +669,7 @@ struct SDataFReader {
uint8_t *aBuf[3];
};
+// NOTE: do NOT change the order of the fields
typedef struct {
int64_t suid;
int64_t uid;
@@ -763,6 +792,9 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr,
int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **h);
int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h);
+int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle);
+int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h);
+
int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey);
@@ -824,6 +856,65 @@ static FORCE_INLINE TSDBROW *tsdbTbDataIterGet(STbDataIter *pIter) {
return pIter->pRow;
}
+int32_t tRowInfoCmprFn(const void *p1, const void *p2);
+
+typedef struct {
+ int64_t suid;
+ int64_t uid;
+ SDelData delData;
+} SDelInfo;
+
+struct STsdbDataIter2 {
+ STsdbDataIter2 *next;
+ SRBTreeNode rbtn;
+
+ int32_t type;
+ SRowInfo rowInfo;
+ SDelInfo delInfo;
+ union {
+ // TSDB_MEM_TABLE_DATA_ITER
+ struct {
+ SMemTable *pMemTable;
+ } mIter;
+
+ // TSDB_DATA_FILE_DATA_ITER
+ struct {
+ SDataFReader *pReader;
+ SArray *aBlockIdx; // SArray
+ SMapData mDataBlk;
+ SBlockData bData;
+ int32_t iBlockIdx;
+ int32_t iDataBlk;
+ int32_t iRow;
+ } dIter;
+
+ // TSDB_STT_FILE_DATA_ITER
+ struct {
+ SDataFReader *pReader;
+ int32_t iStt;
+ SArray *aSttBlk;
+ SBlockData bData;
+ int32_t iSttBlk;
+ int32_t iRow;
+ } sIter;
+ // TSDB_TOMB_FILE_DATA_ITER
+ struct {
+ SDelFReader *pReader;
+ SArray *aDelIdx;
+ SArray *aDelData;
+ int32_t iDelIdx;
+ int32_t iDelData;
+ } tIter;
+ };
+};
+
+struct STsdbFilterInfo {
+ int32_t flag;
+ int64_t sver;
+ int64_t ever;
+ TABLEID tbid;
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h
index e0d0e9408b1dde6edf29b895a4c3c916105de646..88cd1d99e1d9fda6dc28479c4c500220ca37ab96 100644
--- a/source/dnode/vnode/src/inc/vnd.h
+++ b/source/dnode/vnode/src/inc/vnd.h
@@ -100,12 +100,16 @@ int32_t vnodeShouldCommit(SVnode* pVnode);
void vnodeUpdCommitSched(SVnode* pVnode);
void vnodeRollback(SVnode* pVnode);
int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
-int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
+int32_t vnodeCommitInfo(const char* dir);
int32_t vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
int32_t vnodeSyncCommit(SVnode* pVnode);
int32_t vnodeAsyncCommit(SVnode* pVnode);
bool vnodeShouldRollback(SVnode* pVnode);
+// vnodeCompact.c
+int32_t vnodeAsyncCompact(SVnode* pVnode);
+int32_t vnodeSyncCompact(SVnode* pVnode);
+
// vnodeSync.c
int32_t vnodeSyncOpen(SVnode* pVnode, char* path);
int32_t vnodeSyncStart(SVnode* pVnode);
diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h
index 9c5f47b731e2393aca1d21099fbfec6373d97cd0..4c44d799b1e5ee40aaa41c2fb129484127d1e9c0 100644
--- a/source/dnode/vnode/src/inc/vnodeInt.h
+++ b/source/dnode/vnode/src/inc/vnodeInt.h
@@ -76,6 +76,7 @@ typedef struct SRSmaSnapReader SRSmaSnapReader;
typedef struct SRSmaSnapWriter SRSmaSnapWriter;
typedef struct SSnapDataHdr SSnapDataHdr;
typedef struct SCommitInfo SCommitInfo;
+typedef struct SCompactInfo SCompactInfo;
typedef struct SQueryNode SQueryNode;
#define VNODE_META_DIR "meta"
@@ -173,6 +174,7 @@ int tsdbClose(STsdb** pTsdb);
int32_t tsdbBegin(STsdb* pTsdb);
int32_t tsdbPrepareCommit(STsdb* pTsdb);
int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo);
+int32_t tsdbCompact(STsdb* pTsdb, SCompactInfo* pInfo);
int32_t tsdbFinishCommit(STsdb* pTsdb);
int32_t tsdbRollbackCommit(STsdb* pTsdb);
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
@@ -252,7 +254,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader);
int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData);
// STsdbSnapWriter ========================================
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter);
-int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
+int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr);
int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter);
int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback);
// STqSnapshotReader ==
@@ -452,6 +454,12 @@ struct SCommitInfo {
TXN* txn;
};
+struct SCompactInfo {
+ SVnode* pVnode;
+ int32_t flag;
+ int64_t commitID;
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/source/dnode/vnode/src/meta/metaCommit.c b/source/dnode/vnode/src/meta/metaCommit.c
index f61930b84cf54b189af0bc36cb66ff69402b27fc..f597c100d0588dae9123af444dc442c0b7de2c2b 100644
--- a/source/dnode/vnode/src/meta/metaCommit.c
+++ b/source/dnode/vnode/src/meta/metaCommit.c
@@ -56,4 +56,7 @@ int metaPrepareAsyncCommit(SMeta *pMeta) {
}
// abort the meta txn
-int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, pMeta->txn); }
+int metaAbort(SMeta *pMeta) {
+ if (!pMeta->txn) return 0;
+ return tdbAbort(pMeta->pEnv, pMeta->txn);
+}
diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c
index 609ffc58c3d4ed00c3b5db729179a3559b36e93d..e5bc301fa17928e20434e378fcb16a4bb278ea78 100644
--- a/source/dnode/vnode/src/meta/metaOpen.c
+++ b/source/dnode/vnode/src/meta/metaOpen.c
@@ -203,7 +203,7 @@ _err:
int metaClose(SMeta *pMeta) {
if (pMeta) {
- if (pMeta->pEnv) tdbAbort(pMeta->pEnv, pMeta->txn);
+ if (pMeta->pEnv) metaAbort(pMeta);
if (pMeta->pCache) metaCacheClose(pMeta);
if (pMeta->pIdx) metaCloseIdx(pMeta);
if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb);
diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c
index fc41d507a8936eb5e35db53508b74c6dd03d2374..6741b7ca456e78a99f326a77028511039c37b2a0 100644
--- a/source/dnode/vnode/src/meta/metaQuery.c
+++ b/source/dnode/vnode/src/meta/metaQuery.c
@@ -706,9 +706,8 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
}
}
- if (sver <= 0) {
- metaError("meta/query: incorrect sver: %" PRId32 ".", sver);
- code = TSDB_CODE_FAILED;
+ if (ASSERTS(sver > 0, __FILE__, __LINE__, "failed to get table schema version: %d", sver)) {
+ code = TSDB_CODE_NOT_FOUND;
goto _exit;
}
diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c
index 78e0643e1076c04529e04c98e347016aeec0076b..335cfc32d5b9e0cb247417c6452cba82c035c72e 100644
--- a/source/dnode/vnode/src/meta/metaTable.c
+++ b/source/dnode/vnode/src/meta/metaTable.c
@@ -1409,6 +1409,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
int32_t ret = 0;
// get super table
if (tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData) != 0) {
+ metaError("vgId:%d, failed to get stable suid for update. version:%" PRId64, TD_VID(pMeta->pVnode),
+ pCtbEntry->version);
+ terrno = TSDB_CODE_TDB_INVALID_TABLE_ID;
ret = -1;
goto end;
}
diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c
index 38f04bb8e8bea7f12e7fb128775d5a80f54bb51a..51011ef7916a7f5b4173418a6d67186a8ff7869f 100644
--- a/source/dnode/vnode/src/sma/smaCommit.c
+++ b/source/dnode/vnode/src/sma/smaCommit.c
@@ -17,18 +17,26 @@
extern SSmaMgmt smaMgmt;
-static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
+static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit);
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo);
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
+/**
+ * @brief only applicable to Rollup SMA
+ *
+ * @param pSma
+ * @return int32_t
+ */
+int32_t smaPreClose(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma, false); }
+
/**
* @brief async commit, only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
-int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
+int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma, true); }
/**
* @brief async commit, only applicable to Rollup SMA
@@ -122,9 +130,10 @@ _exit:
* 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write)
*
* @param pSma
+ * @param isCommit
* @return int32_t
*/
-static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
+static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit) {
int32_t code = 0;
int32_t lino = 0;
@@ -139,28 +148,30 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
// step 1: set rsma stat
atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED);
- while (atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 1) != 0) {
- ++nLoops;
- if (nLoops > 1000) {
- sched_yield();
- nLoops = 0;
+ if (isCommit) {
+ while (atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 1) != 0) {
+ ++nLoops;
+ if (nLoops > 1000) {
+ sched_yield();
+ nLoops = 0;
+ }
}
- }
- pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
- if (ASSERTS(pRSmaStat->commitAppliedVer >= 0, "commit applied version %" PRIi64 " < 0",
- pRSmaStat->commitAppliedVer)) {
- code = TSDB_CODE_APP_ERROR;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
+ pRSmaStat->commitAppliedVer = pSma->pVnode->state.applied;
+ if (ASSERTS(pRSmaStat->commitAppliedVer >= -1, "commit applied version %" PRIi64 " < -1",
+ pRSmaStat->commitAppliedVer)) {
+ code = TSDB_CODE_APP_ERROR;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
// step 2: wait for all triggered fetch tasks to finish
nLoops = 0;
while (1) {
- if (T_REF_VAL_GET(pStat) == 0) {
- smaDebug("vgId:%d, rsma commit, fetch tasks are all finished", SMA_VID(pSma));
+ if (atomic_load_32(&pRSmaStat->nFetchAll) <= 0) {
+ smaDebug("vgId:%d, rsma commit:%d, fetch tasks are all finished", SMA_VID(pSma), isCommit);
break;
} else {
- smaDebug("vgId:%d, rsma commit, fetch tasks are not all finished yet", SMA_VID(pSma));
+ smaDebug("vgId:%d, rsma commit%d, fetch tasks are not all finished yet", SMA_VID(pSma), isCommit);
}
++nLoops;
if (nLoops > 1000) {
@@ -174,7 +185,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
* 1) This is high cost task and should not put in asyncPreCommit originally.
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
*/
- smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma),
+ smaInfo("vgId:%d, rsma commit:%d, wait for all items to be consumed, TID:%p", SMA_VID(pSma), isCommit,
(void *)taosGetSelfPthreadId());
nLoops = 0;
while (atomic_load_64(&pRSmaStat->nBufItems) > 0) {
@@ -184,10 +195,13 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
nLoops = 0;
}
}
+
+ if (!isCommit) goto _exit;
+
smaInfo("vgId:%d, rsma commit, all items are consumed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat));
TSDB_CHECK_CODE(code, lino, _exit);
-
+
smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
#if 0 // consuming task of qTaskInfo clone
@@ -223,7 +237,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
_exit:
if (code) {
- smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pSma), __func__, lino, tstrerror(code));
+ smaError("vgId:%d, %s failed at line %d since %s(%d)", SMA_VID(pSma), __func__, lino, tstrerror(code), isCommit);
}
return code;
}
@@ -243,7 +257,7 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) {
if (!pSmaEnv) {
goto _exit;
}
-
+
code = tdRSmaFSCommit(pSma);
TSDB_CHECK_CODE(code, lino, _exit);
diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c
index 21c283994345a00badb3e5c12c80f1e3b86bdc6f..00000cb12914d7a0fbda6b2218c09c1726e51e17 100644
--- a/source/dnode/vnode/src/sma/smaOpen.c
+++ b/source/dnode/vnode/src/sma/smaOpen.c
@@ -167,6 +167,7 @@ _exit:
int32_t smaClose(SSma *pSma) {
if (pSma) {
+ smaPreClose(pSma);
taosThreadMutexDestroy(&pSma->mutex);
SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma));
SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma));
diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c
index de3d93395aa3790dcd231b461470ee35462abb46..c00e96a06664db0a60184fdb09e16ee0b68c3d45 100644
--- a/source/dnode/vnode/src/sma/smaSnapshot.c
+++ b/source/dnode/vnode/src/sma/smaSnapshot.c
@@ -446,10 +446,10 @@ int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
// rsma1/rsma2
if (pHdr->type == SNAP_DATA_RSMA1) {
pHdr->type = SNAP_DATA_TSDB;
- code = tsdbSnapWrite(pWriter->pDataWriter[0], pData, nData);
+ code = tsdbSnapWrite(pWriter->pDataWriter[0], pHdr);
} else if (pHdr->type == SNAP_DATA_RSMA2) {
pHdr->type = SNAP_DATA_TSDB;
- code = tsdbSnapWrite(pWriter->pDataWriter[1], pData, nData);
+ code = tsdbSnapWrite(pWriter->pDataWriter[1], pHdr);
} else if (pHdr->type == SNAP_DATA_QTASK) {
code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData);
} else {
diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c
index a27b6988c58d9173ca4250440a7abbac98f71114..753c42ff33ac0adc19e3996d37b6ce2f81a6b1c7 100644
--- a/source/dnode/vnode/src/tq/tq.c
+++ b/source/dnode/vnode/src/tq/tq.c
@@ -520,7 +520,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
tqOffsetResetToData(&fetchOffsetNew, 0, 0);
}
} else {
- tqOffsetResetToLog(&fetchOffsetNew, walGetFirstVer(pTq->pVnode->pWal));
+ pHandle->pRef = walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef);
+ if (pHandle->pRef == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return -1;
+ }
+ tqOffsetResetToLog(&fetchOffsetNew, pHandle->pRef->refVer - 1);
}
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
@@ -683,6 +688,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
.ver = pHead->version,
};
if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp) < 0) {
+ tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", consumerId,
+ TD_VID(pTq->pVnode), req.subKey);
+ return -1;
}
if (taosxRsp.blockNum > 0 /* threshold */) {
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
@@ -699,7 +707,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
} else {
/*A(pHandle->fetchMeta);*/
/*A(IS_META_MSG(pHead->msgType));*/
- tqDebug("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType);
+ tqDebug("fetch meta msg, ver:%" PRId64 ", type:%s", pHead->version, TMSG_INFO(pHead->msgType));
tqOffsetResetToLog(&metaRsp.rspOffset, fetchVer);
metaRsp.resMsgType = pHead->msgType;
metaRsp.metaRspLen = pHead->bodyLen;
diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c
index 40a82cc8e82edbab0a776f0f5f69d6013b5e2de3..7896b931dc9c083feac1af21d1c6978d3a517740 100644
--- a/source/dnode/vnode/src/tq/tqExec.c
+++ b/source/dnode/vnode/src/tq/tqExec.c
@@ -34,7 +34,7 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
return 0;
}
-static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, SMqDataRsp* pRsp) {
+static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp) {
SSchemaWrapper* pSW = tCloneSSchemaWrapper(pExec->pExecReader->pSchemaWrapper);
if (pSW == NULL) {
return -1;
@@ -43,7 +43,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, SMqDataRsp* pRs
return 0;
}
-static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, int32_t n) {
+static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, int32_t n) {
SMetaReader mr = {0};
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
// TODO add reference to gurantee success
@@ -153,7 +153,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
if (pRsp->withTbName) {
if (pOffset->type == TMQ_OFFSET__LOG) {
int64_t uid = pExec->pExecReader->lastBlkUid;
- if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, 1) < 0) {
+ if (tqAddTbNameToRsp(pTq, uid, pRsp, 1) < 0) {
continue;
}
} else {
@@ -163,7 +163,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
}
if (pRsp->withSchema) {
if (pOffset->type == TMQ_OFFSET__LOG) {
- tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);
+ tqAddBlockSchemaToRsp(pExec, pRsp);
} else {
SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task));
taosArrayPush(pRsp->blockSchema, &pSW);
@@ -241,13 +241,14 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
taosArrayClear(pBlocks);
taosArrayClear(pSchemas);
- if (tqRetrieveTaosxBlock2(pReader, pBlocks, pSchemas) < 0) {
+ SSubmitTbData* pSubmitTbDataRet = NULL;
+ if (tqRetrieveTaosxBlock2(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) {
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
}
if (pRsp->withTbName) {
/*int64_t uid = pExec->pExecReader->msgIter.uid;*/
int64_t uid = pExec->pExecReader->lastBlkUid;
- if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlocks)) < 0) {
+ if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSSchemaWrapper);
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
@@ -255,23 +256,33 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
continue;
}
}
- if (pHandle->fetchMeta) {
-#if 0
- SSubmitBlk* pBlk = pReader->pBlock;
- int64_t uid = pExec->pExecReader->lastBlkUid;
- int32_t schemaLen = htonl(pBlk->schemaLen);
- if (schemaLen > 0) {
- if (pRsp->createTableNum == 0) {
- pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
- pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
- }
- void* createReq = taosMemoryCalloc(1, schemaLen);
- memcpy(createReq, pBlk->data, schemaLen);
- taosArrayPush(pRsp->createTableLen, &schemaLen);
- taosArrayPush(pRsp->createTableReq, &createReq);
- pRsp->createTableNum++;
+ if (pHandle->fetchMeta && pSubmitTbDataRet->pCreateTbReq != NULL) {
+ if (pRsp->createTableNum == 0) {
+ pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
+ pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
+ }
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ uint32_t len = 0;
+ tEncodeSize(tEncodeSVCreateTbReq, pSubmitTbDataRet->pCreateTbReq, len, code);
+ if (TSDB_CODE_SUCCESS != code) {
+ continue;
}
-#endif
+ void* createReq = taosMemoryCalloc(1, len);
+ SEncoder encoder = {0};
+ tEncoderInit(&encoder, createReq, len);
+ code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq);
+ if (code < 0) {
+ tEncoderClear(&encoder);
+ taosMemoryFree(createReq);
+ continue;
+ }
+
+ taosArrayPush(pRsp->createTableLen, &len);
+ taosArrayPush(pRsp->createTableReq, &createReq);
+ pRsp->createTableNum++;
+
+ tEncoderClear(&encoder);
}
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
@@ -294,12 +305,13 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
/*}*/
taosArrayClear(pBlocks);
taosArrayClear(pSchemas);
- if (tqRetrieveTaosxBlock2(pReader, pBlocks, pSchemas) < 0) {
+ SSubmitTbData* pSubmitTbDataRet = NULL;
+ if (tqRetrieveTaosxBlock2(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) {
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
}
if (pRsp->withTbName) {
int64_t uid = pExec->pExecReader->lastBlkUid;
- if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlocks)) < 0) {
+ if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) {
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSSchemaWrapper);
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
@@ -307,22 +319,33 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
continue;
}
}
- if (pHandle->fetchMeta) {
-#if 0
- SSubmitBlk* pBlk = pReader->pBlock;
- int32_t schemaLen = htonl(pBlk->schemaLen);
- if (schemaLen > 0) {
- if (pRsp->createTableNum == 0) {
- pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
- pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
- }
- void* createReq = taosMemoryCalloc(1, schemaLen);
- memcpy(createReq, pBlk->data, schemaLen);
- taosArrayPush(pRsp->createTableLen, &schemaLen);
- taosArrayPush(pRsp->createTableReq, &createReq);
- pRsp->createTableNum++;
+ if (pHandle->fetchMeta && pSubmitTbDataRet->pCreateTbReq != NULL) {
+ if (pRsp->createTableNum == 0) {
+ pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t));
+ pRsp->createTableReq = taosArrayInit(0, sizeof(void*));
}
-#endif
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ uint32_t len = 0;
+ tEncodeSize(tEncodeSVCreateTbReq, pSubmitTbDataRet->pCreateTbReq, len, code);
+ if (TSDB_CODE_SUCCESS != code) {
+ continue;
+ }
+ void* createReq = taosMemoryCalloc(1, len);
+ SEncoder encoder = {0};
+ tEncoderInit(&encoder, createReq, len);
+ code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq);
+ if (code < 0) {
+ tEncoderClear(&encoder);
+ taosMemoryFree(createReq);
+ continue;
+ }
+
+ taosArrayPush(pRsp->createTableLen, &len);
+ taosArrayPush(pRsp->createTableReq, &createReq);
+ pRsp->createTableNum++;
+
+ tEncoderClear(&encoder);
}
/*tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),*/
/*pTq->pVnode->config.tsdbCfg.precision);*/
@@ -340,13 +363,11 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
}
}
}
-
taosArrayDestroy(pBlocks);
taosArrayDestroy(pSchemas);
-
- if (pRsp->blockNum == 0) {
- return -1;
- }
+// if (pRsp->blockNum == 0) {
+// return -1;
+// }
return 0;
}
diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c
index eb9c0c3eeb252b53caf2b04a0674e879242cca42..99f0ed77039f8d19c96b2f4100f5aeee9e3cf557 100644
--- a/source/dnode/vnode/src/tq/tqRead.c
+++ b/source/dnode/vnode/src/tq/tqRead.c
@@ -332,7 +332,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
while (tqNextDataBlock2(pReader)) {
// TODO mem free
memset(&ret->data, 0, sizeof(SSDataBlock));
- int32_t code = tqRetrieveDataBlock2(&ret->data, pReader);
+ int32_t code = tqRetrieveDataBlock2(&ret->data, pReader, NULL);
if (code != 0 || ret->data.info.rows == 0) {
continue;
}
@@ -454,12 +454,13 @@ bool tqNextDataBlockFilterOut2(STqReader* pReader, SHashObj* filterOutUids) {
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
while (pReader->nextBlk < blockSz) {
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
- if (pReader->tbIdHash == NULL) return true;
+ if (filterOutUids == NULL) return true;
- void* ret = taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t));
+ void* ret = taosHashGet(filterOutUids, &pSubmitTbData->uid, sizeof(int64_t));
if (ret == NULL) {
return true;
}
+ pReader->nextBlk++;
}
tDestroySSubmitReq2(&pReader->submit, TSDB_MSG_FLG_DECODE);
@@ -550,7 +551,7 @@ int32_t tqScanSubmitSplit(SArray* pBlocks, SArray* schemas, STqReader* pReader)
}
#endif
-int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
+int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbData** pSubmitTbDataRet) {
int32_t blockSz = taosArrayGetSize(pReader->submit.aSubmitTbData);
ASSERT(pReader->nextBlk < blockSz);
@@ -559,6 +560,7 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
pReader->nextBlk++;
+ if(pSubmitTbDataRet) *pSubmitTbDataRet = pSubmitTbData;
int32_t sversion = pSubmitTbData->sver;
int64_t suid = pSubmitTbData->suid;
int64_t uid = pSubmitTbData->uid;
@@ -670,7 +672,7 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
sourceIdx++;
} else if (pCol->cid == pColData->info.colId) {
for (int32_t i = 0; i < pCol->nVal; i++) {
- tColDataGetValue(pCol, sourceIdx, &colVal);
+ tColDataGetValue(pCol, i, &colVal);
#if 0
void* val = NULL;
if (IS_STR_DATA_TYPE(colVal.type)) {
@@ -710,7 +712,6 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
for (int32_t i = 0; i < numOfRows; i++) {
SRow* pRow = taosArrayGetP(pRows, i);
- int32_t targetIdx = 0;
int32_t sourceIdx = 0;
for (int32_t j = 0; j < colActual; j++) {
@@ -743,7 +744,6 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader) {
}
sourceIdx++;
- targetIdx++;
break;
} else {
ASSERT(0);
@@ -1006,14 +1006,258 @@ FAIL:
}
#endif
-int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schemas) {
- SSDataBlock block = {0};
- if (tqRetrieveDataBlock2(&block, pReader) == 0) {
- taosArrayPush(blocks, &block);
- SSchemaWrapper* pSW = tCloneSSchemaWrapper(pReader->pSchemaWrapper);
- taosArrayPush(schemas, &pSW);
- return 0;
+int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schemas, SSubmitTbData** pSubmitTbDataRet) {
+ tqDebug("tq reader retrieve data block %p, %d", pReader->msg2.msgStr, pReader->nextBlk);
+
+ SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk);
+ pReader->nextBlk++;
+
+ if(pSubmitTbDataRet) *pSubmitTbDataRet = pSubmitTbData;
+ int32_t sversion = pSubmitTbData->sver;
+ int64_t suid = pSubmitTbData->suid;
+ int64_t uid = pSubmitTbData->uid;
+ pReader->lastBlkUid = uid;
+
+ taosMemoryFree(pReader->pSchema);
+ pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, uid, sversion, 1);
+ if (pReader->pSchema == NULL) {
+ tqWarn("vgId:%d, cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64
+ "), version %d, possibly dropped table",
+ pReader->pWalReader->pWal->cfg.vgId, uid, suid, sversion);
+ pReader->cachedSchemaSuid = 0;
+ terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
+ return -1;
+ }
+
+ tDeleteSSchemaWrapper(pReader->pSchemaWrapper);
+ pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, uid, sversion, 1);
+ if (pReader->pSchemaWrapper == NULL) {
+ tqWarn("vgId:%d, cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table",
+ pReader->pWalReader->pWal->cfg.vgId, uid, pReader->cachedSchemaVer);
+ pReader->cachedSchemaSuid = 0;
+ terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
+ return -1;
+ }
+
+ STSchema* pTschema = pReader->pSchema;
+ SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
+ int32_t numOfRows = 0;
+
+ if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
+ SArray* pCols = pSubmitTbData->aCol;
+ SColData* pCol = taosArrayGet(pCols, 0);
+ numOfRows = pCol->nVal;
+ } else {
+ SArray* pRows = pSubmitTbData->aRowP;
+ numOfRows = taosArrayGetSize(pRows);
+ }
+
+ int32_t curRow = 0;
+ int32_t lastRow = 0;
+ char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols);
+ if (assigned == NULL) return -1;
+
+ // convert and scan one block
+ if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
+ SArray* pCols = pSubmitTbData->aCol;
+ int32_t numOfCols = taosArrayGetSize(pCols);
+ for (int32_t i = 0; i < numOfRows; i++) {
+ bool buildNew = false;
+
+ for (int32_t j = 0; j < numOfCols; j++){
+ SColData* pCol = taosArrayGet(pCols, j);
+ SColVal colVal;
+ tColDataGetValue(pCol, i, &colVal);
+ if (curRow == 0) {
+ assigned[j] = !COL_VAL_IS_NONE(&colVal);
+ buildNew = true;
+ } else {
+ bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);
+ if (currentRowAssigned != assigned[j]) {
+ assigned[j] = currentRowAssigned;
+ buildNew = true;
+ }
+ }
+ }
+
+ if (buildNew) {
+ if (taosArrayGetSize(blocks) > 0) {
+ SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
+ pLastBlock->info.rows = curRow - lastRow;
+ lastRow = curRow;
+ }
+
+ SSDataBlock block = {0};
+ SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
+ if(pSW == NULL){
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ goto FAIL;
+ }
+
+ if (tqMaskBlock(pSW, &block, pSchemaWrapper, assigned) < 0) {
+ blockDataFreeRes(&block);
+ tDeleteSSchemaWrapper(pSW);
+ goto FAIL;
+ }
+ tqDebug("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
+ (int32_t)taosArrayGetSize(block.pDataBlock));
+
+ block.info.id.uid = uid;
+ block.info.version = pReader->msg2.ver;
+ if (blockDataEnsureCapacity(&block, numOfRows - curRow) < 0) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ blockDataFreeRes(&block);
+ tDeleteSSchemaWrapper(pSW);
+ goto FAIL;
+ }
+ taosArrayPush(blocks, &block);
+ taosArrayPush(schemas, &pSW);
+ }
+
+ SSDataBlock* pBlock = taosArrayGetLast(blocks);
+
+ tqDebug("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
+ (int32_t)taosArrayGetSize(blocks));
+
+ int32_t targetIdx = 0;
+ int32_t sourceIdx = 0;
+ int32_t colActual = blockDataGetNumOfCols(pBlock);
+ while (targetIdx < colActual) {
+ SColData* pCol = taosArrayGet(pCols, sourceIdx);
+ SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
+ SColVal colVal;
+
+ if (pCol->cid < pColData->info.colId) {
+ sourceIdx++;
+ } else if (pCol->cid == pColData->info.colId) {
+ tColDataGetValue(pCol, i, &colVal);
+
+ if (IS_STR_DATA_TYPE(colVal.type)) {
+ if (colVal.value.pData != NULL) {
+ char val[65535 + 2];
+ memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData);
+ varDataSetLen(val, colVal.value.nData);
+ if (colDataAppend(pColData, curRow - lastRow, val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
+ goto FAIL;
+ }
+ } else {
+ colDataAppendNULL(pColData, curRow - lastRow);
+ }
+ } else {
+ if (colDataAppend(pColData, curRow - lastRow, (void*)&colVal.value.val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
+ goto FAIL;
+ }
+ }
+ sourceIdx++;
+ targetIdx++;
+ }
+ }
+
+ curRow++;
+ }
+ } else {
+ SArray* pRows = pSubmitTbData->aRowP;
+ for (int32_t i = 0; i < numOfRows; i++) {
+ SRow* pRow = taosArrayGetP(pRows, i);
+ bool buildNew = false;
+
+ for (int32_t j = 0; j < pTschema->numOfCols; j++){
+ SColVal colVal;
+ tRowGet(pRow, pTschema, j, &colVal);
+ if (curRow == 0) {
+ assigned[j] = !COL_VAL_IS_NONE(&colVal);
+ buildNew = true;
+ } else {
+ bool currentRowAssigned = !COL_VAL_IS_NONE(&colVal);
+ if (currentRowAssigned != assigned[j]) {
+ assigned[j] = currentRowAssigned;
+ buildNew = true;
+ }
+ }
+ }
+
+ if (buildNew) {
+ if (taosArrayGetSize(blocks) > 0) {
+ SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
+ pLastBlock->info.rows = curRow - lastRow;
+ lastRow = curRow;
+ }
+
+ SSDataBlock block = {0};
+ SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
+ if(pSW == NULL){
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ goto FAIL;
+ }
+
+ if (tqMaskBlock(pSW, &block, pSchemaWrapper, assigned) < 0) {
+ blockDataFreeRes(&block);
+ tDeleteSSchemaWrapper(pSW);
+ goto FAIL;
+ }
+ tqDebug("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
+ (int32_t)taosArrayGetSize(block.pDataBlock));
+
+ block.info.id.uid = uid;
+ block.info.version = pReader->msg2.ver;
+ if (blockDataEnsureCapacity(&block, numOfRows - curRow) < 0) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ blockDataFreeRes(&block);
+ tDeleteSSchemaWrapper(pSW);
+ goto FAIL;
+ }
+ taosArrayPush(blocks, &block);
+ taosArrayPush(schemas, &pSW);
+ }
+
+ SSDataBlock* pBlock = taosArrayGetLast(blocks);
+
+ tqDebug("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
+ (int32_t)taosArrayGetSize(blocks));
+
+ int32_t targetIdx = 0;
+ int32_t sourceIdx = 0;
+ int32_t colActual = blockDataGetNumOfCols(pBlock);
+ while (targetIdx < colActual) {
+ SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx);
+ SColVal colVal;
+ tRowGet(pRow, pTschema, sourceIdx, &colVal);
+
+ if (colVal.cid < pColData->info.colId) {
+ sourceIdx++;
+ } else if (colVal.cid == pColData->info.colId) {
+ if (IS_STR_DATA_TYPE(colVal.type)) {
+ if (colVal.value.pData != NULL) {
+ char val[65535 + 2];
+ memcpy(varDataVal(val), colVal.value.pData, colVal.value.nData);
+ varDataSetLen(val, colVal.value.nData);
+ if (colDataAppend(pColData, curRow - lastRow, val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
+ goto FAIL;
+ }
+ } else {
+ colDataAppendNULL(pColData, curRow - lastRow);
+ }
+ } else {
+ if (colDataAppend(pColData, curRow - lastRow, (void*)&colVal.value.val, !COL_VAL_IS_VALUE(&colVal)) < 0) {
+ goto FAIL;
+ }
+ }
+ sourceIdx++;
+ targetIdx++;
+ }
+ }
+ curRow++;
+ }
}
+
+ SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
+ pLastBlock->info.rows = curRow - lastRow;
+
+ taosMemoryFree(assigned);
+ return 0;
+
+ FAIL:
+ taosMemoryFree(assigned);
return -1;
}
diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c
index f1103ad48a1be4101da041e40ddf1e7b4a6b181b..3801a25d6db74e53edb991c104318dd9776b4b07 100644
--- a/source/dnode/vnode/src/tq/tqSink.c
+++ b/source/dnode/vnode/src/tq/tqSink.c
@@ -488,9 +488,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
};
void* pData = colDataGetData(pTagData, rowId);
if (colDataIsNull_s(pTagData, rowId)) {
- tagVal.type = TSDB_DATA_TYPE_NULL;
- tagVal.pData = NULL;
- tagVal.nData = 0;
+ continue;
} else if (IS_VAR_DATA_TYPE(pTagData->info.type)) {
tagVal.nData = varDataLen(pData);
tagVal.pData = varDataVal(pData);
diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c
index d18014c37b096f044a6cf4fbb7a933193e297d02..c67fa4bdf1409b46841b0d6035bc6a18f1f28485 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCache.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCache.c
@@ -15,6 +15,34 @@
#include "tsdb.h"
+static int32_t tsdbOpenBICache(STsdb *pTsdb) {
+ int32_t code = 0;
+ SLRUCache *pCache = taosLRUCacheInit(5 * 1024 * 1024, -1, .5);
+ if (pCache == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+
+ taosLRUCacheSetStrictCapacity(pCache, false);
+
+ taosThreadMutexInit(&pTsdb->biMutex, NULL);
+
+_err:
+ pTsdb->biCache = pCache;
+ return code;
+}
+
+static void tsdbCloseBICache(STsdb *pTsdb) {
+ SLRUCache *pCache = pTsdb->biCache;
+ if (pCache) {
+ taosLRUCacheEraseUnrefEntries(pCache);
+
+ taosLRUCacheCleanup(pCache);
+
+ taosThreadMutexDestroy(&pTsdb->biMutex);
+ }
+}
+
int32_t tsdbOpenCache(STsdb *pTsdb) {
int32_t code = 0;
SLRUCache *pCache = NULL;
@@ -26,6 +54,12 @@ int32_t tsdbOpenCache(STsdb *pTsdb) {
goto _err;
}
+ code = tsdbOpenBICache(pTsdb);
+ if (code != TSDB_CODE_SUCCESS) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+
taosLRUCacheSetStrictCapacity(pCache, false);
taosThreadMutexInit(&pTsdb->lruMutex, NULL);
@@ -44,6 +78,8 @@ void tsdbCloseCache(STsdb *pTsdb) {
taosThreadMutexDestroy(&pTsdb->lruMutex);
}
+
+ tsdbCloseBICache(pTsdb);
}
static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) {
@@ -1538,3 +1574,84 @@ size_t tsdbCacheGetUsage(SVnode *pVnode) {
return usage;
}
+
+static void getBICacheKey(int32_t fid, int64_t commitID, char *key, int *len) {
+ struct {
+ int32_t fid;
+ int64_t commitID;
+ } biKey = {0};
+
+ biKey.fid = fid;
+ biKey.commitID = commitID;
+
+ *len = sizeof(biKey);
+ memcpy(key, &biKey, *len);
+}
+
+static int32_t tsdbCacheLoadBlockIdx(SDataFReader *pFileReader, SArray **aBlockIdx) {
+ SArray *pArray = taosArrayInit(8, sizeof(SBlockIdx));
+ int32_t code = tsdbReadBlockIdx(pFileReader, pArray);
+
+ if (code != TSDB_CODE_SUCCESS) {
+ taosArrayDestroy(pArray);
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ return code;
+ }
+
+ *aBlockIdx = pArray;
+
+ return code;
+}
+
+static void deleteBICache(const void *key, size_t keyLen, void *value) {
+ SArray *pArray = (SArray *)value;
+
+ taosArrayDestroy(pArray);
+}
+
+int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle) {
+ int32_t code = 0;
+ char key[128] = {0};
+ int keyLen = 0;
+
+ getBICacheKey(pFileReader->pSet->fid, pFileReader->pSet->pHeadF->commitID, key, &keyLen);
+ LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
+ if (!h) {
+ STsdb *pTsdb = pFileReader->pTsdb;
+ taosThreadMutexLock(&pTsdb->biMutex);
+
+ h = taosLRUCacheLookup(pCache, key, keyLen);
+ if (!h) {
+ SArray *pArray = NULL;
+ code = tsdbCacheLoadBlockIdx(pFileReader, &pArray);
+ // if table's empty or error, return code of -1
+ if (code != TSDB_CODE_SUCCESS || pArray == NULL) {
+ taosThreadMutexUnlock(&pTsdb->biMutex);
+
+ *handle = NULL;
+ return 0;
+ }
+
+ size_t charge = pArray->capacity * pArray->elemSize + sizeof(*pArray);
+ _taos_lru_deleter_t deleter = deleteBICache;
+ LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pArray, charge, deleter, &h, TAOS_LRU_PRIORITY_LOW);
+ if (status != TAOS_LRU_STATUS_OK) {
+ code = -1;
+ }
+ }
+
+ taosThreadMutexUnlock(&pTsdb->biMutex);
+ }
+
+ *handle = h;
+
+ return code;
+}
+
+int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) {
+ int32_t code = 0;
+
+ taosLRUCacheRelease(pCache, h, false);
+
+ return code;
+}
diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c
index fb3917be64faa058b52f1f13a86ec0034486f279..fc7df98217cfebd8c7979c2e08167330d36bddee 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCompact.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCompact.c
@@ -15,13 +15,653 @@
#include "tsdb.h"
+extern int32_t tsdbUpdateTableSchema(SMeta *pMeta, int64_t suid, int64_t uid, SSkmInfo *pSkmInfo);
+extern int32_t tsdbWriteDataBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SMapData *mDataBlk, int8_t cmprAlg);
+extern int32_t tsdbWriteSttBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SArray *aSttBlk, int8_t cmprAlg);
+
typedef struct {
STsdb *pTsdb;
+ int64_t commitID;
+ int8_t cmprAlg;
+ int32_t maxRows;
+ int32_t minRows;
+
STsdbFS fs;
+
+ int32_t fid;
+ TABLEID tbid;
+ SSkmInfo tbSkm;
+
+ // Tombstone
+ SDelFReader *pDelFReader;
+ SArray *aDelIdx; // SArray
+ SArray *aDelData; // SArray
+ SArray *aSkyLine; // SArray
+ int32_t iDelIdx;
+ int32_t iSkyLine;
+ TSDBKEY *pDKey;
+ TSDBKEY dKey;
+
+ // Reader
+ SDataFReader *pReader;
+ STsdbDataIter2 *iterList; // list of iterators
+ STsdbDataIter2 *pIter;
+ SRBTree rbt;
+
+ // Writer
+ SDataFWriter *pWriter;
+ SArray *aBlockIdx; // SArray
+ SMapData mDataBlk; // SMapData
+ SArray *aSttBlk; // SArray
+ SBlockData bData;
+ SBlockData sData;
} STsdbCompactor;
-int32_t tsdbCompact(STsdb *pTsdb) {
+static int32_t tsdbCommitCompact(STsdbCompactor *pCompactor) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdb *pTsdb = pCompactor->pTsdb;
+
+ code = tsdbFSPrepareCommit(pTsdb, &pCompactor->fs);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ taosThreadRwlockWrlock(&pTsdb->rwLock);
+
+ code = tsdbFSCommit(pTsdb);
+ if (code) {
+ taosThreadRwlockUnlock(&pTsdb->rwLock);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ taosThreadRwlockUnlock(&pTsdb->rwLock);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
+ return code;
+}
+
+static int32_t tsdbAbortCompact(STsdbCompactor *pCompactor) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdb *pTsdb = pCompactor->pTsdb;
+ code = tsdbFSRollback(pTsdb);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
+ return code;
+}
+
+static int32_t tsdbCompactWriteTableDataStart(STsdbCompactor *pCompactor, TABLEID *pId) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ pCompactor->tbid = *pId;
+
+ // tombstone
+ for (;;) {
+ if (pCompactor->iDelIdx >= taosArrayGetSize(pCompactor->aDelIdx)) {
+ pCompactor->pDKey = NULL;
+ break;
+ }
+
+ SDelIdx *pDelIdx = (SDelIdx *)taosArrayGet(pCompactor->aDelIdx, pCompactor->iDelIdx);
+ int32_t c = tTABLEIDCmprFn(pDelIdx, &pCompactor->tbid);
+ if (c < 0) {
+ pCompactor->iDelIdx++;
+ } else if (c == 0) {
+ pCompactor->iDelIdx++;
+
+ code = tsdbReadDelData(pCompactor->pDelFReader, pDelIdx, pCompactor->aDelData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbBuildDeleteSkyline(pCompactor->aDelData, 0, taosArrayGetSize(pCompactor->aDelData) - 1,
+ pCompactor->aSkyLine);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pCompactor->iSkyLine = 0;
+ if (pCompactor->iSkyLine < taosArrayGetSize(pCompactor->aSkyLine)) {
+ TSDBKEY *pKey = (TSDBKEY *)taosArrayGet(pCompactor->aSkyLine, pCompactor->iSkyLine);
+
+ pCompactor->dKey.version = 0;
+ pCompactor->dKey.ts = pKey->ts;
+ pCompactor->pDKey = &pCompactor->dKey;
+ } else {
+ pCompactor->pDKey = NULL;
+ }
+ break;
+ } else {
+ pCompactor->pDKey = NULL;
+ break;
+ }
+ }
+
+ // writer
+ code = tsdbUpdateTableSchema(pCompactor->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pCompactor->tbSkm);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ tMapDataReset(&pCompactor->mDataBlk);
+
+ code = tBlockDataInit(&pCompactor->bData, pId, pCompactor->tbSkm.pTSchema, NULL, 0);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (!TABLE_SAME_SCHEMA(pCompactor->sData.suid, pCompactor->sData.uid, pId->suid, pId->uid)) {
+ if (pCompactor->sData.nRow > 0) {
+ code = tsdbWriteSttBlock(pCompactor->pWriter, &pCompactor->sData, pCompactor->aSttBlk, pCompactor->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ TABLEID tbid = {.suid = pId->suid, .uid = pId->suid ? 0 : pId->uid};
+ code = tBlockDataInit(&pCompactor->sData, &tbid, pCompactor->tbSkm.pTSchema, NULL, 0);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pCompactor->pTsdb->pVnode), __func__, pId->suid,
+ pId->uid);
+ }
+ return code;
+}
+
+static int32_t tsdbCompactWriteTableDataEnd(STsdbCompactor *pCompactor) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ if (pCompactor->bData.nRow > 0) {
+ if (pCompactor->bData.nRow < pCompactor->minRows) {
+ for (int32_t iRow = 0; iRow < pCompactor->bData.nRow; iRow++) {
+ code = tBlockDataAppendRow(&pCompactor->sData, &tsdbRowFromBlockData(&pCompactor->bData, iRow), NULL,
+ pCompactor->tbid.uid);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pCompactor->sData.nRow >= pCompactor->maxRows) {
+ code = tsdbWriteSttBlock(pCompactor->pWriter, &pCompactor->sData, pCompactor->aSttBlk, pCompactor->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
+ tBlockDataClear(&pCompactor->bData);
+ } else {
+ code = tsdbWriteDataBlock(pCompactor->pWriter, &pCompactor->bData, &pCompactor->mDataBlk, pCompactor->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
+
+ if (pCompactor->mDataBlk.nItem > 0) {
+ SBlockIdx *pBlockIdx = (SBlockIdx *)taosArrayReserve(pCompactor->aBlockIdx, 1);
+ if (pBlockIdx == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ pBlockIdx->suid = pCompactor->tbid.suid;
+ pBlockIdx->uid = pCompactor->tbid.uid;
+
+ code = tsdbWriteDataBlk(pCompactor->pWriter, &pCompactor->mDataBlk, pBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pCompactor->pTsdb->pVnode), __func__,
+ pCompactor->tbid.suid, pCompactor->tbid.uid);
+ }
+ return code;
+}
+
+static bool tsdbCompactRowIsDeleted(STsdbCompactor *pCompactor, TSDBROW *pRow) {
+ TSDBKEY tKey = TSDBROW_KEY(pRow);
+ TSDBKEY *aKey = (TSDBKEY *)TARRAY_DATA(pCompactor->aSkyLine);
+ int32_t nKey = TARRAY_SIZE(pCompactor->aSkyLine);
+
+ if (tKey.ts > pCompactor->pDKey->ts) {
+ do {
+ pCompactor->pDKey->version = aKey[pCompactor->iSkyLine].version;
+ pCompactor->iSkyLine++;
+ if (pCompactor->iSkyLine < nKey) {
+ pCompactor->dKey.ts = aKey[pCompactor->iSkyLine].ts;
+ } else {
+ if (pCompactor->pDKey->version == 0) {
+ pCompactor->pDKey = NULL;
+ return false;
+ } else {
+ pCompactor->pDKey->ts = INT64_MAX;
+ }
+ }
+ } while (tKey.ts > pCompactor->pDKey->ts);
+ }
+
+ if (tKey.ts < pCompactor->pDKey->ts) {
+ if (tKey.version > pCompactor->pDKey->version) {
+ return false;
+ } else {
+ return true;
+ }
+ } else if (tKey.ts == pCompactor->pDKey->ts) {
+ ASSERT(pCompactor->iSkyLine < nKey);
+ if (tKey.version > TMAX(pCompactor->pDKey->version, aKey[pCompactor->iSkyLine].version)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static int32_t tsdbCompactWriteTableData(STsdbCompactor *pCompactor, SRowInfo *pRowInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ // start a new table data write if need
+ if (pRowInfo == NULL || pRowInfo->uid != pCompactor->tbid.uid) {
+ if (pCompactor->tbid.uid) {
+ code = tsdbCompactWriteTableDataEnd(pCompactor);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if (pRowInfo == NULL) {
+ if (pCompactor->sData.nRow > 0) {
+ code = tsdbWriteSttBlock(pCompactor->pWriter, &pCompactor->sData, pCompactor->aSttBlk, pCompactor->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ return code;
+ }
+
+ code = tsdbCompactWriteTableDataStart(pCompactor, (TABLEID *)pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ // check if row is deleted
+ if (pCompactor->pDKey && tsdbCompactRowIsDeleted(pCompactor, &pRowInfo->row)) goto _exit;
+
+ if (tBlockDataTryUpsertRow(&pCompactor->bData, &pRowInfo->row, pRowInfo->uid) > pCompactor->maxRows) {
+ code = tsdbWriteDataBlock(pCompactor->pWriter, &pCompactor->bData, &pCompactor->mDataBlk, pCompactor->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ code = tBlockDataUpsertRow(&pCompactor->bData, &pRowInfo->row, NULL, pRowInfo->uid);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code));
+ } else if (pRowInfo) {
+ tsdbTrace("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64 " ts:%" PRId64 " version:%" PRId64,
+ TD_VID(pCompactor->pTsdb->pVnode), __func__, pRowInfo->suid, pRowInfo->uid, TSDBROW_TS(&pRowInfo->row),
+ TSDBROW_VERSION(&pRowInfo->row));
+ }
+ return code;
+}
+
+static bool tsdbCompactTableIsDropped(STsdbCompactor *pCompactor) {
+ SMetaInfo info;
+
+ if (pCompactor->pIter->rowInfo.uid == pCompactor->tbid.uid) return false;
+ if (metaGetInfo(pCompactor->pTsdb->pVnode->pMeta, pCompactor->pIter->rowInfo.uid, &info, NULL)) {
+ return true;
+ }
+ return false;
+}
+static int32_t tsdbCompactNextRow(STsdbCompactor *pCompactor, SRowInfo **ppRowInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ for (;;) {
+ if (pCompactor->pIter) {
+ code = tsdbDataIterNext2(pCompactor->pIter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pCompactor->pIter->rowInfo.suid == 0 && pCompactor->pIter->rowInfo.uid == 0) {
+ pCompactor->pIter = NULL;
+ } else {
+ SRBTreeNode *pNode = tRBTreeMin(&pCompactor->rbt);
+ if (pNode) {
+ int32_t c = tsdbDataIterCmprFn(&pCompactor->pIter->rbtn, pNode);
+ if (c > 0) {
+ tRBTreePut(&pCompactor->rbt, &pCompactor->pIter->rbtn);
+ pCompactor->pIter = NULL;
+ } else if (c == 0) {
+ ASSERT(0);
+ }
+ }
+ }
+ }
+
+ if (pCompactor->pIter == NULL) {
+ SRBTreeNode *pNode = tRBTreeDropMin(&pCompactor->rbt);
+ if (pNode) {
+ pCompactor->pIter = TSDB_RBTN_TO_DATA_ITER(pNode);
+ }
+ }
+
+ if (pCompactor->pIter) {
+ if (tsdbCompactTableIsDropped(pCompactor)) {
+ TABLEID tbid = {.suid = pCompactor->pIter->rowInfo.suid, .uid = pCompactor->pIter->rowInfo.uid};
+ tRBTreeClear(&pCompactor->rbt);
+ for (pCompactor->pIter = pCompactor->iterList; pCompactor->pIter; pCompactor->pIter = pCompactor->pIter->next) {
+ code = tsdbDataIterNext2(pCompactor->pIter,
+ &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_TABLEID, .tbid = tbid});
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pCompactor->pIter->rowInfo.suid || pCompactor->pIter->rowInfo.uid) {
+ tRBTreePut(&pCompactor->rbt, &pCompactor->pIter->rbtn);
+ }
+ }
+ } else {
+ *ppRowInfo = &pCompactor->pIter->rowInfo;
+ break;
+ }
+ } else {
+ *ppRowInfo = NULL;
+ break;
+ }
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code));
+ }
+ return code;
+}
+
+static int32_t tsdbCompactFileSetStart(STsdbCompactor *pCompactor, SDFileSet *pSet) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ pCompactor->fid = pSet->fid;
+ pCompactor->tbid = (TABLEID){0};
+
+ /* tombstone */
+ pCompactor->iDelIdx = 0;
+
+ /* reader */
+ code = tsdbDataFReaderOpen(&pCompactor->pReader, pCompactor->pTsdb, pSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbOpenDataFileDataIter(pCompactor->pReader, &pCompactor->pIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ tRBTreeCreate(&pCompactor->rbt, tsdbDataIterCmprFn);
+ if (pCompactor->pIter) {
+ pCompactor->pIter->next = pCompactor->iterList;
+ pCompactor->iterList = pCompactor->pIter;
+
+ code = tsdbDataIterNext2(pCompactor->pIter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ ASSERT(pCompactor->pIter->rowInfo.suid || pCompactor->pIter->rowInfo.uid);
+ tRBTreePut(&pCompactor->rbt, &pCompactor->pIter->rbtn);
+ }
+
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ code = tsdbOpenSttFileDataIter(pCompactor->pReader, iStt, &pCompactor->pIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pCompactor->pIter) {
+ pCompactor->pIter->next = pCompactor->iterList;
+ pCompactor->iterList = pCompactor->pIter;
+
+ code = tsdbDataIterNext2(pCompactor->pIter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ ASSERT(pCompactor->pIter->rowInfo.suid || pCompactor->pIter->rowInfo.uid);
+ tRBTreePut(&pCompactor->rbt, &pCompactor->pIter->rbtn);
+ }
+ }
+ pCompactor->pIter = NULL;
+
+ /* writer */
+ code = tsdbDataFWriterOpen(&pCompactor->pWriter, pCompactor->pTsdb,
+ &(SDFileSet){.fid = pCompactor->fid,
+ .diskId = pSet->diskId,
+ .pHeadF = &(SHeadFile){.commitID = pCompactor->commitID},
+ .pDataF = &(SDataFile){.commitID = pCompactor->commitID},
+ .pSmaF = &(SSmaFile){.commitID = pCompactor->commitID},
+ .nSttF = 1,
+ .aSttF = {&(SSttFile){.commitID = pCompactor->commitID}}});
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pCompactor->aBlockIdx) {
+ taosArrayClear(pCompactor->aBlockIdx);
+ } else if ((pCompactor->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ tMapDataReset(&pCompactor->mDataBlk);
+
+ if (pCompactor->aSttBlk) {
+ taosArrayClear(pCompactor->aSttBlk);
+ } else if ((pCompactor->aSttBlk = taosArrayInit(0, sizeof(SSttBlk))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ tBlockDataReset(&pCompactor->bData);
+ tBlockDataReset(&pCompactor->sData);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code), pCompactor->fid);
+ } else {
+ tsdbInfo("vgId:%d %s done, fid:%d", TD_VID(pCompactor->pTsdb->pVnode), __func__, pCompactor->fid);
+ }
+ return code;
+}
+
+static int32_t tsdbCompactFileSetEnd(STsdbCompactor *pCompactor) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ ASSERT(pCompactor->bData.nRow == 0);
+ ASSERT(pCompactor->sData.nRow == 0);
+
+ /* update files */
+ code = tsdbWriteSttBlk(pCompactor->pWriter, pCompactor->aSttBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbWriteBlockIdx(pCompactor->pWriter, pCompactor->aBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbUpdateDFileSetHeader(pCompactor->pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbFSUpsertFSet(&pCompactor->fs, &pCompactor->pWriter->wSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbDataFWriterClose(&pCompactor->pWriter, 1);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbDataFReaderClose(&pCompactor->pReader);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ /* do clear */
+ while ((pCompactor->pIter = pCompactor->iterList) != NULL) {
+ pCompactor->iterList = pCompactor->pIter->next;
+ tsdbCloseDataIter2(pCompactor->pIter);
+ }
+
+ tBlockDataReset(&pCompactor->bData);
+ tBlockDataReset(&pCompactor->sData);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code), pCompactor->fid);
+ } else {
+ tsdbInfo("vgId:%d %s done, fid:%d", TD_VID(pCompactor->pTsdb->pVnode), __func__, pCompactor->fid);
+ }
+ return code;
+}
+
+static int32_t tsdbCompactFileSet(STsdbCompactor *pCompactor, SDFileSet *pSet) {
int32_t code = 0;
- // TODO
+ int32_t lino = 0;
+
+ // start compact
+ code = tsdbCompactFileSetStart(pCompactor, pSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ // do compact, end with a NULL row
+ SRowInfo *pRowInfo;
+ do {
+ code = tsdbCompactNextRow(pCompactor, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbCompactWriteTableData(pCompactor, pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ } while (pRowInfo);
+
+ // end compact
+ code = tsdbCompactFileSetEnd(pCompactor);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pCompactor->pTsdb->pVnode), __func__, lino,
+ tstrerror(code), pCompactor->fid);
+ if (pCompactor->pWriter) tsdbDataFWriterClose(&pCompactor->pWriter, 0);
+ while ((pCompactor->pIter = pCompactor->iterList)) {
+ pCompactor->iterList = pCompactor->pIter->next;
+ tsdbCloseDataIter2(pCompactor->pIter);
+ }
+ if (pCompactor->pReader) tsdbDataFReaderClose(&pCompactor->pReader);
+ }
+ return code;
+}
+
+static void tsdbEndCompact(STsdbCompactor *pCompactor) {
+ // writer
+ tBlockDataDestroy(&pCompactor->sData);
+ tBlockDataDestroy(&pCompactor->bData);
+ taosArrayDestroy(pCompactor->aSttBlk);
+ tMapDataClear(&pCompactor->mDataBlk);
+ taosArrayDestroy(pCompactor->aBlockIdx);
+
+ // reader
+
+ // tombstone
+ taosArrayDestroy(pCompactor->aSkyLine);
+ taosArrayDestroy(pCompactor->aDelData);
+ taosArrayDestroy(pCompactor->aDelIdx);
+
+ // others
+ tDestroyTSchema(pCompactor->tbSkm.pTSchema);
+ tsdbFSDestroy(&pCompactor->fs);
+
+ tsdbInfo("vgId:%d %s done, commit ID:%" PRId64, TD_VID(pCompactor->pTsdb->pVnode), __func__, pCompactor->commitID);
+}
+
+static int32_t tsdbBeginCompact(STsdb *pTsdb, SCompactInfo *pInfo, STsdbCompactor *pCompactor) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ pCompactor->pTsdb = pTsdb;
+ pCompactor->commitID = pInfo->commitID;
+ pCompactor->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
+ pCompactor->maxRows = pTsdb->pVnode->config.tsdbCfg.maxRows;
+ pCompactor->minRows = pTsdb->pVnode->config.tsdbCfg.minRows;
+ pCompactor->fid = INT32_MIN;
+
+ code = tsdbFSCopy(pTsdb, &pCompactor->fs);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ /* tombstone */
+ if (pCompactor->fs.pDelFile) {
+ code = tsdbDelFReaderOpen(&pCompactor->pDelFReader, pCompactor->fs.pDelFile, pTsdb);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if ((pCompactor->aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if ((pCompactor->aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if ((pCompactor->aSkyLine = taosArrayInit(0, sizeof(TSDBKEY))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ code = tsdbReadDelIdx(pCompactor->pDelFReader, pCompactor->aDelIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ /* reader */
+
+ /* writer */
+ code = tBlockDataCreate(&pCompactor->bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tBlockDataCreate(&pCompactor->sData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, commit ID:%" PRId64, TD_VID(pTsdb->pVnode), __func__, lino,
+ tstrerror(code), pCompactor->commitID);
+ tBlockDataDestroy(&pCompactor->sData);
+ tBlockDataDestroy(&pCompactor->bData);
+ if (pCompactor->fs.pDelFile) {
+ taosArrayDestroy(pCompactor->aSkyLine);
+ taosArrayDestroy(pCompactor->aDelData);
+ taosArrayDestroy(pCompactor->aDelIdx);
+ if (pCompactor->pDelFReader) tsdbDelFReaderClose(&pCompactor->pDelFReader);
+ }
+ tsdbFSDestroy(&pCompactor->fs);
+ } else {
+ tsdbInfo("vgId:%d %s done, commit ID:%" PRId64, TD_VID(pTsdb->pVnode), __func__, pCompactor->commitID);
+ }
+ return code;
+}
+
+int32_t tsdbCompact(STsdb *pTsdb, SCompactInfo *pInfo) {
+ int32_t code = 0;
+
+ STsdbCompactor *pCompactor = &(STsdbCompactor){0};
+
+ if ((code = tsdbBeginCompact(pTsdb, pInfo, pCompactor))) return code;
+
+ for (;;) {
+ SDFileSet *pSet = (SDFileSet *)taosArraySearch(pCompactor->fs.aDFileSet, &(SDFileSet){.fid = pCompactor->fid},
+ tDFileSetCmprFn, TD_GT);
+ if (pSet == NULL) {
+ pCompactor->fid = INT32_MAX;
+ break;
+ }
+
+ if ((code = tsdbCompactFileSet(pCompactor, pSet))) goto _exit;
+ }
+
+ if ((code = tsdbFSUpsertDelFile(&pCompactor->fs, NULL))) goto _exit;
+
+_exit:
+ if (code) {
+ tsdbAbortCompact(pCompactor);
+ } else {
+ tsdbCommitCompact(pCompactor);
+ }
+ tsdbEndCompact(pCompactor);
return code;
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbDataIter.c b/source/dnode/vnode/src/tsdb/tsdbDataIter.c
new file mode 100644
index 0000000000000000000000000000000000000000..2f49781276082dad126a1d2a1c6a396b7fd9dafe
--- /dev/null
+++ b/source/dnode/vnode/src/tsdb/tsdbDataIter.c
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tsdb.h"
+
+// STsdbDataIter2
+/* open */
+int32_t tsdbOpenDataFileDataIter(SDataFReader* pReader, STsdbDataIter2** ppIter) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ // create handle
+ STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter));
+ if (pIter == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ pIter->type = TSDB_DATA_FILE_DATA_ITER;
+ pIter->dIter.pReader = pReader;
+ if ((pIter->dIter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ code = tBlockDataCreate(&pIter->dIter.bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->dIter.iBlockIdx = 0;
+ pIter->dIter.iDataBlk = 0;
+ pIter->dIter.iRow = 0;
+
+ // read data
+ code = tsdbReadBlockIdx(pReader, pIter->dIter.aBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (taosArrayGetSize(pIter->dIter.aBlockIdx) == 0) goto _clear;
+
+_exit:
+ if (code) {
+ if (pIter) {
+ _clear:
+ tBlockDataDestroy(&pIter->dIter.bData);
+ taosArrayDestroy(pIter->dIter.aBlockIdx);
+ taosMemoryFree(pIter);
+ pIter = NULL;
+ }
+ }
+ *ppIter = pIter;
+ return code;
+}
+
+int32_t tsdbOpenSttFileDataIter(SDataFReader* pReader, int32_t iStt, STsdbDataIter2** ppIter) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ // create handle
+ STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter));
+ if (pIter == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ pIter->type = TSDB_STT_FILE_DATA_ITER;
+ pIter->sIter.pReader = pReader;
+ pIter->sIter.iStt = iStt;
+ pIter->sIter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
+ if (pIter->sIter.aSttBlk == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ code = tBlockDataCreate(&pIter->sIter.bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->sIter.iSttBlk = 0;
+ pIter->sIter.iRow = 0;
+
+ // read data
+ code = tsdbReadSttBlk(pReader, iStt, pIter->sIter.aSttBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (taosArrayGetSize(pIter->sIter.aSttBlk) == 0) goto _clear;
+
+_exit:
+ if (code) {
+ if (pIter) {
+ _clear:
+ taosArrayDestroy(pIter->sIter.aSttBlk);
+ tBlockDataDestroy(&pIter->sIter.bData);
+ taosMemoryFree(pIter);
+ pIter = NULL;
+ }
+ }
+ *ppIter = pIter;
+ return code;
+}
+
+int32_t tsdbOpenTombFileDataIter(SDelFReader* pReader, STsdbDataIter2** ppIter) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter));
+ if (pIter == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ pIter->type = TSDB_TOMB_FILE_DATA_ITER;
+
+ pIter->tIter.pReader = pReader;
+ if ((pIter->tIter.aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ if ((pIter->tIter.aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ code = tsdbReadDelIdx(pReader, pIter->tIter.aDelIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (taosArrayGetSize(pIter->tIter.aDelIdx) == 0) goto _clear;
+
+ pIter->tIter.iDelIdx = 0;
+ pIter->tIter.iDelData = 0;
+
+_exit:
+ if (code) {
+ if (pIter) {
+ _clear:
+ taosArrayDestroy(pIter->tIter.aDelIdx);
+ taosArrayDestroy(pIter->tIter.aDelData);
+ taosMemoryFree(pIter);
+ pIter = NULL;
+ }
+ }
+ *ppIter = pIter;
+ return code;
+}
+
+/* close */
+static void tsdbCloseDataFileDataIter(STsdbDataIter2* pIter) {
+ tBlockDataDestroy(&pIter->dIter.bData);
+ tMapDataClear(&pIter->dIter.mDataBlk);
+ taosArrayDestroy(pIter->dIter.aBlockIdx);
+ taosMemoryFree(pIter);
+}
+
+static void tsdbCloseSttFileDataIter(STsdbDataIter2* pIter) {
+ tBlockDataDestroy(&pIter->sIter.bData);
+ taosArrayDestroy(pIter->sIter.aSttBlk);
+ taosMemoryFree(pIter);
+}
+
+static void tsdbCloseTombFileDataIter(STsdbDataIter2* pIter) {
+ taosArrayDestroy(pIter->tIter.aDelData);
+ taosArrayDestroy(pIter->tIter.aDelIdx);
+ taosMemoryFree(pIter);
+}
+
+void tsdbCloseDataIter2(STsdbDataIter2* pIter) {
+ if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) {
+ ASSERT(0);
+ } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) {
+ tsdbCloseDataFileDataIter(pIter);
+ } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) {
+ tsdbCloseSttFileDataIter(pIter);
+ } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) {
+ tsdbCloseTombFileDataIter(pIter);
+ } else {
+ ASSERT(0);
+ }
+}
+
+/* cmpr */
+int32_t tsdbDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) {
+ STsdbDataIter2* pIter1 = TSDB_RBTN_TO_DATA_ITER(pNode1);
+ STsdbDataIter2* pIter2 = TSDB_RBTN_TO_DATA_ITER(pNode2);
+ return tRowInfoCmprFn(&pIter1->rowInfo, &pIter2->rowInfo);
+}
+
+/* seek */
+
+/* iter next */
+static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ for (;;) {
+ while (pIter->dIter.iRow < pIter->dIter.bData.nRow) {
+ if (pFilterInfo) {
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
+ if (pFilterInfo->tbid.uid == pIter->dIter.bData.uid) {
+ pIter->dIter.iRow = pIter->dIter.bData.nRow;
+ continue;
+ }
+ }
+
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
+ if (pIter->dIter.bData.aVersion[pIter->dIter.iRow] < pFilterInfo->sver ||
+ pIter->dIter.bData.aVersion[pIter->dIter.iRow] > pFilterInfo->ever) {
+ pIter->dIter.iRow++;
+ continue;
+ }
+ }
+ }
+
+ ASSERT(pIter->rowInfo.suid == pIter->dIter.bData.suid);
+ ASSERT(pIter->rowInfo.uid = pIter->dIter.bData.uid);
+ pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->dIter.bData, pIter->dIter.iRow);
+ pIter->dIter.iRow++;
+ goto _exit;
+ }
+
+ for (;;) {
+ while (pIter->dIter.iDataBlk < pIter->dIter.mDataBlk.nItem) {
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pIter->dIter.mDataBlk, pIter->dIter.iDataBlk, &dataBlk, tGetDataBlk);
+
+ // filter
+ if (pFilterInfo) {
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
+ if (tTABLEIDCmprFn(&pFilterInfo->tbid, &pIter->rowInfo) == 0) {
+ pIter->dIter.iDataBlk = pIter->dIter.mDataBlk.nItem;
+ continue;
+ }
+ }
+
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
+ if (pFilterInfo->sver > dataBlk.maxVer || pFilterInfo->ever < dataBlk.minVer) {
+ pIter->dIter.iDataBlk++;
+ continue;
+ }
+ }
+ }
+
+ code = tsdbReadDataBlockEx(pIter->dIter.pReader, &dataBlk, &pIter->dIter.bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->dIter.iDataBlk++;
+ pIter->dIter.iRow = 0;
+
+ break;
+ }
+
+ if (pIter->dIter.iRow < pIter->dIter.bData.nRow) break;
+
+ for (;;) {
+ if (pIter->dIter.iBlockIdx < taosArrayGetSize(pIter->dIter.aBlockIdx)) {
+ SBlockIdx* pBlockIdx = taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx);
+
+ if (pFilterInfo && (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID)) {
+ int32_t c = tTABLEIDCmprFn(pBlockIdx, &pFilterInfo->tbid);
+ if (c == 0) {
+ pIter->dIter.iBlockIdx++;
+ continue;
+ } else if (c < 0) {
+ ASSERT(0);
+ }
+ }
+
+ code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->rowInfo.suid = pBlockIdx->suid;
+ pIter->rowInfo.uid = pBlockIdx->uid;
+
+ pIter->dIter.iBlockIdx++;
+ pIter->dIter.iDataBlk = 0;
+
+ break;
+ } else {
+ pIter->rowInfo = (SRowInfo){0};
+ goto _exit;
+ }
+ }
+ }
+ }
+
+_exit:
+ if (code) {
+ tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
+ }
+ return code;
+}
+
+static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ for (;;) {
+ while (pIter->sIter.iRow < pIter->sIter.bData.nRow) {
+ if (pFilterInfo) {
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
+ int64_t uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow];
+ if (pFilterInfo->tbid.uid == uid) {
+ pIter->sIter.iRow++;
+ continue;
+ }
+ }
+
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
+ if (pFilterInfo->sver > pIter->sIter.bData.aVersion[pIter->sIter.iRow] ||
+ pFilterInfo->ever < pIter->sIter.bData.aVersion[pIter->sIter.iRow]) {
+ pIter->sIter.iRow++;
+ continue;
+ }
+ }
+ }
+
+ pIter->rowInfo.suid = pIter->sIter.bData.suid;
+ pIter->rowInfo.uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow];
+ pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->sIter.bData, pIter->sIter.iRow);
+ pIter->sIter.iRow++;
+ goto _exit;
+ }
+
+ for (;;) {
+ if (pIter->sIter.iSttBlk < taosArrayGetSize(pIter->sIter.aSttBlk)) {
+ SSttBlk* pSttBlk = taosArrayGet(pIter->sIter.aSttBlk, pIter->sIter.iSttBlk);
+
+ if (pFilterInfo) {
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_TABLEID) {
+ if (pSttBlk->suid == pFilterInfo->tbid.suid && pSttBlk->minUid == pFilterInfo->tbid.uid &&
+ pSttBlk->maxUid == pFilterInfo->tbid.uid) {
+ pIter->sIter.iSttBlk++;
+ continue;
+ }
+ }
+
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
+ if (pFilterInfo->sver > pSttBlk->maxVer || pFilterInfo->ever < pSttBlk->minVer) {
+ pIter->sIter.iSttBlk++;
+ continue;
+ }
+ }
+ }
+
+ code = tsdbReadSttBlockEx(pIter->sIter.pReader, pIter->sIter.iStt, pSttBlk, &pIter->sIter.bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->sIter.iRow = 0;
+ pIter->sIter.iSttBlk++;
+ break;
+ } else {
+ pIter->rowInfo = (SRowInfo){0};
+ goto _exit;
+ }
+ }
+ }
+
+_exit:
+ if (code) {
+ tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
+ }
+ return code;
+}
+
+static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ for (;;) {
+ while (pIter->tIter.iDelData < taosArrayGetSize(pIter->tIter.aDelData)) {
+ SDelData* pDelData = taosArrayGet(pIter->tIter.aDelData, pIter->tIter.iDelData);
+
+ if (pFilterInfo) {
+ if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) {
+ if (pFilterInfo->sver > pDelData->version || pFilterInfo->ever < pDelData->version) {
+ pIter->tIter.iDelData++;
+ continue;
+ }
+ }
+ }
+
+ pIter->delInfo.delData = *pDelData;
+ pIter->tIter.iDelData++;
+ goto _exit;
+ }
+
+ for (;;) {
+ if (pIter->tIter.iDelIdx < taosArrayGetSize(pIter->tIter.aDelIdx)) {
+ SDelIdx* pDelIdx = taosArrayGet(pIter->tIter.aDelIdx, pIter->tIter.iDelIdx);
+
+ code = tsdbReadDelData(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pIter->delInfo.suid = pDelIdx->suid;
+ pIter->delInfo.uid = pDelIdx->uid;
+ pIter->tIter.iDelData = 0;
+ pIter->tIter.iDelIdx++;
+ break;
+ } else {
+ pIter->delInfo = (SDelInfo){0};
+ goto _exit;
+ }
+ }
+ }
+
+_exit:
+ if (code) {
+ tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
+ }
+ return code;
+}
+
+int32_t tsdbDataIterNext2(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) {
+ int32_t code = 0;
+
+ if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) {
+ ASSERT(0);
+ return code;
+ } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) {
+ return tsdbDataFileDataIterNext(pIter, pFilterInfo);
+ } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) {
+ return tsdbSttFileDataIterNext(pIter, pFilterInfo);
+ } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) {
+ return tsdbTombFileDataIterNext(pIter, pFilterInfo);
+ } else {
+ ASSERT(0);
+ return code;
+ }
+}
+
+/* get */
+
+// STsdbFSetIter
+typedef struct STsdbFSetDataIter {
+ STsdb* pTsdb;
+ int32_t flags;
+
+ /* tombstone */
+ SDelFReader* pDelFReader;
+ SArray* aDelIdx; // SArray
+ SArray* aDelData; // SArray
+ SArray* aSkeyLine; // SArray
+ int32_t iDelIdx;
+ int32_t iSkyLine;
+
+ /* time-series data */
+ SDataFReader* pReader;
+ STsdbDataIter2* iterList;
+ STsdbDataIter2* pIter;
+ SRBTree rbt;
+} STsdbFSetDataIter;
diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c
index 51fdc69a95cc0a935a6b6e2abd390d5927384a50..5519d43012f46dc2e24ad56083ff421d5fcff1c5 100644
--- a/source/dnode/vnode/src/tsdb/tsdbFS.c
+++ b/source/dnode/vnode/src/tsdb/tsdbFS.c
@@ -629,7 +629,15 @@ static int32_t tsdbFSApplyChange(STsdb *pTsdb, STsdbFS *pFS) {
}
}
} else {
- ASSERT(pTsdb->fs.pDelFile == NULL);
+ if (pTsdb->fs.pDelFile) {
+ nRef = atomic_sub_fetch_32(&pTsdb->fs.pDelFile->nRef, 1);
+ if (nRef == 0) {
+ tsdbDelFileName(pTsdb, pTsdb->fs.pDelFile, fname);
+ (void)taosRemoveFile(fname);
+ taosMemoryFree(pTsdb->fs.pDelFile);
+ }
+ pTsdb->fs.pDelFile = NULL;
+ }
}
// aDFileSet
@@ -906,14 +914,21 @@ _exit:
int32_t tsdbFSUpsertDelFile(STsdbFS *pFS, SDelFile *pDelFile) {
int32_t code = 0;
- if (pFS->pDelFile == NULL) {
- pFS->pDelFile = (SDelFile *)taosMemoryMalloc(sizeof(SDelFile));
+ if (pDelFile) {
if (pFS->pDelFile == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
+ pFS->pDelFile = (SDelFile *)taosMemoryMalloc(sizeof(SDelFile));
+ if (pFS->pDelFile == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+ }
+ *pFS->pDelFile = *pDelFile;
+ } else {
+ if (pFS->pDelFile) {
+ taosMemoryFree(pFS->pDelFile);
+ pFS->pDelFile = NULL;
}
}
- *pFS->pDelFile = *pDelFile;
_exit:
return code;
diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
index 1f99444cf3cc655be656ce86a70ea22920c26fe8..a97cd3db2752ea35c34dddbd14499d357d9177de 100644
--- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
@@ -515,7 +515,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow);
_exit:
- return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL);
+ return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL) && (pBlockData != NULL);
}
SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; }
diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c
index 588debbe52907a33541e4c08ecfe0ba620f88ae0..4466721fb9444e4ee158de6d974cfe87affe4941 100644
--- a/source/dnode/vnode/src/tsdb/tsdbRead.c
+++ b/source/dnode/vnode/src/tsdb/tsdbRead.c
@@ -79,6 +79,9 @@ typedef struct SIOCostSummary {
int64_t composedBlocks;
double buildComposedBlockTime;
double createScanInfoList;
+ // double getTbFromMemTime;
+ // double getTbFromIMemTime;
+ double initDelSkylineIterTime;
} SIOCostSummary;
typedef struct SBlockLoadSuppInfo {
@@ -176,10 +179,9 @@ struct STsdbReader {
SDataFReader* pFileReader; // the file reader
SDelFReader* pDelFReader; // the del file reader
SArray* pDelIdx; // del file block index;
- // SVersionRange verRange;
- SBlockInfoBuf blockInfoBuf;
- int32_t step;
- STsdbReader* innerReader[2];
+ SBlockInfoBuf blockInfoBuf;
+ int32_t step;
+ STsdbReader* innerReader[2];
};
static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter);
@@ -218,6 +220,9 @@ static int32_t doBuildDataBlock(STsdbReader* pReader);
static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo);
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter);
+static int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order);
+
+static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid);
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
@@ -573,6 +578,68 @@ static SSDataBlock* createResBlock(SQueryTableDataCond* pCond, int32_t capacity)
return pResBlock;
}
+static int32_t tsdbInitReaderLock(STsdbReader* pReader) {
+ int32_t code = -1;
+ qTrace("tsdb/read: %p, pre-init read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ code = taosThreadMutexInit(&pReader->readerMutex, NULL);
+
+ qTrace("tsdb/read: %p, post-init read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ return code;
+}
+
+static int32_t tsdbUninitReaderLock(STsdbReader* pReader) {
+ int32_t code = -1;
+ qTrace("tsdb/read: %p, pre-uninit read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ code = taosThreadMutexDestroy(&pReader->readerMutex);
+
+ qTrace("tsdb/read: %p, post-uninit read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ return code;
+}
+
+static int32_t tsdbAcquireReader(STsdbReader* pReader) {
+ int32_t code = -1;
+ qTrace("tsdb/read: %p, pre-take read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ code = taosThreadMutexLock(&pReader->readerMutex);
+
+ qTrace("tsdb/read: %p, post-take read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ return code;
+}
+
+static int32_t tsdbTryAcquireReader(STsdbReader* pReader) {
+ int32_t code = -1;
+ qTrace("tsdb/read: %p, pre-trytake read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ code = taosThreadMutexTryLock(&pReader->readerMutex);
+
+ qTrace("tsdb/read: %p, post-trytake read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ return code;
+}
+
+static int32_t tsdbReleaseReader(STsdbReader* pReader) {
+ int32_t code = -1;
+ qTrace("tsdb/read: %p, pre-untake read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ code = taosThreadMutexUnlock(&pReader->readerMutex);
+
+ qTrace("tsdb/read: %p, post-untake read mutex: %p, code: %d", pReader, &pReader->readerMutex, code);
+
+ return code;
+}
+
+void tsdbReleaseDataBlock(STsdbReader* pReader) {
+ SReaderStatus* pStatus = &pReader->status;
+ if (!pStatus->composedDataBlock) {
+ tsdbReleaseReader(pReader);
+ }
+}
+
static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsdbReader** ppReader, int32_t capacity,
SSDataBlock* pResBlock, const char* idstr) {
int32_t code = 0;
@@ -636,7 +703,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
setColumnIdSlotList(&pReader->suppInfo, pCond->colList, pCond->pSlotList, pCond->numOfCols);
- taosThreadMutexInit(&pReader->readerMutex, NULL);
+ tsdbInitReaderLock(pReader);
*ppReader = pReader;
return code;
@@ -648,17 +715,21 @@ _end:
}
static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, SArray* pIndexList) {
- SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx));
+ // SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx));
int64_t st = taosGetTimestampUs();
- int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx);
- if (code != TSDB_CODE_SUCCESS) {
+ // int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx);
+ LRUHandle* handle = NULL;
+ int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle);
+ if (code != TSDB_CODE_SUCCESS || handle == NULL) {
goto _end;
}
- size_t num = taosArrayGetSize(aBlockIdx);
+ SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle);
+ size_t num = taosArrayGetSize(aBlockIdx);
if (num == 0) {
- taosArrayDestroy(aBlockIdx);
+ tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle);
+ // taosArrayDestroy(aBlockIdx);
return TSDB_CODE_SUCCESS;
}
@@ -694,7 +765,8 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader,
pReader->cost.headFileLoadTime += (et1 - st) / 1000.0;
_end:
- taosArrayDestroy(aBlockIdx);
+ // taosArrayDestroy(aBlockIdx);
+ tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle);
return code;
}
@@ -1007,7 +1079,7 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
}
}
-static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) {
+static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) {
SReaderStatus* pStatus = &pReader->status;
SDataBlockIter* pBlockIter = &pStatus->blockIter;
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
@@ -1024,6 +1096,14 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
bool asc = ASCENDING_TRAVERSE(pReader->order);
int32_t step = asc ? 1 : -1;
+ // no data exists, return directly.
+ if (pBlockData->nRow == 0 || pBlockData->aTSKEY == 0) {
+ tsdbWarn("%p no need to copy since no data in blockData, table uid:%" PRIu64 " has been dropped, %s", pReader,
+ pBlockInfo->uid, pReader->idStr);
+ pResBlock->info.rows = 0;
+ return 0;
+ }
+
if ((pDumpInfo->rowIndex == 0 && asc) || (pDumpInfo->rowIndex == pBlock->nRow - 1 && (!asc))) {
if (asc && pReader->window.skey <= pBlock->minKey.ts) {
// pDumpInfo->rowIndex = 0;
@@ -1123,28 +1203,33 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
setBlockAllDumped(pDumpInfo, ts, pReader->order);
}
- pBlockScanInfo->lastKey = pDumpInfo->lastKey;
-
double elapsedTime = (taosGetTimestampUs() - st) / 1000.0;
pReader->cost.blockLoadTime += elapsedTime;
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
- ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
+ ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", uid:%" PRIu64 " elapsed time:%.2f ms, %s",
pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, dumpedRows,
- unDumpedRows, pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
+ unDumpedRows, pBlock->minVer, pBlock->maxVer, pBlockInfo->uid, elapsedTime, pReader->idStr);
return TSDB_CODE_SUCCESS;
}
static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockIter, SBlockData* pBlockData,
uint64_t uid) {
+ int32_t code = 0;
int64_t st = taosGetTimestampUs();
tBlockDataReset(pBlockData);
- TABLEID tid = {.suid = pReader->suid, .uid = uid};
- int32_t code =
- tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1);
+ STSchema* pSchema = getLatestTableSchema(pReader, uid);
+ if (pSchema == NULL) {
+ tsdbDebug("%p table uid:%" PRIu64 " has been dropped, no data existed, %s", pReader, uid, pReader->idStr);
+ return code;
+ }
+
+ SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
+ TABLEID tid = {.suid = pReader->suid, .uid = uid};
+ code = tBlockDataInit(pBlockData, &tid, pSchema, &pSup->colId[1], pSup->numOfCols - 1);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@@ -1570,7 +1655,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pBlock
// log the reason why load the datablock for profile
if (loadDataBlock) {
tsdbDebug("%p uid:%" PRIu64
- " need to load the datablock, overlapwithneighborblock:%d, hasDup:%d, partiallyRequired:%d, "
+ " need to load the datablock, overlapneighbor:%d, hasDup:%d, partiallyRequired:%d, "
"overlapWithKey:%d, greaterThanBuf:%d, overlapWithDel:%d, overlapWithlastBlock:%d, %s",
pReader, pBlockInfo->uid, info.overlapWithNeighborBlock, info.hasDupTs, info.partiallyRequired,
info.overlapWithKeyInBuf, info.moreThanCapcity, info.overlapWithDelInfo, info.overlapWithLastBlock,
@@ -1606,9 +1691,9 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo*
double elapsedTime = (taosGetTimestampUs() - st) / 1000.0;
tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange:%" PRId64
- " - %" PRId64 " %s",
+ " - %" PRId64 ", uid:%"PRIu64", %s",
pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey,
- pReader->idStr);
+ pBlockScanInfo->uid, pReader->idStr);
pReader->cost.buildmemBlock += elapsedTime;
return code;
@@ -1634,8 +1719,10 @@ static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pB
return false;
}
-static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pBlockScanInfo,
+static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo,
SVersionRange* pVerRange) {
+ int32_t step = ASCENDING_TRAVERSE(pLastBlockReader->order)? 1:-1;
+
while (1) {
bool hasVal = tMergeTreeNext(&pLastBlockReader->mergeTree);
if (!hasVal) {
@@ -1644,8 +1731,15 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc
TSDBROW row = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
TSDBKEY k = TSDBROW_KEY(&row);
- if (!hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order,
- pVerRange)) {
+ if (hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order, pVerRange)) {
+ pScanInfo->lastKey = k.ts;
+ } else {
+ // the qualifed ts may equal to k.ts, only a greater version one.
+ // here we need to fallback one step.
+ if (pScanInfo->lastKey == k.ts) {
+ pScanInfo->lastKey -= step;
+ }
+
return true;
}
}
@@ -1668,6 +1762,19 @@ static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SLastBlockReader* pLas
return false;
}
+static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid) {
+ if (pReader->pSchema != NULL) {
+ return pReader->pSchema;
+ }
+
+ pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, -1, 1);
+ if (pReader->pSchema == NULL) {
+ tsdbError("failed to get table schema, uid:%" PRIu64 ", it may have been dropped, ver:-1, %s", uid, pReader->idStr);
+ }
+
+ return pReader->pSchema;
+}
+
static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader* pReader, uint64_t uid) {
// always set the newest schema version in pReader->pSchema
if (pReader->pSchema == NULL) {
@@ -2197,6 +2304,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
}
int32_t backward = (!ASCENDING_TRAVERSE(pReader->order));
+ int64_t st = 0;
STbData* d = NULL;
if (pReader->pReadSnap->pMem != NULL) {
@@ -2206,17 +2314,17 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
if (code == TSDB_CODE_SUCCESS) {
pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL);
- tsdbDebug("%p uid:%" PRId64 ", check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
+ tsdbDebug("%p uid:%" PRIu64 ", check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
"-%" PRId64 " %s",
pReader, pBlockScanInfo->uid, startKey.ts, pReader->order, d->minKey, d->maxKey, pReader->idStr);
} else {
- tsdbError("%p uid:%" PRId64 ", failed to create iterator for imem, code:%s, %s", pReader, pBlockScanInfo->uid,
+ tsdbError("%p uid:%" PRIu64 ", failed to create iterator for imem, code:%s, %s", pReader, pBlockScanInfo->uid,
tstrerror(code), pReader->idStr);
return code;
}
}
} else {
- tsdbDebug("%p uid:%" PRId64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr);
+ tsdbDebug("%p uid:%" PRIu64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr);
}
STbData* di = NULL;
@@ -2227,20 +2335,22 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
if (code == TSDB_CODE_SUCCESS) {
pBlockScanInfo->iiter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iiter.iter) != NULL);
- tsdbDebug("%p uid:%" PRId64 ", check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
+ tsdbDebug("%p uid:%" PRIu64 ", check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
"-%" PRId64 " %s",
pReader, pBlockScanInfo->uid, startKey.ts, pReader->order, di->minKey, di->maxKey, pReader->idStr);
} else {
- tsdbError("%p uid:%" PRId64 ", failed to create iterator for mem, code:%s, %s", pReader, pBlockScanInfo->uid,
+ tsdbError("%p uid:%" PRIu64 ", failed to create iterator for mem, code:%s, %s", pReader, pBlockScanInfo->uid,
tstrerror(code), pReader->idStr);
return code;
}
}
} else {
- tsdbDebug("%p uid:%" PRId64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr);
+ tsdbDebug("%p uid:%" PRIu64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr);
}
+ st = taosGetTimestampUs();
initDelSkylineIterator(pBlockScanInfo, pReader, d, di);
+ pReader->cost.initDelSkylineIterTime += (taosGetTimestampUs() - st) / 1000.0;
pBlockScanInfo->iterInit = true;
return TSDB_CODE_SUCCESS;
@@ -2297,6 +2407,7 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
w.ekey = pScanInfo->lastKey + step;
}
+ tsdbDebug("init last block reader, window:%"PRId64"-%"PRId64", uid:%"PRIu64", %s", w.skey, w.ekey, pScanInfo->uid, pReader->idStr);
int32_t code = tMergeTreeOpen(&pLBlockReader->mergeTree, (pLBlockReader->order == TSDB_ORDER_DESC),
pReader->pFileReader, pReader->suid, pScanInfo->uid, &w, &pLBlockReader->verRange,
pLBlockReader->pInfo, false, pReader->idStr);
@@ -2470,7 +2581,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) &&
pBlock->nRow <= pReader->capacity) {
if (asc || ((!asc) && (!hasDataInLastBlock(pLastBlockReader)))) {
- copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
+ copyBlockDataToSDataBlock(pReader);
// record the last key value
pBlockScanInfo->lastKey = asc ? pBlock->maxKey.ts : pBlock->minKey.ts;
@@ -2547,6 +2658,14 @@ _end:
void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; }
+int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order) {
+ if (pDelSkyline == NULL) {
+ return 0;
+ }
+
+ return ASCENDING_TRAVERSE(order) ? 0 : taosArrayGetSize(pDelSkyline) - 1;
+}
+
int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData,
STbData* piMemTbData) {
if (pBlockScanInfo->delSkyline != NULL) {
@@ -2564,7 +2683,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
if (pIdx != NULL) {
code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData);
}
-
if (code != TSDB_CODE_SUCCESS) {
goto _err;
}
@@ -2593,11 +2711,13 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
}
taosArrayDestroy(pDelData);
- pBlockScanInfo->iter.index =
- ASCENDING_TRAVERSE(pReader->order) ? 0 : taosArrayGetSize(pBlockScanInfo->delSkyline) - 1;
- pBlockScanInfo->iiter.index = pBlockScanInfo->iter.index;
- pBlockScanInfo->fileDelIndex = pBlockScanInfo->iter.index;
- pBlockScanInfo->lastBlockDelIndex = pBlockScanInfo->iter.index;
+ int32_t index = getInitialDelIndex(pBlockScanInfo->delSkyline, pReader->order);
+
+ pBlockScanInfo->iter.index = index;
+ pBlockScanInfo->iiter.index = index;
+ pBlockScanInfo->fileDelIndex = index;
+ pBlockScanInfo->lastBlockDelIndex = index;
+
return code;
_err:
@@ -2606,21 +2726,39 @@ _err:
}
TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
- TSDBKEY key = {.ts = TSKEY_INITIAL_VAL};
+ bool asc = ASCENDING_TRAVERSE(pReader->order);
+ // TSKEY initialVal = asc? TSKEY_MIN:TSKEY_MAX;
+
+ TSDBKEY key = {.ts = TSKEY_INITIAL_VAL}, ikey = {.ts = TSKEY_INITIAL_VAL};
+
+ bool hasKey = false, hasIKey = false;
TSDBROW* pRow = getValidMemRow(&pScanInfo->iter, pScanInfo->delSkyline, pReader);
if (pRow != NULL) {
+ hasKey = true;
key = TSDBROW_KEY(pRow);
}
- pRow = getValidMemRow(&pScanInfo->iiter, pScanInfo->delSkyline, pReader);
- if (pRow != NULL) {
- TSDBKEY k = TSDBROW_KEY(pRow);
- if (key.ts > k.ts) {
- key = k;
- }
+ TSDBROW* pIRow = getValidMemRow(&pScanInfo->iiter, pScanInfo->delSkyline, pReader);
+ if (pIRow != NULL) {
+ hasIKey = true;
+ ikey = TSDBROW_KEY(pIRow);
}
- return key;
+ if (hasKey) {
+ if (hasIKey) { // has data in mem & imem
+ if (asc) {
+ return key.ts <= ikey.ts ? key : ikey;
+ } else {
+ return key.ts <= ikey.ts ? ikey : key;
+ }
+ } else { // no data in imem
+ return key;
+ }
+ } else {
+ // no data in mem & imem, return the initial value
+ // only imem has data, return ikey
+ return ikey;
+ }
}
static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
@@ -2696,7 +2834,7 @@ static int32_t uidComparFunc(const void* p1, const void* p2) {
}
}
-static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) {
+static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus, int32_t order) {
int32_t index = 0;
int32_t total = taosHashGetSize(pStatus->pTableMap);
@@ -2710,7 +2848,9 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SRea
taosSort(pOrderCheckInfo->tableUidList, total, sizeof(uint64_t), uidComparFunc);
}
-static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) {
+static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, STsdbReader* pReader) {
+ SReaderStatus* pStatus = &pReader->status;
+
int32_t total = taosHashGetSize(pStatus->pTableMap);
if (total == 0) {
return TSDB_CODE_SUCCESS;
@@ -2723,7 +2863,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt
return TSDB_CODE_OUT_OF_MEMORY;
}
- extractOrderedTableUidList(pOrderCheckInfo, pStatus);
+ extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order);
uint64_t uid = pOrderCheckInfo->tableUidList[0];
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
} else {
@@ -2740,7 +2880,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt
}
pOrderCheckInfo->tableUidList = p;
- extractOrderedTableUidList(pOrderCheckInfo, pStatus);
+ extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order);
uid = pOrderCheckInfo->tableUidList[0];
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
@@ -2760,11 +2900,7 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus
uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex];
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
- if (pStatus->pTableIter == NULL) {
- return false;
- }
-
- return true;
+ return (pStatus->pTableIter != NULL);
}
static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
@@ -2772,7 +2908,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader;
SUidOrderCheckInfo* pOrderedCheckInfo = &pStatus->uidCheckInfo;
- int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus);
+ int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pReader);
if (code != TSDB_CODE_SUCCESS || (taosHashGetSize(pStatus->pTableMap) == 0)) {
return code;
}
@@ -2837,59 +2973,21 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
- if (pBlockInfo != NULL) {
- pScanInfo =
- *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
- } else {
- pScanInfo = *pReader->status.pTableIter;
- }
+ ASSERT(pBlockInfo != NULL);
+ pScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
if (pScanInfo == NULL) {
tsdbError("failed to get table scan-info, %s", pReader->idStr);
code = TSDB_CODE_INVALID_PARA;
return code;
}
- if (pBlockInfo != NULL) {
- pBlock = getCurrentBlock(pBlockIter);
- }
+ pBlock = getCurrentBlock(pBlockIter);
initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
- if (pBlockInfo == NULL) { // build data block from last data file
- SBlockData* pBData = &pReader->status.fileBlockData;
- tBlockDataReset(pBData);
-
- SSDataBlock* pResBlock = pReader->pResBlock;
- tsdbDebug("load data in last block firstly, due to desc scan data, %s", pReader->idStr);
-
- int64_t st = taosGetTimestampUs();
-
- while (1) {
- bool hasBlockLData = hasDataInLastBlock(pLastBlockReader);
-
- // no data in last block and block, no need to proceed.
- if (hasBlockLData == false) {
- break;
- }
-
- buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader);
- if (pResBlock->info.rows >= pReader->capacity) {
- break;
- }
- }
-
- double el = (taosGetTimestampUs() - st) / 1000.0;
- updateComposedBlockInfo(pReader, el, pScanInfo);
-
- if (pResBlock->info.rows > 0) {
- tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64
- " rows:%d, elapsed time:%.2f ms %s",
- pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
- pResBlock->info.rows, el, pReader->idStr);
- }
- } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
+ if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid);
if (code != TSDB_CODE_SUCCESS) {
return code;
@@ -2943,12 +3041,18 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
SDataBlockInfo* pInfo = &pReader->pResBlock->info;
pInfo->rows = pBlock->nRow;
pInfo->id.uid = pScanInfo->uid;
+ pInfo->dataLoad = 0;
pInfo->window = (STimeWindow){.skey = pBlock->minKey.ts, .ekey = pBlock->maxKey.ts};
setComposedBlockFlag(pReader, false);
setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlock->maxKey.ts, pReader->order);
// update the last key for the corresponding table
pScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order) ? pInfo->window.ekey : pInfo->window.skey;
+ tsdbDebug("%p uid:%" PRIu64
+ " clean file block retrieved from file, global index:%d, "
+ "table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s",
+ pReader, pScanInfo->uid, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->nRow, pBlock->minKey.ts,
+ pBlock->maxKey.ts, pReader->idStr);
}
}
@@ -3957,6 +4061,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
return;
}
+ tsdbAcquireReader(pReader);
{
if (pReader->innerReader[0] != NULL || pReader->innerReader[1] != NULL) {
STsdbReader* p = pReader->innerReader[0];
@@ -4014,10 +4119,13 @@ void tsdbReaderClose(STsdbReader* pReader) {
pReader->pDelIdx = NULL;
}
- qTrace("tsdb/reader: %p, untake snapshot", pReader);
+ qTrace("tsdb/reader-close: %p, untake snapshot", pReader);
tsdbUntakeReadSnap(pReader, pReader->pReadSnap, true);
+ pReader->pReadSnap = NULL;
- taosThreadMutexDestroy(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
+
+ tsdbUninitReaderLock(pReader);
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
SIOCostSummary* pCost = &pReader->cost;
@@ -4033,19 +4141,21 @@ void tsdbReaderClose(STsdbReader* pReader) {
taosMemoryFree(pLReader);
}
- tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
- " SMA-time:%.2f ms, fileBlocks:%" PRId64
- ", fileBlocks-load-time:%.2f ms, "
- "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64
- ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64
- ", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb, creatTime:%.2f ms, %s",
- pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime,
- pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad,
- pCost->lastBlockLoadTime, pCost->composedBlocks, pCost->buildComposedBlockTime,
- numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pCost->createScanInfoList, pReader->idStr);
+ tsdbDebug(
+ "%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
+ " SMA-time:%.2f ms, fileBlocks:%" PRId64
+ ", fileBlocks-load-time:%.2f ms, "
+ "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64 ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64
+ ", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb, createTime:%.2f ms,initDelSkylineIterTime:%.2f "
+ "ms, %s",
+ pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime, pCost->numOfBlocks,
+ pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad, pCost->lastBlockLoadTime, pCost->composedBlocks,
+ pCost->buildComposedBlockTime, numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pCost->createScanInfoList,
+ pCost->initDelSkylineIterTime, pReader->idStr);
taosMemoryFree(pReader->idStr);
taosMemoryFree(pReader->pSchema);
+
if (pReader->pMemSchema != pReader->pSchema) {
taosMemoryFree(pReader->pMemSchema);
}
@@ -4164,16 +4274,16 @@ static int32_t tsdbSetQueryReseek(void* pQHandle) {
int32_t code = 0;
STsdbReader* pReader = pQHandle;
- code = taosThreadMutexTryLock(&pReader->readerMutex);
+ code = tsdbTryAcquireReader(pReader);
if (code == 0) {
if (pReader->suspended) {
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return code;
}
tsdbReaderSuspend(pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return code;
} else if (code == EBUSY) {
@@ -4274,8 +4384,9 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
SReaderStatus* pStatus = &pReader->status;
- qTrace("tsdb/read: %p, take read mutex", pReader);
- taosThreadMutexLock(&pReader->readerMutex);
+ int32_t code = tsdbAcquireReader(pReader);
+ qTrace("tsdb/read: %p, take read mutex, code: %d", pReader, code);
+
if (pReader->suspended) {
tsdbReaderResume(pReader);
}
@@ -4287,7 +4398,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
pStatus = &pReader->innerReader[0]->status;
if (pStatus->composedDataBlock) {
qTrace("tsdb/read: %p, unlock read mutex", pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
}
return ret;
@@ -4310,7 +4421,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
if (ret) {
if (pStatus->composedDataBlock) {
qTrace("tsdb/read: %p, unlock read mutex", pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
}
return ret;
@@ -4330,7 +4441,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
pStatus = &pReader->innerReader[1]->status;
if (pStatus->composedDataBlock) {
qTrace("tsdb/read: %p, unlock read mutex", pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
}
return ret1;
@@ -4338,31 +4449,11 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
}
qTrace("tsdb/read: %p, unlock read mutex", pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return false;
}
-static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
- *rows = pReader->pResBlock->info.rows;
- *uid = pReader->pResBlock->info.id.uid;
- *pWindow = pReader->pResBlock->info.window;
-}
-
-void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
- if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
- if (pReader->step == EXTERNAL_ROWS_MAIN) {
- setBlockInfo(pReader, rows, uid, pWindow);
- } else if (pReader->step == EXTERNAL_ROWS_PREV) {
- setBlockInfo(pReader->innerReader[0], rows, uid, pWindow);
- } else {
- setBlockInfo(pReader->innerReader[1], rows, uid, pWindow);
- }
- } else {
- setBlockInfo(pReader, rows, uid, pWindow);
- }
-}
-
static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, SColumnDataAgg* pTsAgg) {
// do fill all null column value SMA info
int32_t i = 0, j = 0;
@@ -4493,17 +4584,10 @@ static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) {
return NULL;
}
- copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
+ copyBlockDataToSDataBlock(pReader);
return pReader->pResBlock;
}
-void tsdbReleaseDataBlock(STsdbReader* pReader) {
- // SReaderStatus* pStatus = &pReader->status;
- // if (!pStatus->composedDataBlock) {
- taosThreadMutexUnlock(&pReader->readerMutex);
- //}
-}
-
SSDataBlock* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
STsdbReader* pTReader = pReader;
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
@@ -4522,7 +4606,7 @@ SSDataBlock* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
SSDataBlock* ret = doRetrieveDataBlock(pTReader);
qTrace("tsdb/read-retrieve: %p, unlock read mutex", pReader);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return ret;
}
@@ -4531,7 +4615,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
SReaderStatus* pStatus = &pReader->status;
qTrace("tsdb/reader-reset: %p, take read mutex", pReader);
- taosThreadMutexLock(&pReader->readerMutex);
+ tsdbAcquireReader(pReader);
if (pReader->suspended) {
tsdbReaderResume(pReader);
@@ -4540,7 +4624,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
if (isEmptyQueryTimeWindow(&pReader->window) || pReader->pReadSnap == NULL) {
tsdbDebug("tsdb reader reset return %p", pReader->pReadSnap);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return TSDB_CODE_SUCCESS;
}
@@ -4578,7 +4662,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
tsdbError("%p reset reader failed, numOfTables:%d, query range:%" PRId64 " - %" PRId64 " in query %s", pReader,
numOfTables, pReader->window.skey, pReader->window.ekey, pReader->idStr);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return code;
}
@@ -4589,7 +4673,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
pReader, pReader->suid, numOfTables, pCond->twindows.skey, pReader->window.skey, pReader->window.ekey,
pReader->idStr);
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return code;
}
@@ -4674,7 +4758,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
int64_t rows = 0;
SReaderStatus* pStatus = &pReader->status;
- taosThreadMutexLock(&pReader->readerMutex);
+ tsdbAcquireReader(pReader);
if (pReader->suspended) {
tsdbReaderResume(pReader);
}
@@ -4704,7 +4788,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) {
pStatus->pTableIter = taosHashIterate(pStatus->pTableMap, pStatus->pTableIter);
}
- taosThreadMutexUnlock(&pReader->readerMutex);
+ tsdbReleaseReader(pReader);
return rows;
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
index 5c7bfee5a7bc07bdf1e91015e4d3d36e5873d7ec..9f57887d485d6d3674e599956453074d5edc3a33 100644
--- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
@@ -15,274 +15,181 @@
#include "tsdb.h"
-// STsdbSnapReader ========================================
-typedef enum { SNAP_DATA_FILE_ITER = 0, SNAP_STT_FILE_ITER } EFIterT;
-typedef struct {
- SRBTreeNode n;
- SRowInfo rInfo;
- EFIterT type;
- union {
- struct {
- SArray* aBlockIdx;
- int32_t iBlockIdx;
- SBlockIdx* pBlockIdx;
- SMapData mBlock;
- int32_t iBlock;
- }; // .data file
- struct {
- int32_t iStt;
- SArray* aSttBlk;
- int32_t iSttBlk;
- }; // .stt file
- };
- SBlockData bData;
- int32_t iRow;
-} SFDataIter;
-
-struct STsdbSnapReader {
- STsdb* pTsdb;
- int64_t sver;
- int64_t ever;
- STsdbFS fs;
- int8_t type;
- // for data file
- int8_t dataDone;
- int32_t fid;
- SDataFReader* pDataFReader;
- SFDataIter* pIter;
- SRBTree rbt;
- SFDataIter aFDataIter[TSDB_MAX_STT_TRIGGER + 1];
- SBlockData bData;
- SSkmInfo skmTable;
- // for del file
- int8_t delDone;
- SDelFReader* pDelFReader;
- SArray* aDelIdx; // SArray
- int32_t iDelIdx;
- SArray* aDelData; // SArray
- uint8_t* aBuf[5];
-};
-
-extern int32_t tRowInfoCmprFn(const void* p1, const void* p2);
-extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData);
extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo);
+extern int32_t tsdbWriteDataBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SMapData* mDataBlk, int8_t cmprAlg);
+extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SArray* aSttBlk, int8_t cmprAlg);
-static int32_t tFDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) {
- SFDataIter* pIter1 = (SFDataIter*)(((uint8_t*)pNode1) - offsetof(SFDataIter, n));
- SFDataIter* pIter2 = (SFDataIter*)(((uint8_t*)pNode2) - offsetof(SFDataIter, n));
+// STsdbSnapReader ========================================
+struct STsdbSnapReader {
+ STsdb* pTsdb;
+ int64_t sver;
+ int64_t ever;
+ int8_t type;
+ uint8_t* aBuf[5];
- return tRowInfoCmprFn(&pIter1->rInfo, &pIter2->rInfo);
-}
+ STsdbFS fs;
+ TABLEID tbid;
+ SSkmInfo skmTable;
+
+ // timeseries data
+ int8_t dataDone;
+ int32_t fid;
+
+ SDataFReader* pDataFReader;
+ STsdbDataIter2* iterList;
+ STsdbDataIter2* pIter;
+ SRBTree rbt;
+ SBlockData bData;
+
+ // tombstone data
+ int8_t delDone;
+ SDelFReader* pDelFReader;
+ STsdbDataIter2* pTIter;
+ SArray* aDelData;
+};
-static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
+static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) {
int32_t code = 0;
int32_t lino = 0;
- SDFileSet dFileSet = {.fid = pReader->fid};
- SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &dFileSet, tDFileSetCmprFn, TD_GT);
- if (pSet == NULL) return code;
+ SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &(SDFileSet){.fid = pReader->fid}, tDFileSetCmprFn, TD_GT);
+ if (pSet == NULL) {
+ pReader->fid = INT32_MAX;
+ goto _exit;
+ }
pReader->fid = pSet->fid;
- code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet);
- TSDB_CHECK_CODE(code, lino, _exit);
-
- pReader->pIter = NULL;
- tRBTreeCreate(&pReader->rbt, tFDataIterCmprFn);
- // .data file
- SFDataIter* pIter = &pReader->aFDataIter[0];
- pIter->type = SNAP_DATA_FILE_ITER;
+ tRBTreeCreate(&pReader->rbt, tsdbDataIterCmprFn);
- code = tsdbReadBlockIdx(pReader->pDataFReader, pIter->aBlockIdx);
+ code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet);
TSDB_CHECK_CODE(code, lino, _exit);
- for (pIter->iBlockIdx = 0; pIter->iBlockIdx < taosArrayGetSize(pIter->aBlockIdx); pIter->iBlockIdx++) {
- pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx);
+ code = tsdbOpenDataFileDataIter(pReader->pDataFReader, &pReader->pIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock);
+ if (pReader->pIter) {
+ // iter to next with filter info (sver, ever)
+ code = tsdbDataIterNext2(pReader->pIter,
+ &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
+ .sver = pReader->sver,
+ .ever = pReader->ever});
TSDB_CHECK_CODE(code, lino, _exit);
- for (pIter->iBlock = 0; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) {
- SDataBlk dataBlk;
- tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk);
-
- if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue;
+ if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) {
+ // add to rbtree
+ tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn);
- code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData);
- TSDB_CHECK_CODE(code, lino, _exit);
-
- ASSERT(pIter->pBlockIdx->suid == pIter->bData.suid);
- ASSERT(pIter->pBlockIdx->uid == pIter->bData.uid);
-
- for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
- int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
-
- if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
- pIter->rInfo.suid = pIter->pBlockIdx->suid;
- pIter->rInfo.uid = pIter->pBlockIdx->uid;
- pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
- goto _add_iter_and_break;
- }
- }
+ // add to iterList
+ pReader->pIter->next = pReader->iterList;
+ pReader->iterList = pReader->pIter;
+ } else {
+ tsdbCloseDataIter2(pReader->pIter);
}
-
- continue;
-
- _add_iter_and_break:
- tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter);
- break;
}
- // .stt file
- pIter = &pReader->aFDataIter[1];
- for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
- pIter->type = SNAP_STT_FILE_ITER;
- pIter->iStt = iStt;
-
- code = tsdbReadSttBlk(pReader->pDataFReader, iStt, pIter->aSttBlk);
+ for (int32_t iStt = 0; iStt < pSet->nSttF; ++iStt) {
+ code = tsdbOpenSttFileDataIter(pReader->pDataFReader, iStt, &pReader->pIter);
TSDB_CHECK_CODE(code, lino, _exit);
- for (pIter->iSttBlk = 0; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
- SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
-
- if (pSttBlk->minVer > pReader->ever) continue;
- if (pSttBlk->maxVer < pReader->sver) continue;
-
- code = tsdbReadSttBlockEx(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData);
+ if (pReader->pIter) {
+ // iter to valid row
+ code = tsdbDataIterNext2(pReader->pIter,
+ &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
+ .sver = pReader->sver,
+ .ever = pReader->ever});
TSDB_CHECK_CODE(code, lino, _exit);
- for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
- int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
+ if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) {
+ // add to rbtree
+ tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn);
- if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
- pIter->rInfo.suid = pIter->bData.suid;
- pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
- pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
- goto _add_iter;
- }
+ // add to iterList
+ pReader->pIter->next = pReader->iterList;
+ pReader->iterList = pReader->pIter;
+ } else {
+ tsdbCloseDataIter2(pReader->pIter);
}
}
-
- continue;
-
- _add_iter:
- tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter);
- pIter++;
}
+ pReader->pIter = NULL;
+
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed since %s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code));
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
} else {
- tsdbInfo("vgId:%d, %s done, path:%s, fid:%d", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path,
- pReader->fid);
+ tsdbInfo("vgId:%d %s done, fid:%d", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->fid);
}
return code;
}
-static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
- int32_t code = 0;
-
- if (pReader->pIter) {
- SFDataIter* pIter = NULL;
- while (true) {
- _find_row:
- pIter = pReader->pIter;
- for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
- int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
-
- if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
- pIter->rInfo.suid = pIter->bData.suid;
- pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
- pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
- goto _out;
- }
- }
-
- if (pIter->type == SNAP_DATA_FILE_ITER) {
- while (true) {
- for (pIter->iBlock++; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) {
- SDataBlk dataBlk;
- tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk);
-
- if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue;
-
- code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData);
- if (code) goto _err;
-
- pIter->iRow = -1;
- goto _find_row;
- }
-
- pIter->iBlockIdx++;
- if (pIter->iBlockIdx >= taosArrayGetSize(pIter->aBlockIdx)) break;
-
- pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx);
- code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock);
- if (code) goto _err;
- pIter->iBlock = -1;
- }
+static void tsdbSnapReadFileDataEnd(STsdbSnapReader* pReader) {
+ while (pReader->iterList) {
+ STsdbDataIter2* pIter = pReader->iterList;
+ pReader->iterList = pIter->next;
+ tsdbCloseDataIter2(pIter);
+ }
- pReader->pIter = NULL;
- break;
- } else if (pIter->type == SNAP_STT_FILE_ITER) {
- for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
- SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
+ tsdbDataFReaderClose(&pReader->pDataFReader);
+}
- if (pSttBlk->minVer > pReader->ever || pSttBlk->maxVer < pReader->sver) continue;
+static int32_t tsdbSnapReadNextRow(STsdbSnapReader* pReader, SRowInfo** ppRowInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
- code = tsdbReadSttBlockEx(pReader->pDataFReader, pIter->iStt, pSttBlk, &pIter->bData);
- if (code) goto _err;
+ if (pReader->pIter) {
+ code = tsdbDataIterNext2(pReader->pIter, &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag
+ .sver = pReader->sver,
+ .ever = pReader->ever});
+ TSDB_CHECK_CODE(code, lino, _exit);
- pIter->iRow = -1;
- goto _find_row;
+ if (pReader->pIter->rowInfo.suid == 0 && pReader->pIter->rowInfo.uid == 0) {
+ pReader->pIter = NULL;
+ } else {
+ SRBTreeNode* pNode = tRBTreeMin(&pReader->rbt);
+ if (pNode) {
+ int32_t c = tsdbDataIterCmprFn(&pReader->pIter->rbtn, pNode);
+ if (c > 0) {
+ tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn);
+ pReader->pIter = NULL;
+ } else if (c == 0) {
+ ASSERT(0);
}
-
- pReader->pIter = NULL;
- break;
- } else {
- ASSERT(0);
}
}
+ }
- _out:
- pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt);
- if (pReader->pIter && pIter) {
- int32_t c = tRowInfoCmprFn(&pReader->pIter->rInfo, &pIter->rInfo);
- if (c > 0) {
- tRBTreePut(&pReader->rbt, (SRBTreeNode*)pReader->pIter);
- pReader->pIter = NULL;
- } else {
- ASSERT(c);
- }
+ if (pReader->pIter == NULL) {
+ SRBTreeNode* pNode = tRBTreeMin(&pReader->rbt);
+ if (pNode) {
+ tRBTreeDrop(&pReader->rbt, pNode);
+ pReader->pIter = TSDB_RBTN_TO_DATA_ITER(pNode);
}
}
- if (pReader->pIter == NULL) {
- pReader->pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt);
+ if (ppRowInfo) {
if (pReader->pIter) {
- tRBTreeDrop(&pReader->rbt, (SRBTreeNode*)pReader->pIter);
+ *ppRowInfo = &pReader->pIter->rowInfo;
+ } else {
+ *ppRowInfo = NULL;
}
}
- return code;
-
-_err:
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
return code;
}
-static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) {
+static int32_t tsdbSnapReadGetRow(STsdbSnapReader* pReader, SRowInfo** ppRowInfo) {
if (pReader->pIter) {
- return &pReader->pIter->rInfo;
- } else {
- tsdbSnapNextRow(pReader);
-
- if (pReader->pIter) {
- return &pReader->pIter->rInfo;
- } else {
- return NULL;
- }
+ *ppRowInfo = &pReader->pIter->rowInfo;
+ return 0;
}
+
+ return tsdbSnapReadNextRow(pReader, ppRowInfo);
}
static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
@@ -302,7 +209,7 @@ static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
}
SSnapDataHdr* pHdr = (SSnapDataHdr*)*ppData;
- pHdr->type = SNAP_DATA_TSDB;
+ pHdr->type = pReader->type;
pHdr->size = size;
memcpy(pHdr->data, pReader->aBuf[3], aBufN[3]);
@@ -318,155 +225,215 @@ _exit:
return code;
}
-static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
+static int32_t tsdbSnapReadTimeSeriesData(STsdbSnapReader* pReader, uint8_t** ppData) {
int32_t code = 0;
int32_t lino = 0;
STsdb* pTsdb = pReader->pTsdb;
- while (true) {
+ tBlockDataReset(&pReader->bData);
+
+ for (;;) {
+ // start a new file read if need
if (pReader->pDataFReader == NULL) {
- code = tsdbSnapReadOpenFile(pReader);
+ code = tsdbSnapReadFileDataStart(pReader);
TSDB_CHECK_CODE(code, lino, _exit);
}
if (pReader->pDataFReader == NULL) break;
- SRowInfo* pRowInfo = tsdbSnapGetRow(pReader);
+ SRowInfo* pRowInfo;
+ code = tsdbSnapReadGetRow(pReader, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
if (pRowInfo == NULL) {
- tsdbDataFReaderClose(&pReader->pDataFReader);
+ tsdbSnapReadFileDataEnd(pReader);
continue;
}
- TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid};
- SBlockData* pBlockData = &pReader->bData;
-
- code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, id.suid, id.uid, &pReader->skmTable);
+ code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, pRowInfo->suid, pRowInfo->uid, &pReader->skmTable);
TSDB_CHECK_CODE(code, lino, _exit);
- code = tBlockDataInit(pBlockData, &id, pReader->skmTable.pTSchema, NULL, 0);
+ code = tBlockDataInit(&pReader->bData, (TABLEID*)pRowInfo, pReader->skmTable.pTSchema, NULL, 0);
TSDB_CHECK_CODE(code, lino, _exit);
- while (pRowInfo->suid == id.suid && pRowInfo->uid == id.uid) {
- code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pRowInfo->uid);
+ do {
+ if (!TABLE_SAME_SCHEMA(pReader->bData.suid, pReader->bData.uid, pRowInfo->suid, pRowInfo->uid)) break;
+
+ if (pReader->bData.uid && pReader->bData.uid != pRowInfo->uid) {
+ code = tRealloc((uint8_t**)&pReader->bData.aUid, sizeof(int64_t) * (pReader->bData.nRow + 1));
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ for (int32_t iRow = 0; iRow < pReader->bData.nRow; ++iRow) {
+ pReader->bData.aUid[iRow] = pReader->bData.uid;
+ }
+ pReader->bData.uid = 0;
+ }
+
+ code = tBlockDataAppendRow(&pReader->bData, &pRowInfo->row, NULL, pRowInfo->uid);
TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbSnapNextRow(pReader);
+ code = tsdbSnapReadNextRow(pReader, &pRowInfo);
TSDB_CHECK_CODE(code, lino, _exit);
- pRowInfo = tsdbSnapGetRow(pReader);
- if (pRowInfo == NULL) {
- tsdbDataFReaderClose(&pReader->pDataFReader);
- break;
- }
+ if (pReader->bData.nRow >= 4096) break;
+ } while (pRowInfo);
- if (pBlockData->nRow >= 4096) break;
- }
+ ASSERT(pReader->bData.nRow > 0);
+
+ break;
+ }
+
+ if (pReader->bData.nRow > 0) {
+ ASSERT(pReader->bData.suid || pReader->bData.uid);
code = tsdbSnapCmprData(pReader, ppData);
TSDB_CHECK_CODE(code, lino, _exit);
-
- break;
}
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path);
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
}
return code;
}
-static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
+static int32_t tsdbSnapCmprTombData(STsdbSnapReader* pReader, uint8_t** ppData) {
int32_t code = 0;
int32_t lino = 0;
- STsdb* pTsdb = pReader->pTsdb;
- SDelFile* pDelFile = pReader->fs.pDelFile;
-
- if (pReader->pDelFReader == NULL) {
- if (pDelFile == NULL) {
- goto _exit;
- }
+ int64_t size = sizeof(TABLEID);
+ for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); ++iDelData) {
+ size += tPutDelData(NULL, taosArrayGet(pReader->aDelData, iDelData));
+ }
- // open
- code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pTsdb);
+ uint8_t* pData = (uint8_t*)taosMemoryMalloc(sizeof(SSnapDataHdr) + size);
+ if (pData == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
TSDB_CHECK_CODE(code, lino, _exit);
+ }
- // read index
- code = tsdbReadDelIdx(pReader->pDelFReader, pReader->aDelIdx);
- TSDB_CHECK_CODE(code, lino, _exit);
+ SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
+ pHdr->type = SNAP_DATA_DEL;
+ pHdr->size = size;
- pReader->iDelIdx = 0;
+ TABLEID* pId = (TABLEID*)(pData + sizeof(SSnapDataHdr));
+ *pId = pReader->tbid;
+
+ size = sizeof(SSnapDataHdr) + sizeof(TABLEID);
+ for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); ++iDelData) {
+ size += tPutDelData(pData + size, taosArrayGet(pReader->aDelData, iDelData));
}
- while (true) {
- if (pReader->iDelIdx >= taosArrayGetSize(pReader->aDelIdx)) {
- tsdbDelFReaderClose(&pReader->pDelFReader);
- break;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ if (pData) {
+ taosMemoryFree(pData);
+ pData = NULL;
}
+ }
+ *ppData = pData;
+ return code;
+}
- SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pReader->aDelIdx, pReader->iDelIdx);
+static void tsdbSnapReadGetTombData(STsdbSnapReader* pReader, SDelInfo** ppDelInfo) {
+ if (pReader->pTIter == NULL || (pReader->pTIter->delInfo.suid == 0 && pReader->pTIter->delInfo.uid == 0)) {
+ *ppDelInfo = NULL;
+ } else {
+ *ppDelInfo = &pReader->pTIter->delInfo;
+ }
+}
- pReader->iDelIdx++;
+static int32_t tsdbSnapReadNextTombData(STsdbSnapReader* pReader, SDelInfo** ppDelInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
- code = tsdbReadDelData(pReader->pDelFReader, pDelIdx, pReader->aDelData);
- TSDB_CHECK_CODE(code, lino, _exit);
+ code = tsdbDataIterNext2(
+ pReader->pTIter,
+ &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, .sver = pReader->sver, .ever = pReader->ever});
+ TSDB_CHECK_CODE(code, lino, _exit);
- int32_t size = 0;
- for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) {
- SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData);
+ if (ppDelInfo) {
+ tsdbSnapReadGetTombData(pReader, ppDelInfo);
+ }
- if (pDelData->version >= pReader->sver && pDelData->version <= pReader->ever) {
- size += tPutDelData(NULL, pDelData);
- }
- }
- if (size == 0) continue;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
+ return code;
+}
- // org data
- size = sizeof(TABLEID) + size;
- *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size);
- if (*ppData == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
+static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdb* pTsdb = pReader->pTsdb;
+
+ // open tombstone data iter if need
+ if (pReader->pDelFReader == NULL) {
+ if (pReader->fs.pDelFile == NULL) goto _exit;
+
+ // open
+ code = tsdbDelFReaderOpen(&pReader->pDelFReader, pReader->fs.pDelFile, pTsdb);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbOpenTombFileDataIter(pReader->pDelFReader, &pReader->pTIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pReader->pTIter) {
+ code = tsdbSnapReadNextTombData(pReader, NULL);
TSDB_CHECK_CODE(code, lino, _exit);
}
+ }
+
+ // loop to get tombstone data
+ SDelInfo* pDelInfo;
+ tsdbSnapReadGetTombData(pReader, &pDelInfo);
- SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
- pHdr->type = SNAP_DATA_DEL;
- pHdr->size = size;
+ if (pDelInfo == NULL) goto _exit;
- TABLEID* pId = (TABLEID*)(&pHdr[1]);
- pId->suid = pDelIdx->suid;
- pId->uid = pDelIdx->uid;
- int32_t n = sizeof(SSnapDataHdr) + sizeof(TABLEID);
- for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) {
- SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData);
+ pReader->tbid = *(TABLEID*)pDelInfo;
- if (pDelData->version < pReader->sver) continue;
- if (pDelData->version > pReader->ever) continue;
+ if (pReader->aDelData) {
+ taosArrayClear(pReader->aDelData);
+ } else if ((pReader->aDelData = taosArrayInit(16, sizeof(SDelData))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- n += tPutDelData((*ppData) + n, pDelData);
+ while (pDelInfo && pDelInfo->suid == pReader->tbid.suid && pDelInfo->uid == pReader->tbid.uid) {
+ if (taosArrayPush(pReader->aDelData, &pDelInfo->delData) < 0) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%" PRId64 " size:%d",
- TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size);
+ code = tsdbSnapReadNextTombData(pReader, &pDelInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- break;
+ // encode tombstone data
+ if (taosArrayGetSize(pReader->aDelData) > 0) {
+ code = tsdbSnapCmprTombData(pReader, ppData);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path);
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
}
return code;
}
int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, STsdbSnapReader** ppReader) {
- int32_t code = 0;
- int32_t lino = 0;
- STsdbSnapReader* pReader = NULL;
+ int32_t code = 0;
+ int32_t lino = 0;
// alloc
- pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
+ STsdbSnapReader* pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
if (pReader == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
TSDB_CHECK_CODE(code, lino, _exit);
@@ -476,118 +443,80 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
pReader->ever = ever;
pReader->type = type;
- code = taosThreadRwlockRdlock(&pTsdb->rwLock);
- if (code) {
- code = TAOS_SYSTEM_ERROR(code);
- TSDB_CHECK_CODE(code, lino, _exit);
- }
-
+ taosThreadRwlockRdlock(&pTsdb->rwLock);
code = tsdbFSRef(pTsdb, &pReader->fs);
if (code) {
taosThreadRwlockUnlock(&pTsdb->rwLock);
TSDB_CHECK_CODE(code, lino, _exit);
}
+ taosThreadRwlockUnlock(&pTsdb->rwLock);
- code = taosThreadRwlockUnlock(&pTsdb->rwLock);
- if (code) {
- code = TAOS_SYSTEM_ERROR(code);
- TSDB_CHECK_CODE(code, lino, _exit);
- }
-
- // data
+ // init
pReader->fid = INT32_MIN;
- for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) {
- SFDataIter* pIter = &pReader->aFDataIter[iIter];
-
- if (iIter == 0) {
- pIter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
- if (pIter->aBlockIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- } else {
- pIter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
- if (pIter->aSttBlk == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- }
-
- code = tBlockDataCreate(&pIter->bData);
- TSDB_CHECK_CODE(code, lino, _exit);
- }
code = tBlockDataCreate(&pReader->bData);
TSDB_CHECK_CODE(code, lino, _exit);
- // del
- pReader->aDelIdx = taosArrayInit(0, sizeof(SDelIdx));
- if (pReader->aDelIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- pReader->aDelData = taosArrayInit(0, sizeof(SDelData));
- if (pReader->aDelData == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
-
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), __func__, lino,
- tstrerror(code), pTsdb->path);
- *ppReader = NULL;
-
+ tsdbError("vgId:%d %s failed at line %d since %s, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(pTsdb->pVnode),
+ __func__, lino, tstrerror(code), sver, ever, type);
if (pReader) {
- taosArrayDestroy(pReader->aDelData);
- taosArrayDestroy(pReader->aDelIdx);
tBlockDataDestroy(&pReader->bData);
- tsdbFSDestroy(&pReader->fs);
+ tsdbFSUnref(pTsdb, &pReader->fs);
taosMemoryFree(pReader);
+ pReader = NULL;
}
} else {
- *ppReader = pReader;
- tsdbInfo("vgId:%d, vnode snapshot tsdb reader opened for %s", TD_VID(pTsdb->pVnode), pTsdb->path);
+ tsdbInfo("vgId:%d %s done, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(pTsdb->pVnode), __func__, sver, ever,
+ type);
}
+ *ppReader = pReader;
return code;
}
int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
- int32_t code = 0;
- STsdbSnapReader* pReader = *ppReader;
-
- // data
- if (pReader->pDataFReader) tsdbDataFReaderClose(&pReader->pDataFReader);
- for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) {
- SFDataIter* pIter = &pReader->aFDataIter[iIter];
+ int32_t code = 0;
+ int32_t lino = 0;
- if (iIter == 0) {
- taosArrayDestroy(pIter->aBlockIdx);
- tMapDataClear(&pIter->mBlock);
- } else {
- taosArrayDestroy(pIter->aSttBlk);
- }
+ STsdbSnapReader* pReader = *ppReader;
+ STsdb* pTsdb = pReader->pTsdb;
- tBlockDataDestroy(&pIter->bData);
+ // tombstone
+ if (pReader->pTIter) {
+ tsdbCloseDataIter2(pReader->pTIter);
+ pReader->pTIter = NULL;
+ }
+ if (pReader->pDelFReader) {
+ tsdbDelFReaderClose(&pReader->pDelFReader);
}
+ taosArrayDestroy(pReader->aDelData);
+ // timeseries
+ while (pReader->iterList) {
+ STsdbDataIter2* pIter = pReader->iterList;
+ pReader->iterList = pIter->next;
+ tsdbCloseDataIter2(pIter);
+ }
+ if (pReader->pDataFReader) {
+ tsdbDataFReaderClose(&pReader->pDataFReader);
+ }
tBlockDataDestroy(&pReader->bData);
- tDestroyTSchema(pReader->skmTable.pTSchema);
-
- // del
- if (pReader->pDelFReader) tsdbDelFReaderClose(&pReader->pDelFReader);
- taosArrayDestroy(pReader->aDelIdx);
- taosArrayDestroy(pReader->aDelData);
+ // other
+ tDestroyTSchema(pReader->skmTable.pTSchema);
tsdbFSUnref(pReader->pTsdb, &pReader->fs);
-
- tsdbInfo("vgId:%d, vnode snapshot tsdb reader closed for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path);
-
for (int32_t iBuf = 0; iBuf < sizeof(pReader->aBuf) / sizeof(pReader->aBuf[0]); iBuf++) {
tFree(pReader->aBuf[iBuf]);
}
-
taosMemoryFree(pReader);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
*ppReader = NULL;
return code;
}
@@ -600,7 +529,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) {
// read data file
if (!pReader->dataDone) {
- code = tsdbSnapReadData(pReader, ppData);
+ code = tsdbSnapReadTimeSeriesData(pReader, ppData);
TSDB_CHECK_CODE(code, lino, _exit);
if (*ppData) {
goto _exit;
@@ -611,7 +540,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) {
// read del file
if (!pReader->delDone) {
- code = tsdbSnapReadDel(pReader, ppData);
+ code = tsdbSnapReadTombData(pReader, ppData);
TSDB_CHECK_CODE(code, lino, _exit);
if (*ppData) {
goto _exit;
@@ -622,22 +551,18 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) {
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code),
- pReader->pTsdb->path);
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code));
} else {
- tsdbDebug("vgId:%d, %s done, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path);
+ tsdbDebug("vgId:%d %s done", TD_VID(pReader->pTsdb->pVnode), __func__);
}
return code;
}
// STsdbSnapWriter ========================================
struct STsdbSnapWriter {
- STsdb* pTsdb;
- int64_t sver;
- int64_t ever;
- STsdbFS fs;
-
- // config
+ STsdb* pTsdb;
+ int64_t sver;
+ int64_t ever;
int32_t minutes;
int8_t precision;
int32_t minRow;
@@ -646,641 +571,816 @@ struct STsdbSnapWriter {
int64_t commitID;
uint8_t* aBuf[5];
- // for data file
- SBlockData bData;
- int32_t fid;
- TABLEID id;
- SSkmInfo skmTable;
- struct {
- SDataFReader* pReader;
- SArray* aBlockIdx;
- int32_t iBlockIdx;
- SBlockIdx* pBlockIdx;
- SMapData mDataBlk;
- int32_t iDataBlk;
- SBlockData bData;
- int32_t iRow;
- } dReader;
- struct {
- SDataFWriter* pWriter;
- SArray* aBlockIdx;
- SMapData mDataBlk;
- SArray* aSttBlk;
- SBlockData bData;
- SBlockData sData;
- } dWriter;
-
- // for del file
- SDelFReader* pDelFReader;
+ STsdbFS fs;
+ TABLEID tbid;
+
+ // time-series data
+ SBlockData inData;
+
+ int32_t fid;
+ SSkmInfo skmTable;
+
+ /* reader */
+ SDataFReader* pDataFReader;
+ STsdbDataIter2* iterList;
+ STsdbDataIter2* pDIter;
+ STsdbDataIter2* pSIter;
+ SRBTree rbt; // SRBTree
+
+ /* writer */
+ SDataFWriter* pDataFWriter;
+ SArray* aBlockIdx;
+ SMapData mDataBlk; // SMapData
+ SArray* aSttBlk; // SArray
+ SBlockData bData;
+ SBlockData sData;
+
+ // tombstone data
+ /* reader */
+ SDelFReader* pDelFReader;
+ STsdbDataIter2* pTIter;
+
+ /* writer */
SDelFWriter* pDelFWriter;
- int32_t iDelIdx;
- SArray* aDelIdxR;
+ SArray* aDelIdx;
SArray* aDelData;
- SArray* aDelIdxW;
};
// SNAP_DATA_TSDB
-extern int32_t tsdbWriteDataBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SMapData* mDataBlk, int8_t cmprAlg);
-extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SArray* aSttBlk, int8_t cmprAlg);
-
-static int32_t tsdbSnapNextTableData(STsdbSnapWriter* pWriter) {
+static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) {
int32_t code = 0;
+ int32_t lino = 0;
- ASSERT(pWriter->dReader.iRow >= pWriter->dReader.bData.nRow);
-
- if (pWriter->dReader.iBlockIdx < taosArrayGetSize(pWriter->dReader.aBlockIdx)) {
- pWriter->dReader.pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->dReader.aBlockIdx, pWriter->dReader.iBlockIdx);
-
- code = tsdbReadDataBlk(pWriter->dReader.pReader, pWriter->dReader.pBlockIdx, &pWriter->dReader.mDataBlk);
- if (code) goto _exit;
-
- pWriter->dReader.iBlockIdx++;
+ if (pId) {
+ pWriter->tbid = *pId;
} else {
- pWriter->dReader.pBlockIdx = NULL;
- tMapDataReset(&pWriter->dReader.mDataBlk);
+ pWriter->tbid = (TABLEID){INT64_MAX, INT64_MAX};
}
- pWriter->dReader.iDataBlk = 0; // point to the next one
- tBlockDataReset(&pWriter->dReader.bData);
- pWriter->dReader.iRow = 0;
-_exit:
- return code;
-}
+ if (pWriter->pDIter) {
+ STsdbDataIter2* pIter = pWriter->pDIter;
-static int32_t tsdbSnapWriteCopyData(STsdbSnapWriter* pWriter, TABLEID* pId) {
- int32_t code = 0;
+ // assert last table data end
+ ASSERT(pIter->dIter.iRow >= pIter->dIter.bData.nRow);
+ ASSERT(pIter->dIter.iDataBlk >= pIter->dIter.mDataBlk.nItem);
- while (true) {
- if (pWriter->dReader.pBlockIdx == NULL) break;
- if (tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, pId) >= 0) break;
+ for (;;) {
+ if (pIter->dIter.iBlockIdx >= taosArrayGetSize(pIter->dIter.aBlockIdx)) {
+ pWriter->pDIter = NULL;
+ break;
+ }
- SBlockIdx blkIdx = *pWriter->dReader.pBlockIdx;
- code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dReader.mDataBlk, &blkIdx);
- if (code) goto _exit;
+ SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx);
- if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blkIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
- }
+ int32_t c = tTABLEIDCmprFn(pBlockIdx, &pWriter->tbid);
+ if (c < 0) {
+ code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbSnapNextTableData(pWriter);
- if (code) goto _exit;
- }
+ SBlockIdx* pNewBlockIdx = taosArrayReserve(pWriter->aBlockIdx, 1);
+ if (pNewBlockIdx == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
-_exit:
- return code;
-}
+ pNewBlockIdx->suid = pBlockIdx->suid;
+ pNewBlockIdx->uid = pBlockIdx->uid;
-static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) {
- int32_t code = 0;
+ code = tsdbWriteDataBlk(pWriter->pDataFWriter, &pIter->dIter.mDataBlk, pNewBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbSnapWriteCopyData(pWriter, pId);
- if (code) goto _err;
+ pIter->dIter.iBlockIdx++;
+ } else if (c == 0) {
+ code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
- pWriter->id.suid = pId->suid;
- pWriter->id.uid = pId->uid;
+ pIter->dIter.iDataBlk = 0;
+ pIter->dIter.iBlockIdx++;
- code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pWriter->skmTable);
- if (code) goto _err;
+ break;
+ } else {
+ pIter->dIter.iDataBlk = pIter->dIter.mDataBlk.nItem;
+ break;
+ }
+ }
+ }
- tMapDataReset(&pWriter->dWriter.mDataBlk);
- code = tBlockDataInit(&pWriter->dWriter.bData, pId, pWriter->skmTable.pTSchema, NULL, 0);
- if (code) goto _err;
+ if (pId) {
+ code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pWriter->skmTable);
+ TSDB_CHECK_CODE(code, lino, _exit);
- return code;
+ tMapDataReset(&pWriter->mDataBlk);
-_err:
- tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
- return code;
+ code = tBlockDataInit(&pWriter->bData, pId, pWriter->skmTable.pTSchema, NULL, 0);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if (!TABLE_SAME_SCHEMA(pWriter->tbid.suid, pWriter->tbid.uid, pWriter->sData.suid, pWriter->sData.uid)) {
+ if ((pWriter->sData.nRow > 0)) {
+ code = tsdbWriteSttBlock(pWriter->pDataFWriter, &pWriter->sData, pWriter->aSttBlk, pWriter->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if (pId) {
+ TABLEID id = {.suid = pWriter->tbid.suid, .uid = pWriter->tbid.suid ? 0 : pWriter->tbid.uid};
+ code = tBlockDataInit(&pWriter->sData, &id, pWriter->skmTable.pTSchema, NULL, 0);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbTrace("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__,
+ pWriter->tbid.suid, pWriter->tbid.uid);
+ }
+ return code;
}
-static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
+static int32_t tsdbSnapWriteTableRowImpl(STsdbSnapWriter* pWriter, TSDBROW* pRow) {
int32_t code = 0;
+ int32_t lino = 0;
- if (pWriter->id.suid == 0 && pWriter->id.uid == 0) return code;
+ code = tBlockDataAppendRow(&pWriter->bData, pRow, pWriter->skmTable.pTSchema, pWriter->tbid.uid);
+ TSDB_CHECK_CODE(code, lino, _exit);
- int32_t c = 1;
- if (pWriter->dReader.pBlockIdx) {
- c = tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &pWriter->id);
- ASSERT(c >= 0);
+ if (pWriter->bData.nRow >= pWriter->maxRow) {
+ code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- if (c == 0) {
- SBlockData* pBData = &pWriter->dWriter.bData;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
+ return code;
+}
- for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) {
- TSDBROW row = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow);
+static int32_t tsdbSnapWriteTableRow(STsdbSnapWriter* pWriter, TSDBROW* pRow) {
+ int32_t code = 0;
+ int32_t lino = 0;
- code = tBlockDataAppendRow(pBData, &row, NULL, pWriter->id.uid);
- if (code) goto _err;
+ TSDBKEY inKey = pRow ? TSDBROW_KEY(pRow) : TSDBKEY_MAX;
- if (pBData->nRow >= pWriter->maxRow) {
- code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg);
- if (code) goto _err;
+ if (pWriter->pDIter == NULL || (pWriter->pDIter->dIter.iRow >= pWriter->pDIter->dIter.bData.nRow &&
+ pWriter->pDIter->dIter.iDataBlk >= pWriter->pDIter->dIter.mDataBlk.nItem)) {
+ goto _write_row;
+ } else {
+ for (;;) {
+ while (pWriter->pDIter->dIter.iRow < pWriter->pDIter->dIter.bData.nRow) {
+ TSDBROW row = tsdbRowFromBlockData(&pWriter->pDIter->dIter.bData, pWriter->pDIter->dIter.iRow);
+
+ int32_t c = tsdbKeyCmprFn(&inKey, &TSDBROW_KEY(&row));
+ if (c < 0) {
+ goto _write_row;
+ } else if (c > 0) {
+ code = tsdbSnapWriteTableRowImpl(pWriter, &row);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pWriter->pDIter->dIter.iRow++;
+ } else {
+ ASSERT(0);
+ }
}
- }
- code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg);
- if (code) goto _err;
+ for (;;) {
+ if (pWriter->pDIter->dIter.iDataBlk >= pWriter->pDIter->dIter.mDataBlk.nItem) goto _write_row;
- for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) {
- SDataBlk dataBlk;
- tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk);
+ // FIXME: Here can be slow, use array instead
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pWriter->pDIter->dIter.mDataBlk, pWriter->pDIter->dIter.iDataBlk, &dataBlk, tGetDataBlk);
- code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk);
- if (code) goto _err;
- }
-
- code = tsdbSnapNextTableData(pWriter);
- if (code) goto _err;
- }
+ int32_t c = tDataBlkCmprFn(&dataBlk, &(SDataBlk){.minKey = inKey, .maxKey = inKey});
+ if (c > 0) {
+ goto _write_row;
+ } else if (c < 0) {
+ if (pWriter->bData.nRow > 0) {
+ code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- if (pWriter->dWriter.mDataBlk.nItem) {
- SBlockIdx blockIdx = {.suid = pWriter->id.suid, .uid = pWriter->id.uid};
- code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dWriter.mDataBlk, &blockIdx);
+ tMapDataPutItem(&pWriter->mDataBlk, &dataBlk, tPutDataBlk);
+ pWriter->pDIter->dIter.iDataBlk++;
+ } else {
+ code = tsdbReadDataBlockEx(pWriter->pDataFReader, &dataBlk, &pWriter->pDIter->dIter.bData);
+ TSDB_CHECK_CODE(code, lino, _exit);
- if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blockIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
+ pWriter->pDIter->dIter.iRow = 0;
+ pWriter->pDIter->dIter.iDataBlk++;
+ break;
+ }
+ }
}
}
- pWriter->id.suid = 0;
- pWriter->id.uid = 0;
-
- return code;
+_write_row:
+ if (pRow) {
+ code = tsdbSnapWriteTableRowImpl(pWriter, pRow);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
-_err:
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
return code;
}
-static int32_t tsdbSnapWriteOpenFile(STsdbSnapWriter* pWriter, int32_t fid) {
+static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
- STsdb* pTsdb = pWriter->pTsdb;
+ int32_t lino = 0;
+
+ // write a NULL row to end current table data write
+ code = tsdbSnapWriteTableRow(pWriter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
- ASSERT(pWriter->dWriter.pWriter == NULL);
+ if (pWriter->bData.nRow > 0) {
+ if (pWriter->bData.nRow < pWriter->minRow) {
+ ASSERT(TABLE_SAME_SCHEMA(pWriter->sData.suid, pWriter->sData.uid, pWriter->tbid.suid, pWriter->tbid.uid));
+ for (int32_t iRow = 0; iRow < pWriter->bData.nRow; iRow++) {
+ code =
+ tBlockDataAppendRow(&pWriter->sData, &tsdbRowFromBlockData(&pWriter->bData, iRow), NULL, pWriter->tbid.uid);
+ TSDB_CHECK_CODE(code, lino, _exit);
- pWriter->fid = fid;
- pWriter->id = (TABLEID){0};
- SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
+ if (pWriter->sData.nRow >= pWriter->maxRow) {
+ code = tsdbWriteSttBlock(pWriter->pDataFWriter, &pWriter->sData, pWriter->aSttBlk, pWriter->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
- // Reader
- if (pSet) {
- code = tsdbDataFReaderOpen(&pWriter->dReader.pReader, pWriter->pTsdb, pSet);
- if (code) goto _err;
+ tBlockDataClear(&pWriter->bData);
+ } else {
+ code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ }
- code = tsdbReadBlockIdx(pWriter->dReader.pReader, pWriter->dReader.aBlockIdx);
- if (code) goto _err;
- } else {
- ASSERT(pWriter->dReader.pReader == NULL);
- taosArrayClear(pWriter->dReader.aBlockIdx);
- }
- pWriter->dReader.iBlockIdx = 0; // point to the next one
- code = tsdbSnapNextTableData(pWriter);
- if (code) goto _err;
-
- // Writer
- SHeadFile fHead = {.commitID = pWriter->commitID};
- SDataFile fData = {.commitID = pWriter->commitID};
- SSmaFile fSma = {.commitID = pWriter->commitID};
- SSttFile fStt = {.commitID = pWriter->commitID};
- SDFileSet wSet = {.fid = pWriter->fid, .pHeadF = &fHead, .pDataF = &fData, .pSmaF = &fSma};
- if (pSet) {
- wSet.diskId = pSet->diskId;
- fData = *pSet->pDataF;
- fSma = *pSet->pSmaF;
- for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
- wSet.aSttF[iStt] = pSet->aSttF[iStt];
+ if (pWriter->mDataBlk.nItem) {
+ SBlockIdx* pBlockIdx = taosArrayReserve(pWriter->aBlockIdx, 1);
+ if (pBlockIdx == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- wSet.nSttF = pSet->nSttF + 1; // TODO: fix pSet->nSttF == pTsdb->maxFile
- } else {
- SDiskID did = {0};
- tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did);
- tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
- wSet.diskId = did;
- wSet.nSttF = 1;
- }
- wSet.aSttF[wSet.nSttF - 1] = &fStt;
-
- code = tsdbDataFWriterOpen(&pWriter->dWriter.pWriter, pWriter->pTsdb, &wSet);
- if (code) goto _err;
- taosArrayClear(pWriter->dWriter.aBlockIdx);
- tMapDataReset(&pWriter->dWriter.mDataBlk);
- taosArrayClear(pWriter->dWriter.aSttBlk);
- tBlockDataReset(&pWriter->dWriter.bData);
- tBlockDataReset(&pWriter->dWriter.sData);
- return code;
+ pBlockIdx->suid = pWriter->tbid.suid;
+ pBlockIdx->uid = pWriter->tbid.uid;
-_err:
+ code = tsdbWriteDataBlk(pWriter->pDataFWriter, &pWriter->mDataBlk, pBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
return code;
}
-static int32_t tsdbSnapWriteCloseFile(STsdbSnapWriter* pWriter) {
+static int32_t tsdbSnapWriteFileDataStart(STsdbSnapWriter* pWriter, int32_t fid) {
int32_t code = 0;
+ int32_t lino = 0;
- ASSERT(pWriter->dWriter.pWriter);
+ ASSERT(pWriter->pDataFWriter == NULL && pWriter->fid < fid);
- code = tsdbSnapWriteTableDataEnd(pWriter);
- if (code) goto _err;
+ STsdb* pTsdb = pWriter->pTsdb;
- // copy remain table data
- TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX};
- code = tsdbSnapWriteCopyData(pWriter, &id);
- if (code) goto _err;
+ pWriter->fid = fid;
+ pWriter->tbid = (TABLEID){0};
+ SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
- code =
- tsdbWriteSttBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.sData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
- if (code) goto _err;
+ // open reader
+ pWriter->pDataFReader = NULL;
+ pWriter->iterList = NULL;
+ pWriter->pDIter = NULL;
+ pWriter->pSIter = NULL;
+ tRBTreeCreate(&pWriter->rbt, tsdbDataIterCmprFn);
+ if (pSet) {
+ code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
- // Indices
- code = tsdbWriteBlockIdx(pWriter->dWriter.pWriter, pWriter->dWriter.aBlockIdx);
- if (code) goto _err;
+ code = tsdbOpenDataFileDataIter(pWriter->pDataFReader, &pWriter->pDIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ if (pWriter->pDIter) {
+ pWriter->pDIter->next = pWriter->iterList;
+ pWriter->iterList = pWriter->pDIter;
+ }
- code = tsdbWriteSttBlk(pWriter->dWriter.pWriter, pWriter->dWriter.aSttBlk);
- if (code) goto _err;
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ code = tsdbOpenSttFileDataIter(pWriter->pDataFReader, iStt, &pWriter->pSIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbUpdateDFileSetHeader(pWriter->dWriter.pWriter);
- if (code) goto _err;
+ if (pWriter->pSIter) {
+ code = tsdbDataIterNext2(pWriter->pSIter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->dWriter.pWriter->wSet);
- if (code) goto _err;
+ // add to tree
+ tRBTreePut(&pWriter->rbt, &pWriter->pSIter->rbtn);
- code = tsdbDataFWriterClose(&pWriter->dWriter.pWriter, 1);
- if (code) goto _err;
+ // add to list
+ pWriter->pSIter->next = pWriter->iterList;
+ pWriter->iterList = pWriter->pSIter;
+ }
+ }
- if (pWriter->dReader.pReader) {
- code = tsdbDataFReaderClose(&pWriter->dReader.pReader);
- if (code) goto _err;
+ pWriter->pSIter = NULL;
}
-_exit:
- return code;
-
-_err:
- return code;
-}
+ // open writer
+ SDiskID diskId;
+ if (pSet) {
+ diskId = pSet->diskId;
+ } else {
+ tfsAllocDisk(pTsdb->pVnode->pTfs, 0 /*TODO*/, &diskId);
+ tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, diskId);
+ }
+ SDFileSet wSet = {.diskId = diskId,
+ .fid = fid,
+ .pHeadF = &(SHeadFile){.commitID = pWriter->commitID},
+ .pDataF = (pSet) ? pSet->pDataF : &(SDataFile){.commitID = pWriter->commitID},
+ .pSmaF = (pSet) ? pSet->pSmaF : &(SSmaFile){.commitID = pWriter->commitID},
+ .nSttF = 1,
+ .aSttF = {&(SSttFile){.commitID = pWriter->commitID}}};
+ code = tsdbDataFWriterOpen(&pWriter->pDataFWriter, pTsdb, &wSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
-static int32_t tsdbSnapWriteToDataFile(STsdbSnapWriter* pWriter, int32_t iRow, int8_t* done) {
- int32_t code = 0;
+ if (pWriter->aBlockIdx) {
+ taosArrayClear(pWriter->aBlockIdx);
+ } else if ((pWriter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- SBlockData* pBData = &pWriter->bData;
- TABLEID id = {.suid = pBData->suid, .uid = pBData->uid ? pBData->uid : pBData->aUid[iRow]};
- TSDBROW row = tsdbRowFromBlockData(pBData, iRow);
- TSDBKEY key = TSDBROW_KEY(&row);
+ tMapDataReset(&pWriter->mDataBlk);
- *done = 0;
- while (pWriter->dReader.iRow < pWriter->dReader.bData.nRow ||
- pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem) {
- // Merge row by row
- for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) {
- TSDBROW trow = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow);
- TSDBKEY tKey = TSDBROW_KEY(&trow);
+ if (pWriter->aSttBlk) {
+ taosArrayClear(pWriter->aSttBlk);
+ } else if ((pWriter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- ASSERT(pWriter->dReader.bData.suid == id.suid && pWriter->dReader.bData.uid == id.uid);
+ tBlockDataReset(&pWriter->bData);
+ tBlockDataReset(&pWriter->sData);
- int32_t c = tsdbKeyCmprFn(&key, &tKey);
- if (c < 0) {
- code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid);
- if (code) goto _err;
- } else if (c > 0) {
- code = tBlockDataAppendRow(&pWriter->dWriter.bData, &trow, NULL, id.uid);
- if (code) goto _err;
- } else {
- ASSERT(0);
- }
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code),
+ fid);
+ } else {
+ tsdbDebug("vgId:%d %s done, fid:%d", TD_VID(pTsdb->pVnode), __func__, fid);
+ }
+ return code;
+}
- if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) {
- code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
- pWriter->cmprAlg);
- if (code) goto _err;
- }
+static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, SRowInfo* pRowInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
- if (c < 0) {
- *done = 1;
- goto _exit;
- }
+ // switch to new table if need
+ if (pRowInfo == NULL || pRowInfo->uid != pWriter->tbid.uid) {
+ if (pWriter->tbid.uid) {
+ code = tsdbSnapWriteTableDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- // Merge row by block
- SDataBlk tDataBlk = {.minKey = key, .maxKey = key};
- for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) {
- SDataBlk dataBlk;
- tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk);
-
- int32_t c = tDataBlkCmprFn(&dataBlk, &tDataBlk);
- if (c < 0) {
- code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
- pWriter->cmprAlg);
- if (code) goto _err;
-
- code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk);
- if (code) goto _err;
- } else if (c > 0) {
- code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid);
- if (code) goto _err;
-
- if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) {
- code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
- pWriter->cmprAlg);
- if (code) goto _err;
- }
+ code = tsdbSnapWriteTableDataStart(pWriter, (TABLEID*)pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- *done = 1;
- goto _exit;
- } else {
- code = tsdbReadDataBlockEx(pWriter->dReader.pReader, &dataBlk, &pWriter->dReader.bData);
- if (code) goto _err;
- pWriter->dReader.iRow = 0;
+ if (pRowInfo == NULL) goto _exit;
- pWriter->dReader.iDataBlk++;
- break;
- }
- }
- }
+ code = tsdbSnapWriteTableRow(pWriter, &pRowInfo->row);
+ TSDB_CHECK_CODE(code, lino, _exit);
_exit:
- return code;
-
-_err:
- tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
return code;
}
-static int32_t tsdbSnapWriteToSttFile(STsdbSnapWriter* pWriter, int32_t iRow) {
+static int32_t tsdbSnapWriteNextRow(STsdbSnapWriter* pWriter, SRowInfo** ppRowInfo) {
int32_t code = 0;
+ int32_t lino = 0;
- TABLEID id = {.suid = pWriter->bData.suid,
- .uid = pWriter->bData.uid ? pWriter->bData.uid : pWriter->bData.aUid[iRow]};
- TSDBROW row = tsdbRowFromBlockData(&pWriter->bData, iRow);
- SBlockData* pBData = &pWriter->dWriter.sData;
+ if (pWriter->pSIter) {
+ code = tsdbDataIterNext2(pWriter->pSIter, NULL);
+ TSDB_CHECK_CODE(code, lino, _exit);
- if (pBData->suid || pBData->uid) {
- if (!TABLE_SAME_SCHEMA(pBData->suid, pBData->uid, id.suid, id.uid)) {
- code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
- if (code) goto _err;
+ if (pWriter->pSIter->rowInfo.suid == 0 && pWriter->pSIter->rowInfo.uid == 0) {
+ pWriter->pSIter = NULL;
+ } else {
+ SRBTreeNode* pNode = tRBTreeMin(&pWriter->rbt);
+ if (pNode) {
+ int32_t c = tsdbDataIterCmprFn(&pWriter->pSIter->rbtn, pNode);
+ if (c > 0) {
+ tRBTreePut(&pWriter->rbt, &pWriter->pSIter->rbtn);
+ pWriter->pSIter = NULL;
+ } else if (c == 0) {
+ ASSERT(0);
+ }
+ }
+ }
+ }
- pBData->suid = 0;
- pBData->uid = 0;
+ if (pWriter->pSIter == NULL) {
+ SRBTreeNode* pNode = tRBTreeMin(&pWriter->rbt);
+ if (pNode) {
+ tRBTreeDrop(&pWriter->rbt, pNode);
+ pWriter->pSIter = TSDB_RBTN_TO_DATA_ITER(pNode);
}
}
- if (pBData->suid == 0 && pBData->uid == 0) {
- code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pWriter->id.suid, pWriter->id.uid, &pWriter->skmTable);
- if (code) goto _err;
+ if (ppRowInfo) {
+ if (pWriter->pSIter) {
+ *ppRowInfo = &pWriter->pSIter->rowInfo;
+ } else {
+ *ppRowInfo = NULL;
+ }
+ }
- TABLEID tid = {.suid = pWriter->id.suid, .uid = pWriter->id.suid ? 0 : pWriter->id.uid};
- code = tBlockDataInit(pBData, &tid, pWriter->skmTable.pTSchema, NULL, 0);
- if (code) goto _err;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
}
+ return code;
+}
- code = tBlockDataAppendRow(pBData, &row, NULL, id.uid);
- if (code) goto _err;
+static int32_t tsdbSnapWriteGetRow(STsdbSnapWriter* pWriter, SRowInfo** ppRowInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
- if (pBData->nRow >= pWriter->maxRow) {
- code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
- if (code) goto _err;
+ if (pWriter->pSIter) {
+ *ppRowInfo = &pWriter->pSIter->rowInfo;
+ goto _exit;
}
-_exit:
- return code;
+ code = tsdbSnapWriteNextRow(pWriter, ppRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
-_err:
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
return code;
}
-static int32_t tsdbSnapWriteRowData(STsdbSnapWriter* pWriter, int32_t iRow) {
+static int32_t tsdbSnapWriteFileDataEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
+ int32_t lino = 0;
- SBlockData* pBlockData = &pWriter->bData;
- TABLEID id = {.suid = pBlockData->suid, .uid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[iRow]};
+ ASSERT(pWriter->pDataFWriter);
- // End last table data write if need
- if (tTABLEIDCmprFn(&pWriter->id, &id) != 0) {
- code = tsdbSnapWriteTableDataEnd(pWriter);
- if (code) goto _err;
- }
+ // consume remain data and end with a NULL table row
+ SRowInfo* pRowInfo;
+ code = tsdbSnapWriteGetRow(pWriter, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ for (;;) {
+ code = tsdbSnapWriteTableData(pWriter, pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pRowInfo == NULL) break;
- // Start new table data write if need
- if (pWriter->id.suid == 0 && pWriter->id.uid == 0) {
- code = tsdbSnapWriteTableDataStart(pWriter, &id);
- if (code) goto _err;
+ code = tsdbSnapWriteNextRow(pWriter, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- // Merge with .data file data
- int8_t done = 0;
- if (pWriter->dReader.pBlockIdx && tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &id) == 0) {
- code = tsdbSnapWriteToDataFile(pWriter, iRow, &done);
- if (code) goto _err;
+ // do file-level updates
+ code = tsdbWriteSttBlk(pWriter->pDataFWriter, pWriter->aSttBlk);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbUpdateDFileSetHeader(pWriter->pDataFWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->pDataFWriter->wSet);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ if (pWriter->pDataFReader) {
+ code = tsdbDataFReaderClose(&pWriter->pDataFReader);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- // Append to the .stt data block (todo: check if need to set/reload sst block)
- if (!done) {
- code = tsdbSnapWriteToSttFile(pWriter, iRow);
- if (code) goto _err;
+ // clear sources
+ while (pWriter->iterList) {
+ STsdbDataIter2* pIter = pWriter->iterList;
+ pWriter->iterList = pIter->next;
+ tsdbCloseDataIter2(pIter);
}
_exit:
- return code;
-
-_err:
- tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ if (code) {
+ tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s is done", TD_VID(pWriter->pTsdb->pVnode), __func__);
+ }
return code;
}
-static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
- int32_t code = 0;
- STsdb* pTsdb = pWriter->pTsdb;
- SBlockData* pBlockData = &pWriter->bData;
+static int32_t tsdbSnapWriteTimeSeriesData(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) {
+ int32_t code = 0;
+ int32_t lino = 0;
- // Decode data
- SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
- code = tDecmprBlockData(pHdr->data, pHdr->size, pBlockData, pWriter->aBuf);
- if (code) goto _err;
+ code = tDecmprBlockData(pHdr->data, pHdr->size, &pWriter->inData, pWriter->aBuf);
+ TSDB_CHECK_CODE(code, lino, _exit);
- ASSERT(pBlockData->nRow > 0);
+ ASSERT(pWriter->inData.nRow > 0);
- // Loop to handle each row
- for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
- TSKEY ts = pBlockData->aTSKEY[iRow];
- int32_t fid = tsdbKeyFid(ts, pWriter->minutes, pWriter->precision);
+ // switch to new data file if need
+ int32_t fid = tsdbKeyFid(pWriter->inData.aTSKEY[0], pWriter->minutes, pWriter->precision);
+ if (pWriter->fid != fid) {
+ if (pWriter->pDataFWriter) {
+ code = tsdbSnapWriteFileDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- if (pWriter->dWriter.pWriter == NULL || pWriter->fid != fid) {
- if (pWriter->dWriter.pWriter) {
- // ASSERT(fid > pWriter->fid);
+ code = tsdbSnapWriteFileDataStart(pWriter, fid);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- code = tsdbSnapWriteCloseFile(pWriter);
- if (code) goto _err;
- }
+ // loop write each row
+ SRowInfo* pRowInfo;
+ code = tsdbSnapWriteGetRow(pWriter, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ for (int32_t iRow = 0; iRow < pWriter->inData.nRow; ++iRow) {
+ SRowInfo rInfo = {.suid = pWriter->inData.suid,
+ .uid = pWriter->inData.uid ? pWriter->inData.uid : pWriter->inData.aUid[iRow],
+ .row = tsdbRowFromBlockData(&pWriter->inData, iRow)};
- code = tsdbSnapWriteOpenFile(pWriter, fid);
- if (code) goto _err;
+ for (;;) {
+ if (pRowInfo == NULL) {
+ code = tsdbSnapWriteTableData(pWriter, &rInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ break;
+ } else {
+ int32_t c = tRowInfoCmprFn(&rInfo, pRowInfo);
+ if (c < 0) {
+ code = tsdbSnapWriteTableData(pWriter, &rInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ break;
+ } else if (c > 0) {
+ code = tsdbSnapWriteTableData(pWriter, pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbSnapWriteNextRow(pWriter, &pRowInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ } else {
+ ASSERT(0);
+ }
+ }
}
-
- code = tsdbSnapWriteRowData(pWriter, iRow);
- if (code) goto _err;
}
- return code;
-
-_err:
- tsdbError("vgId:%d, vnode snapshot tsdb write data for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
- tstrerror(code));
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64 " nRow:%d", TD_VID(pWriter->pTsdb->pVnode), __func__,
+ pWriter->inData.suid, pWriter->inData.uid, pWriter->inData.nRow);
+ }
return code;
}
// SNAP_DATA_DEL
-static int32_t tsdbSnapMoveWriteDelData(STsdbSnapWriter* pWriter, TABLEID* pId) {
+static int32_t tsdbSnapWriteDelTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) {
int32_t code = 0;
+ int32_t lino = 0;
- while (true) {
- if (pWriter->iDelIdx >= taosArrayGetSize(pWriter->aDelIdxR)) break;
+ if (pId) {
+ pWriter->tbid = *pId;
+ } else {
+ pWriter->tbid = (TABLEID){.suid = INT64_MAX, .uid = INT64_MAX};
+ }
- SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
+ taosArrayClear(pWriter->aDelData);
- if (tTABLEIDCmprFn(pDelIdx, pId) >= 0) break;
+ if (pWriter->pTIter) {
+ while (pWriter->pTIter->tIter.iDelIdx < taosArrayGetSize(pWriter->pTIter->tIter.aDelIdx)) {
+ SDelIdx* pDelIdx = taosArrayGet(pWriter->pTIter->tIter.aDelIdx, pWriter->pTIter->tIter.iDelIdx);
- code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
- if (code) goto _exit;
+ int32_t c = tTABLEIDCmprFn(pDelIdx, &pWriter->tbid);
+ if (c < 0) {
+ code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->pTIter->tIter.aDelData);
+ TSDB_CHECK_CODE(code, lino, _exit);
- SDelIdx delIdx = *pDelIdx;
- code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
- if (code) goto _exit;
+ SDelIdx* pDelIdxNew = taosArrayReserve(pWriter->aDelIdx, 1);
+ if (pDelIdxNew == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
- }
+ pDelIdxNew->suid = pDelIdx->suid;
+ pDelIdxNew->uid = pDelIdx->uid;
+
+ code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->pTIter->tIter.aDelData, pDelIdxNew);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ pWriter->pTIter->tIter.iDelIdx++;
+ } else if (c == 0) {
+ code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
+ TSDB_CHECK_CODE(code, lino, _exit);
- pWriter->iDelIdx++;
+ pWriter->pTIter->tIter.iDelIdx++;
+ break;
+ } else {
+ break;
+ }
+ }
}
_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbTrace("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__,
+ pWriter->tbid.suid, pWriter->tbid.uid);
+ }
return code;
}
-static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
+static int32_t tsdbSnapWriteDelTableDataEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
- STsdb* pTsdb = pWriter->pTsdb;
-
- // Open del file if not opened yet
- if (pWriter->pDelFWriter == NULL) {
- SDelFile* pDelFile = pWriter->fs.pDelFile;
-
- // reader
- if (pDelFile) {
- code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb);
- if (code) goto _err;
+ int32_t lino = 0;
- code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR);
- if (code) goto _err;
- } else {
- taosArrayClear(pWriter->aDelIdxR);
+ if (taosArrayGetSize(pWriter->aDelData) > 0) {
+ SDelIdx* pDelIdx = taosArrayReserve(pWriter->aDelIdx, 1);
+ if (pDelIdx == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- pWriter->iDelIdx = 0;
- // writer
- SDelFile delFile = {.commitID = pWriter->commitID};
- code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb);
- if (code) goto _err;
- taosArrayClear(pWriter->aDelIdxW);
- }
+ pDelIdx->suid = pWriter->tbid.suid;
+ pDelIdx->uid = pWriter->tbid.uid;
- SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
- TABLEID id = *(TABLEID*)pHdr->data;
-
- ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
+ code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, pDelIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- // Move write data < id
- code = tsdbSnapMoveWriteDelData(pWriter, &id);
- if (code) goto _err;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbTrace("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__);
+ }
+ return code;
+}
- // Merge incoming data with current
- if (pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdxR) &&
- tTABLEIDCmprFn(taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx), &id) == 0) {
- SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
+static int32_t tsdbSnapWriteDelTableData(STsdbSnapWriter* pWriter, TABLEID* pId, uint8_t* pData, int64_t size) {
+ int32_t code = 0;
+ int32_t lino = 0;
- code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
- if (code) goto _err;
+ if (pId == NULL || pId->uid != pWriter->tbid.uid) {
+ if (pWriter->tbid.uid) {
+ code = tsdbSnapWriteDelTableDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
- pWriter->iDelIdx++;
- } else {
- taosArrayClear(pWriter->aDelData);
+ code = tsdbSnapWriteDelTableDataStart(pWriter, pId);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- int64_t n = sizeof(SSnapDataHdr) + sizeof(TABLEID);
- while (n < nData) {
- SDelData delData;
+ if (pId == NULL) goto _exit;
+ int64_t n = 0;
+ while (n < size) {
+ SDelData delData;
n += tGetDelData(pData + n, &delData);
- if (taosArrayPush(pWriter->aDelData, &delData) == NULL) {
+ if (taosArrayPush(pWriter->aDelData, &delData) < 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
}
}
+ ASSERT(n == size);
- SDelIdx delIdx = {.suid = id.suid, .uid = id.uid};
- code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
- if (code) goto _err;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ }
+ return code;
+}
- if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
+static int32_t tsdbSnapWriteDelDataStart(STsdbSnapWriter* pWriter) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdb* pTsdb = pWriter->pTsdb;
+ SDelFile* pDelFile = pWriter->fs.pDelFile;
+
+ pWriter->tbid = (TABLEID){0};
+
+ // reader
+ if (pDelFile) {
+ code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ code = tsdbOpenTombFileDataIter(pWriter->pDelFReader, &pWriter->pTIter);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- return code;
+ // writer
+ code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &(SDelFile){.commitID = pWriter->commitID}, pTsdb);
+ TSDB_CHECK_CODE(code, lino, _exit);
-_err:
- tsdbError("vgId:%d, vnode snapshot tsdb write del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
- tstrerror(code));
+ if ((pWriter->aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+ if ((pWriter->aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
return code;
}
-static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
+static int32_t tsdbSnapWriteDelDataEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
- STsdb* pTsdb = pWriter->pTsdb;
+ int32_t lino = 0;
- if (pWriter->pDelFWriter == NULL) return code;
+ STsdb* pTsdb = pWriter->pTsdb;
- TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX};
- code = tsdbSnapMoveWriteDelData(pWriter, &id);
- if (code) goto _err;
+ // end remaining table with NULL data
+ code = tsdbSnapWriteDelTableData(pWriter, NULL, NULL, 0);
+ TSDB_CHECK_CODE(code, lino, _exit);
- code = tsdbWriteDelIdx(pWriter->pDelFWriter, pWriter->aDelIdxW);
- if (code) goto _err;
+ // update file-level info
+ code = tsdbWriteDelIdx(pWriter->pDelFWriter, pWriter->aDelIdx);
+ TSDB_CHECK_CODE(code, lino, _exit);
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
- if (code) goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
code = tsdbFSUpsertDelFile(&pWriter->fs, &pWriter->pDelFWriter->fDel);
- if (code) goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1);
- if (code) goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
if (pWriter->pDelFReader) {
code = tsdbDelFReaderClose(&pWriter->pDelFReader);
- if (code) goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ if (pWriter->pTIter) {
+ tsdbCloseDataIter2(pWriter->pTIter);
+ pWriter->pTIter = NULL;
}
- tsdbInfo("vgId:%d, vnode snapshot tsdb write del for %s end", TD_VID(pTsdb->pVnode), pTsdb->path);
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
return code;
+}
+
+static int32_t tsdbSnapWriteDelData(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ STsdb* pTsdb = pWriter->pTsdb;
-_err:
- tsdbError("vgId:%d, vnode snapshot tsdb write del end for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
- tstrerror(code));
+ // start to write del data if need
+ if (pWriter->pDelFWriter == NULL) {
+ code = tsdbSnapWriteDelDataStart(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ // do write del data
+ code = tsdbSnapWriteDelTableData(pWriter, (TABLEID*)pHdr->data, pHdr->data + sizeof(TABLEID),
+ pHdr->size - sizeof(TABLEID));
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed since %s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code));
+ } else {
+ tsdbTrace("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
return code;
}
// APIs
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) {
- int32_t code = 0;
- int32_t lino = 0;
- STsdbSnapWriter* pWriter = NULL;
+ int32_t code = 0;
+ int32_t lino = 0;
// alloc
- pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
+ STsdbSnapWriter* pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
if (pWriter == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
TSDB_CHECK_CODE(code, lino, _exit);
@@ -1288,11 +1388,6 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
pWriter->pTsdb = pTsdb;
pWriter->sver = sver;
pWriter->ever = ever;
-
- code = tsdbFSCopy(pTsdb, &pWriter->fs);
- TSDB_CHECK_CODE(code, lino, _exit);
-
- // config
pWriter->minutes = pTsdb->keepCfg.days;
pWriter->precision = pTsdb->keepCfg.precision;
pWriter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows;
@@ -1300,102 +1395,70 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
pWriter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
pWriter->commitID = pTsdb->pVnode->state.commitID;
+ code = tsdbFSCopy(pTsdb, &pWriter->fs);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
// SNAP_DATA_TSDB
- code = tBlockDataCreate(&pWriter->bData);
+ code = tBlockDataCreate(&pWriter->inData);
TSDB_CHECK_CODE(code, lino, _exit);
pWriter->fid = INT32_MIN;
- pWriter->id = (TABLEID){0};
- // Reader
- pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
- if (pWriter->dReader.aBlockIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- code = tBlockDataCreate(&pWriter->dReader.bData);
- TSDB_CHECK_CODE(code, lino, _exit);
- // Writer
- pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
- if (pWriter->dWriter.aBlockIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
- if (pWriter->dWriter.aSttBlk == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- code = tBlockDataCreate(&pWriter->dWriter.bData);
+ code = tBlockDataCreate(&pWriter->bData);
TSDB_CHECK_CODE(code, lino, _exit);
- code = tBlockDataCreate(&pWriter->dWriter.sData);
+
+ code = tBlockDataCreate(&pWriter->sData);
TSDB_CHECK_CODE(code, lino, _exit);
// SNAP_DATA_DEL
- pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx));
- if (pWriter->aDelIdxR == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- pWriter->aDelData = taosArrayInit(0, sizeof(SDelData));
- if (pWriter->aDelData == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
- pWriter->aDelIdxW = taosArrayInit(0, sizeof(SDelIdx));
- if (pWriter->aDelIdxW == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- TSDB_CHECK_CODE(code, lino, _exit);
- }
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
- *ppWriter = NULL;
-
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
if (pWriter) {
- if (pWriter->aDelIdxW) taosArrayDestroy(pWriter->aDelIdxW);
- if (pWriter->aDelData) taosArrayDestroy(pWriter->aDelData);
- if (pWriter->aDelIdxR) taosArrayDestroy(pWriter->aDelIdxR);
- tBlockDataDestroy(&pWriter->dWriter.sData);
- tBlockDataDestroy(&pWriter->dWriter.bData);
- if (pWriter->dWriter.aSttBlk) taosArrayDestroy(pWriter->dWriter.aSttBlk);
- if (pWriter->dWriter.aBlockIdx) taosArrayDestroy(pWriter->dWriter.aBlockIdx);
- tBlockDataDestroy(&pWriter->dReader.bData);
- if (pWriter->dReader.aBlockIdx) taosArrayDestroy(pWriter->dReader.aBlockIdx);
+ tBlockDataDestroy(&pWriter->sData);
tBlockDataDestroy(&pWriter->bData);
+ tBlockDataDestroy(&pWriter->inData);
tsdbFSDestroy(&pWriter->fs);
- taosMemoryFree(pWriter);
+ pWriter = NULL;
}
} else {
- tsdbInfo("vgId:%d, %s done", TD_VID(pTsdb->pVnode), __func__);
- *ppWriter = pWriter;
+ tsdbInfo("vgId:%d %s done, sver:%" PRId64 " ever:%" PRId64, TD_VID(pTsdb->pVnode), __func__, sver, ever);
}
+ *ppWriter = pWriter;
return code;
}
int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter) {
int32_t code = 0;
- if (pWriter->dWriter.pWriter) {
- code = tsdbSnapWriteCloseFile(pWriter);
- if (code) goto _exit;
+ int32_t lino = 0;
+
+ if (pWriter->pDataFWriter) {
+ code = tsdbSnapWriteFileDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- code = tsdbSnapWriteDelEnd(pWriter);
- if (code) goto _exit;
+ if (pWriter->pDelFWriter) {
+ code = tsdbSnapWriteDelDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
code = tsdbFSPrepareCommit(pWriter->pTsdb, &pWriter->fs);
- if (code) goto _exit;
+ TSDB_CHECK_CODE(code, lino, _exit);
_exit:
if (code) {
- tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbDebug("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__);
}
return code;
}
int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
- int32_t code = 0;
+ int32_t code = 0;
+ int32_t lino = 0;
+
STsdbSnapWriter* pWriter = *ppWriter;
STsdb* pTsdb = pWriter->pTsdb;
@@ -1408,7 +1471,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
code = tsdbFSCommit(pWriter->pTsdb);
if (code) {
taosThreadRwlockUnlock(&pTsdb->rwLock);
- goto _err;
+ TSDB_CHECK_CODE(code, lino, _exit);
}
// unlock
@@ -1416,72 +1479,60 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
}
// SNAP_DATA_DEL
- taosArrayDestroy(pWriter->aDelIdxW);
taosArrayDestroy(pWriter->aDelData);
- taosArrayDestroy(pWriter->aDelIdxR);
+ taosArrayDestroy(pWriter->aDelIdx);
// SNAP_DATA_TSDB
-
- // Writer
- tBlockDataDestroy(&pWriter->dWriter.sData);
- tBlockDataDestroy(&pWriter->dWriter.bData);
- taosArrayDestroy(pWriter->dWriter.aSttBlk);
- tMapDataClear(&pWriter->dWriter.mDataBlk);
- taosArrayDestroy(pWriter->dWriter.aBlockIdx);
-
- // Reader
- tBlockDataDestroy(&pWriter->dReader.bData);
- tMapDataClear(&pWriter->dReader.mDataBlk);
- taosArrayDestroy(pWriter->dReader.aBlockIdx);
-
+ tBlockDataDestroy(&pWriter->sData);
tBlockDataDestroy(&pWriter->bData);
+ taosArrayDestroy(pWriter->aSttBlk);
+ tMapDataClear(&pWriter->mDataBlk);
+ taosArrayDestroy(pWriter->aBlockIdx);
tDestroyTSchema(pWriter->skmTable.pTSchema);
+ tBlockDataDestroy(&pWriter->inData);
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
tFree(pWriter->aBuf[iBuf]);
}
- tsdbInfo("vgId:%d, %s done", TD_VID(pWriter->pTsdb->pVnode), __func__);
+ tsdbFSDestroy(&pWriter->fs);
taosMemoryFree(pWriter);
*ppWriter = NULL;
- return code;
-_err:
- tsdbError("vgId:%d, vnode snapshot tsdb writer close for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path, tstrerror(code));
- taosMemoryFree(pWriter);
- *ppWriter = NULL;
+_exit:
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
+ } else {
+ tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
+ }
return code;
}
-int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
- int32_t code = 0;
- SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
+int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) {
+ int32_t code = 0;
+ int32_t lino = 0;
- // ts data
if (pHdr->type == SNAP_DATA_TSDB) {
- code = tsdbSnapWriteData(pWriter, pData, nData);
- if (code) goto _err;
-
+ code = tsdbSnapWriteTimeSeriesData(pWriter, pHdr);
+ TSDB_CHECK_CODE(code, lino, _exit);
goto _exit;
- } else {
- if (pWriter->dWriter.pWriter) {
- code = tsdbSnapWriteCloseFile(pWriter);
- if (code) goto _err;
- }
+ } else if (pWriter->pDataFWriter) {
+ code = tsdbSnapWriteFileDataEnd(pWriter);
+ TSDB_CHECK_CODE(code, lino, _exit);
}
- // del data
if (pHdr->type == SNAP_DATA_DEL) {
- code = tsdbSnapWriteDel(pWriter, pData, nData);
- if (code) goto _err;
+ code = tsdbSnapWriteDelData(pWriter, pHdr);
+ TSDB_CHECK_CODE(code, lino, _exit);
+ goto _exit;
}
_exit:
- tsdbDebug("vgId:%d, tsdb snapshot write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb snapshot write for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path,
- tstrerror(code));
+ if (code) {
+ tsdbError("vgId:%d %s failed at line %d since %s, type:%d index:%" PRId64 " size:%" PRId64,
+ TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code), pHdr->type, pHdr->index, pHdr->size);
+ } else {
+ tsdbDebug("vgId:%d %s done, type:%d index:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__,
+ pHdr->type, pHdr->index, pHdr->size);
+ }
return code;
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c
index 25fafff25a0e56a5ad70f7c3208a3b773f0c854e..24dcae91d998a0c973e7788c1032aded1000e366 100644
--- a/source/dnode/vnode/src/tsdb/tsdbUtil.c
+++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c
@@ -758,7 +758,7 @@ int32_t tsdbRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema)
pTColVal->value.nData = pColVal->value.nData;
if (pTColVal->value.nData) {
- memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData);
+ memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData);
}
pTColVal->flag = 0;
} else {
@@ -926,8 +926,9 @@ int32_t tsdbRowMergerGetRow(SRowMerger *pMerger, SRow **ppRow) {
return tRowBuild(pMerger->pArray, pMerger->pTSchema, ppRow);
}
+/*
// delete skyline ======================================================
-static int32_t tsdbMergeSkyline(SArray *aSkyline1, SArray *aSkyline2, SArray *aSkyline) {
+static int32_t tsdbMergeSkyline2(SArray *aSkyline1, SArray *aSkyline2, SArray *aSkyline) {
int32_t code = 0;
int32_t i1 = 0;
int32_t n1 = taosArrayGetSize(aSkyline1);
@@ -993,7 +994,139 @@ static int32_t tsdbMergeSkyline(SArray *aSkyline1, SArray *aSkyline2, SArray *aS
_exit:
return code;
}
+*/
+
+// delete skyline ======================================================
+static int32_t tsdbMergeSkyline(SArray *pSkyline1, SArray *pSkyline2, SArray *pSkyline) {
+ int32_t code = 0;
+ int32_t i1 = 0;
+ int32_t n1 = taosArrayGetSize(pSkyline1);
+ int32_t i2 = 0;
+ int32_t n2 = taosArrayGetSize(pSkyline2);
+ TSDBKEY *pKey1;
+ TSDBKEY *pKey2;
+ int64_t version1 = 0;
+ int64_t version2 = 0;
+
+ ASSERT(n1 > 0 && n2 > 0);
+
+ taosArrayClear(pSkyline);
+ TSDBKEY **pItem = TARRAY_GET_ELEM(pSkyline, 0);
+
+ while (i1 < n1 && i2 < n2) {
+ pKey1 = (TSDBKEY *)taosArrayGetP(pSkyline1, i1);
+ pKey2 = (TSDBKEY *)taosArrayGetP(pSkyline2, i2);
+
+ if (pKey1->ts < pKey2->ts) {
+ version1 = pKey1->version;
+ *pItem = pKey1;
+ i1++;
+ } else if (pKey1->ts > pKey2->ts) {
+ version2 = pKey2->version;
+ *pItem = pKey2;
+ i2++;
+ } else {
+ version1 = pKey1->version;
+ version2 = pKey2->version;
+ *pItem = pKey1;
+ i1++;
+ i2++;
+ }
+
+ (*pItem)->version = TMAX(version1, version2);
+ pItem++;
+ }
+
+ while (i1 < n1) {
+ pKey1 = (TSDBKEY *)taosArrayGetP(pSkyline1, i1);
+ *pItem = pKey1;
+ pItem++;
+ i1++;
+ }
+
+ while (i2 < n2) {
+ pKey2 = (TSDBKEY *)taosArrayGetP(pSkyline2, i2);
+ *pItem = pKey2;
+ pItem++;
+ i2++;
+ }
+
+ taosArraySetSize(pSkyline, TARRAY_ELEM_IDX(pSkyline, pItem));
+
+_exit:
+ return code;
+}
+
+int32_t tsdbBuildDeleteSkylineImpl(SArray *aSkyline, int32_t sidx, int32_t eidx, SArray *pSkyline) {
+ int32_t code = 0;
+ SDelData *pDelData;
+ int32_t midx;
+
+ taosArrayClear(pSkyline);
+ if (sidx == eidx) {
+ TSDBKEY *pItem1 = taosArrayGet(aSkyline, sidx * 2);
+ TSDBKEY *pItem2 = taosArrayGet(aSkyline, sidx * 2 + 1);
+ taosArrayPush(pSkyline, &pItem1);
+ taosArrayPush(pSkyline, &pItem2);
+ } else {
+ SArray *pSkyline1 = NULL;
+ SArray *pSkyline2 = NULL;
+ midx = (sidx + eidx) / 2;
+
+ pSkyline1 = taosArrayInit((midx - sidx + 1) * 2, POINTER_BYTES);
+ pSkyline2 = taosArrayInit((eidx - midx) * 2, POINTER_BYTES);
+ if (pSkyline1 == NULL || pSkyline1 == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _clear;
+ }
+
+ code = tsdbBuildDeleteSkylineImpl(aSkyline, sidx, midx, pSkyline1);
+ if (code) goto _clear;
+
+ code = tsdbBuildDeleteSkylineImpl(aSkyline, midx + 1, eidx, pSkyline2);
+ if (code) goto _clear;
+
+ code = tsdbMergeSkyline(pSkyline1, pSkyline2, pSkyline);
+
+ _clear:
+ taosArrayDestroy(pSkyline1);
+ taosArrayDestroy(pSkyline2);
+ }
+
+ return code;
+}
+
int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline) {
+ SDelData *pDelData;
+ int32_t code = 0;
+ int32_t dataNum = eidx - sidx + 1;
+ SArray *aTmpSkyline = taosArrayInit(dataNum * 2, sizeof(TSDBKEY));
+ SArray *pSkyline = taosArrayInit(dataNum * 2, POINTER_BYTES);
+
+ for (int32_t i = sidx; i <= eidx; ++i) {
+ pDelData = (SDelData *)taosArrayGet(aDelData, i);
+ taosArrayPush(aTmpSkyline, &(TSDBKEY){.ts = pDelData->sKey, .version = pDelData->version});
+ taosArrayPush(aTmpSkyline, &(TSDBKEY){.ts = pDelData->eKey, .version = 0});
+ }
+
+ code = tsdbBuildDeleteSkylineImpl(aTmpSkyline, sidx, eidx, pSkyline);
+ if (code) goto _clear;
+
+ int32_t skylineNum = taosArrayGetSize(pSkyline);
+ for (int32_t i = 0; i < skylineNum; ++i) {
+ TSDBKEY *p = taosArrayGetP(pSkyline, i);
+ taosArrayPush(aSkyline, p);
+ }
+
+_clear:
+ taosArrayDestroy(aTmpSkyline);
+ taosArrayDestroy(pSkyline);
+
+ return code;
+}
+
+/*
+int32_t tsdbBuildDeleteSkyline2(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline) {
int32_t code = 0;
SDelData *pDelData;
int32_t midx;
@@ -1030,6 +1163,7 @@ int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SAr
return code;
}
+*/
// SBlockData ======================================================
int32_t tBlockDataCreate(SBlockData *pBlockData) {
@@ -1133,6 +1267,7 @@ _exit:
void tBlockDataReset(SBlockData *pBlockData) {
pBlockData->suid = 0;
pBlockData->uid = 0;
+ pBlockData->nRow = 0;
}
void tBlockDataClear(SBlockData *pBlockData) {
@@ -1144,7 +1279,12 @@ void tBlockDataClear(SBlockData *pBlockData) {
}
}
-static int32_t tBlockDataAppendBlockRow(SBlockData *pBlockData, SBlockData *pBlockDataFrom, int32_t iRow) {
+/* flag > 0: forward update
+ * flag == 0: insert
+ * flag < 0: backward update
+ */
+static int32_t tBlockDataUpsertBlockRow(SBlockData *pBlockData, SBlockData *pBlockDataFrom, int32_t iRow,
+ int32_t flag) {
int32_t code = 0;
SColVal cv = {0};
@@ -1159,12 +1299,16 @@ static int32_t tBlockDataAppendBlockRow(SBlockData *pBlockData, SBlockData *pBlo
}
if (pColDataFrom == NULL || pColDataFrom->cid > pColDataTo->cid) {
- code = tColDataAppendValue(pColDataTo, &COL_VAL_NONE(pColDataTo->cid, pColDataTo->type));
- if (code) goto _exit;
+ cv = COL_VAL_NONE(pColDataTo->cid, pColDataTo->type);
+ if (flag == 0 && (code = tColDataAppendValue(pColDataTo, &cv))) goto _exit;
} else {
tColDataGetValue(pColDataFrom, iRow, &cv);
- code = tColDataAppendValue(pColDataTo, &cv);
+ if (flag) {
+ code = tColDataUpdateValue(pColDataTo, &cv, flag > 0);
+ } else {
+ code = tColDataAppendValue(pColDataTo, &cv);
+ }
if (code) goto _exit;
pColDataFrom = (++iColDataFrom < pBlockDataFrom->nColData) ? &pBlockDataFrom->aColData[iColDataFrom] : NULL;
@@ -1184,36 +1328,77 @@ int32_t tBlockDataAppendRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTS
if (pBlockData->uid == 0) {
ASSERT(uid);
code = tRealloc((uint8_t **)&pBlockData->aUid, sizeof(int64_t) * (pBlockData->nRow + 1));
- if (code) goto _err;
+ if (code) goto _exit;
pBlockData->aUid[pBlockData->nRow] = uid;
}
// version
code = tRealloc((uint8_t **)&pBlockData->aVersion, sizeof(int64_t) * (pBlockData->nRow + 1));
- if (code) goto _err;
+ if (code) goto _exit;
pBlockData->aVersion[pBlockData->nRow] = TSDBROW_VERSION(pRow);
// timestamp
code = tRealloc((uint8_t **)&pBlockData->aTSKEY, sizeof(TSKEY) * (pBlockData->nRow + 1));
- if (code) goto _err;
+ if (code) goto _exit;
pBlockData->aTSKEY[pBlockData->nRow] = TSDBROW_TS(pRow);
- SColVal cv = {0};
if (pRow->type == TSDBROW_ROW_FMT) {
- code = tRowAppendToColData(pRow->pTSRow, pTSchema, pBlockData->aColData, pBlockData->nColData);
- if (code) goto _err;
+ code = tRowUpsertColData(pRow->pTSRow, pTSchema, pBlockData->aColData, pBlockData->nColData, 0 /* append */);
+ if (code) goto _exit;
} else if (pRow->type == TSDBROW_COL_FMT) {
- code = tBlockDataAppendBlockRow(pBlockData, pRow->pBlockData, pRow->iRow);
- if (code) goto _err;
+ code = tBlockDataUpsertBlockRow(pBlockData, pRow->pBlockData, pRow->iRow, 0 /* append */);
+ if (code) goto _exit;
} else {
ASSERT(0);
}
pBlockData->nRow++;
+_exit:
return code;
+}
+static int32_t tBlockDataUpdateRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema) {
+ int32_t code = 0;
+
+ // version
+ int64_t lversion = pBlockData->aVersion[pBlockData->nRow - 1];
+ int64_t rversion = TSDBROW_VERSION(pRow);
+ ASSERT(lversion != rversion);
+ if (rversion > lversion) {
+ pBlockData->aVersion[pBlockData->nRow - 1] = rversion;
+ }
+
+ // update other rows
+ if (pRow->type == TSDBROW_ROW_FMT) {
+ code = tRowUpsertColData(pRow->pTSRow, pTSchema, pBlockData->aColData, pBlockData->nColData,
+ (rversion > lversion) ? 1 : -1 /* update */);
+ if (code) goto _exit;
+ } else if (pRow->type == TSDBROW_COL_FMT) {
+ code = tBlockDataUpsertBlockRow(pBlockData, pRow->pBlockData, pRow->iRow, (rversion > lversion) ? 1 : -1);
+ if (code) goto _exit;
+ } else {
+ ASSERT(0);
+ }
-_err:
+_exit:
return code;
}
+int32_t tBlockDataTryUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, int64_t uid) {
+ if (pBlockData->nRow == 0) {
+ return 1;
+ } else if (pBlockData->aTSKEY[pBlockData->nRow - 1] == TSDBROW_TS(pRow)) {
+ return pBlockData->nRow;
+ } else {
+ return pBlockData->nRow + 1;
+ }
+}
+
+int32_t tBlockDataUpsertRow(SBlockData *pBlockData, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
+ if (pBlockData->nRow > 0 && pBlockData->aTSKEY[pBlockData->nRow - 1] == TSDBROW_TS(pRow)) {
+ return tBlockDataUpdateRow(pBlockData, pRow, pTSchema);
+ } else {
+ return tBlockDataAppendRow(pBlockData, pRow, pTSchema, uid);
+ }
+}
+
void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColData) {
ASSERT(cid != PRIMARYKEY_TIMESTAMP_COL_ID);
int32_t lidx = 0;
diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c
index b1575fb49642b4b5ee93265f8286c64e433f98fa..40112c55791fe8d2cd3545f57169e2ba7ec33838 100644
--- a/source/dnode/vnode/src/vnd/vnodeBufPool.c
+++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c
@@ -219,10 +219,10 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
if (pPool->node.size != size) {
SVBufPool *pNewPool = NULL;
if (vnodeBufPoolCreate(pVnode, pPool->id, size, &pNewPool) < 0) {
- vWarn("vgId:%d failed to change buffer pool of id %d size from %" PRId64 " to %" PRId64 " since %s",
+ vWarn("vgId:%d, failed to change buffer pool of id %d size from %" PRId64 " to %" PRId64 " since %s",
TD_VID(pVnode), pPool->id, pPool->node.size, size, tstrerror(errno));
} else {
- vInfo("vgId:%d buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id,
+ vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id,
pPool->node.size, size);
vnodeBufPoolDestroy(pPool);
@@ -232,7 +232,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
}
// add to free list
- vDebug("vgId:%d buffer pool %p of id %d is added to free list", TD_VID(pVnode), pPool, pPool->id);
+ vDebug("vgId:%d, buffer pool %p of id %d is added to free list", TD_VID(pVnode), pPool, pPool->id);
vnodeBufPoolReset(pPool);
pPool->freeNext = pVnode->freeList;
pVnode->freeList = pPool;
@@ -307,7 +307,7 @@ int32_t vnodeBufPoolRecycle(SVBufPool *pPool) {
SVnode *pVnode = pPool->pVnode;
- vDebug("vgId:%d recycle buffer pool %p of id %d", TD_VID(pVnode), pPool, pPool->id);
+ vDebug("vgId:%d, recycle buffer pool %p of id %d", TD_VID(pVnode), pPool, pPool->id);
taosThreadMutexLock(&pPool->mutex);
diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c
index aeb90b7080ac0dd0b0e5dd0b4735fc865e842703..b075c3d8355f8a5476096a5ff43a4354df8807e6 100644
--- a/source/dnode/vnode/src/vnd/vnodeCommit.c
+++ b/source/dnode/vnode/src/vnd/vnodeCommit.c
@@ -28,10 +28,10 @@ static int32_t vnodeTryRecycleBufPool(SVnode *pVnode) {
if (pVnode->onRecycle == NULL) {
if (pVnode->recycleHead == NULL) {
- vDebug("vgId:%d no recyclable buffer pool", TD_VID(pVnode));
+ vDebug("vgId:%d, no recyclable buffer pool", TD_VID(pVnode));
goto _exit;
} else {
- vDebug("vgId:%d buffer pool %p of id %d on recycle queue, try to recycle", TD_VID(pVnode), pVnode->recycleHead,
+ vDebug("vgId:%d, buffer pool %p of id %d on recycle queue, try to recycle", TD_VID(pVnode), pVnode->recycleHead,
pVnode->recycleHead->id);
pVnode->onRecycle = pVnode->recycleHead;
@@ -50,7 +50,7 @@ static int32_t vnodeTryRecycleBufPool(SVnode *pVnode) {
_exit:
if (code) {
- vError("vgId:%d %s failed since %s", TD_VID(pVnode), __func__, tstrerror(code));
+ vError("vgId:%d, %s failed since %s", TD_VID(pVnode), __func__, tstrerror(code));
}
return code;
}
@@ -65,7 +65,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
++nTry;
if (pVnode->freeList) {
- vDebug("vgId:%d allocate free buffer pool on %d try, pPool:%p id:%d", TD_VID(pVnode), nTry, pVnode->freeList,
+ vDebug("vgId:%d, allocate free buffer pool on %d try, pPool:%p id:%d", TD_VID(pVnode), nTry, pVnode->freeList,
pVnode->freeList->id);
pVnode->inUse = pVnode->freeList;
@@ -74,13 +74,13 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
pVnode->inUse->freeNext = NULL;
break;
} else {
- vDebug("vgId:%d no free buffer pool on %d try, try to recycle...", TD_VID(pVnode), nTry);
+ vDebug("vgId:%d, no free buffer pool on %d try, try to recycle...", TD_VID(pVnode), nTry);
code = vnodeTryRecycleBufPool(pVnode);
TSDB_CHECK_CODE(code, lino, _exit);
if (pVnode->freeList == NULL) {
- vDebug("vgId:%d no free buffer pool on %d try, wait %d ms...", TD_VID(pVnode), nTry, WAIT_TIME_MILI_SEC);
+ vDebug("vgId:%d, no free buffer pool on %d try, wait %d ms...", TD_VID(pVnode), nTry, WAIT_TIME_MILI_SEC);
struct timeval tv;
struct timespec ts;
@@ -105,7 +105,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
_exit:
taosThreadMutexUnlock(&pVnode->mutex);
if (code) {
- vError("vgId:%d %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
+ vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
}
return code;
}
@@ -113,8 +113,6 @@ int vnodeBegin(SVnode *pVnode) {
int32_t code = 0;
int32_t lino = 0;
- pVnode->state.commitID++;
-
// alloc buffer pool
code = vnodeGetBufPoolToUse(pVnode);
TSDB_CHECK_CODE(code, lino, _exit);
@@ -140,7 +138,7 @@ int vnodeBegin(SVnode *pVnode) {
_exit:
if (code) {
terrno = code;
- vError("vgId:%d %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
+ vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
}
return code;
}
@@ -221,7 +219,7 @@ _err:
return -1;
}
-int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) {
+int vnodeCommitInfo(const char *dir) {
char fname[TSDB_FILENAME_LEN];
char tfname[TSDB_FILENAME_LEN];
@@ -233,8 +231,7 @@ int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) {
return -1;
}
- vInfo("vgId:%d, vnode info is committed", pInfo->config.vgId);
-
+ vInfo("vnode info is committed, dir:%s", dir);
return 0;
}
@@ -296,18 +293,12 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
tsem_wait(&pVnode->canCommit);
- taosThreadMutexLock(&pVnode->mutex);
- ASSERT(pVnode->onCommit == NULL);
- pVnode->onCommit = pVnode->inUse;
- pVnode->inUse = NULL;
- taosThreadMutexUnlock(&pVnode->mutex);
-
pVnode->state.commitTerm = pVnode->state.applyTerm;
pInfo->info.config = pVnode->config;
pInfo->info.state.committed = pVnode->state.applied;
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
- pInfo->info.state.commitID = pVnode->state.commitID;
+ pInfo->info.state.commitID = ++pVnode->state.commitID;
pInfo->pVnode = pVnode;
pInfo->txn = metaGetTxn(pVnode->pMeta);
@@ -331,12 +322,18 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
code = smaPrepareAsyncCommit(pVnode->pSma);
if (code) goto _exit;
+ taosThreadMutexLock(&pVnode->mutex);
+ ASSERT(pVnode->onCommit == NULL);
+ pVnode->onCommit = pVnode->inUse;
+ pVnode->inUse = NULL;
+ taosThreadMutexUnlock(&pVnode->mutex);
+
_exit:
if (code) {
vError("vgId:%d, %s failed at line %d since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, lino,
tstrerror(code), pVnode->state.commitID);
} else {
- vDebug("vgId:%d, %s done", TD_VID(pVnode), __func__);
+ vDebug("vgId:%d, %s done, commit id:%" PRId64, TD_VID(pVnode), __func__, pInfo->info.state.commitID);
}
return code;
@@ -351,7 +348,7 @@ static void vnodeReturnBufPool(SVnode *pVnode) {
if (nRef == 0) {
vnodeBufPoolAddToFreeList(pPool);
} else if (nRef > 0) {
- vDebug("vgId:%d buffer pool %p of id %d is added to recycle queue", TD_VID(pVnode), pPool, pPool->id);
+ vDebug("vgId:%d, buffer pool %p of id %d is added to recycle queue", TD_VID(pVnode), pPool, pPool->id);
if (pVnode->recycleTail == NULL) {
pPool->recyclePrev = pPool->recycleNext = NULL;
@@ -468,7 +465,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
}
// commit info
- if (vnodeCommitInfo(dir, &pInfo->info) < 0) {
+ if (vnodeCommitInfo(dir) < 0) {
code = terrno;
TSDB_CHECK_CODE(code, lino, _exit);
}
diff --git a/source/dnode/vnode/src/vnd/vnodeCompact.c b/source/dnode/vnode/src/vnd/vnodeCompact.c
new file mode 100644
index 0000000000000000000000000000000000000000..14d893042d9a6d0eefd3d0023d4d69ad670f91bf
--- /dev/null
+++ b/source/dnode/vnode/src/vnd/vnodeCompact.c
@@ -0,0 +1,107 @@
+/*
+ * 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 "vnd.h"
+
+static int32_t vnodeCompactTask(void *param) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ SCompactInfo *pInfo = (SCompactInfo *)param;
+ SVnode *pVnode = pInfo->pVnode;
+
+ // do compact
+ code = tsdbCompact(pInfo->pVnode->pTsdb, pInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ // end compact
+ char dir[TSDB_FILENAME_LEN] = {0};
+ if (pVnode->pTfs) {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
+ } else {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
+ }
+ vnodeCommitInfo(dir);
+
+_exit:
+ taosMemoryFree(pInfo);
+ tsem_post(&pInfo->pVnode->canCommit);
+ return code;
+}
+static int32_t vnodePrepareCompact(SVnode *pVnode, SCompactInfo *pInfo) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ tsem_wait(&pVnode->canCommit);
+
+ pInfo->pVnode = pVnode;
+ pInfo->flag = 0;
+ pInfo->commitID = ++pVnode->state.commitID;
+
+ char dir[TSDB_FILENAME_LEN] = {0};
+ SVnodeInfo info = {0};
+
+ if (pVnode->pTfs) {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
+ } else {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
+ }
+
+ vnodeLoadInfo(dir, &info);
+ info.state.commitID = pInfo->commitID;
+ vnodeSaveInfo(dir, &info);
+
+_exit:
+ if (code) {
+ vError("vgId:%d %s failed at line %d since %s, commit ID:%" PRId64, TD_VID(pVnode), __func__, lino, tstrerror(code),
+ pVnode->state.commitID);
+ } else {
+ vDebug("vgId:%d %s done, commit ID:%" PRId64, TD_VID(pVnode), __func__, pVnode->state.commitID);
+ }
+ return code;
+}
+int32_t vnodeAsyncCompact(SVnode *pVnode) {
+ int32_t code = 0;
+ int32_t lino = 0;
+
+ SCompactInfo *pInfo = taosMemoryCalloc(1, sizeof(*pInfo));
+ if (pInfo == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ TSDB_CHECK_CODE(code, lino, _exit);
+ }
+
+ vnodeAsyncCommit(pVnode);
+
+ code = vnodePrepareCompact(pVnode, pInfo);
+ TSDB_CHECK_CODE(code, lino, _exit);
+
+ vnodeScheduleTask(vnodeCompactTask, pInfo);
+
+_exit:
+ if (code) {
+ vError("vgId:%d %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
+ if (pInfo) taosMemoryFree(pInfo);
+ } else {
+ vInfo("vgId:%d %s done", TD_VID(pVnode), __func__);
+ }
+ return code;
+}
+
+int32_t vnodeSyncCompact(SVnode *pVnode) {
+ vnodeAsyncCompact(pVnode);
+ tsem_wait(&pVnode->canCommit);
+ tsem_post(&pVnode->canCommit);
+ return 0;
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c
index 61cb75b1da592a4b6d06b3fea21a2bb7b69ae22a..11d8583ff899f317334ba3a719e88b7d89f424d3 100644
--- a/source/dnode/vnode/src/vnd/vnodeOpen.c
+++ b/source/dnode/vnode/src/vnd/vnodeOpen.c
@@ -49,7 +49,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
info.state.commitID = 0;
vInfo("vgId:%d, save config while create", pCfg->vgId);
- if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
+ if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir) < 0) {
vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno));
return -1;
}
@@ -58,7 +58,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
return 0;
}
-int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
+int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
SVnodeInfo info = {0};
char dir[TSDB_FILENAME_LEN] = {0};
int32_t ret = 0;
@@ -97,7 +97,7 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
return -1;
}
- ret = vnodeCommitInfo(dir, &info);
+ ret = vnodeCommitInfo(dir);
if (ret < 0) {
vError("vgId:%d, failed to commit vnode config since %s", pReq->vgId, tstrerror(terrno));
return -1;
@@ -107,6 +107,117 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
return 0;
}
+int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t srcVgId, int32_t dstVgId, STfs *pTfs) {
+ int32_t ret = tfsRename(pTfs, srcPath, dstPath);
+ if (ret != 0) return ret;
+
+ char oldRname[TSDB_FILENAME_LEN] = {0};
+ char newRname[TSDB_FILENAME_LEN] = {0};
+ char tsdbPath[TSDB_FILENAME_LEN] = {0};
+ char tsdbFilePrefix[TSDB_FILENAME_LEN] = {0};
+ snprintf(tsdbPath, TSDB_FILENAME_LEN, "%s%stsdb", dstPath, TD_DIRSEP);
+ snprintf(tsdbFilePrefix, TSDB_FILENAME_LEN, "tsdb%sv", TD_DIRSEP);
+
+ STfsDir *tsdbDir = tfsOpendir(pTfs, tsdbPath);
+ if (tsdbDir == NULL) return 0;
+
+ while (1) {
+ const STfsFile *tsdbFile = tfsReaddir(tsdbDir);
+ if (tsdbFile == NULL) break;
+ if (tsdbFile->rname == NULL) continue;
+ tstrncpy(oldRname, tsdbFile->rname, TSDB_FILENAME_LEN);
+
+ char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
+ if (tsdbFilePrefixPos == NULL) continue;
+
+ int32_t tsdbFileVgId = atoi(tsdbFilePrefixPos + 6);
+ if (tsdbFileVgId == srcVgId) {
+ char *tsdbFileSurfixPos = strstr(tsdbFilePrefixPos, "f");
+ if (tsdbFileSurfixPos == NULL) continue;
+
+ tsdbFilePrefixPos[6] = 0;
+ snprintf(newRname, TSDB_FILENAME_LEN, "%s%d%s", oldRname, dstVgId, tsdbFileSurfixPos);
+ vInfo("vgId:%d, rename file from %s to %s", dstVgId, tsdbFile->rname, newRname);
+
+ ret = tfsRename(pTfs, tsdbFile->rname, newRname);
+ if (ret != 0) {
+ vInfo("vgId:%d, failed to rename file from %s to %s since %s", dstVgId, tsdbFile->rname, newRname, terrstr());
+ tfsClosedir(tsdbDir);
+ return ret;
+ }
+ }
+ }
+
+ tfsClosedir(tsdbDir);
+ return 0;
+}
+
+int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnodeHashRangeReq *pReq, STfs *pTfs) {
+ SVnodeInfo info = {0};
+ char dir[TSDB_FILENAME_LEN] = {0};
+ int32_t ret = 0;
+
+ if (pTfs) {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, srcPath);
+ } else {
+ snprintf(dir, TSDB_FILENAME_LEN, "%s", srcPath);
+ }
+
+ // todo add stat file to handle exception while vnode open
+
+ ret = vnodeLoadInfo(dir, &info);
+ if (ret < 0) {
+ vError("vgId:%d, failed to read vnode config from %s since %s", pReq->srcVgId, srcPath, tstrerror(terrno));
+ return -1;
+ }
+
+ vInfo("vgId:%d, alter hashrange from [%u, %u] to [%u, %u]", pReq->srcVgId, info.config.hashBegin, info.config.hashEnd,
+ pReq->hashBegin, pReq->hashEnd);
+ info.config.vgId = pReq->dstVgId;
+ info.config.hashBegin = pReq->hashBegin;
+ info.config.hashEnd = pReq->hashEnd;
+ info.config.walCfg.vgId = pReq->dstVgId;
+
+ SSyncCfg *pCfg = &info.config.syncCfg;
+ pCfg->myIndex = 0;
+ pCfg->replicaNum = 1;
+ memset(&pCfg->nodeInfo, 0, sizeof(pCfg->nodeInfo));
+
+ vInfo("vgId:%d, alter vnode replicas to 1", pReq->srcVgId);
+ SNodeInfo *pNode = &pCfg->nodeInfo[0];
+ pNode->nodePort = tsServerPort;
+ tstrncpy(pNode->nodeFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
+ (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
+ vInfo("vgId:%d, ep:%s:%u dnode:%d", pReq->srcVgId, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);
+
+ info.config.syncCfg = *pCfg;
+
+ ret = vnodeSaveInfo(dir, &info);
+ if (ret < 0) {
+ vError("vgId:%d, failed to save vnode config since %s", pReq->dstVgId, tstrerror(terrno));
+ return -1;
+ }
+
+ ret = vnodeCommitInfo(dir);
+ if (ret < 0) {
+ vError("vgId:%d, failed to commit vnode config since %s", pReq->dstVgId, tstrerror(terrno));
+ return -1;
+ }
+
+ vInfo("vgId:%d, rename %s to %s", pReq->dstVgId, srcPath, dstPath);
+ ret = vnodeRenameVgroupId(srcPath, dstPath, pReq->srcVgId, pReq->dstVgId, pTfs);
+ if (ret < 0) {
+ vError("vgId:%d, failed to rename vnode from %s to %s since %s", pReq->dstVgId, srcPath, dstPath,
+ tstrerror(terrno));
+ return -1;
+ }
+
+ // todo vnode compact here
+
+ vInfo("vgId:%d, vnode hashrange is altered", info.config.vgId);
+ return 0;
+}
+
void vnodeDestroy(const char *path, STfs *pTfs) {
vInfo("path:%s is removed while destroy vnode", path);
tfsRmdir(pTfs, path);
@@ -146,7 +257,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
if (updated) {
vInfo("vgId:%d, save vnode info since dnode info changed", info.config.vgId);
(void)vnodeSaveInfo(dir, &info);
- (void)vnodeCommitInfo(dir, &info);
+ (void)vnodeCommitInfo(dir);
}
// create handle
diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c
index e75dc24329c03ade45e12242fd70a62b963f74ff..71458acce2cdab30365c452d23efd5841bb9424a 100644
--- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c
+++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c
@@ -349,7 +349,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
snprintf(dir, TSDB_FILENAME_LEN, "%s", pWriter->pVnode->path);
}
- vnodeCommitInfo(dir, &pWriter->info);
+ vnodeCommitInfo(dir);
} else {
vnodeRollback(pWriter->pVnode);
}
@@ -426,7 +426,13 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
SVnode *pVnode = pWriter->pVnode;
ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
- ASSERT(pHdr->index == pWriter->index + 1);
+
+ if (pHdr->index != pWriter->index + 1) {
+ vError("vgId:%d, unexpected vnode snapshot msg. index:%" PRId64 ", expected index:%" PRId64, TD_VID(pVnode),
+ pHdr->index, pWriter->index + 1);
+ return -1;
+ }
+
pWriter->index = pHdr->index;
vDebug("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d blockLen:%d", TD_VID(pVnode), pHdr->index,
@@ -455,7 +461,7 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
if (code) goto _err;
}
- code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData, nData);
+ code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pHdr);
if (code) goto _err;
} break;
case SNAP_DATA_TQ_HANDLE: {
diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c
index 6abc144b911720244e33b3553249b98b48550af7..05d29656ef7c2676ce6c210fc3e909f6fce54c45 100644
--- a/source/dnode/vnode/src/vnd/vnodeSvr.c
+++ b/source/dnode/vnode/src/vnd/vnodeSvr.c
@@ -24,12 +24,12 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
-static int32_t vnodeProcessAlterHashRangeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessTrimReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
+static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
int32_t code = 0;
@@ -313,15 +313,15 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
case TDMT_VND_ALTER_CONFIRM:
vnodeProcessAlterConfirmReq(pVnode, version, pReq, len, pRsp);
break;
- case TDMT_VND_ALTER_HASHRANGE:
- vnodeProcessAlterHashRangeReq(pVnode, version, pReq, len, pRsp);
- break;
case TDMT_VND_ALTER_CONFIG:
vnodeProcessAlterConfigReq(pVnode, version, pReq, len, pRsp);
break;
case TDMT_VND_COMMIT:
needCommit = true;
break;
+ case TDMT_VND_COMPACT:
+ vnodeProcessCompactVnodeReq(pVnode, version, pReq, len, pRsp);
+ goto _exit;
default:
vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType);
return -1;
@@ -1246,16 +1246,6 @@ static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void
return 0;
}
-static int32_t vnodeProcessAlterHashRangeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
- vInfo("vgId:%d, alter hashrange msg will be processed", TD_VID(pVnode));
-
- // todo
- // 1. stop work
- // 2. adjust hash range / compact / remove wals / rename vgroups
- // 3. reload sync
- return 0;
-}
-
static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
bool walChanged = false;
bool tsdbChanged = false;
@@ -1349,7 +1339,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
tDecodeSBatchDeleteReq(&decoder, &deleteReq);
SMetaReader mr = {0};
- metaReaderInit(&mr, pVnode->pMeta, 0);
+ metaReaderInit(&mr, pVnode->pMeta, META_READER_NOLOCK);
int32_t sz = taosArrayGetSize(deleteReq.deleteReqs);
for (int32_t i = 0; i < sz; i++) {
@@ -1418,3 +1408,18 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq
_err:
return code;
}
+
+static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
+ SCompactVnodeReq req = {0};
+ if (tDeserializeSCompactVnodeReq(pReq, len, &req) != 0) {
+ terrno = TSDB_CODE_INVALID_MSG;
+ return TSDB_CODE_INVALID_MSG;
+ }
+ vInfo("vgId:%d, compact msg will be processed, db:%s dbUid:%" PRId64 " compactStartTime:%" PRId64, TD_VID(pVnode),
+ req.db, req.dbUid, req.compactStartTime);
+
+ vnodeAsyncCompact(pVnode);
+ vnodeBegin(pVnode);
+
+ return 0;
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c
index 6f3788616a5f45e440d07f23b89e3e493d07fa4d..1e96a76170ca3eb972a9199d41c47e512c11639d 100644
--- a/source/dnode/vnode/src/vnd/vnodeSync.c
+++ b/source/dnode/vnode/src/vnd/vnodeSync.c
@@ -219,7 +219,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
isWeak, isBlock, msg, numOfMsgs, arrayPos, pMsg->info.handle);
if (!pVnode->restored) {
- vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg);
+ vGError("vgId:%d, msg:%p failed to process since restore not finished, type:%s", vgId, pMsg, TMSG_INFO(pMsg->msgType));
terrno = TSDB_CODE_SYN_RESTORING;
vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_SYN_RESTORING);
rpcFreeCont(pMsg->pCont);
@@ -228,7 +228,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
}
if (pMsgArr == NULL || pIsWeakArr == NULL) {
- vGError("vgId:%d, msg:%p failed to process since out of memory", vgId, pMsg);
+ vGError("vgId:%d, msg:%p failed to process since out of memory, type:%s", vgId, pMsg, TMSG_INFO(pMsg->msgType));
terrno = TSDB_CODE_OUT_OF_MEMORY;
vnodeHandleProposeError(pVnode, pMsg, terrno);
rpcFreeCont(pMsg->pCont);
@@ -281,7 +281,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
vnodeIsMsgBlock(pMsg->msgType), msg, numOfMsgs, pMsg->info.handle);
if (!pVnode->restored) {
- vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg);
+ vGError("vgId:%d, msg:%p failed to process since restore not finished, type:%s", vgId, pMsg, TMSG_INFO(pMsg->msgType));
vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_SYN_RESTORING);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
@@ -635,7 +635,7 @@ int32_t vnodeSyncStart(SVnode *pVnode) {
}
void vnodeSyncPreClose(SVnode *pVnode) {
- vInfo("vgId:%d, pre close sync", pVnode->config.vgId);
+ vInfo("vgId:%d, sync pre close", pVnode->config.vgId);
syncLeaderTransfer(pVnode->sync);
syncPreStop(pVnode->sync);
@@ -649,7 +649,7 @@ void vnodeSyncPreClose(SVnode *pVnode) {
}
void vnodeSyncPostClose(SVnode *pVnode) {
- vInfo("vgId:%d, post close sync", pVnode->config.vgId);
+ vInfo("vgId:%d, sync post close", pVnode->config.vgId);
syncPostStop(pVnode->sync);
}
diff --git a/source/libs/CMakeLists.txt b/source/libs/CMakeLists.txt
index 72459f4d35437c704f7021d14126f6166388bbe5..e18be94ace94c35a486a7ebd8c54e4eb3ae2e009 100644
--- a/source/libs/CMakeLists.txt
+++ b/source/libs/CMakeLists.txt
@@ -1,5 +1,4 @@
add_subdirectory(tdb)
-add_subdirectory(cache)
add_subdirectory(transport)
add_subdirectory(wal)
add_subdirectory(monitor)
diff --git a/source/libs/cache/CMakeLists.txt b/source/libs/cache/CMakeLists.txt
deleted file mode 100644
index dc631e5bfd4126fe2edbc057668430043a43f31c..0000000000000000000000000000000000000000
--- a/source/libs/cache/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-aux_source_directory(src CACHE_SRC)
-add_library(cache STATIC ${CACHE_SRC})
-target_include_directories(
- cache
- PUBLIC "${TD_SOURCE_DIR}/include/libs/cache"
- PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
-)
\ No newline at end of file
diff --git a/source/libs/cache/inc/cacheDef.h b/source/libs/cache/inc/cacheDef.h
deleted file mode 100644
index 2e0dbfcdb6065ee7cdb15c479e7755dee9d4a77d..0000000000000000000000000000000000000000
--- a/source/libs/cache/inc/cacheDef.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-#ifndef _TD_CACHE_DEF_H_
-#define _TD_CACHE_DEF_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_TD_CACHE_DEF_H_*/
\ No newline at end of file
diff --git a/source/libs/cache/src/cache.c b/source/libs/cache/src/cache.c
deleted file mode 100644
index 6dea4a4e57392be988126c579648f39a8270b9bf..0000000000000000000000000000000000000000
--- a/source/libs/cache/src/cache.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright (c) 2019 TAOS Data, Inc.
- *
- * This program is free software: you can use, redistribute, and/or modify
- * it under the terms of the GNU Affero General Public License, version 3
- * or later ("AGPL"), as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
\ No newline at end of file
diff --git a/source/libs/cache/test/cacheTests.cpp b/source/libs/cache/test/cacheTests.cpp
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h
index 7d33f150ffc3b38faf93800fe18651c1afaecef8..549ce6ae79f2dfe9ac24092628c167b52b05bf06 100644
--- a/source/libs/executor/inc/executorimpl.h
+++ b/source/libs/executor/inc/executorimpl.h
@@ -479,6 +479,8 @@ typedef struct SStreamScanInfo {
SSDataBlock* pRecoverRes;
SSDataBlock* pCreateTbRes;
+ int8_t igCheckUpdate;
+ int8_t igExpired;
} SStreamScanInfo;
typedef struct {
@@ -570,7 +572,7 @@ typedef struct SStreamIntervalOperatorInfo {
SWinKey delKey;
uint64_t numOfDatapack;
SArray* pUpdated;
- SHashObj* pUpdatedMap;
+ SSHashObj* pUpdatedMap;
} SStreamIntervalOperatorInfo;
typedef struct SDataGroupInfo {
@@ -717,9 +719,10 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
SDiskbasedBuf* pBuf);
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
+bool hasSlimitOffsetInfo(SLimitInfo* pLimitInfo);
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo);
void resetLimitInfoForNextGroup(SLimitInfo* pLimitInfo);
-bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, SOperatorInfo* pOperator);
+bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData,
int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput);
@@ -868,8 +871,8 @@ int32_t releaseOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResul
int32_t saveOutputBuf(SStreamState* pState, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
void getNextIntervalWindow(SInterval* pInterval, STimeWindow* tw, int32_t order);
int32_t qAppendTaskStopInfo(SExecTaskInfo* pTaskInfo, SExchangeOpStopInfo* pInfo);
-int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos,
- int32_t order, int64_t* pData);
+int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn_t searchFn, TSKEY ekey, int32_t pos, int32_t order,
+ int64_t* pData);
void appendCreateTableRow(SStreamState* pState, SExprSupp* pTableSup, SExprSupp* pTagSup, int64_t groupId,
SSDataBlock* pSrcBlock, int32_t rowId, SSDataBlock* pDestBlock);
@@ -877,8 +880,8 @@ SSDataBlock* buildCreateTableBlock(SExprSupp* tbName, SExprSupp* tag);
SExprInfo* createExpr(SNodeList* pNodeList, int32_t* numOfExprs);
void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultRow* pRow, SqlFunctionCtx* pCtx,
- SSDataBlock* pBlock, const int32_t* rowEntryOffset, SExecTaskInfo* pTaskInfo);
-void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) ;
+ SSDataBlock* pBlock, const int32_t* rowEntryOffset, SExecTaskInfo* pTaskInfo);
+void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset);
#ifdef __cplusplus
}
diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c
index a8051ea7c3eb294e7beb9ce6b5a23be601e635ef..184b9e0148df711439c23c66aa34d6d4a779b1fc 100644
--- a/source/libs/executor/src/dataDeleter.c
+++ b/source/libs/executor/src/dataDeleter.c
@@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
pEntry->numOfCols = taosArrayGetSize(pInput->pData->pDataBlock);
pEntry->dataLen = sizeof(SDeleterRes);
-// ASSERT(1 == pEntry->numOfRows);
-// ASSERT(3 == pEntry->numOfCols);
+ // ASSERT(1 == pEntry->numOfRows);
+ // ASSERT(3 == pEntry->numOfCols);
pBuf->useSize = sizeof(SDataCacheEntry);
@@ -142,7 +142,7 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput,
taosFreeQitem(pBuf);
return TSDB_CODE_OUT_OF_MEMORY;
}
-
+
toDataCacheEntry(pDeleter, pInput, pBuf);
taosWriteQitem(pDeleter->pDataBlocks, pBuf);
*pContinue = (DS_BUF_LOW == updateStatus(pDeleter) ? true : false);
@@ -167,8 +167,10 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataDeleterBuf* pBuf = NULL;
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
- memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
- taosFreeQitem(pBuf);
+ if (pBuf != NULL) {
+ memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
+ taosFreeQitem(pBuf);
+ }
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDeleter->nextOutput.pData;
*pLen = pEntry->dataLen;
@@ -256,7 +258,7 @@ int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pData
deleter->pDeleter = pDeleterNode;
deleter->pSchema = pDataSink->pInputDataBlockDesc;
- if(pParam == NULL) {
+ if (pParam == NULL) {
code = TSDB_CODE_QRY_INVALID_INPUT;
qError("invalid input param in creating data deleter, code%s", tstrerror(code));
goto _end;
@@ -275,7 +277,7 @@ int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pData
*pHandle = deleter;
return code;
- _end:
+_end:
if (deleter != NULL) {
destroyDataSinker((SDataSinkHandle*)deleter);
taosMemoryFree(deleter);
diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c
index a603bffba5f37b79ee9f4a42546b8bbb3a0c32ea..d8efcf50cac24dca0b444f2e54bf886453e1bb96 100644
--- a/source/libs/executor/src/dataDispatcher.c
+++ b/source/libs/executor/src/dataDispatcher.c
@@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
pBuf->useSize = sizeof(SDataCacheEntry);
pEntry->dataLen = blockEncode(pInput->pData, pEntry->data, numOfCols);
-// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
-// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
+ // ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
+ // ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
pBuf->useSize += pEntry->dataLen;
@@ -135,7 +135,7 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput,
taosFreeQitem(pBuf);
return TSDB_CODE_OUT_OF_MEMORY;
}
-
+
toDataCacheEntry(pDispatcher, pInput, pBuf);
taosWriteQitem(pDispatcher->pDataBlocks, pBuf);
@@ -162,14 +162,16 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataDispatchBuf* pBuf = NULL;
taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf);
- memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
- taosFreeQitem(pBuf);
+ if (pBuf != NULL) {
+ memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
+ taosFreeQitem(pBuf);
+ }
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData;
*pLen = pEntry->dataLen;
-// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
-// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
+ // ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
+ // ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
*pQueryEnd = pDispatcher->queryEnd;
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen,
@@ -192,8 +194,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput->numOfCols = pEntry->numOfCols;
pOutput->compressed = pEntry->compressed;
-// ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
-// ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
+ // ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
+ // ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen);
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c
index f78e3c22e13c8b99885c451cd16f76ed038b79a1..a823baa2ae1350dfe51124caf6b58c1c5a19cd65 100644
--- a/source/libs/executor/src/dataInserter.c
+++ b/source/libs/executor/src/dataInserter.c
@@ -46,6 +46,7 @@ typedef struct SDataInserterHandle {
uint64_t cachedSize;
TdThreadMutex mutex;
tsem_t ready;
+ bool explain;
} SDataInserterHandle;
typedef struct SSubmitRspParam {
@@ -333,26 +334,28 @@ int32_t dataBlocksToSubmitReq(SDataInserterHandle* pInserter, void** pMsg, int32
static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) {
SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle;
- taosArrayPush(pInserter->pDataBlocks, &pInput->pData);
- void* pMsg = NULL;
- int32_t msgLen = 0;
- int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen);
- if (code) {
- return code;
- }
+ if (!pInserter->explain) {
+ taosArrayPush(pInserter->pDataBlocks, &pInput->pData);
+ void* pMsg = NULL;
+ int32_t msgLen = 0;
+ int32_t code = dataBlocksToSubmitReq(pInserter, &pMsg, &msgLen);
+ if (code) {
+ return code;
+ }
- taosArrayClear(pInserter->pDataBlocks);
+ taosArrayClear(pInserter->pDataBlocks);
- code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc,
- &pInserter->pNode->epSet);
- if (code) {
- return code;
- }
+ code = sendSubmitRequest(pInserter, pMsg, msgLen, pInserter->pParam->readHandle->pMsgCb->clientRpc,
+ &pInserter->pNode->epSet);
+ if (code) {
+ return code;
+ }
- tsem_wait(&pInserter->ready);
+ tsem_wait(&pInserter->ready);
- if (pInserter->submitRes.code) {
- return pInserter->submitRes.code;
+ if (pInserter->submitRes.code) {
+ return pInserter->submitRes.code;
+ }
}
*pContinue = true;
@@ -412,6 +415,7 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
inserter->pParam = pParam;
inserter->status = DS_BUF_EMPTY;
inserter->queryEnd = false;
+ inserter->explain = pInserterNode->explain;
int64_t suid = 0;
int32_t code =
diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c
index 037b33dc9f35c0b36c5e8fb092bf15102821b089..e5089ab4a9b6a6486d86bebbf82bf54c4abd543e 100644
--- a/source/libs/executor/src/exchangeoperator.c
+++ b/source/libs/executor/src/exchangeoperator.c
@@ -218,10 +218,7 @@ static SSDataBlock* loadRemoteData(SOperatorInfo* pOperator) {
if (status == PROJECT_RETRIEVE_CONTINUE) {
continue;
} else if (status == PROJECT_RETRIEVE_DONE) {
- size_t rows = pBlock->info.rows;
- pExchangeInfo->limitInfo.numOfOutputRows += rows;
-
- if (rows == 0) {
+ if (pBlock->info.rows == 0) {
setOperatorCompleted(pOperator);
return NULL;
} else {
@@ -707,6 +704,8 @@ int32_t prepareLoadRemoteData(SOperatorInfo* pOperator) {
}
int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf) {
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+
if (pLimitInfo->remainGroupOffset > 0) {
if (pLimitInfo->currentGroupId == 0) { // it is the first group
pLimitInfo->currentGroupId = pBlock->info.id.groupId;
@@ -750,36 +749,20 @@ int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDa
// set current group id
pLimitInfo->currentGroupId = pBlock->info.id.groupId;
- if (pLimitInfo->remainOffset >= pBlock->info.rows) {
- pLimitInfo->remainOffset -= pBlock->info.rows;
- blockDataCleanup(pBlock);
+ bool limitReached = applyLimitOffset(pLimitInfo, pBlock, pTaskInfo);
+ if (pBlock->info.rows == 0) {
return PROJECT_RETRIEVE_CONTINUE;
- } else if (pLimitInfo->remainOffset < pBlock->info.rows && pLimitInfo->remainOffset > 0) {
- blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
- pLimitInfo->remainOffset = 0;
- }
-
- // check for the limitation in each group
- if (pLimitInfo->limit.limit >= 0 && pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) {
- int32_t keepRows = (int32_t)(pLimitInfo->limit.limit - pLimitInfo->numOfOutputRows);
- blockDataKeepFirstNRows(pBlock, keepRows);
- if (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups) {
+ } else {
+ if (limitReached && (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
setOperatorCompleted(pOperator);
- } else {
- // current group limitation is reached, and future blocks of this group need to be discarded.
- if (pBlock->info.rows == 0) {
- return PROJECT_RETRIEVE_CONTINUE;
- }
+ return PROJECT_RETRIEVE_DONE;
}
-
- return PROJECT_RETRIEVE_DONE;
}
// todo optimize performance
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
// they may not belong to the same group the limit/offset value is not valid in this case.
- if ((!holdDataInBuf) || (pBlock->info.rows >= pOperator->resultInfo.threshold) || pLimitInfo->slimit.offset != -1 ||
- pLimitInfo->slimit.limit != -1) {
+ if ((!holdDataInBuf) || (pBlock->info.rows >= pOperator->resultInfo.threshold) || hasSlimitOffsetInfo(pLimitInfo)) {
return PROJECT_RETRIEVE_DONE;
} else { // not full enough, continue to accumulate the output data in the buffer.
return PROJECT_RETRIEVE_CONTINUE;
diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c
index 1d16a3418d30acfd06a07952723750921337fc1c..1add82bdc45bd8aadad9680ef02f201fdd795660 100644
--- a/source/libs/executor/src/executil.c
+++ b/source/libs/executor/src/executil.c
@@ -155,7 +155,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList) {
if (pGroupResInfo->pRows != NULL) {
- taosArrayDestroyP(pGroupResInfo->pRows, taosMemoryFree);
+ taosArrayDestroy(pGroupResInfo->pRows);
}
pGroupResInfo->pRows = pArrayList;
@@ -1670,12 +1670,18 @@ int32_t convertFillType(int32_t mode) {
case FILL_MODE_NULL:
type = TSDB_FILL_NULL;
break;
+ case FILL_MODE_NULL_F:
+ type = TSDB_FILL_NULL_F;
+ break;
case FILL_MODE_NEXT:
type = TSDB_FILL_NEXT;
break;
case FILL_MODE_VALUE:
type = TSDB_FILL_SET_VALUE;
break;
+ case FILL_MODE_VALUE_F:
+ type = TSDB_FILL_SET_VALUE_F;
+ break;
case FILL_MODE_LINEAR:
type = TSDB_FILL_LINEAR;
break;
@@ -1761,6 +1767,10 @@ bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo) {
pLimitInfo->slimit.offset != -1);
}
+bool hasSlimitOffsetInfo(SLimitInfo* pLimitInfo) {
+ return (pLimitInfo->slimit.limit != -1 || pLimitInfo->slimit.offset != -1);
+}
+
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo) {
SLimit limit = {.limit = getLimit(pLimit), .offset = getOffset(pLimit)};
SLimit slimit = {.limit = getLimit(pSLimit), .offset = getOffset(pSLimit)};
@@ -1820,28 +1830,30 @@ int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t
int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalGroupIndex, STableKeyInfo** pKeyInfo,
int32_t* size) {
- int32_t total = tableListGetOutputGroups(pTableList);
- if (ordinalGroupIndex < 0 || ordinalGroupIndex >= total) {
+ int32_t totalGroups = tableListGetOutputGroups(pTableList);
+ int32_t numOfTables = tableListGetSize(pTableList);
+
+ if (ordinalGroupIndex < 0 || ordinalGroupIndex >= totalGroups) {
return TSDB_CODE_INVALID_PARA;
}
// here handle two special cases:
// 1. only one group exists, and 2. one table exists for each group.
- if (total == 1) {
- *size = tableListGetSize(pTableList);
+ if (totalGroups == 1) {
+ *size = numOfTables;
*pKeyInfo = (*size == 0) ? NULL : taosArrayGet(pTableList->pTableList, 0);
return TSDB_CODE_SUCCESS;
- } else if (total == tableListGetSize(pTableList)) {
+ } else if (totalGroups == numOfTables) {
*size = 1;
*pKeyInfo = taosArrayGet(pTableList->pTableList, ordinalGroupIndex);
return TSDB_CODE_SUCCESS;
}
int32_t offset = pTableList->groupOffset[ordinalGroupIndex];
- if (ordinalGroupIndex < total - 1) {
- *size = pTableList->groupOffset[offset + 1] - pTableList->groupOffset[offset];
+ if (ordinalGroupIndex < totalGroups - 1) {
+ *size = pTableList->groupOffset[ordinalGroupIndex + 1] - offset;
} else {
- *size = total - pTableList->groupOffset[offset] - 1;
+ *size = numOfTables - offset;
}
*pKeyInfo = taosArrayGet(pTableList->pTableList, offset);
diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c
index 21ef5dfab3891e8c00d164790df0762e047750af..08d7f02f8c0f36f227fdf2e04b6cb642552dbb60 100644
--- a/source/libs/executor/src/executorimpl.c
+++ b/source/libs/executor/src/executorimpl.c
@@ -2589,26 +2589,22 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
- SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
+ SWinKey* pKey = taosArrayGet(pGroupResInfo->pRows, i);
int32_t size = 0;
void* pVal = NULL;
- SWinKey key = {
- .ts = *(TSKEY*)pPos->key,
- .groupId = pPos->groupId,
- };
- int32_t code = streamStateGet(pState, &key, &pVal, &size);
+ int32_t code = streamStateGet(pState, pKey, &pVal, &size);
ASSERT(code == 0);
SResultRow* pRow = (SResultRow*)pVal;
doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
// no results, continue to check the next one
if (pRow->numOfRows == 0) {
pGroupResInfo->index += 1;
- releaseOutputBuf(pState, &key, pRow);
+ releaseOutputBuf(pState, pKey, pRow);
continue;
}
if (pBlock->info.id.groupId == 0) {
- pBlock->info.id.groupId = pPos->groupId;
+ pBlock->info.id.groupId = pKey->groupId;
void* tbname = NULL;
if (streamStateGetParName(pTaskInfo->streamInfo.pState, pBlock->info.id.groupId, &tbname) < 0) {
pBlock->info.parTbName[0] = 0;
@@ -2618,15 +2614,15 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
tdbFree(tbname);
} else {
// current value belongs to different group, it can't be packed into one datablock
- if (pBlock->info.id.groupId != pPos->groupId) {
- releaseOutputBuf(pState, &key, pRow);
+ if (pBlock->info.id.groupId != pKey->groupId) {
+ releaseOutputBuf(pState, pKey, pRow);
break;
}
}
if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
ASSERT(pBlock->info.rows > 0);
- releaseOutputBuf(pState, &key, pRow);
+ releaseOutputBuf(pState, pKey, pRow);
break;
}
@@ -2656,7 +2652,7 @@ int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pStat
}
pBlock->info.rows += pRow->numOfRows;
- releaseOutputBuf(pState, &key, pRow);
+ releaseOutputBuf(pState, pKey, pRow);
}
pBlock->info.dataLoad = 1;
blockDataUpdateTsWindow(pBlock, 0);
diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c
index 187c8f582afc56e2b8eb9293fd44bafd307a6151..41e4c990f851a3cbcaf3a5982e16dc024caf0eab 100644
--- a/source/libs/executor/src/filloperator.c
+++ b/source/libs/executor/src/filloperator.c
@@ -140,7 +140,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
while (1) {
SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream);
if (pBlock == NULL) {
- if (pInfo->totalInputRows == 0) {
+ if (pInfo->totalInputRows == 0 && (pInfo->pFillInfo->type != TSDB_FILL_NULL_F && pInfo->pFillInfo->type != TSDB_FILL_SET_VALUE_F)) {
setOperatorCompleted(pOperator);
return NULL;
}
@@ -456,7 +456,8 @@ void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) {
return NULL;
}
void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) {
- if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_NULL) {
+ if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_SET_VALUE_F ||
+ pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) {
taosMemoryFreeClear(pFillInfo->pResRow->pRowVal);
taosMemoryFreeClear(pFillInfo->pResRow);
}
@@ -661,7 +662,9 @@ void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillS
pFillInfo->pos = FILL_POS_INVALID;
switch (pFillInfo->type) {
case TSDB_FILL_NULL:
+ case TSDB_FILL_NULL_F:
case TSDB_FILL_SET_VALUE:
+ case TSDB_FILL_SET_VALUE_F:
break;
case TSDB_FILL_PREV:
pFillInfo->pResRow = &pFillSup->prev;
@@ -720,7 +723,9 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS
pFillInfo->pos = FILL_POS_INVALID;
switch (pFillInfo->type) {
case TSDB_FILL_NULL:
- case TSDB_FILL_SET_VALUE: {
+ case TSDB_FILL_NULL_F:
+ case TSDB_FILL_SET_VALUE:
+ case TSDB_FILL_SET_VALUE_F: {
if (pFillSup->prev.key == pFillInfo->preRowKey) {
resetFillWindow(&pFillSup->prev);
}
@@ -1360,7 +1365,8 @@ SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock*
pFillInfo->pLinearInfo->winIndex = 0;
pFillInfo->pResRow = NULL;
- if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_NULL) {
+ if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_SET_VALUE_F
+ || pFillSup->type == TSDB_FILL_NULL || pFillSup->type == TSDB_FILL_NULL_F) {
pFillInfo->pResRow = taosMemoryCalloc(1, sizeof(SResultRowData));
pFillInfo->pResRow->key = INT64_MIN;
pFillInfo->pResRow->pRowVal = taosMemoryCalloc(1, pFillSup->rowSize);
@@ -1405,7 +1411,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
goto _error;
}
- if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE) {
+ if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE || pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE_F) {
for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) {
SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i;
int32_t slotId = GET_DEST_SLOT_ID(pFillCol);
@@ -1427,7 +1433,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
pCell->isNull = true;
}
}
- } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL) {
+ } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL || pInfo->pFillInfo->type == TSDB_FILL_NULL_F) {
for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) {
SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i;
int32_t slotId = GET_DEST_SLOT_ID(pFillCol);
diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c
index fb122b077fc21477b18c5db83b28d0caa294e605..45f38a43e6cced55a90f1180b036b5d5e2fa3659 100644
--- a/source/libs/executor/src/groupoperator.c
+++ b/source/libs/executor/src/groupoperator.c
@@ -492,8 +492,8 @@ _error:
static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
SPartitionOperatorInfo* pInfo = pOperator->info;
- SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
-
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j);
int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
@@ -690,8 +690,8 @@ static int compareDataGroupInfo(const void* group1, const void* group2) {
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
SPartitionOperatorInfo* pInfo = pOperator->info;
- SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
-
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+
SDataGroupInfo* pGroupInfo =
(pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL;
if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) {
@@ -713,7 +713,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
T_LONG_JMP(pTaskInfo->env, terrno);
}
-
+
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity);
blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity);
@@ -829,6 +829,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
SPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SPartitionOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ pTaskInfo->code = terrno;
goto _error;
}
@@ -841,6 +843,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
SExprInfo* pExprInfo1 = createExprInfo(pPartNode->pExprs, NULL, &num);
int32_t code = initExprSupp(&pInfo->scalarSup, pExprInfo1, num);
if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ pTaskInfo->code = terrno;
goto _error;
}
}
@@ -848,6 +852,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
pInfo->pGroupSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
if (pInfo->pGroupSet == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ pTaskInfo->code = terrno;
goto _error;
}
@@ -866,6 +872,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir);
if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ pTaskInfo->code = code;
goto _error;
}
@@ -873,6 +881,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
pInfo->columnOffset = setupColumnOffset(pInfo->binfo.pRes, pInfo->rowCapacity);
code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pInfo->pGroupCols);
if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ pTaskInfo->code = code;
goto _error;
}
@@ -885,10 +895,15 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL);
code = appendDownstream(pOperator, &downstream, 1);
+ if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ pTaskInfo->code = code;
+ goto _error;
+ }
+
return pOperator;
_error:
- pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
if (pInfo != NULL) {
destroyPartitionOperatorInfo(pInfo);
}
@@ -971,7 +986,7 @@ static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
void appendCreateTableRow(SStreamState* pState, SExprSupp* pTableSup, SExprSupp* pTagSup, int64_t groupId,
SSDataBlock* pSrcBlock, int32_t rowId, SSDataBlock* pDestBlock) {
void* pValue = NULL;
- if (groupId != 0 && streamStateGetParName(pState, groupId, &pValue) != 0) {
+ if (streamStateGetParName(pState, groupId, &pValue) != 0) {
SSDataBlock* pTmpBlock = blockCopyOneRow(pSrcBlock, rowId);
if (pTableSup->numOfExprs > 0) {
projectApplyFunctions(pTableSup->pExprInfo, pDestBlock, pTmpBlock, pTableSup->pCtx, pTableSup->numOfExprs, NULL);
@@ -1138,7 +1153,7 @@ void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup
SStreamScanInfo* pScanInfo = downstream->info;
pScanInfo->partitionSup = *pParSup;
pScanInfo->pPartScalarSup = pExpr;
- if (!pScanInfo->pUpdateInfo) {
+ if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) {
pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0);
}
}
diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c
index 6c2bcf086ddf1a66b007711537f847f686d180e2..5a221a0fbd3e9fbffdf57a922c656961a83df297 100644
--- a/source/libs/executor/src/projectoperator.c
+++ b/source/libs/executor/src/projectoperator.c
@@ -90,7 +90,16 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
pInfo->binfo.pRes = pResBlock;
pInfo->pFinalRes = createOneDataBlock(pResBlock, false);
- pInfo->mergeDataBlocks = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) ? false : pProjPhyNode->mergeDataBlock;
+
+ if (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
+ pInfo->mergeDataBlocks = false;
+ } else {
+ if (!pProjPhyNode->ignoreGroupId) {
+ pInfo->mergeDataBlocks = false;
+ } else {
+ pInfo->mergeDataBlocks = pProjPhyNode->mergeDataBlock;
+ }
+ }
int32_t numOfRows = 4096;
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
@@ -181,40 +190,20 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S
return PROJECT_RETRIEVE_DONE;
}
+// todo refactor
static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SSDataBlock* pBlock,
SOperatorInfo* pOperator) {
// set current group id
pLimitInfo->currentGroupId = groupId;
-
- if (pLimitInfo->remainOffset >= pBlock->info.rows) {
- pLimitInfo->remainOffset -= pBlock->info.rows;
- blockDataCleanup(pBlock);
+ bool limitReached = applyLimitOffset(pLimitInfo, pBlock, pOperator->pTaskInfo);
+ if (pBlock->info.rows == 0) {
return PROJECT_RETRIEVE_CONTINUE;
- } else if (pLimitInfo->remainOffset < pBlock->info.rows && pLimitInfo->remainOffset > 0) {
- blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
- pLimitInfo->remainOffset = 0;
- }
-
- // check for the limitation in each group
- if (pLimitInfo->limit.limit >= 0 && pLimitInfo->numOfOutputRows + pBlock->info.rows >= pLimitInfo->limit.limit) {
- int32_t keepRows = (int32_t)(pLimitInfo->limit.limit - pLimitInfo->numOfOutputRows);
- blockDataKeepFirstNRows(pBlock, keepRows);
-
- // TODO: optimize it later when partition by + limit
- // all retrieved requirement has been fulfilled, let's finish this
- if ((pLimitInfo->slimit.limit == -1 && pLimitInfo->currentGroupId == 0) ||
- (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
+ } else {
+ if (limitReached && (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
setOperatorCompleted(pOperator);
- } else {
- // Even current group is done, there may be many vgroups remain existed, and we need to continue to retrieve data
- // from next group. So let's continue this retrieve process
- if (keepRows == 0) {
- return PROJECT_RETRIEVE_CONTINUE;
- }
}
}
- pLimitInfo->numOfOutputRows += pBlock->info.rows;
return PROJECT_RETRIEVE_DONE;
}
diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c
index 37c33c44e28137bc2fec87f51a54e531bbb5a0dc..7d05b9c66d5d6162111de92710dd5a561053dd32 100644
--- a/source/libs/executor/src/scanoperator.c
+++ b/source/libs/executor/src/scanoperator.c
@@ -256,12 +256,11 @@ static void doSetTagColumnData(STableScanBase* pTableScanInfo, SSDataBlock* pBlo
}
}
-// todo handle the slimit info
-bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, SOperatorInfo* pOperator) {
+bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
SLimit* pLimit = &pLimitInfo->limit;
const char* id = GET_TASKID(pTaskInfo);
- if (pLimit->offset > 0 && pLimitInfo->remainOffset > 0) {
+ if (pLimitInfo->remainOffset > 0) {
if (pLimitInfo->remainOffset >= pBlock->info.rows) {
pLimitInfo->remainOffset -= pBlock->info.rows;
blockDataEmpty(pBlock);
@@ -276,12 +275,14 @@ bool applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
if (pLimit->limit != -1 && pLimit->limit <= (pLimitInfo->numOfOutputRows + pBlock->info.rows)) {
// limit the output rows
int32_t keep = (int32_t)(pLimit->limit - pLimitInfo->numOfOutputRows);
-
blockDataKeepFirstNRows(pBlock, keep);
+
+ pLimitInfo->numOfOutputRows += pBlock->info.rows;
qDebug("output limit %" PRId64 " has reached, %s", pLimit->limit, id);
return true;
}
+ pLimitInfo->numOfOutputRows += pBlock->info.rows;
return false;
}
@@ -311,8 +312,8 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
tsdbReleaseDataBlock(pTableScanInfo->dataReader);
return TSDB_CODE_SUCCESS;
} else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
- qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo),
- pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
+ qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d, uid:%" PRIu64, GET_TASKID(pTaskInfo),
+ pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, pBlockInfo->id.uid);
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1);
pCost->skipBlocks += 1;
tsdbReleaseDataBlock(pTableScanInfo->dataReader);
@@ -397,13 +398,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
}
}
- bool limitReached = applyLimitOffset(&pTableScanInfo->limitInfo, pBlock, pTaskInfo, pOperator);
- if (limitReached) { // set operator flag is done
+ bool limitReached = applyLimitOffset(&pTableScanInfo->limitInfo, pBlock, pTaskInfo);
+ if (limitReached) { // set operator flag is done
setOperatorCompleted(pOperator);
}
pCost->totalRows += pBlock->info.rows;
- pTableScanInfo->limitInfo.numOfOutputRows = pCost->totalRows;
return TSDB_CODE_SUCCESS;
}
@@ -450,6 +450,15 @@ static STableCachedVal* createTableCacheVal(const SMetaReader* pMetaReader) {
// const void *key, size_t keyLen, void *value
static void freeCachedMetaItem(const void* key, size_t keyLen, void* value) { freeTableCachedVal(value); }
+static void doSetNullValue(SSDataBlock* pBlock, const SExprInfo* pExpr, int32_t numOfExpr) {
+ for (int32_t j = 0; j < numOfExpr; ++j) {
+ int32_t dstSlotId = pExpr[j].base.resSchema.slotId;
+
+ SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
+ colDataAppendNNULL(pColInfoData, 0, pBlock->info.rows);
+ }
+}
+
int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock,
int32_t rows, const char* idStr, STableMetaCacheInfo* pCache) {
// currently only the tbname pseudo column
@@ -469,14 +478,21 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
SMetaReader mr = {0};
LRUHandle* h = NULL;
+ // todo refactor: extract method
+ // the handling of the null data should be packed in the extracted method
+
// 1. check if it is existed in meta cache
if (pCache == NULL) {
metaReaderInit(&mr, pHandle->meta, 0);
code = metaGetTableEntryByUidCache(&mr, pBlock->info.id.uid);
if (code != TSDB_CODE_SUCCESS) {
+ // when encounter the TSDB_CODE_PAR_TABLE_NOT_EXIST error, we proceed.
if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s",
pBlock->info.id.uid, tstrerror(terrno), idStr);
+
+ // append null value before return to caller, since the caller will ignore this error code and proceed
+ doSetNullValue(pBlock, pExpr, numOfExpr);
} else {
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno),
idStr);
@@ -502,6 +518,8 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s",
pBlock->info.id.uid, tstrerror(terrno), idStr);
+ // append null value before return to caller, since the caller will ignore this error code and proceed
+ doSetNullValue(pBlock, pExpr, numOfExpr);
} else {
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno),
idStr);
@@ -618,9 +636,15 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
while (tsdbNextDataBlock(pTableScanInfo->base.dataReader)) {
if (isTaskKilled(pTaskInfo)) {
+ tsdbReleaseDataBlock(pTableScanInfo->base.dataReader);
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
}
+ if (pOperator->status == OP_EXEC_DONE) {
+ tsdbReleaseDataBlock(pTableScanInfo->base.dataReader);
+ break;
+ }
+
// process this data block based on the probabilities
bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample);
if (!processThisBlock) {
@@ -632,9 +656,8 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
uint32_t status = 0;
int32_t code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status);
- // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
if (code != TSDB_CODE_SUCCESS) {
- T_LONG_JMP(pOperator->pTaskInfo->env, code);
+ T_LONG_JMP(pTaskInfo->env, code);
}
// current block is filter out according to filter condition, continue load the next block
@@ -1410,7 +1433,12 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
dumyInfo.cur.pageId = -1;
bool isClosed = false;
STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX};
- if (tableInserted && isOverdue(tsCol[rowId], &pInfo->twAggSup)) {
+ bool overDue = isOverdue(tsCol[rowId], &pInfo->twAggSup);
+ if (pInfo->igExpired && overDue) {
+ continue;
+ }
+
+ if (tableInserted && overDue) {
win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[rowId], &pInfo->interval, TSDB_ORDER_ASC);
isClosed = isCloseWindow(&win, &pInfo->twAggSup);
}
@@ -1532,7 +1560,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
while (tqNextDataBlock2(pInfo->tqReader)) {
SSDataBlock block = {0};
- int32_t code = tqRetrieveDataBlock2(&block, pInfo->tqReader);
+ int32_t code = tqRetrieveDataBlock2(&block, pInfo->tqReader, NULL);
if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) {
continue;
@@ -1786,7 +1814,7 @@ FETCH_NEXT_BLOCK:
int32_t current = pInfo->validBlockIndex++;
SPackedData* pPacked = taosArrayGet(pInfo->pBlockLists, current);
SSDataBlock* pBlock = pPacked->pDataBlock;
- if (pBlock->info.id.groupId && pBlock->info.parTbName[0]) {
+ if (pBlock->info.parTbName[0]) {
streamStatePutParName(pTaskInfo->streamInfo.pState, pBlock->info.id.groupId, pBlock->info.parTbName);
}
// TODO move into scan
@@ -1941,7 +1969,7 @@ FETCH_NEXT_BLOCK:
while (tqNextDataBlock2(pInfo->tqReader)) {
SSDataBlock block = {0};
- int32_t code = tqRetrieveDataBlock2(&block, pInfo->tqReader);
+ int32_t code = tqRetrieveDataBlock2(&block, pInfo->tqReader, NULL);
if (code != TSDB_CODE_SUCCESS || block.info.rows == 0) {
continue;
@@ -2022,6 +2050,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) {
if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) {
if (isTaskKilled(pTaskInfo)) {
+ tsdbReleaseDataBlock(pInfo->dataReader);
longjmp(pTaskInfo->env, pTaskInfo->code);
}
@@ -2343,6 +2372,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR);
pInfo->assignBlockUid = pTableScanNode->assignBlockUid;
pInfo->partitionSup.needCalc = false;
+ pInfo->igCheckUpdate = pTableScanNode->igCheckUpdate;
+ pInfo->igExpired = pTableScanNode->igExpired;
+ pInfo->twAggSup.maxTs = INT64_MIN;
setOperatorInfo(pOperator, "StreamScanOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, false, OP_NOT_OPENED, pInfo,
pTaskInfo);
@@ -2523,6 +2555,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
qTrace("tsdb/read-table-data: %p, enter next reader", reader);
while (tsdbNextDataBlock(reader)) {
if (isTaskKilled(pTaskInfo)) {
+ tsdbReleaseDataBlock(reader);
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
}
@@ -2539,7 +2572,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
}
uint32_t status = 0;
- loadDataBlock(pOperator, &pInfo->base, pBlock, &status);
+ code = loadDataBlock(pOperator, &pInfo->base, pBlock, &status);
// code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status);
if (code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, code);
@@ -2714,12 +2747,13 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock*
}
}
- applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo, pOperator);
- pInfo->limitInfo.numOfOutputRows += pResBlock->info.rows;
-
- qDebug("%s get sorted row block, rows:%d, limit:%"PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows,
- pInfo->limitInfo.numOfOutputRows);
+ bool limitReached = applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo);
+ qDebug("%s get sorted row block, rows:%d, limit:%" PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows,
+ pInfo->limitInfo.numOfOutputRows);
+ if (limitReached) {
+ resetLimitInfoForNextGroup(&pInfo->limitInfo);
+ }
return (pResBlock->info.rows > 0) ? pResBlock : NULL;
}
diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c
index 97b4fd9dc43635a9afdc67bd4a61513c722b84b9..98ef6b8a3621abb1560d9f04924f92cff84b4935 100644
--- a/source/libs/executor/src/sortoperator.c
+++ b/source/libs/executor/src/sortoperator.c
@@ -222,6 +222,7 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
T_LONG_JMP(pTaskInfo->env, code);
}
+ // multi-group case not handle here
SSDataBlock* pBlock = NULL;
while (1) {
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
@@ -236,28 +237,14 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
continue;
}
- // todo add the limit/offset info
- if (pInfo->limitInfo.remainOffset > 0) {
- if (pInfo->limitInfo.remainOffset >= blockDataGetNumOfRows(pBlock)) {
- pInfo->limitInfo.remainOffset -= pBlock->info.rows;
- continue;
- }
-
- blockDataTrimFirstNRows(pBlock, pInfo->limitInfo.remainOffset);
- pInfo->limitInfo.remainOffset = 0;
- }
-
- if (pInfo->limitInfo.limit.limit > 0 &&
- pInfo->limitInfo.limit.limit <= pInfo->limitInfo.numOfOutputRows + blockDataGetNumOfRows(pBlock)) {
- int32_t remain = pInfo->limitInfo.limit.limit - pInfo->limitInfo.numOfOutputRows;
- blockDataKeepFirstNRows(pBlock, remain);
+ // there are bugs?
+ bool limitReached = applyLimitOffset(&pInfo->limitInfo, pBlock, pTaskInfo);
+ if (limitReached) {
+ resetLimitInfoForNextGroup(&pInfo->limitInfo);
}
- size_t numOfRows = blockDataGetNumOfRows(pBlock);
- pInfo->limitInfo.numOfOutputRows += numOfRows;
- pOperator->resultInfo.totalRows += numOfRows;
-
- if (numOfRows > 0) {
+ pOperator->resultInfo.totalRows += pBlock->info.rows;
+ if (pBlock->info.rows > 0) {
break;
}
}
@@ -557,7 +544,6 @@ typedef struct SMultiwayMergeOperatorInfo {
SSDataBlock* pIntermediateBlock; // to hold the intermediate result
int64_t startTs; // sort start time
bool groupSort;
- bool hasGroupId;
uint64_t groupId;
STupleHandle* prefetchedTuple;
} SMultiwayMergeOperatorInfo;
@@ -604,7 +590,9 @@ int32_t openMultiwayMergeOperator(SOperatorInfo* pOperator) {
return TSDB_CODE_SUCCESS;
}
-static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle* pHandle, int32_t capacity, SSDataBlock* p) {
+static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle* pHandle, int32_t capacity,
+ SSDataBlock* p, bool* newgroup) {
+ *newgroup = false;
while (1) {
STupleHandle* pTupleHandle = NULL;
@@ -613,8 +601,12 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
pTupleHandle = tsortNextTuple(pHandle);
} else {
pTupleHandle = pInfo->prefetchedTuple;
- pInfo->groupId = tsortGetGroupId(pTupleHandle);
pInfo->prefetchedTuple = NULL;
+ uint64_t gid = tsortGetGroupId(pTupleHandle);
+ if (gid != pInfo->groupId) {
+ *newgroup = true;
+ pInfo->groupId = gid;
+ }
}
} else {
pTupleHandle = tsortNextTuple(pHandle);
@@ -627,12 +619,10 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
if (pInfo->groupSort) {
uint64_t tupleGroupId = tsortGetGroupId(pTupleHandle);
- if (!pInfo->hasGroupId) {
- pInfo->groupId = tupleGroupId;
- pInfo->hasGroupId = true;
- appendOneRowToDataBlock(p, pTupleHandle);
- } else if (pInfo->groupId == tupleGroupId) {
+ if (pInfo->groupId == 0 || pInfo->groupId == tupleGroupId) {
appendOneRowToDataBlock(p, pTupleHandle);
+ p->info.id.groupId = tupleGroupId;
+ pInfo->groupId = tupleGroupId;
} else {
pInfo->prefetchedTuple = pTupleHandle;
break;
@@ -645,11 +635,6 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
break;
}
}
-
- if (pInfo->groupSort) {
- pInfo->hasGroupId = false;
- }
-
}
SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, SArray* pColMatchInfo,
@@ -673,14 +658,19 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
}
SSDataBlock* p = pInfo->pIntermediateBlock;
+ bool newgroup = false;
while (1) {
- doGetSortedBlockData(pInfo, pHandle, capacity, p);
+ doGetSortedBlockData(pInfo, pHandle, capacity, p, &newgroup);
if (p->info.rows == 0) {
break;
}
- bool limitReached = applyLimitOffset(&pInfo->limitInfo, p, pTaskInfo, pOperator);
+ if (newgroup) {
+ resetLimitInfoForNextGroup(&pInfo->limitInfo);
+ }
+
+ bool limitReached = applyLimitOffset(&pInfo->limitInfo, p, pTaskInfo);
if (limitReached) {
resetLimitInfoForNextGroup(&pInfo->limitInfo);
}
diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c
index 2b78f265fb4d6f2a1e41350f2f649582f9b84213..7b226a03916cc4c62017e36910d5a946ac250c7a 100644
--- a/source/libs/executor/src/sysscanoperator.c
+++ b/source/libs/executor/src/sysscanoperator.c
@@ -65,8 +65,8 @@ typedef struct SSysTableScanInfo {
SSDataBlock* pRes;
int64_t numOfBlocks; // extract basic running information.
SLoadRemoteDataInfo loadInfo;
-
- int32_t tbnameSlotId;
+ SLimitInfo limitInfo;
+ int32_t tbnameSlotId;
} SSysTableScanInfo;
typedef struct {
@@ -355,9 +355,11 @@ static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt);
static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name,
SExecTaskInfo* pTaskInfo);
void extractTbnameSlotId(SSysTableScanInfo* pInfo, const SScanPhysiNode* pScanNode);
-static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, const char* name,
- SSDataBlock* pBlock);
-__optSysFilter optSysGetFilterFunc(int32_t ctype, bool* reverse) {
+
+static void sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, const char* name,
+ SSDataBlock* pBlock);
+
+__optSysFilter optSysGetFilterFunc(int32_t ctype, bool* reverse) {
if (ctype == OP_TYPE_LOWER_EQUAL || ctype == OP_TYPE_LOWER_THAN) {
*reverse = true;
}
@@ -731,7 +733,7 @@ void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t numOfR
pInfo->pRes->info.rows = numOfRows;
relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, dataBlock->pDataBlock, false);
- doFilterResult(pInfo->pRes, pFilterInfo);
+ doFilter(pInfo->pRes, pFilterInfo, NULL);
blockDataCleanup(dataBlock);
}
@@ -1210,7 +1212,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
pInfo->pRes->info.rows = numOfRows;
relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
blockDataCleanup(p);
numOfRows = 0;
@@ -1226,7 +1228,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
pInfo->pRes->info.rows = numOfRows;
relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
blockDataCleanup(p);
numOfRows = 0;
@@ -1387,7 +1389,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
pInfo->pRes->info.rows = numOfRows;
relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
blockDataCleanup(p);
numOfRows = 0;
@@ -1403,7 +1405,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
pInfo->pRes->info.rows = numOfRows;
relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
blockDataCleanup(p);
numOfRows = 0;
@@ -1434,7 +1436,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
if (pInfo->readHandle.mnd != NULL) {
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
setOperatorCompleted(pOperator);
@@ -1578,30 +1580,37 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
}
- return sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
-}
-
-static SSDataBlock* sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, const char* name,
- SSDataBlock* pBlock) {
+ sysTableScanFillTbName(pOperator, pInfo, name, pBlock);
if (pBlock != NULL) {
- if (pInfo->tbnameSlotId != -1) {
- SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId);
- char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0};
- memcpy(varDataVal(varTbName), name, strlen(name));
- varDataSetLen(varTbName, strlen(name));
- for (int i = 0; i < pBlock->info.rows; ++i) {
- colDataAppend(pColumnInfoData, i, varTbName, NULL);
- }
- doFilterResult(pBlock, pOperator->exprSupp.pFilterInfo);
+ bool limitReached = applyLimitOffset(&pInfo->limitInfo, pBlock, pTaskInfo);
+ if (limitReached) {
+ setOperatorCompleted(pOperator);
}
- }
- if (pBlock && pBlock->info.rows != 0) {
- return pBlock;
+
+ return pBlock->info.rows > 0 ? pBlock : NULL;
} else {
return NULL;
}
}
+static void sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScanInfo* pInfo, const char* name,
+ SSDataBlock* pBlock) {
+ if (pBlock == NULL) {
+ return;
+ }
+
+ if (pInfo->tbnameSlotId != -1) {
+ SColumnInfoData* pColumnInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, pInfo->tbnameSlotId);
+ char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0};
+ memcpy(varDataVal(varTbName), name, strlen(name));
+ varDataSetLen(varTbName, strlen(name));
+
+ colDataAppendNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows);
+ }
+
+ doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL);
+}
+
static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableScanInfo* pInfo, const char* name,
SExecTaskInfo* pTaskInfo) {
if (pOperator->status == OP_EXEC_DONE) {
@@ -1665,7 +1674,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator);
// todo log the filter info
- doFilterResult(pInfo->pRes, pOperator->exprSupp.pFilterInfo);
+ doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
taosMemoryFree(pRsp);
if (pInfo->pRes->info.rows > 0) {
return pInfo->pRes;
@@ -1700,13 +1709,13 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
pInfo->sysInfo = pScanPhyNode->sysInfo;
pInfo->showRewrite = pScanPhyNode->showRewrite;
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
-
pInfo->pCondition = pScanNode->node.pConditions;
code = filterInitFromNode(pScanNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
+ initLimitInfo(pScanPhyNode->scan.node.pLimit, pScanPhyNode->scan.node.pSlimit, &pInfo->limitInfo);
initResultSizeInfo(&pOperator->resultInfo, 4096);
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
@@ -1801,15 +1810,6 @@ int32_t loadSysTableCallback(void* param, SDataBuf* pMsg, int32_t code) {
return TSDB_CODE_SUCCESS;
}
-SSDataBlock* doFilterResult(SSDataBlock* pDataBlock, SFilterInfo* pFilterInfo) {
- if (pFilterInfo == NULL) {
- return pDataBlock->info.rows == 0 ? NULL : pDataBlock;
- }
-
- doFilter(pDataBlock, pFilterInfo, NULL);
- return pDataBlock->info.rows == 0 ? NULL : pDataBlock;
-}
-
static int32_t sysChkFilter__Comm(SNode* pNode) {
// impl
SOperatorNode* pOper = (SOperatorNode*)pNode;
diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c
index 2d921d43d34726b64b0be3dde97a52a95cf19f61..778281f9b42a3db59a53b20cbbe47bf213c409cb 100644
--- a/source/libs/executor/src/tfill.c
+++ b/source/libs/executor/src/tfill.c
@@ -186,7 +186,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock*
}
}
}
- } else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL
+ } else if (pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { // fill with NULL
setNullRow(pBlock, pFillInfo, index);
} else { // fill with user specified value for each column
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
@@ -349,7 +349,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
bool isNull = colDataIsNull_s(pSrc, pFillInfo->index);
colDataAppend(pDst, index, src, isNull);
saveColData(pFillInfo->prev.pRowVal, i, src, isNull); // todo:
- } else if (pFillInfo->type == TSDB_FILL_NULL) {
+ } else if (pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) {
colDataAppendNULL(pDst, index);
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next.pRowVal : pFillInfo->prev.pRowVal;
@@ -447,32 +447,6 @@ struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t
taosResetFillInfo(pFillInfo, skey);
- switch (fillType) {
- case FILL_MODE_NONE:
- pFillInfo->type = TSDB_FILL_NONE;
- break;
- case FILL_MODE_PREV:
- pFillInfo->type = TSDB_FILL_PREV;
- break;
- case FILL_MODE_NULL:
- pFillInfo->type = TSDB_FILL_NULL;
- break;
- case FILL_MODE_LINEAR:
- pFillInfo->type = TSDB_FILL_LINEAR;
- break;
- case FILL_MODE_NEXT:
- pFillInfo->type = TSDB_FILL_NEXT;
- break;
- case FILL_MODE_VALUE:
- pFillInfo->type = TSDB_FILL_SET_VALUE;
- break;
- default: {
- taosMemoryFree(pFillInfo);
- terrno = TSDB_CODE_INVALID_PARA;
- return NULL;
- }
- }
-
pFillInfo->type = fillType;
pFillInfo->pFillCol = pCol;
pFillInfo->numOfCols = numOfFillCols + numOfNotFillCols;
@@ -572,15 +546,14 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
}
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows) {
- SColumnInfoData* pCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId);
-
- int64_t* tsList = (int64_t*)pCol->pData;
int32_t numOfRows = taosNumOfRemainRows(pFillInfo);
TSKEY ekey1 = ekey;
int64_t numOfRes = -1;
if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set.
+ SColumnInfoData* pCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId);
+ int64_t* tsList = (int64_t*)pCol->pData;
TSKEY lastKey = tsList[pFillInfo->numOfRows - 1];
numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c
index f5ceeeafe72de613bfaea86a5fded3c19dc51d9c..bce8443353aecb19de7d8a4a052bce0f695eadd2 100644
--- a/source/libs/executor/src/timesliceoperator.c
+++ b/source/libs/executor/src/timesliceoperator.c
@@ -185,12 +185,14 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
switch (pSliceInfo->fillType) {
- case TSDB_FILL_NULL: {
+ case TSDB_FILL_NULL:
+ case TSDB_FILL_NULL_F: {
colDataAppendNULL(pDst, rows);
break;
}
- case TSDB_FILL_SET_VALUE: {
+ case TSDB_FILL_SET_VALUE:
+ case TSDB_FILL_SET_VALUE_F: {
SVariant* pVar = &pSliceInfo->pFillColInfo[j].fillVal;
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
@@ -440,6 +442,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break;
}
+ if (pSliceInfo->scalarSup.pExprInfo != NULL) {
+ SExprSupp* pExprSup = &pSliceInfo->scalarSup;
+ projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
+ }
+
int32_t code = initKeeperInfo(pSliceInfo, pBlock);
if (code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, code);
@@ -538,6 +545,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
}
+ doFilter(pResBlock, pOperator->exprSupp.pFilterInfo, NULL);
+
// restore the value
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
if (pResBlock->info.rows == 0) {
@@ -573,6 +582,11 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
}
}
+ code = filterInitFromNode((SNode*)pInterpPhyNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _error;
+ }
+
pInfo->tsCol = extractColumnFromColumnNode((SColumnNode*)pInterpPhyNode->pTimeSeries);
pInfo->fillType = convertFillType(pInterpPhyNode->fillMode);
initResultSizeInfo(&pOperator->resultInfo, 4096);
@@ -629,6 +643,7 @@ void destroyTimeSliceOperatorInfo(void* param) {
taosMemoryFree(pKey->end.val);
}
taosArrayDestroy(pInfo->pLinearInfo);
+ cleanupExprSupp(&pInfo->scalarSup);
taosMemoryFree(pInfo->pFillColInfo);
taosMemoryFreeClear(param);
diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c
index eccdcb85bf048969d6e04d98c9dc4a4bc24dacb8..1b9767f193f7b28d190f9cc2ccd1985b225268d7 100644
--- a/source/libs/executor/src/timewindowoperator.c
+++ b/source/libs/executor/src/timewindowoperator.c
@@ -639,7 +639,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
if (NULL == pr) {
T_LONG_JMP(pTaskInfo->env, terrno);
}
-
+
ASSERT(pr->offset == p1->offset && pr->pageId == p1->pageId);
if (pr->closed) {
@@ -842,68 +842,61 @@ static int32_t saveResult(SResultWindowInfo winInfo, SSHashObj* pStUpdated) {
return tSimpleHashPut(pStUpdated, &winInfo.sessionWin, sizeof(SSessionKey), &winInfo, sizeof(SResultWindowInfo));
}
-static int32_t saveWinResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, SHashObj* pUpdatedMap) {
- SResKeyPos* newPos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
- if (newPos == NULL) {
- return TSDB_CODE_OUT_OF_MEMORY;
- }
- newPos->groupId = groupId;
- newPos->pos = (SResultRowPosition){.pageId = pageId, .offset = offset};
- *(int64_t*)newPos->key = ts;
+static int32_t saveWinResult(int64_t ts, uint64_t groupId, SSHashObj* pUpdatedMap) {
SWinKey key = {.ts = ts, .groupId = groupId};
- if (taosHashPut(pUpdatedMap, &key, sizeof(SWinKey), &newPos, sizeof(void*)) != TSDB_CODE_SUCCESS) {
- taosMemoryFree(newPos);
- }
+ tSimpleHashPut(pUpdatedMap, &key, sizeof(SWinKey), NULL, 0);
return TSDB_CODE_SUCCESS;
}
-static int32_t saveWinResultInfo(TSKEY ts, uint64_t groupId, SHashObj* pUpdatedMap) {
- return saveWinResult(ts, -1, -1, groupId, pUpdatedMap);
+static int32_t saveWinResultInfo(TSKEY ts, uint64_t groupId, SSHashObj* pUpdatedMap) {
+ return saveWinResult(ts, groupId, pUpdatedMap);
}
-static void removeResults(SArray* pWins, SHashObj* pUpdatedMap) {
+static void removeResults(SArray* pWins, SSHashObj* pUpdatedMap) {
int32_t size = taosArrayGetSize(pWins);
for (int32_t i = 0; i < size; i++) {
SWinKey* pW = taosArrayGet(pWins, i);
- void* tmp = taosHashGet(pUpdatedMap, pW, sizeof(SWinKey));
+ void* tmp = tSimpleHashGet(pUpdatedMap, pW, sizeof(SWinKey));
if (tmp) {
void* value = *(void**)tmp;
taosMemoryFree(value);
- taosHashRemove(pUpdatedMap, pW, sizeof(SWinKey));
+ tSimpleHashRemove(pUpdatedMap, pW, sizeof(SWinKey));
}
}
}
-int32_t compareWinRes(void* pKey, void* data, int32_t index) {
- SArray* res = (SArray*)data;
- SWinKey* pDataPos = taosArrayGet(res, index);
- SResKeyPos* pRKey = (SResKeyPos*)pKey;
- if (pRKey->groupId > pDataPos->groupId) {
+int32_t compareWinKey(void* pKey, void* data, int32_t index) {
+ SArray* res = (SArray*)data;
+ SWinKey* pDataPos = taosArrayGet(res, index);
+ SWinKey* pWKey = (SWinKey*)pKey;
+
+ if (pWKey->groupId > pDataPos->groupId) {
return 1;
- } else if (pRKey->groupId < pDataPos->groupId) {
+ } else if (pWKey->groupId < pDataPos->groupId) {
return -1;
}
- if (*(int64_t*)pRKey->key > pDataPos->ts) {
+ if (pWKey->ts > pDataPos->ts) {
return 1;
- } else if (*(int64_t*)pRKey->key < pDataPos->ts) {
+ } else if (pWKey->ts < pDataPos->ts) {
return -1;
}
return 0;
}
-static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
+static void removeDeleteResults(SSHashObj* pUpdatedMap, SArray* pDelWins) {
taosArraySort(pDelWins, winKeyCmprImpl);
taosArrayRemoveDuplicate(pDelWins, winKeyCmprImpl, NULL);
int32_t delSize = taosArrayGetSize(pDelWins);
- if (taosHashGetSize(pUpdatedMap) == 0 || delSize == 0) {
+ if (tSimpleHashGetSize(pUpdatedMap) == 0 || delSize == 0) {
return;
}
- void* pIte = NULL;
- while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) {
- SResKeyPos* pResKey = *(SResKeyPos**)pIte;
- int32_t index = binarySearchCom(pDelWins, delSize, pResKey, TSDB_ORDER_DESC, compareWinRes);
- if (index >= 0 && 0 == compareWinRes(pResKey, pDelWins, index)) {
+ void* pIte = NULL;
+ int32_t iter = 0;
+ while ((pIte = tSimpleHashIterate(pUpdatedMap, pIte, &iter)) != NULL) {
+ SWinKey* pResKey = tSimpleHashGetKey(pIte, NULL);
+ int32_t index = binarySearchCom(pDelWins, delSize, pResKey, TSDB_ORDER_DESC, compareWinKey);
+ if (index >= 0 && 0 == compareWinKey(pResKey, pDelWins, index)) {
taosArrayRemove(pDelWins, index);
delSize = taosArrayGetSize(pDelWins);
}
@@ -1318,11 +1311,11 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type
}
static void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp* pSup, int32_t numOfOutput) {
- SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false);
+ SResultRow* pResult = getResultRowByPos(pResultBuf, p1, false);
if (NULL == pResult) {
return;
}
-
+
SqlFunctionCtx* pCtx = pSup->pCtx;
for (int32_t i = 0; i < numOfOutput; ++i) {
pCtx[i].resultInfo = getResultEntryInfo(pResult, i, pSup->rowEntryInfoOffset);
@@ -1352,7 +1345,7 @@ static bool doDeleteWindow(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId)
}
static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDataBlock* pBlock, SArray* pUpWins,
- SHashObj* pUpdatedMap) {
+ SSHashObj* pUpdatedMap) {
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
TSKEY* startTsCols = (TSKEY*)pStartTsCol->pData;
@@ -1388,28 +1381,21 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa
taosArrayPush(pUpWins, &winRes);
}
if (pUpdatedMap) {
- void* tmp = taosHashGet(pUpdatedMap, &winRes, sizeof(SWinKey));
- if (tmp) {
- void* value = *(void**)tmp;
- taosMemoryFree(value);
- taosHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey));
- }
+ tSimpleHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey));
}
getNextTimeWindow(pInterval, pInterval->precision, TSDB_ORDER_ASC, &win);
} while (win.ekey <= endTsCols[i]);
}
}
-static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
+static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SSHashObj* resWins) {
void* pIte = NULL;
- size_t keyLen = 0;
int32_t iter = 0;
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
- void* key = tSimpleHashGetKey(pIte, &keyLen);
- uint64_t groupId = *(uint64_t*)key;
- TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t));
- SResultRowPosition* pPos = (SResultRowPosition*)pIte;
- int32_t code = saveWinResult(ts, pPos->pageId, pPos->offset, groupId, resWins);
+ SWinKey* pKey = tSimpleHashGetKey(pIte, NULL);
+ uint64_t groupId = pKey->groupId;
+ TSKEY ts = pKey->ts;
+ int32_t code = saveWinResult(ts, groupId, resWins);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@@ -1417,36 +1403,16 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
return TSDB_CODE_SUCCESS;
}
-int32_t compareWinKey(void* pKey, void* data, int32_t index) {
- SArray* res = (SArray*)data;
- SWinKey* pDataPos = taosArrayGet(res, index);
- SWinKey* pWKey = (SWinKey*)pKey;
-
- if (pWKey->groupId > pDataPos->groupId) {
- return 1;
- } else if (pWKey->groupId < pDataPos->groupId) {
- return -1;
- }
-
- if (pWKey->ts > pDataPos->ts) {
- return 1;
- } else if (pWKey->ts < pDataPos->ts) {
- return -1;
- }
- return 0;
-}
-
static int32_t closeStreamIntervalWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SInterval* pInterval,
- SHashObj* pPullDataMap, SHashObj* closeWins, SArray* pDelWins,
+ SHashObj* pPullDataMap, SSHashObj* closeWins, SArray* pDelWins,
SOperatorInfo* pOperator) {
qDebug("===stream===close interval window");
void* pIte = NULL;
- size_t keyLen = 0;
int32_t iter = 0;
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
int32_t delSize = taosArrayGetSize(pDelWins);
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
- void* key = tSimpleHashGetKey(pIte, &keyLen);
+ void* key = tSimpleHashGetKey(pIte, NULL);
SWinKey* pWinKey = (SWinKey*)key;
if (delSize > 0) {
int32_t index = binarySearchCom(pDelWins, delSize, pWinKey, TSDB_ORDER_DESC, compareWinKey);
@@ -1648,7 +1614,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) {
}
nodesDestroyNode((SNode*)pInfo->pPhyNode);
colDataDestroy(&pInfo->twAggSup.timeWindowData);
- cleanupGroupResInfo(&pInfo->groupResInfo);
+ pInfo->groupResInfo.pRows = taosArrayDestroy(pInfo->groupResInfo.pRows);
cleanupExprSupp(&pInfo->scalarSupp);
taosMemoryFreeClear(param);
@@ -1726,7 +1692,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor
SStreamScanInfo* pScanInfo = downstream->info;
pScanInfo->windowSup.parentType = type;
pScanInfo->windowSup.pIntervalAggSup = pSup;
- if (!pScanInfo->pUpdateInfo) {
+ if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) {
pScanInfo->pUpdateInfo = updateInfoInitP(pInterval, pTwSup->waterMark);
}
pScanInfo->interval = *pInterval;
@@ -2157,7 +2123,7 @@ bool hasIntervalWindow(SStreamState* pState, SWinKey* pKey) {
return TSDB_CODE_SUCCESS == streamStateGet(pState, pKey, NULL, 0);
}
-static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, SHashObj* pUpdatedMap) {
+static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, SSHashObj* pUpdatedMap) {
SStreamIntervalOperatorInfo* pInfo = pOperator->info;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
int32_t size = taosArrayGetSize(pWinArray);
@@ -2343,7 +2309,8 @@ static void clearFunctionContext(SExprSupp* pSup) {
}
}
-void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SGroupResInfo* pGroupResInfo) {
+void doBuildStreamIntervalResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock,
+ SGroupResInfo* pGroupResInfo) {
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
// set output datablock version
pBlock->info.version = pTaskInfo->version;
@@ -2370,7 +2337,7 @@ static int32_t getNextQualifiedFinalWindow(SInterval* pInterval, STimeWindow* pN
}
static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t groupId,
- SHashObj* pUpdatedMap) {
+ SSHashObj* pUpdatedMap) {
SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info;
SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo);
@@ -2478,7 +2445,19 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
pInfo->delKey = key;
}
int32_t prevEndPos = (forwardRows - 1) * step + startPos;
- ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0);
+ if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) {
+ qError("table uid %" PRIu64 " data block timestamp range may not be calculated! minKey %" PRId64
+ ",maxKey %" PRId64,
+ pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey);
+ blockDataUpdateTsWindow(pSDataBlock, 0);
+
+ // timestamp of the data is incorrect
+ if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) {
+ qError("table uid %" PRIu64 " data block timestamp is out of range! minKey %" PRId64 ",maxKey %" PRId64,
+ pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey);
+ }
+ }
+
if (IS_FINAL_OP(pInfo)) {
startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos);
} else {
@@ -2516,7 +2495,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
return pInfo->pDelRes;
}
- doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ doBuildStreamIntervalResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
if (pInfo->binfo.pRes->info.rows != 0) {
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
return pInfo->binfo.pRes;
@@ -2543,7 +2522,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
return pInfo->pDelRes;
}
- doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ doBuildStreamIntervalResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
if (pInfo->binfo.pRes->info.rows != 0) {
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
return pInfo->binfo.pRes;
@@ -2552,11 +2531,11 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
}
if (!pInfo->pUpdated) {
- pInfo->pUpdated = taosArrayInit(4, POINTER_BYTES);
+ pInfo->pUpdated = taosArrayInit(4, sizeof(SWinKey));
}
if (!pInfo->pUpdatedMap) {
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
- pInfo->pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
+ pInfo->pUpdatedMap = tSimpleHashInit(1024, hashFn);
}
while (1) {
@@ -2649,13 +2628,14 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
}
pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs;
- void* pIte = NULL;
- while ((pIte = taosHashIterate(pInfo->pUpdatedMap, pIte)) != NULL) {
+ void* pIte = NULL;
+ int32_t iter = 0;
+ while ((pIte = tSimpleHashIterate(pInfo->pUpdatedMap, pIte, &iter)) != NULL) {
taosArrayPush(pInfo->pUpdated, pIte);
}
- taosHashCleanup(pInfo->pUpdatedMap);
+ tSimpleHashCleanup(pInfo->pUpdatedMap);
pInfo->pUpdatedMap = NULL;
- taosArraySort(pInfo->pUpdated, resultrowComparAsc);
+ taosArraySort(pInfo->pUpdated, winKeyCmprImpl);
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
pInfo->pUpdated = NULL;
@@ -2675,7 +2655,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
return pInfo->pDelRes;
}
- doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ doBuildStreamIntervalResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
if (pInfo->binfo.pRes->info.rows != 0) {
printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi");
return pInfo->binfo.pRes;
@@ -2889,7 +2869,7 @@ void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uin
}
SStreamScanInfo* pScanInfo = downstream->info;
pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = pAggSup->gap, .parentType = type};
- if (!pScanInfo->pUpdateInfo) {
+ if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) {
pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark);
}
pScanInfo->twAggSup = *pTwSup;
@@ -3239,10 +3219,9 @@ static inline int32_t sessionKeyCompareAsc(const void* pKey1, const void* pKey2)
static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) {
void* pIte = NULL;
- size_t keyLen = 0;
int32_t iter = 0;
while ((pIte = tSimpleHashIterate(pStUpdated, pIte, &iter)) != NULL) {
- void* key = tSimpleHashGetKey(pIte, &keyLen);
+ void* key = tSimpleHashGetKey(pIte, NULL);
taosArrayPush(pUpdated, key);
}
taosArraySort(pUpdated, sessionKeyCompareAsc);
@@ -3256,13 +3235,12 @@ void doBuildDeleteDataBlock(SOperatorInfo* pOp, SSHashObj* pStDeleted, SSDataBlo
return;
}
blockDataEnsureCapacity(pBlock, size);
- size_t keyLen = 0;
int32_t iter = 0;
while (((*Ite) = tSimpleHashIterate(pStDeleted, *Ite, &iter)) != NULL) {
if (pBlock->info.rows + 1 > pBlock->info.capacity) {
break;
}
- SSessionKey* res = tSimpleHashGetKey(*Ite, &keyLen);
+ SSessionKey* res = tSimpleHashGetKey(*Ite, NULL);
SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
colDataAppend(pStartTsCol, pBlock->info.rows, (const char*)&res->win.skey, false);
SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
@@ -3351,7 +3329,6 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHashObj* pClosed) {
void* pIte = NULL;
- size_t keyLen = 0;
int32_t iter = 0;
while ((pIte = tSimpleHashIterate(pHashMap, pIte, &iter)) != NULL) {
SResultWindowInfo* pWinInfo = pIte;
@@ -3362,7 +3339,7 @@ int32_t closeSessionWindow(SSHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SSHa
return code;
}
}
- SSessionKey* pKey = tSimpleHashGetKey(pIte, &keyLen);
+ SSessionKey* pKey = tSimpleHashGetKey(pIte, NULL);
tSimpleHashIterateRemove(pHashMap, pKey, sizeof(SSessionKey), &pIte, &iter);
}
}
@@ -3451,7 +3428,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
pInfo->pUpdated = taosArrayInit(16, sizeof(SSessionKey));
}
if (!pInfo->pStUpdated) {
- _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
+ _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
pInfo->pStUpdated = tSimpleHashInit(64, hashFn);
}
while (1) {
@@ -3675,7 +3652,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
pInfo->pUpdated = taosArrayInit(16, sizeof(SSessionKey));
}
if (!pInfo->pStUpdated) {
- _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
+ _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
pInfo->pStUpdated = tSimpleHashInit(64, hashFn);
}
while (1) {
@@ -4006,7 +3983,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
pInfo->pUpdated = taosArrayInit(16, sizeof(SSessionKey));
}
if (!pInfo->pSeUpdated) {
- _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
+ _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
pInfo->pSeUpdated = tSimpleHashInit(64, hashFn);
}
while (1) {
@@ -4761,7 +4738,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
return pInfo->pDelRes;
}
- doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ doBuildStreamIntervalResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
if (pInfo->binfo.pRes->info.rows > 0) {
printDataBlock(pInfo->binfo.pRes, "single interval");
return pInfo->binfo.pRes;
@@ -4776,14 +4753,13 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
SOperatorInfo* downstream = pOperator->pDownstream[0];
if (!pInfo->pUpdated) {
- pInfo->pUpdated = taosArrayInit(4, POINTER_BYTES);
+ pInfo->pUpdated = taosArrayInit(4, sizeof(SWinKey));
}
if (!pInfo->pUpdatedMap) {
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
- pInfo->pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
+ pInfo->pUpdatedMap = tSimpleHashInit(1024, hashFn);
}
-
while (1) {
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
if (pBlock == NULL) {
@@ -4832,19 +4808,21 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
}
pOperator->status = OP_RES_TO_RETURN;
removeDeleteResults(pInfo->pUpdatedMap, pInfo->pDelWins);
- closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pInfo->pUpdatedMap,
- pInfo->pDelWins, pOperator);
+ closeStreamIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL,
+ pInfo->pUpdatedMap, pInfo->pDelWins, pOperator);
- void* pIte = NULL;
- while ((pIte = taosHashIterate(pInfo->pUpdatedMap, pIte)) != NULL) {
- taosArrayPush(pInfo->pUpdated, pIte);
+ void* pIte = NULL;
+ int32_t iter = 0;
+ while ((pIte = tSimpleHashIterate(pInfo->pUpdatedMap, pIte, &iter)) != NULL) {
+ SWinKey* pKey = tSimpleHashGetKey(pIte, NULL);
+ taosArrayPush(pInfo->pUpdated, pKey);
}
- taosArraySort(pInfo->pUpdated, resultrowComparAsc);
+ taosArraySort(pInfo->pUpdated, winKeyCmprImpl);
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated);
pInfo->pUpdated = NULL;
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
- taosHashCleanup(pInfo->pUpdatedMap);
+ tSimpleHashCleanup(pInfo->pUpdatedMap);
pInfo->pUpdatedMap = NULL;
doBuildDeleteResult(pInfo, pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
@@ -4853,7 +4831,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
return pInfo->pDelRes;
}
- doBuildResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ doBuildStreamIntervalResult(pOperator, pInfo->pState, pInfo->binfo.pRes, &pInfo->groupResInfo);
if (pInfo->binfo.pRes->info.rows > 0) {
printDataBlock(pInfo->binfo.pRes, "single interval");
return pInfo->binfo.pRes;
diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c
index 661e9f97b74e33fd4f372a7eba51ccb42df385d2..90f20f40b820c9503eeb13be1e52de8eb4c4a66b 100644
--- a/source/libs/executor/src/tsort.c
+++ b/source/libs/executor/src/tsort.c
@@ -190,8 +190,9 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
qError("Add to buf failed since %s", terrstr(terrno));
return terrno;
}
+
int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize,
- "doAddToBuf", tsTempDir);
+ "sortExternalBuf", tsTempDir);
dBufSetPrintInfo(pHandle->pBuf);
if (code != TSDB_CODE_SUCCESS) {
return code;
@@ -635,6 +636,7 @@ int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols) {
static int32_t createInitialSources(SSortHandle* pHandle) {
size_t sortBufSize = pHandle->numOfPages * pHandle->pageSize;
+ int32_t code = 0;
if (pHandle->type == SORT_SINGLESOURCE_SORT) {
SSortSource** pSource = taosArrayGet(pHandle->pOrderedSource, 0);
@@ -663,8 +665,8 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
pHandle->beforeFp(pBlock, pHandle->param);
}
- int32_t code = blockDataMerge(pHandle->pDataBlock, pBlock);
- if (code != 0) {
+ code = blockDataMerge(pHandle->pDataBlock, pBlock);
+ if (code != TSDB_CODE_SUCCESS) {
if (source->param && !source->onlyRef) {
taosMemoryFree(source->param);
}
@@ -689,6 +691,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
blockDataDestroy(source->src.pBlock);
source->src.pBlock = NULL;
}
+
taosMemoryFree(source);
return code;
}
@@ -696,13 +699,17 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
int64_t el = taosGetTimestampUs() - p;
pHandle->sortElapsed += el;
- doAddToBuf(pHandle->pDataBlock, pHandle);
+ code = doAddToBuf(pHandle->pDataBlock, pHandle);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
}
}
if (source->param && !source->onlyRef) {
taosMemoryFree(source->param);
}
+
taosMemoryFree(source);
if (pHandle->pDataBlock != NULL && pHandle->pDataBlock->info.rows > 0) {
@@ -711,7 +718,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
// Perform the in-memory sort and then flush data in the buffer into disk.
int64_t p = taosGetTimestampUs();
- int32_t code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo);
+ code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo);
if (code != 0) {
return code;
}
@@ -729,12 +736,12 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
pHandle->tupleHandle.pBlock = pHandle->pDataBlock;
return 0;
} else {
- doAddToBuf(pHandle->pDataBlock, pHandle);
+ code = doAddToBuf(pHandle->pDataBlock, pHandle);
}
}
}
- return TSDB_CODE_SUCCESS;
+ return code;
}
int32_t tsortOpen(SSortHandle* pHandle) {
diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c
index 847c7386550c13cc93e2e9e118fa0b8045804702..a511ca97f16dc169679f74bf98c5b881630fd8c1 100644
--- a/source/libs/function/src/detail/tminmax.c
+++ b/source/libs/function/src/detail/tminmax.c
@@ -714,26 +714,18 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
pBuf->type = type;
if (IS_NULL_TYPE(type)) {
- numOfElems = 0;
goto _over;
}
// data in current data block are qualified to the query
if (pInput->colDataSMAIsSet) {
numOfElems = pInput->numOfRows - pAgg->numOfNull;
-
if (numOfElems == 0) {
goto _over;
}
- void* tval = NULL;
int16_t index = 0;
-
- if (isMinFunc) {
- tval = &pInput->pColumnDataAgg[0]->min;
- } else {
- tval = &pInput->pColumnDataAgg[0]->max;
- }
+ void* tval = (isMinFunc) ? &pInput->pColumnDataAgg[0]->min : &pInput->pColumnDataAgg[0]->max;
if (!pBuf->assign) {
if (type == TSDB_DATA_TYPE_FLOAT) {
@@ -824,8 +816,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems)
}
}
+ numOfElems = 1;
pBuf->assign = true;
- return TSDB_CODE_SUCCESS;
+ goto _over;
}
int32_t start = pInput->startRowIndex;
diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c
index 6ab91a4483eeaf0dabf5968c6f0cd424cb80fb96..e3127fcd7ba233d478c58cc16b7543587b5eaf90 100644
--- a/source/libs/function/src/functionMgt.c
+++ b/source/libs/function/src/functionMgt.c
@@ -262,6 +262,13 @@ bool fmIsGroupKeyFunc(int32_t funcId) {
return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type;
}
+bool fmIsBlockDistFunc(int32_t funcId) {
+ if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
+ return false;
+ }
+ return FUNCTION_TYPE_BLOCK_DIST == funcMgtBuiltins[funcId].type;
+}
+
void fmFuncMgtDestroy() {
void* m = gFunMgtService.pFuncNameHashTable;
if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) {
diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c
index 12041bd2ae8557a1832c735b128fd4ca7861106f..185f4428f255e045c05af4dce04f6b95b277eca3 100644
--- a/source/libs/nodes/src/nodesCloneFuncs.c
+++ b/source/libs/nodes/src/nodesCloneFuncs.c
@@ -387,6 +387,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_SCALAR_FIELD(watermark);
COPY_SCALAR_FIELD(deleteMark);
COPY_SCALAR_FIELD(igExpired);
+ COPY_SCALAR_FIELD(igCheckUpdate);
CLONE_NODE_LIST_FIELD(pGroupTags);
COPY_SCALAR_FIELD(groupSort);
CLONE_NODE_LIST_FIELD(pTags);
@@ -476,6 +477,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p
COPY_SCALAR_FIELD(watermark);
COPY_SCALAR_FIELD(deleteMark);
COPY_SCALAR_FIELD(igExpired);
+ COPY_SCALAR_FIELD(igCheckUpdate);
COPY_SCALAR_FIELD(windowAlgo);
COPY_SCALAR_FIELD(inputTsOrder);
COPY_SCALAR_FIELD(outputTsOrder);
diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c
index d9b3237993732b21da75ab9eea5249e9e4019226..099cd0d3b3adf1a7404fa2cbd947bfc1800fd9c3 100644
--- a/source/libs/nodes/src/nodesCodeFuncs.c
+++ b/source/libs/nodes/src/nodesCodeFuncs.c
@@ -165,6 +165,8 @@ const char* nodesNodeName(ENodeType type) {
return "ExplainStmt";
case QUERY_NODE_DESCRIBE_STMT:
return "DescribeStmt";
+ case QUERY_NODE_COMPACT_DATABASE_STMT:
+ return "CompactDatabaseStmt";
case QUERY_NODE_CREATE_STREAM_STMT:
return "CreateStreamStmt";
case QUERY_NODE_DROP_STREAM_STMT:
@@ -176,7 +178,7 @@ const char* nodesNodeName(ENodeType type) {
case QUERY_NODE_SHOW_DB_ALIVE_STMT:
return "ShowDbAliveStmt";
case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
- return "ShowClusterAliveStmt";
+ return "ShowClusterAliveStmt";
case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT:
return "RedistributeVgroupStmt";
case QUERY_NODE_SPLIT_VGROUP_STMT:
@@ -1642,6 +1644,7 @@ static const char* jkTableScanPhysiPlanGroupSort = "GroupSort";
static const char* jkTableScanPhysiPlanTags = "Tags";
static const char* jkTableScanPhysiPlanSubtable = "Subtable";
static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid";
+static const char* jkTableScanPhysiPlanIgnoreUpdate = "IgnoreUpdate";
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
@@ -1707,6 +1710,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIgnoreUpdate, pNode->igCheckUpdate);
+ }
return code;
}
@@ -1775,6 +1781,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIgnoreUpdate, &pNode->igCheckUpdate);
+ }
return code;
}
@@ -2595,6 +2604,7 @@ static const char* jkQueryInsertPhysiPlanTableType = "TableType";
static const char* jkQueryInsertPhysiPlanTableFName = "TableFName";
static const char* jkQueryInsertPhysiPlanVgId = "VgId";
static const char* jkQueryInsertPhysiPlanEpSet = "EpSet";
+static const char* jkQueryInsertPhysiPlanExplain = "Explain";
static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) {
const SQueryInserterNode* pNode = (const SQueryInserterNode*)pObj;
@@ -2621,6 +2631,9 @@ static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkQueryInsertPhysiPlanEpSet, epSetToJson, &pNode->epSet);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tjsonAddBoolToObject(pJson, jkQueryInsertPhysiPlanExplain, pNode->explain);
+ }
return code;
}
@@ -2650,6 +2663,9 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) {
code = tjsonToObject(pJson, jkQueryInsertPhysiPlanEpSet, jsonToEpSet, &pNode->epSet);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tjsonGetBoolValue(pJson, jkQueryInsertPhysiPlanExplain, &pNode->explain);
+ }
return code;
}
@@ -5686,6 +5702,18 @@ static int32_t jsonToDescribeStmt(const SJson* pJson, void* pObj) {
return code;
}
+static const char* jkCompactDatabaseStmtDbName = "DbName";
+
+static int32_t compactDatabaseStmtToJson(const void* pObj, SJson* pJson) {
+ const SCompactDatabaseStmt* pNode = (const SCompactDatabaseStmt*)pObj;
+ return tjsonAddStringToObject(pJson, jkCompactDatabaseStmtDbName, pNode->dbName);
+}
+
+static int32_t jsonToCompactDatabaseStmt(const SJson* pJson, void* pObj) {
+ SCompactDatabaseStmt* pNode = (SCompactDatabaseStmt*)pObj;
+ return tjsonGetStringValue(pJson, jkCompactDatabaseStmtDbName, pNode->dbName);
+}
+
static const char* jkCreateStreamStmtStreamName = "StreamName";
static const char* jkCreateStreamStmtTargetDbName = "TargetDbName";
static const char* jkCreateStreamStmtTargetTabName = "TargetTabName";
@@ -6397,6 +6425,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return explainStmtToJson(pObj, pJson);
case QUERY_NODE_DESCRIBE_STMT:
return describeStmtToJson(pObj, pJson);
+ case QUERY_NODE_COMPACT_DATABASE_STMT:
+ return compactDatabaseStmtToJson(pObj, pJson);
case QUERY_NODE_CREATE_STREAM_STMT:
return createStreamStmtToJson(pObj, pJson);
case QUERY_NODE_DROP_STREAM_STMT:
@@ -6703,6 +6733,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return jsonToExplainStmt(pJson, pObj);
case QUERY_NODE_DESCRIBE_STMT:
return jsonToDescribeStmt(pJson, pObj);
+ case QUERY_NODE_COMPACT_DATABASE_STMT:
+ return jsonToCompactDatabaseStmt(pJson, pObj);
case QUERY_NODE_CREATE_STREAM_STMT:
return jsonToCreateStreamStmt(pJson, pObj);
case QUERY_NODE_DROP_STREAM_STMT:
diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c
index a4b77fad6928cdb46c52e44266f74c1f3ec6fb46..e94b2bba6cd90b288615014f3abf3edcdb6a4970 100644
--- a/source/libs/nodes/src/nodesMsgFuncs.c
+++ b/source/libs/nodes/src/nodesMsgFuncs.c
@@ -2078,6 +2078,9 @@ static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEnc
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeValueBool(pEncoder, pNode->assignBlockUid);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeValueI8(pEncoder, pNode->igCheckUpdate);
+ }
return code;
}
@@ -2154,6 +2157,9 @@ static int32_t msgToPhysiTableScanNodeInline(STlvDecoder* pDecoder, void* pObj)
if (TSDB_CODE_SUCCESS == code) {
code = tlvDecodeValueBool(pDecoder, &pNode->assignBlockUid);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvDecodeValueI8(pDecoder, &pNode->igCheckUpdate);
+ }
return code;
}
@@ -3244,7 +3250,8 @@ enum {
PHY_QUERY_INSERT_CODE_TABLE_TYPE,
PHY_QUERY_INSERT_CODE_TABLE_NAME,
PHY_QUERY_INSERT_CODE_VG_ID,
- PHY_QUERY_INSERT_CODE_EP_SET
+ PHY_QUERY_INSERT_CODE_EP_SET,
+ PHY_QUERY_INSERT_CODE_EXPLAIN
};
static int32_t physiQueryInsertNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
@@ -3272,6 +3279,9 @@ static int32_t physiQueryInsertNodeToMsg(const void* pObj, STlvEncoder* pEncoder
if (TSDB_CODE_SUCCESS == code) {
code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_EP_SET, epSetToMsg, &pNode->epSet);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_QUERY_INSERT_CODE_EXPLAIN, pNode->explain);
+ }
return code;
}
@@ -3307,6 +3317,9 @@ static int32_t msgToPhysiQueryInsertNode(STlvDecoder* pDecoder, void* pObj) {
case PHY_QUERY_INSERT_CODE_EP_SET:
code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->epSet);
break;
+ case PHY_QUERY_INSERT_CODE_EXPLAIN:
+ code = tlvDecodeBool(pTlv, &pNode->explain);
+ break;
default:
break;
}
diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c
index 61bb3778fa2d692816e99f43c5b09713b7673341..0419c883e6320aea75743f9106a65606668e21a4 100644
--- a/source/libs/nodes/src/nodesUtilFuncs.c
+++ b/source/libs/nodes/src/nodesUtilFuncs.c
@@ -374,8 +374,8 @@ SNode* nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SDescribeStmt));
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
return makeNode(type, sizeof(SNode));
- case QUERY_NODE_COMPACT_STMT:
- break;
+ case QUERY_NODE_COMPACT_DATABASE_STMT:
+ return makeNode(type, sizeof(SCompactDatabaseStmt));
case QUERY_NODE_CREATE_FUNCTION_STMT:
return makeNode(type, sizeof(SCreateFunctionStmt));
case QUERY_NODE_DROP_FUNCTION_STMT:
@@ -436,7 +436,7 @@ SNode* nodesMakeNode(ENodeType type) {
return makeNode(type, sizeof(SShowCreateDatabaseStmt));
case QUERY_NODE_SHOW_DB_ALIVE_STMT:
case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
- return makeNode(type, sizeof(SShowAliveStmt));
+ return makeNode(type, sizeof(SShowAliveStmt));
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
return makeNode(type, sizeof(SShowCreateTableStmt));
@@ -923,7 +923,7 @@ void nodesDestroyNode(SNode* pNode) {
taosMemoryFree(((SDescribeStmt*)pNode)->pMeta);
break;
case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field
- case QUERY_NODE_COMPACT_STMT: // no pointer field
+ case QUERY_NODE_COMPACT_DATABASE_STMT: // no pointer field
case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field
case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field
break;
@@ -964,7 +964,7 @@ void nodesDestroyNode(SNode* pNode) {
case QUERY_NODE_SHOW_LICENCES_STMT:
case QUERY_NODE_SHOW_VGROUPS_STMT:
case QUERY_NODE_SHOW_DB_ALIVE_STMT:
- case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
+ case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
case QUERY_NODE_SHOW_TOPICS_STMT:
case QUERY_NODE_SHOW_CONSUMERS_STMT:
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
@@ -1103,6 +1103,8 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode(pLogicNode->pTspk);
nodesDestroyNode(pLogicNode->pTsEnd);
nodesDestroyNode(pLogicNode->pStateExpr);
+ nodesDestroyNode(pLogicNode->pStartCond);
+ nodesDestroyNode(pLogicNode->pEndCond);
break;
}
case QUERY_NODE_LOGIC_PLAN_FILL: {
@@ -2017,10 +2019,14 @@ char* nodesGetFillModeString(EFillMode mode) {
return "none";
case FILL_MODE_VALUE:
return "value";
+ case FILL_MODE_VALUE_F:
+ return "value_f";
case FILL_MODE_PREV:
return "prev";
case FILL_MODE_NULL:
return "null";
+ case FILL_MODE_NULL_F:
+ return "null_f";
case FILL_MODE_LINEAR:
return "linear";
case FILL_MODE_NEXT:
diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h
index d202e60a4575c9ad3efcdbcccc938a4c8fe1ed31..3b309db1db61b1d1e99918962fe73bd1ffa5cb09 100644
--- a/source/libs/parser/inc/parAst.h
+++ b/source/libs/parser/inc/parAst.h
@@ -151,6 +151,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions);
SNode* createFlushDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t maxSpeed);
+SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName);
SNode* createDefaultTableOptions(SAstCreateContext* pCxt);
SNode* createAlterTableOptions(SAstCreateContext* pCxt);
SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal);
@@ -210,7 +211,6 @@ SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* p
SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery);
SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable);
SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt);
-SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups);
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName);
diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h
index 7b816359f9c77b5fe370177fae2aedc67d6cc9a3..303d349b34a1d182bd65a839f866a5b70892afad 100644
--- a/source/libs/parser/inc/parInsertUtil.h
+++ b/source/libs/parser/inc/parInsertUtil.h
@@ -20,11 +20,11 @@
struct SToken;
-#define NEXT_TOKEN(pSql, sToken) \
- do { \
- int32_t index = 0; \
- sToken = tStrGetToken(pSql, &index, false); \
- pSql += index; \
+#define NEXT_TOKEN(pSql, sToken) \
+ do { \
+ int32_t index = 0; \
+ sToken = tStrGetToken(pSql, &index, false, NULL); \
+ pSql += index; \
} while (0)
#define CHECK_CODE(expr) \
diff --git a/source/libs/parser/inc/parToken.h b/source/libs/parser/inc/parToken.h
index 642979c471ab7b409bd622de26c2c2deb1879e83..86bcc18fd5ed91a39c285a6c98357cf04154352c 100644
--- a/source/libs/parser/inc/parToken.h
+++ b/source/libs/parser/inc/parToken.h
@@ -55,7 +55,7 @@ uint32_t tGetToken(const char *z, uint32_t *tokenType);
* @param isPrevOptr
* @return
*/
-SToken tStrGetToken(const char *str, int32_t *i, bool isPrevOptr);
+SToken tStrGetToken(const char *str, int32_t *i, bool isPrevOptr, bool *pIgnoreComma);
/**
* check if it is a keyword or not
diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y
index ba17488470d62a831a79d0255199d02f4c7e4348..19992498a04f9bf496e840cbe1da394ce292bcc7 100644
--- a/source/libs/parser/inc/sql.y
+++ b/source/libs/parser/inc/sql.y
@@ -167,6 +167,7 @@ cmd ::= USE db_name(A).
cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); }
cmd ::= FLUSH DATABASE db_name(A). { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &A); }
cmd ::= TRIM DATABASE db_name(A) speed_opt(B). { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &A, B); }
+cmd ::= COMPACT DATABASE db_name(A). { pCxt->pRootNode = createCompactStmt(pCxt, &A); }
%type not_exists_opt { bool }
%destructor not_exists_opt { }
@@ -517,6 +518,7 @@ cmd ::= RESET QUERY CACHE.
/************************************************ explain *************************************************************/
cmd ::= EXPLAIN analyze_opt(A) explain_options(B) query_or_subquery(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); }
+cmd ::= EXPLAIN analyze_opt(A) explain_options(B) insert_query(C). { pCxt->pRootNode = createExplainStmt(pCxt, A, B, C); }
%type analyze_opt { bool }
%destructor analyze_opt { }
@@ -527,9 +529,6 @@ explain_options(A) ::= .
explain_options(A) ::= explain_options(B) VERBOSE NK_BOOL(C). { A = setExplainVerbose(pCxt, B, &C); }
explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); }
-/************************************************ compact *************************************************************/
-//cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
-
/************************************************ create/drop function ************************************************/
cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B)
AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E); }
@@ -569,6 +568,7 @@ stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C).
stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
stream_options(A) ::= stream_options(B) IGNORE EXPIRED NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreExpired = taosStr2Int8(C.z, NULL, 10); A = B; }
stream_options(A) ::= stream_options(B) FILL_HISTORY NK_INTEGER(C). { ((SStreamOptions*)B)->fillHistory = taosStr2Int8(C.z, NULL, 10); A = B; }
+stream_options(A) ::= stream_options(B) IGNORE UPDATE NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreUpdate = taosStr2Int8(C.z, NULL, 10); A = B; }
subtable_opt(A) ::= . { A = NULL; }
subtable_opt(A) ::= SUBTABLE NK_LP expression(B) NK_RP. { A = releaseRawExprNode(pCxt, B); }
@@ -599,9 +599,11 @@ cmd ::= DELETE FROM full_table_name(A) where_clause_opt(B).
cmd ::= query_or_subquery(A). { pCxt->pRootNode = A; }
/************************************************ insert **************************************************************/
-cmd ::= INSERT INTO full_table_name(A)
- NK_LP col_name_list(B) NK_RP query_or_subquery(C). { pCxt->pRootNode = createInsertStmt(pCxt, A, B, C); }
-cmd ::= INSERT INTO full_table_name(A) query_or_subquery(B). { pCxt->pRootNode = createInsertStmt(pCxt, A, NULL, B); }
+cmd ::= insert_query(A). { pCxt->pRootNode = A; }
+
+insert_query(A) ::= INSERT INTO full_table_name(D)
+ NK_LP col_name_list(B) NK_RP query_or_subquery(C). { A = createInsertStmt(pCxt, D, B, C); }
+insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B). { A = createInsertStmt(pCxt, C, NULL, B); }
/************************************************ literal *************************************************************/
literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); }
@@ -1006,12 +1008,14 @@ sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP.
fill_opt(A) ::= . { A = NULL; }
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
fill_opt(A) ::= FILL NK_LP VALUE NK_COMMA literal_list(B) NK_RP. { A = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, B)); }
+fill_opt(A) ::= FILL NK_LP VALUE_F NK_COMMA literal_list(B) NK_RP. { A = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, B)); }
%type fill_mode { EFillMode }
%destructor fill_mode { }
fill_mode(A) ::= NONE. { A = FILL_MODE_NONE; }
fill_mode(A) ::= PREV. { A = FILL_MODE_PREV; }
fill_mode(A) ::= NULL. { A = FILL_MODE_NULL; }
+fill_mode(A) ::= NULL_F. { A = FILL_MODE_NULL_F; }
fill_mode(A) ::= LINEAR. { A = FILL_MODE_LINEAR; }
fill_mode(A) ::= NEXT. { A = FILL_MODE_NEXT; }
@@ -1101,6 +1105,6 @@ null_ordering_opt(A) ::= .
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
-%fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL
+%fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL
FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT
- STRICT STRING TIMES UPDATE VALUES VARIABLE VIEW WAL.
+ STRICT STRING TIMES VALUES VARIABLE VIEW WAL.
diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c
index f582adb0c6fe7d75cd0ac68c035bac5dc5c71926..15a796e0866b041024ad1dd5bcd6ca3b9531805b 100644
--- a/source/libs/parser/src/parAstCreater.c
+++ b/source/libs/parser/src/parAstCreater.c
@@ -1105,6 +1105,17 @@ SNode* createTrimDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, int32_t
return (SNode*)pStmt;
}
+SNode* createCompactStmt(SAstCreateContext* pCxt, SToken* pDbName) {
+ CHECK_PARSER_STATUS(pCxt);
+ if (!checkDbName(pCxt, pDbName, false)) {
+ return NULL;
+ }
+ SCompactDatabaseStmt* pStmt = (SCompactDatabaseStmt*)nodesMakeNode(QUERY_NODE_COMPACT_DATABASE_STMT);
+ CHECK_OUT_OF_MEM(pStmt);
+ COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName);
+ return (SNode*)pStmt;
+}
+
SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
CHECK_PARSER_STATUS(pCxt);
STableOptions* pOptions = (STableOptions*)nodesMakeNode(QUERY_NODE_TABLE_OPTIONS);
@@ -1768,13 +1779,6 @@ SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt) {
return pStmt;
}
-SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) {
- CHECK_PARSER_STATUS(pCxt);
- SNode* pStmt = nodesMakeNode(QUERY_NODE_COMPACT_STMT);
- CHECK_OUT_OF_MEM(pStmt);
- return pStmt;
-}
-
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
const SToken* pLibPath, SDataType dataType, int32_t bufSize) {
CHECK_PARSER_STATUS(pCxt);
@@ -1809,6 +1813,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) {
pOptions->triggerType = STREAM_TRIGGER_AT_ONCE;
pOptions->fillHistory = STREAM_DEFAULT_FILL_HISTORY;
pOptions->ignoreExpired = STREAM_DEFAULT_IGNORE_EXPIRED;
+ pOptions->ignoreUpdate = STREAM_DEFAULT_IGNORE_UPDATE;
return (SNode*)pOptions;
}
diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c
index 3c5d4d506a72d9a9e3d8bda482cbf1010c8acb3f..e82b1edee1ae46238a62136e31c36d8c541286b4 100644
--- a/source/libs/parser/src/parInsertSql.c
+++ b/source/libs/parser/src/parInsertSql.c
@@ -18,16 +18,23 @@
#include "tglobal.h"
#include "ttime.h"
-#define NEXT_TOKEN_WITH_PREV(pSql, token) \
- do { \
- int32_t index = 0; \
- token = tStrGetToken(pSql, &index, true); \
- pSql += index; \
+#define NEXT_TOKEN_WITH_PREV(pSql, token) \
+ do { \
+ int32_t index = 0; \
+ token = tStrGetToken(pSql, &index, true, NULL); \
+ pSql += index; \
} while (0)
-#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
- do { \
- token = tStrGetToken(pSql, &index, false); \
+#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \
+ do { \
+ int32_t index = 0; \
+ token = tStrGetToken(pSql, &index, true, pIgnoreComma); \
+ pSql += index; \
+ } while (0)
+
+#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \
+ do { \
+ token = tStrGetToken(pSql, &index, false, NULL); \
} while (0)
#define NEXT_VALID_TOKEN(pSql, token) \
@@ -266,12 +273,12 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t
* e.g., now+12a, now-5h
*/
index = 0;
- SToken token = tStrGetToken(pTokenEnd, &index, false);
+ SToken token = tStrGetToken(pTokenEnd, &index, false, NULL);
pTokenEnd += index;
if (token.type == TK_NK_MINUS || token.type == TK_NK_PLUS) {
index = 0;
- SToken valueToken = tStrGetToken(pTokenEnd, &index, false);
+ SToken valueToken = tStrGetToken(pTokenEnd, &index, false, NULL);
pTokenEnd += index;
if (valueToken.n < 2) {
@@ -1240,7 +1247,14 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataC
int32_t code = TSDB_CODE_SUCCESS;
// 1. set the parsed value from sql string
for (int i = 0; i < pCols->numOfBound && TSDB_CODE_SUCCESS == code; ++i) {
- NEXT_TOKEN_WITH_PREV(*pSql, *pToken);
+ const char* pOrigSql = *pSql;
+ bool ignoreComma = false;
+ NEXT_TOKEN_WITH_PREV_EXT(*pSql, *pToken, &ignoreComma);
+ if (ignoreComma) {
+ code = buildSyntaxErrMsg(&pCxt->msg, "invalid data or symbol", pOrigSql);
+ break;
+ }
+
SSchema* pSchema = &pSchemas[pCols->pColIndex[i]];
SColVal* pVal = taosArrayGet(pTableCxt->pValues, pCols->pColIndex[i]);
@@ -1248,20 +1262,22 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataC
isParseBindParam = true;
if (NULL == pCxt->pComCxt->pStmtCb) {
code = buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pToken->z);
+ break;
+ }
+ } else {
+ if (TK_NK_RP == pToken->type) {
+ code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM);
+ break;
}
- continue;
- }
-
- if (TSDB_CODE_SUCCESS == code && TK_NK_RP == pToken->type) {
- code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM);
- }
- if (TSDB_CODE_SUCCESS == code && isParseBindParam) {
- code = buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and values");
- }
+ if (isParseBindParam) {
+ code = buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and values");
+ break;
+ }
- if (TSDB_CODE_SUCCESS == code) {
- code = parseValueToken(pCxt, pSql, pToken, pSchema, getTableInfo(pTableCxt->pMeta).precision, pVal);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = parseValueToken(pCxt, pSql, pToken, pSchema, getTableInfo(pTableCxt->pMeta).precision, pVal);
+ }
}
if (TSDB_CODE_SUCCESS == code && i < pCols->numOfBound - 1) {
@@ -1693,6 +1709,9 @@ static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMeta
if (TSDB_CODE_SUCCESS == code && !isStb && TSDB_SUPER_TABLE == pStmt->pTableMeta->tableType) {
code = buildInvalidOperationMsg(&pCxt->msg, "insert data into super table is not supported");
}
+ if (TSDB_CODE_SUCCESS == code && isStb) {
+ code = storeTableMeta(pCxt, pStmt);
+ }
if (TSDB_CODE_SUCCESS == code) {
code = getTableVgroupFromMetaData(pMetaData->pTableHash, pStmt, isStb);
}
diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c
index 7cc93b448fec577d7449b9d71e481b56080090d9..fbdaf6fc9f494e715ee0096da855b7e31a7fc800 100644
--- a/source/libs/parser/src/parInsertUtil.c
+++ b/source/libs/parser/src/parInsertUtil.c
@@ -290,7 +290,8 @@ int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta*
}
int32_t code = createTableDataCxt(pTableMeta, pCreateTbReq, pTableCxt, colMode);
if (TSDB_CODE_SUCCESS == code) {
- code = taosHashPut(pHash, id, idLen, pTableCxt, POINTER_BYTES);
+ void* pData = *pTableCxt; // deal scan coverity
+ code = taosHashPut(pHash, id, idLen, &pData, POINTER_BYTES);
}
return code;
}
@@ -608,7 +609,7 @@ static int bindFileds(SBoundColInfo* pBoundInfo, SSchema* pSchema, TAOS_FIELD* f
}
int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD* tFields,
- int numFields) {
+ int numFields, bool needChangeLength) {
STableDataCxt* pTableCxt = NULL;
int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
sizeof(pTableMeta->uid), pTableMeta, &pCreateTb, &pTableCxt, true);
@@ -678,10 +679,15 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
pStart += BitmapLen(numOfRows);
}
char* pData = pStart;
+// uError("rawBlockBindData col bytes:%d, type:%d, size:%d, htonl size:%d", pColSchema->bytes, pColSchema->type, colLength[c], htonl(colLength[c]));
tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData);
fields += sizeof(int8_t) + sizeof(int32_t);
- pStart += colLength[c];
+ if(needChangeLength) {
+ pStart += htonl(colLength[c]);
+ }else{
+ pStart += colLength[c];
+ }
}
end:
diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c
index 93bfe179f486775111d0f5aa9781b585cb583057..678dcf34d3a9a1d08bfa8c51e25abe3cd2161daf 100644
--- a/source/libs/parser/src/parTokenizer.c
+++ b/source/libs/parser/src/parTokenizer.c
@@ -61,6 +61,7 @@ static SKeyword keywordTable[] = {
{"COLUMN", TK_COLUMN},
{"COMMENT", TK_COMMENT},
{"COMP", TK_COMP},
+ {"COMPACT", TK_COMPACT},
{"CONNECTION", TK_CONNECTION},
{"CONNECTIONS", TK_CONNECTIONS},
{"CONNS", TK_CONNS},
@@ -149,6 +150,7 @@ static SKeyword keywordTable[] = {
{"NOT", TK_NOT},
{"NOW", TK_NOW},
{"NULL", TK_NULL},
+ {"NULL_F", TK_NULL_F},
{"NULLS", TK_NULLS},
{"OFFSET", TK_OFFSET},
{"ON", TK_ON},
@@ -234,11 +236,13 @@ static SKeyword keywordTable[] = {
{"TTL", TK_TTL},
{"UNION", TK_UNION},
{"UNSIGNED", TK_UNSIGNED},
+ {"UPDATE", TK_UPDATE},
{"USE", TK_USE},
{"USER", TK_USER},
{"USERS", TK_USERS},
{"USING", TK_USING},
{"VALUE", TK_VALUE},
+ {"VALUE_F", TK_VALUE_F},
{"VALUES", TK_VALUES},
{"VARCHAR", TK_VARCHAR},
{"VARIABLES", TK_VARIABLES},
@@ -624,7 +628,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
return 0;
}
-SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
+SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreComma) {
SToken t0 = {0};
// here we reach the end of sql string, null-terminated string
@@ -645,6 +649,10 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
return t0;
}
+ if (NULL != pIgnoreComma && t == ',') {
+ *pIgnoreComma = true;
+ }
+
t = str[++(*i)];
}
diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c
index 6e94883849c13fb719654df477ab550aee716ef1..1347193d993c1ef2c4c9ca655636a9d69a465371 100644
--- a/source/libs/parser/src/parTranslater.c
+++ b/source/libs/parser/src/parTranslater.c
@@ -1550,11 +1550,35 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p
// select percentile() without from clause is also valid
if ((NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) ||
(TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
- TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType))) ||
- NULL != pSelect->pPartitionByList) {
+ TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType)))) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
"%s is only supported in single table query", pFunc->functionName);
}
+ if (NULL != pSelect->pPartitionByList) {
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
+ "%s function is not supported in partition query", pFunc->functionName);
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t translateBlockDistFunc(STranslateContext* pCtx, SFunctionNode* pFunc) {
+ if (!fmIsBlockDistFunc(pFunc->funcId)) {
+ return TSDB_CODE_SUCCESS;
+ }
+ if (!isSelectStmt(pCtx->pCurrStmt)) {
+ return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE,
+ "%s is only supported in single table query", pFunc->functionName);
+ }
+ SSelectStmt* pSelect = (SSelectStmt*)pCtx->pCurrStmt;
+ SNode* pTable = pSelect->pFromTable;
+ if (NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) ||
+ (TSDB_SUPER_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
+ TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType &&
+ TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType))) {
+ return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC,
+ "%s is only supported on super table, child table or normal table",
+ pFunc->functionName);
+ }
return TSDB_CODE_SUCCESS;
}
@@ -1581,6 +1605,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
}
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias) {
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
+ strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
}
return TSDB_CODE_SUCCESS;
}
@@ -1717,7 +1742,7 @@ static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) {
return TSDB_CODE_PAR_INTERNAL_ERROR;
}
-static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
+static int32_t translateNormalFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
int32_t code = translateAggFunc(pCxt, pFunc);
if (TSDB_CODE_SUCCESS == code) {
code = translateScanPseudoColumnFunc(pCxt, pFunc);
@@ -1749,6 +1774,9 @@ static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* p
if (TSDB_CODE_SUCCESS == code) {
code = translateTimelineFunc(pCxt, pFunc);
}
+ if (TSDB_CODE_SUCCESS == code) {
+ code = translateBlockDistFunc(pCxt, pFunc);
+ }
if (TSDB_CODE_SUCCESS == code) {
setFuncClassification(pCxt->pCurrStmt, pFunc);
}
@@ -1809,7 +1837,7 @@ static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pF
if (fmIsClientPseudoColumnFunc((*pFunc)->funcId)) {
return rewriteClientPseudoColumnFunc(pCxt, (SNode**)pFunc);
}
- return translateNoramlFunction(pCxt, *pFunc);
+ return translateNormalFunction(pCxt, *pFunc);
}
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc) {
@@ -2524,11 +2552,12 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
int32_t len = 0;
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
SColumnNode* pCol = (SColumnNode*)pExpr;
- len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
- strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1));
if (tsKeepColumnName) {
strcpy(pFunc->node.userAlias, pCol->colName);
+ strcpy(pFunc->node.aliasName, pCol->colName);
} else {
+ len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
+ strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1));
len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName);
strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1));
}
@@ -2795,7 +2824,7 @@ static int32_t convertFillValue(STranslateContext* pCxt, SDataType dt, SNodeList
}
static int32_t checkFillValues(STranslateContext* pCxt, SFillNode* pFill, SNodeList* pProjectionList) {
- if (FILL_MODE_VALUE != pFill->mode) {
+ if (FILL_MODE_VALUE != pFill->mode && FILL_MODE_VALUE_F != pFill->mode) {
return TSDB_CODE_SUCCESS;
}
@@ -2979,7 +3008,7 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode*
intervalRange = pInterval->datum.i;
}
- if ((timeRange == 0) || (timeRange / intervalRange) >= MAX_INTERVAL_TIME_WINDOW) {
+ if ((timeRange / intervalRange) >= MAX_INTERVAL_TIME_WINDOW) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE);
}
@@ -3281,9 +3310,6 @@ static int32_t translateInterp(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
- if (NULL == pSelect->pPartitionByList) {
- return TSDB_CODE_SUCCESS;
- }
pCxt->currClause = SQL_CLAUSE_PARTITION_BY;
int32_t code = translateExprList(pCxt, pSelect->pPartitionByList);
if (TSDB_CODE_SUCCESS == code) {
@@ -3517,7 +3543,7 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
if (comp > 0) {
SNode* pRightFunc = NULL;
int32_t code = createCastFunc(pCxt, pRight, pLeftExpr->resType, &pRightFunc);
- if (TSDB_CODE_SUCCESS != code) {
+ if (TSDB_CODE_SUCCESS != code || NULL == pRightFunc) { // deal scan coverity
return code;
}
REPLACE_LIST2_NODE(pRightFunc);
@@ -3525,7 +3551,7 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
} else if (comp < 0) {
SNode* pLeftFunc = NULL;
int32_t code = createCastFunc(pCxt, pLeft, pRightExpr->resType, &pLeftFunc);
- if (TSDB_CODE_SUCCESS != code) {
+ if (TSDB_CODE_SUCCESS != code || NULL == pLeftFunc) { // deal scan coverity
return code;
}
REPLACE_LIST1_NODE(pLeftFunc);
@@ -5507,7 +5533,7 @@ static int32_t translateDropCGroup(STranslateContext* pCxt, SDropCGroupStmt* pSt
}
static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pStmt) {
- // todo
+ // The statement is executed directly on the client without constructing a message.
return TSDB_CODE_SUCCESS;
}
@@ -5522,6 +5548,14 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
return refreshGetTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
}
+static int32_t translateCompact(STranslateContext* pCxt, SCompactDatabaseStmt* pStmt) {
+ SCompactDbReq compactReq = {0};
+ SName name;
+ tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
+ tNameGetFullDbName(&name, compactReq.db);
+ return buildCmdMsg(pCxt, TDMT_MND_COMPACT_DB, (FSerializeFunc)tSerializeSCompactDbReq, &compactReq);
+}
+
static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt) {
SKillConnReq killReq = {0};
killReq.connId = pStmt->targetId;
@@ -5674,10 +5708,6 @@ static SNode* createNullValue() {
}
static int32_t addNullTagsForExistTable(STranslateContext* pCxt, STableMeta* pMeta, SSelectStmt* pSelect) {
- if (NULL == pMeta) {
- return TSDB_CODE_SUCCESS;
- }
-
int32_t numOfTags = getNumOfTags(pMeta);
int32_t code = TSDB_CODE_SUCCESS;
for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < numOfTags; ++i) {
@@ -5731,14 +5761,30 @@ static int32_t addSubtableNameToCreateStreamQuery(STranslateContext* pCxt, SCrea
return pCxt->errCode;
}
+static int32_t addNullTagsForCreateTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < LIST_LENGTH(pStmt->pTags); ++i) {
+ code = nodesListMakeStrictAppend(&((SSelectStmt*)pStmt->pQuery)->pTags, createNullValue());
+ }
+ return code;
+}
+
+static int32_t addNullTagsToCreateStreamQuery(STranslateContext* pCxt, STableMeta* pMeta, SCreateStreamStmt* pStmt) {
+ if (NULL == pMeta) {
+ return addNullTagsForCreateTable(pCxt, pStmt);
+ }
+ return addNullTagsForExistTable(pCxt, pMeta, (SSelectStmt*)pStmt->pQuery);
+}
+
static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, STableMeta* pMeta,
SCreateStreamStmt* pStmt) {
+ int32_t code = TSDB_CODE_SUCCESS;
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
if (NULL == pSelect->pPartitionByList) {
- return addNullTagsForExistTable(pCxt, pMeta, pSelect);
+ code = addNullTagsToCreateStreamQuery(pCxt, pMeta, pStmt);
+ } else {
+ code = addTagsToCreateStreamQuery(pCxt, pStmt, pSelect);
}
-
- int32_t code = addTagsToCreateStreamQuery(pCxt, pStmt, pSelect);
if (TSDB_CODE_SUCCESS == code) {
code = addSubtableNameToCreateStreamQuery(pCxt, pStmt, pSelect);
}
@@ -5797,7 +5843,7 @@ static int32_t projColPosCompar(const void* l, const void* r) {
return ((SProjColPos*)l)->colId > ((SProjColPos*)r)->colId;
}
-static void projColPosDelete(void* p) { taosMemoryFree(((SProjColPos*)p)->pProj); }
+static void projColPosDelete(void* p) { nodesDestroyNode(((SProjColPos*)p)->pProj); }
static int32_t addProjToProjColPos(STranslateContext* pCxt, const SSchema* pSchema, SNode* pProj, SArray* pProjColPos) {
SNode* pNewProj = nodesCloneNode(pProj);
@@ -6013,17 +6059,66 @@ static int32_t adjustTagsForExistTable(STranslateContext* pCxt, SCreateStreamStm
return adjustOrderOfTags(pCxt, pStmt->pTags, pMeta, &pSelect->pTags, pReq);
}
+static int32_t adjustTagsForCreateTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq) {
+ SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
+ if (NULL == pSelect->pPartitionByList || NULL == pSelect->pTags) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ SNode* pTagDef = NULL;
+ SNode* pTagExpr = NULL;
+ FORBOTH(pTagDef, pStmt->pTags, pTagExpr, pSelect->pTags) {
+ SColumnDefNode* pDef = (SColumnDefNode*)pTagDef;
+ if (!dataTypeEqual(&pDef->dataType, &((SExprNode*)pTagExpr)->resType)) {
+ SNode* pFunc = NULL;
+ int32_t code = createCastFunc(pCxt, pTagExpr, pDef->dataType, &pFunc);
+ if (TSDB_CODE_SUCCESS != code) {
+ return code;
+ }
+ REPLACE_LIST2_NODE(pFunc);
+ }
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t adjustTags(STranslateContext* pCxt, SCreateStreamStmt* pStmt, const STableMeta* pMeta,
+ SCMCreateStreamReq* pReq) {
+ if (NULL == pMeta) {
+ return adjustTagsForCreateTable(pCxt, pStmt, pReq);
+ }
+ return adjustTagsForExistTable(pCxt, pStmt, pMeta, pReq);
+}
+
+static bool isTagDef(SNodeList* pTags) {
+ if (NULL == pTags) {
+ return false;
+ }
+ return QUERY_NODE_COLUMN_DEF == nodeType(nodesListGetNode(pTags, 0));
+}
+
+static bool isTagBound(SNodeList* pTags) {
+ if (NULL == pTags) {
+ return false;
+ }
+ return QUERY_NODE_COLUMN == nodeType(nodesListGetNode(pTags, 0));
+}
+
static int32_t translateStreamTargetTable(STranslateContext* pCxt, SCreateStreamStmt* pStmt, SCMCreateStreamReq* pReq,
STableMeta** pMeta) {
int32_t code = getTableMeta(pCxt, pStmt->targetDbName, pStmt->targetTabName, pMeta);
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
- if (NULL != pStmt->pCols) {
+ if (NULL != pStmt->pCols || isTagBound(pStmt->pTags)) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pStmt->targetTabName);
}
pReq->createStb = STREAM_CREATE_STABLE_TRUE;
pReq->targetStbUid = 0;
return TSDB_CODE_SUCCESS;
} else {
+ if (isTagDef(pStmt->pTags)) {
+ return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Table already exist: %s",
+ pStmt->targetTabName);
+ }
pReq->createStb = STREAM_CREATE_STABLE_FALSE;
pReq->targetStbUid = (*pMeta)->suid;
}
@@ -6049,8 +6144,8 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
if (TSDB_CODE_SUCCESS == code && NULL != pMeta) {
code = adjustProjectionsForExistTable(pCxt, pStmt, pMeta, pReq);
}
- if (TSDB_CODE_SUCCESS == code && NULL != pMeta) {
- code = adjustTagsForExistTable(pCxt, pStmt, pMeta, pReq);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = adjustTags(pCxt, pStmt, pMeta, pReq);
}
if (TSDB_CODE_SUCCESS == code) {
getSourceDatabase(pStmt->pQuery, pCxt->pParseCxt->acctId, pReq->sourceDB);
@@ -6091,6 +6186,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
columnDefNodeToField(pStmt->pTags, &pReq->pTags);
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
}
+ pReq->igUpdate = pStmt->pOptions->ignoreUpdate;
}
return code;
@@ -6394,6 +6490,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case QUERY_NODE_DESCRIBE_STMT:
code = translateDescribe(pCxt, (SDescribeStmt*)pNode);
break;
+ case QUERY_NODE_COMPACT_DATABASE_STMT:
+ code = translateCompact(pCxt, (SCompactDatabaseStmt*)pNode);
+ break;
case QUERY_NODE_KILL_CONNECTION_STMT:
code = translateKillConnection(pCxt, (SKillStmt*)pNode);
break;
diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c
index cf338d63ff43182330d2f1e229aa2a03070feb6a..47482db7400f98c839c112d93e503b20d25f8073 100644
--- a/source/libs/parser/src/parser.c
+++ b/source/libs/parser/src/parser.c
@@ -27,7 +27,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
const char* pSql = pStr;
int32_t index = 0;
- SToken t = tStrGetToken((char*)pStr, &index, false);
+ SToken t = tStrGetToken((char*)pStr, &index, false, NULL);
if (TK_INSERT != t.type && TK_IMPORT != t.type) {
return false;
}
@@ -35,7 +35,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
do {
pStr += index;
index = 0;
- t = tStrGetToken((char*)pStr, &index, false);
+ t = tStrGetToken((char*)pStr, &index, false, NULL);
if (TK_USING == t.type || TK_VALUES == t.type || TK_FILE == t.type) {
return true;
} else if (TK_SELECT == t.type) {
diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c
index 03cd8093f9b85519ec9a091e62c38316dfe461ff..836d1c5de937617a279a6f386d83db0993bf32ae 100644
--- a/source/libs/parser/src/sql.c
+++ b/source/libs/parser/src/sql.c
@@ -104,26 +104,26 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 466
+#define YYNOCODE 469
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SToken
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
- int8_t yy27;
- ENullOrder yy89;
- int64_t yy129;
- SToken yy233;
- SAlterOption yy257;
- bool yy397;
- EJoinType yy428;
- EFillMode yy646;
- SNodeList* yy776;
- int32_t yy832;
- SDataType yy852;
- EOperatorType yy856;
- EOrder yy870;
- SNode* yy924;
+ EOperatorType yy2;
+ SNode* yy42;
+ bool yy103;
+ EOrder yy106;
+ SNodeList* yy110;
+ SToken yy225;
+ EFillMode yy410;
+ SDataType yy448;
+ SAlterOption yy459;
+ int32_t yy508;
+ ENullOrder yy599;
+ EJoinType yy638;
+ int64_t yy641;
+ int8_t yy705;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -139,17 +139,17 @@ typedef union {
#define ParseCTX_FETCH
#define ParseCTX_STORE
#define YYFALLBACK 1
-#define YYNSTATE 734
-#define YYNRULE 556
-#define YYNTOKEN 326
-#define YY_MAX_SHIFT 733
-#define YY_MIN_SHIFTREDUCE 1087
-#define YY_MAX_SHIFTREDUCE 1642
-#define YY_ERROR_ACTION 1643
-#define YY_ACCEPT_ACTION 1644
-#define YY_NO_ACTION 1645
-#define YY_MIN_REDUCE 1646
-#define YY_MAX_REDUCE 2201
+#define YYNSTATE 741
+#define YYNRULE 562
+#define YYNTOKEN 328
+#define YY_MAX_SHIFT 740
+#define YY_MIN_SHIFTREDUCE 1099
+#define YY_MAX_SHIFTREDUCE 1660
+#define YY_ERROR_ACTION 1661
+#define YY_ACCEPT_ACTION 1662
+#define YY_NO_ACTION 1663
+#define YY_MIN_REDUCE 1664
+#define YY_MAX_REDUCE 2225
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -216,793 +216,753 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (2952)
+#define YY_ACTTAB_COUNT (2749)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 1918, 2177, 366, 623, 1788, 2172, 474, 2001, 475, 1682,
- /* 10 */ 163, 557, 45, 43, 1572, 1916, 610, 54, 1997, 1801,
- /* 20 */ 374, 2176, 1421, 38, 37, 2173, 2175, 44, 42, 41,
- /* 30 */ 40, 39, 419, 1502, 1799, 1419, 1715, 44, 42, 41,
- /* 40 */ 40, 39, 38, 37, 2001, 175, 44, 42, 41, 40,
- /* 50 */ 39, 1993, 1999, 356, 219, 1997, 377, 377, 1497, 163,
- /* 60 */ 348, 2015, 633, 18, 160, 163, 344, 1901, 1802, 170,
- /* 70 */ 1427, 354, 327, 1801, 1801, 509, 505, 501, 497, 216,
- /* 80 */ 1850, 598, 379, 45, 43, 1845, 1847, 1448, 1993, 1999,
- /* 90 */ 369, 374, 2033, 1421, 1446, 14, 2177, 337, 104, 633,
- /* 100 */ 601, 528, 527, 526, 1502, 1983, 1419, 639, 101, 136,
- /* 110 */ 522, 1609, 139, 1448, 521, 86, 480, 730, 214, 520,
- /* 120 */ 525, 349, 476, 347, 346, 519, 515, 60, 1446, 1497,
- /* 130 */ 517, 1120, 1504, 1505, 18, 2014, 623, 105, 1531, 2050,
- /* 140 */ 177, 1427, 108, 2016, 643, 2018, 2019, 638, 1852, 633,
- /* 150 */ 131, 140, 516, 1839, 178, 353, 2103, 513, 1421, 1791,
- /* 160 */ 368, 2099, 1477, 1487, 1850, 1430, 14, 1799, 1503, 1506,
- /* 170 */ 1122, 1419, 1125, 1126, 183, 600, 179, 2111, 2112, 85,
- /* 180 */ 137, 2116, 2129, 1422, 234, 1420, 213, 207, 730, 1632,
- /* 190 */ 64, 212, 38, 37, 488, 1532, 44, 42, 41, 40,
- /* 200 */ 39, 1447, 1795, 1504, 1505, 165, 1427, 1658, 1425, 1426,
- /* 210 */ 205, 1476, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486,
- /* 220 */ 635, 631, 1495, 1496, 1498, 1499, 1500, 1501, 2, 60,
- /* 230 */ 1139, 266, 1138, 1477, 1487, 492, 1344, 1345, 121, 1503,
- /* 240 */ 1506, 120, 119, 118, 117, 116, 115, 114, 113, 112,
- /* 250 */ 1398, 1399, 2033, 730, 1422, 622, 1420, 266, 38, 37,
- /* 260 */ 580, 1140, 44, 42, 41, 40, 39, 34, 372, 1526,
- /* 270 */ 1527, 1528, 1529, 1530, 1534, 1535, 1536, 1537, 184, 1425,
- /* 280 */ 1426, 60, 1476, 1479, 1480, 1481, 1482, 1483, 1484, 1485,
- /* 290 */ 1486, 635, 631, 1495, 1496, 1498, 1499, 1500, 1501, 2,
- /* 300 */ 175, 11, 45, 43, 579, 483, 598, 475, 1682, 457,
- /* 310 */ 374, 420, 1421, 1361, 1362, 1433, 412, 622, 411, 1422,
- /* 320 */ 49, 1420, 1902, 1502, 421, 1419, 1246, 665, 664, 663,
- /* 330 */ 1250, 662, 1252, 1253, 661, 1255, 658, 139, 1261, 655,
- /* 340 */ 1263, 1264, 652, 649, 1425, 1426, 1588, 608, 1497, 1360,
- /* 350 */ 1363, 31, 267, 18, 41, 40, 39, 38, 37, 1639,
- /* 360 */ 1427, 44, 42, 41, 40, 39, 598, 197, 196, 528,
- /* 370 */ 527, 526, 2118, 45, 43, 1507, 1882, 136, 522, 593,
- /* 380 */ 184, 374, 521, 1421, 1599, 14, 1646, 520, 525, 60,
- /* 390 */ 456, 91, 48, 519, 1502, 622, 1419, 139, 2115, 408,
- /* 400 */ 1533, 264, 2111, 597, 1669, 132, 596, 730, 1447, 2172,
- /* 410 */ 130, 129, 128, 127, 126, 125, 124, 123, 122, 1497,
- /* 420 */ 410, 406, 1504, 1505, 585, 181, 1918, 35, 285, 2173,
- /* 430 */ 587, 1427, 184, 573, 1597, 1598, 1600, 1601, 365, 38,
- /* 440 */ 37, 1915, 610, 44, 42, 41, 40, 39, 1983, 581,
- /* 450 */ 166, 1449, 1477, 1487, 1638, 1753, 46, 52, 1503, 1506,
- /* 460 */ 1647, 180, 2111, 2112, 561, 137, 2116, 1852, 233, 1445,
- /* 470 */ 48, 184, 32, 1422, 341, 1420, 473, 1777, 730, 478,
- /* 480 */ 1688, 121, 1538, 1850, 120, 119, 118, 117, 116, 115,
- /* 490 */ 114, 113, 112, 1504, 1505, 276, 277, 413, 1425, 1426,
- /* 500 */ 275, 1476, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486,
- /* 510 */ 635, 631, 1495, 1496, 1498, 1499, 1500, 1501, 2, 733,
- /* 520 */ 1289, 1290, 482, 1477, 1487, 478, 1688, 437, 623, 1503,
- /* 530 */ 1506, 88, 332, 292, 1446, 546, 436, 544, 542, 492,
- /* 540 */ 184, 562, 186, 586, 1422, 2172, 1420, 2172, 174, 1776,
- /* 550 */ 677, 540, 609, 538, 723, 719, 715, 711, 290, 1799,
- /* 560 */ 2178, 181, 585, 181, 551, 2173, 587, 2173, 587, 1425,
- /* 570 */ 1426, 604, 1476, 1479, 1480, 1481, 1482, 1483, 1484, 1485,
- /* 580 */ 1486, 635, 631, 1495, 1496, 1498, 1499, 1500, 1501, 2,
- /* 590 */ 45, 43, 2118, 533, 106, 244, 1954, 283, 374, 490,
- /* 600 */ 1421, 1911, 1644, 609, 594, 675, 576, 1852, 543, 60,
- /* 610 */ 1775, 1502, 2118, 1419, 362, 562, 1846, 1847, 2114, 2172,
- /* 620 */ 2015, 184, 232, 1850, 153, 152, 672, 671, 670, 150,
- /* 630 */ 619, 11, 623, 9, 2178, 181, 1497, 536, 2113, 2173,
- /* 640 */ 587, 235, 530, 1139, 1668, 1138, 131, 231, 1427, 1667,
- /* 650 */ 607, 2033, 1911, 518, 13, 12, 675, 11, 218, 640,
- /* 660 */ 193, 45, 43, 1799, 1983, 270, 639, 1446, 389, 374,
- /* 670 */ 269, 1421, 677, 46, 1140, 153, 152, 672, 671, 670,
- /* 680 */ 150, 1427, 1502, 68, 1419, 1206, 67, 1387, 1983, 238,
- /* 690 */ 582, 577, 571, 1983, 2014, 730, 82, 141, 2050, 81,
- /* 700 */ 2074, 167, 2016, 643, 2018, 2019, 638, 1497, 633, 586,
- /* 710 */ 1504, 1505, 562, 2172, 524, 523, 2172, 38, 37, 1427,
- /* 720 */ 1208, 44, 42, 41, 40, 39, 609, 299, 585, 181,
- /* 730 */ 1829, 2178, 181, 2173, 587, 1689, 2173, 587, 701, 699,
- /* 740 */ 1477, 1487, 563, 2140, 14, 33, 1503, 1506, 623, 1545,
- /* 750 */ 668, 38, 37, 27, 598, 44, 42, 41, 40, 39,
- /* 760 */ 184, 1422, 417, 1420, 38, 37, 730, 1852, 44, 42,
- /* 770 */ 41, 40, 39, 618, 367, 1911, 1666, 689, 625, 1799,
- /* 780 */ 2075, 1504, 1505, 1850, 725, 139, 1425, 1426, 1774, 1476,
- /* 790 */ 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 635, 631,
- /* 800 */ 1495, 1496, 1498, 1499, 1500, 1501, 2, 85, 627, 1478,
- /* 810 */ 2075, 1477, 1487, 330, 1784, 1444, 1897, 1503, 1506, 1852,
- /* 820 */ 1983, 135, 450, 380, 623, 464, 378, 189, 463, 2176,
- /* 830 */ 1794, 163, 1422, 1786, 1420, 1850, 387, 99, 418, 669,
- /* 840 */ 1801, 1790, 1843, 433, 50, 465, 3, 1665, 435, 182,
- /* 850 */ 2111, 2112, 1997, 137, 2116, 1799, 1782, 1425, 1426, 1792,
- /* 860 */ 1476, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 635,
- /* 870 */ 631, 1495, 1496, 1498, 1499, 1500, 1501, 2, 623, 623,
- /* 880 */ 562, 1576, 1569, 164, 2172, 1993, 1999, 1446, 305, 345,
- /* 890 */ 1712, 1983, 427, 442, 667, 675, 633, 623, 623, 2178,
- /* 900 */ 181, 423, 303, 71, 2173, 587, 70, 1852, 8, 1799,
- /* 910 */ 1799, 443, 491, 1449, 153, 152, 672, 671, 670, 150,
- /* 920 */ 162, 1897, 1897, 1851, 201, 470, 468, 673, 1799, 1799,
- /* 930 */ 1843, 461, 191, 195, 455, 454, 453, 452, 449, 448,
- /* 940 */ 447, 446, 445, 441, 440, 439, 438, 329, 430, 429,
- /* 950 */ 428, 1664, 425, 424, 343, 707, 706, 705, 704, 384,
- /* 960 */ 60, 703, 702, 143, 697, 696, 695, 694, 693, 692,
- /* 970 */ 691, 155, 687, 686, 685, 383, 382, 682, 681, 680,
- /* 980 */ 679, 678, 674, 386, 690, 1843, 1769, 590, 1663, 623,
- /* 990 */ 1512, 549, 371, 370, 2177, 1983, 1446, 623, 2172, 107,
- /* 1000 */ 38, 37, 1435, 1796, 44, 42, 41, 40, 39, 1125,
- /* 1010 */ 1126, 236, 623, 1502, 2176, 1428, 1641, 1642, 2173, 2174,
- /* 1020 */ 1799, 1662, 623, 1449, 2123, 1565, 558, 562, 1799, 1478,
- /* 1030 */ 623, 2172, 1983, 1661, 1660, 562, 602, 151, 1497, 2172,
- /* 1040 */ 79, 78, 416, 1799, 606, 188, 2178, 181, 623, 2015,
- /* 1050 */ 1427, 2173, 587, 1799, 2178, 181, 1970, 190, 1657, 2173,
- /* 1060 */ 587, 1799, 280, 328, 2002, 1983, 404, 623, 402, 398,
- /* 1070 */ 394, 391, 388, 239, 72, 1997, 2015, 1983, 1983, 1799,
- /* 1080 */ 2033, 620, 623, 1702, 1656, 623, 623, 151, 640, 53,
- /* 1090 */ 1659, 589, 1655, 1983, 630, 639, 621, 629, 1799, 286,
- /* 1100 */ 381, 1654, 1983, 1653, 396, 529, 1429, 2033, 1993, 1999,
- /* 1110 */ 1754, 184, 1652, 1799, 1565, 601, 1799, 1799, 224, 633,
- /* 1120 */ 1983, 222, 639, 2014, 80, 1568, 1651, 2050, 1983, 1650,
- /* 1130 */ 108, 2016, 643, 2018, 2019, 638, 1983, 633, 1478, 1393,
- /* 1140 */ 142, 2015, 148, 2074, 2103, 1983, 517, 1983, 368, 2099,
- /* 1150 */ 2014, 1649, 226, 634, 2050, 225, 1983, 108, 2016, 643,
- /* 1160 */ 2018, 2019, 638, 1436, 633, 1431, 151, 243, 516, 178,
- /* 1170 */ 1983, 2103, 2033, 1983, 1695, 368, 2099, 145, 228, 133,
- /* 1180 */ 640, 227, 242, 62, 2143, 1983, 1693, 639, 1439, 1441,
- /* 1190 */ 248, 230, 151, 1168, 229, 1983, 531, 2130, 2004, 2015,
- /* 1200 */ 47, 631, 1495, 1496, 1498, 1499, 1500, 1501, 534, 273,
- /* 1210 */ 591, 683, 69, 149, 151, 2014, 13, 12, 1396, 2050,
- /* 1220 */ 62, 89, 108, 2016, 643, 2018, 2019, 638, 1169, 633,
- /* 1230 */ 2033, 261, 2015, 1187, 2192, 1596, 2103, 47, 640, 1523,
- /* 1240 */ 368, 2099, 250, 1983, 605, 639, 2006, 684, 47, 647,
- /* 1250 */ 149, 2137, 1358, 151, 217, 134, 1432, 574, 255, 2034,
- /* 1260 */ 149, 278, 385, 2033, 615, 282, 1239, 1683, 1906, 1185,
- /* 1270 */ 1840, 640, 1539, 2014, 2133, 599, 1983, 2050, 639, 260,
- /* 1280 */ 108, 2016, 643, 2018, 2019, 638, 263, 633, 1, 1488,
- /* 1290 */ 2015, 390, 2192, 4, 2103, 395, 342, 1380, 368, 2099,
- /* 1300 */ 298, 1267, 1271, 293, 194, 1278, 2014, 1276, 422, 2150,
- /* 1310 */ 2050, 1449, 154, 108, 2016, 643, 2018, 2019, 638, 1907,
- /* 1320 */ 633, 2033, 426, 459, 431, 2192, 1444, 2103, 444, 640,
- /* 1330 */ 451, 368, 2099, 1899, 1983, 458, 639, 460, 466, 467,
- /* 1340 */ 1450, 198, 569, 469, 471, 472, 481, 1452, 204, 484,
- /* 1350 */ 1447, 206, 485, 1451, 486, 1453, 487, 1142, 489, 512,
- /* 1360 */ 209, 211, 493, 1960, 2014, 83, 84, 215, 2050, 510,
- /* 1370 */ 2015, 108, 2016, 643, 2018, 2019, 638, 511, 633, 331,
- /* 1380 */ 548, 514, 1959, 2192, 111, 2103, 1789, 221, 550, 368,
- /* 1390 */ 2099, 87, 1785, 2015, 223, 156, 157, 147, 1787, 294,
- /* 1400 */ 2166, 2033, 1783, 237, 158, 552, 159, 553, 556, 640,
- /* 1410 */ 240, 559, 2149, 2134, 1983, 575, 639, 2148, 613, 7,
- /* 1420 */ 584, 2125, 566, 2144, 2033, 572, 254, 171, 357, 256,
- /* 1430 */ 578, 567, 640, 257, 565, 358, 564, 1983, 246, 639,
- /* 1440 */ 2195, 258, 249, 595, 2014, 592, 2171, 1565, 2050, 138,
- /* 1450 */ 1448, 108, 2016, 643, 2018, 2019, 638, 262, 633, 361,
- /* 1460 */ 2015, 268, 603, 2192, 259, 2103, 1454, 2014, 94, 368,
- /* 1470 */ 2099, 2050, 2119, 1912, 108, 2016, 643, 2018, 2019, 638,
- /* 1480 */ 2122, 633, 295, 611, 2015, 612, 2078, 1926, 2103, 296,
- /* 1490 */ 1925, 2033, 368, 2099, 616, 96, 1924, 297, 617, 640,
- /* 1500 */ 1800, 364, 98, 59, 1983, 2084, 639, 100, 645, 1844,
- /* 1510 */ 1770, 729, 726, 289, 300, 2033, 727, 324, 333, 334,
- /* 1520 */ 309, 51, 304, 640, 302, 1977, 1976, 323, 1983, 76,
- /* 1530 */ 639, 1975, 2015, 77, 2014, 313, 1974, 1971, 2050, 392,
- /* 1540 */ 393, 108, 2016, 643, 2018, 2019, 638, 1413, 633, 1414,
- /* 1550 */ 187, 397, 1969, 2076, 399, 2103, 2015, 400, 2014, 368,
- /* 1560 */ 2099, 401, 2050, 2033, 1968, 108, 2016, 643, 2018, 2019,
- /* 1570 */ 638, 640, 633, 403, 1967, 405, 1983, 626, 639, 2103,
- /* 1580 */ 1966, 407, 1965, 368, 2099, 409, 1383, 2033, 1382, 1937,
- /* 1590 */ 1936, 1935, 414, 415, 1934, 640, 1335, 1890, 1889, 1887,
- /* 1600 */ 1983, 1886, 639, 144, 1885, 1888, 2014, 1884, 1883, 1881,
- /* 1610 */ 2050, 1880, 1879, 109, 2016, 643, 2018, 2019, 638, 192,
- /* 1620 */ 633, 432, 2015, 1878, 434, 1892, 1877, 2103, 1876, 1875,
- /* 1630 */ 2014, 2102, 2099, 1874, 2050, 1873, 1872, 109, 2016, 643,
- /* 1640 */ 2018, 2019, 638, 1871, 633, 2015, 1870, 1869, 1868, 1867,
- /* 1650 */ 1866, 2103, 1865, 2033, 1864, 628, 2099, 1863, 146, 1862,
- /* 1660 */ 1861, 640, 1860, 1891, 1859, 1858, 1983, 1337, 639, 1857,
- /* 1670 */ 1856, 1855, 1854, 462, 1853, 1214, 2033, 1717, 199, 1716,
- /* 1680 */ 200, 1714, 1678, 202, 637, 2003, 176, 1128, 1677, 1983,
- /* 1690 */ 74, 639, 1127, 203, 1950, 1944, 641, 75, 1933, 1932,
- /* 1700 */ 2050, 210, 477, 109, 2016, 643, 2018, 2019, 638, 1910,
- /* 1710 */ 633, 1778, 1713, 2015, 479, 208, 1711, 2103, 494, 2014,
- /* 1720 */ 1709, 336, 2099, 2050, 496, 1161, 321, 2016, 643, 2018,
- /* 1730 */ 2019, 638, 636, 633, 624, 2068, 498, 495, 499, 2015,
- /* 1740 */ 1707, 500, 502, 504, 2033, 503, 1705, 508, 506, 1692,
- /* 1750 */ 1691, 507, 640, 1674, 1780, 1282, 1283, 1983, 1779, 639,
- /* 1760 */ 1205, 1204, 1203, 1202, 1199, 1198, 698, 700, 220, 1197,
- /* 1770 */ 2033, 1196, 61, 1703, 350, 1696, 1694, 351, 640, 352,
- /* 1780 */ 535, 532, 1673, 1983, 1672, 639, 537, 2014, 1671, 541,
- /* 1790 */ 110, 2050, 1405, 1949, 168, 2016, 643, 2018, 2019, 638,
- /* 1800 */ 539, 633, 1943, 1403, 2015, 545, 1402, 1389, 55, 26,
- /* 1810 */ 65, 554, 1931, 2014, 2177, 16, 161, 2050, 1929, 28,
- /* 1820 */ 109, 2016, 643, 2018, 2019, 638, 570, 633, 1611, 2015,
- /* 1830 */ 19, 568, 245, 169, 2103, 2033, 58, 247, 1595, 2100,
- /* 1840 */ 1587, 241, 252, 640, 555, 30, 588, 2193, 1983, 63,
- /* 1850 */ 639, 355, 253, 2004, 251, 29, 560, 5, 90, 21,
- /* 1860 */ 2033, 1626, 2015, 6, 20, 1631, 1625, 17, 640, 359,
- /* 1870 */ 1632, 1630, 1629, 1983, 360, 639, 1562, 1561, 2014, 265,
- /* 1880 */ 172, 56, 2050, 1930, 57, 167, 2016, 643, 2018, 2019,
- /* 1890 */ 638, 1928, 633, 2033, 1927, 2015, 1909, 93, 92, 271,
- /* 1900 */ 272, 640, 22, 2014, 1593, 274, 1983, 2050, 639, 1908,
- /* 1910 */ 315, 2016, 643, 2018, 2019, 638, 279, 633, 66, 95,
- /* 1920 */ 97, 101, 284, 614, 10, 23, 2033, 2141, 12, 281,
- /* 1930 */ 1437, 363, 173, 2053, 640, 1514, 2014, 1492, 632, 1983,
- /* 1940 */ 2050, 639, 36, 168, 2016, 643, 2018, 2019, 638, 1490,
- /* 1950 */ 633, 1524, 1489, 185, 583, 15, 24, 1469, 1461, 25,
- /* 1960 */ 2015, 644, 1268, 1513, 646, 376, 648, 650, 1265, 2014,
- /* 1970 */ 1260, 642, 651, 2050, 1262, 653, 322, 2016, 643, 2018,
- /* 1980 */ 2019, 638, 654, 633, 1256, 2015, 656, 657, 659, 1254,
- /* 1990 */ 660, 2033, 1259, 1245, 102, 1258, 2194, 103, 1257, 637,
- /* 2000 */ 287, 1277, 1273, 1159, 1983, 666, 639, 73, 676, 1193,
- /* 2010 */ 1192, 1191, 1190, 1189, 1188, 688, 2033, 1186, 1184, 1183,
- /* 2020 */ 1182, 373, 1212, 1180, 640, 288, 1179, 1178, 1177, 1983,
- /* 2030 */ 1176, 639, 1175, 1174, 2014, 1209, 1207, 1171, 2050, 1170,
- /* 2040 */ 1167, 321, 2016, 643, 2018, 2019, 638, 2015, 633, 1166,
- /* 2050 */ 2069, 1165, 1164, 1710, 708, 709, 1708, 710, 712, 2014,
- /* 2060 */ 713, 714, 1706, 2050, 2015, 716, 322, 2016, 643, 2018,
- /* 2070 */ 2019, 638, 717, 633, 718, 1704, 720, 722, 2033, 721,
- /* 2080 */ 1690, 724, 1117, 375, 1670, 291, 640, 728, 1645, 1423,
- /* 2090 */ 301, 1983, 731, 639, 732, 2033, 1645, 1645, 1645, 1645,
- /* 2100 */ 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645,
- /* 2110 */ 639, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2120 */ 1645, 2014, 1645, 1645, 2015, 2050, 1645, 1645, 322, 2016,
- /* 2130 */ 643, 2018, 2019, 638, 1645, 633, 1645, 1645, 547, 1645,
- /* 2140 */ 1645, 1645, 2050, 2015, 1645, 317, 2016, 643, 2018, 2019,
- /* 2150 */ 638, 1645, 633, 1645, 1645, 2033, 1645, 1645, 1645, 1645,
- /* 2160 */ 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645,
- /* 2170 */ 639, 1645, 1645, 1645, 2033, 1645, 1645, 1645, 1645, 1645,
- /* 2180 */ 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645, 639,
- /* 2190 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014, 1645,
- /* 2200 */ 1645, 1645, 2050, 2015, 1645, 306, 2016, 643, 2018, 2019,
- /* 2210 */ 638, 1645, 633, 1645, 1645, 1645, 1645, 2014, 1645, 2015,
- /* 2220 */ 1645, 2050, 1645, 1645, 307, 2016, 643, 2018, 2019, 638,
- /* 2230 */ 1645, 633, 1645, 1645, 2033, 1645, 2015, 1645, 1645, 1645,
- /* 2240 */ 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645, 639,
- /* 2250 */ 2033, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 640, 1645,
- /* 2260 */ 1645, 1645, 1645, 1983, 1645, 639, 1645, 2033, 1645, 1645,
- /* 2270 */ 1645, 1645, 1645, 1645, 1645, 640, 1645, 2014, 1645, 1645,
- /* 2280 */ 1983, 2050, 639, 1645, 308, 2016, 643, 2018, 2019, 638,
- /* 2290 */ 1645, 633, 1645, 2014, 1645, 1645, 1645, 2050, 1645, 2015,
- /* 2300 */ 314, 2016, 643, 2018, 2019, 638, 1645, 633, 1645, 1645,
- /* 2310 */ 2014, 1645, 1645, 1645, 2050, 2015, 1645, 318, 2016, 643,
- /* 2320 */ 2018, 2019, 638, 1645, 633, 1645, 1645, 1645, 1645, 1645,
- /* 2330 */ 2033, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 640, 1645,
- /* 2340 */ 1645, 1645, 1645, 1983, 1645, 639, 2033, 1645, 1645, 1645,
- /* 2350 */ 1645, 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983,
- /* 2360 */ 1645, 639, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2370 */ 1645, 2015, 1645, 2014, 1645, 1645, 1645, 2050, 1645, 1645,
- /* 2380 */ 310, 2016, 643, 2018, 2019, 638, 1645, 633, 1645, 2014,
- /* 2390 */ 1645, 1645, 1645, 2050, 2015, 1645, 319, 2016, 643, 2018,
- /* 2400 */ 2019, 638, 2033, 633, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2410 */ 640, 1645, 1645, 1645, 1645, 1983, 1645, 639, 1645, 1645,
- /* 2420 */ 1645, 1645, 1645, 1645, 1645, 2033, 1645, 1645, 1645, 1645,
- /* 2430 */ 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645,
- /* 2440 */ 639, 1645, 1645, 1645, 1645, 2014, 1645, 1645, 1645, 2050,
- /* 2450 */ 1645, 1645, 311, 2016, 643, 2018, 2019, 638, 2015, 633,
- /* 2460 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014, 1645,
- /* 2470 */ 1645, 1645, 2050, 1645, 1645, 320, 2016, 643, 2018, 2019,
- /* 2480 */ 638, 1645, 633, 1645, 1645, 2015, 1645, 1645, 1645, 2033,
- /* 2490 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 640, 1645, 1645,
- /* 2500 */ 1645, 1645, 1983, 1645, 639, 1645, 1645, 1645, 1645, 1645,
- /* 2510 */ 1645, 1645, 1645, 1645, 1645, 1645, 2033, 1645, 1645, 1645,
- /* 2520 */ 1645, 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983,
- /* 2530 */ 1645, 639, 2014, 2015, 1645, 1645, 2050, 1645, 1645, 312,
- /* 2540 */ 2016, 643, 2018, 2019, 638, 1645, 633, 1645, 1645, 2015,
- /* 2550 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014,
- /* 2560 */ 1645, 1645, 1645, 2050, 2033, 1645, 325, 2016, 643, 2018,
- /* 2570 */ 2019, 638, 640, 633, 1645, 1645, 1645, 1983, 1645, 639,
- /* 2580 */ 2033, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 640, 1645,
- /* 2590 */ 1645, 1645, 1645, 1983, 1645, 639, 1645, 2015, 1645, 1645,
- /* 2600 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014, 1645, 1645,
- /* 2610 */ 1645, 2050, 1645, 1645, 326, 2016, 643, 2018, 2019, 638,
- /* 2620 */ 1645, 633, 1645, 2014, 1645, 1645, 1645, 2050, 2033, 1645,
- /* 2630 */ 2027, 2016, 643, 2018, 2019, 638, 640, 633, 1645, 1645,
- /* 2640 */ 1645, 1983, 1645, 639, 1645, 2015, 1645, 1645, 1645, 1645,
- /* 2650 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2660 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2015, 1645,
- /* 2670 */ 1645, 2014, 1645, 1645, 1645, 2050, 2033, 1645, 2026, 2016,
- /* 2680 */ 643, 2018, 2019, 638, 640, 633, 1645, 1645, 1645, 1983,
- /* 2690 */ 1645, 639, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2033,
- /* 2700 */ 1645, 2015, 1645, 1645, 1645, 1645, 1645, 640, 1645, 1645,
- /* 2710 */ 1645, 1645, 1983, 1645, 639, 1645, 1645, 1645, 1645, 2014,
- /* 2720 */ 1645, 1645, 1645, 2050, 2015, 1645, 2025, 2016, 643, 2018,
- /* 2730 */ 2019, 638, 2033, 633, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2740 */ 640, 1645, 2014, 1645, 1645, 1983, 2050, 639, 1645, 338,
- /* 2750 */ 2016, 643, 2018, 2019, 638, 2033, 633, 1645, 1645, 1645,
- /* 2760 */ 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983, 1645,
- /* 2770 */ 639, 1645, 1645, 1645, 1645, 2014, 1645, 1645, 1645, 2050,
- /* 2780 */ 1645, 1645, 339, 2016, 643, 2018, 2019, 638, 2015, 633,
- /* 2790 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014, 1645,
- /* 2800 */ 1645, 1645, 2050, 1645, 1645, 335, 2016, 643, 2018, 2019,
- /* 2810 */ 638, 1645, 633, 1645, 1645, 2015, 1645, 1645, 1645, 2033,
- /* 2820 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 640, 1645, 1645,
- /* 2830 */ 1645, 1645, 1983, 1645, 639, 1645, 1645, 1645, 1645, 1645,
- /* 2840 */ 1645, 1645, 1645, 1645, 1645, 1645, 2033, 1645, 1645, 1645,
- /* 2850 */ 1645, 1645, 1645, 1645, 640, 1645, 1645, 1645, 1645, 1983,
- /* 2860 */ 1645, 639, 2014, 2015, 1645, 1645, 2050, 1645, 1645, 340,
- /* 2870 */ 2016, 643, 2018, 2019, 638, 1645, 633, 1645, 1645, 1645,
- /* 2880 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 641,
- /* 2890 */ 1645, 1645, 1645, 2050, 2033, 1645, 317, 2016, 643, 2018,
- /* 2900 */ 2019, 638, 640, 633, 1645, 1645, 1645, 1983, 1645, 639,
- /* 2910 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2920 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645,
- /* 2930 */ 1645, 1645, 1645, 1645, 1645, 1645, 1645, 2014, 1645, 1645,
- /* 2940 */ 1645, 2050, 1645, 1645, 316, 2016, 643, 2018, 2019, 638,
- /* 2950 */ 1645, 633,
+ /* 0 */ 1937, 2201, 1796, 605, 480, 2196, 481, 1700, 489, 1807,
+ /* 10 */ 481, 1700, 45, 43, 1588, 1935, 617, 31, 176, 178,
+ /* 20 */ 378, 2200, 1437, 38, 37, 2197, 2199, 44, 42, 41,
+ /* 30 */ 40, 39, 1858, 1518, 140, 1435, 1462, 2037, 1871, 346,
+ /* 40 */ 1920, 2023, 38, 37, 611, 356, 44, 42, 41, 40,
+ /* 50 */ 39, 423, 2019, 2201, 1869, 38, 37, 2196, 1513, 44,
+ /* 60 */ 42, 41, 40, 39, 18, 498, 383, 1465, 2055, 1864,
+ /* 70 */ 1866, 1443, 1662, 2200, 167, 605, 644, 2197, 2198, 1772,
+ /* 80 */ 1151, 2005, 1150, 646, 45, 43, 2015, 2021, 359, 568,
+ /* 90 */ 1132, 329, 378, 2196, 1437, 220, 14, 640, 339, 181,
+ /* 100 */ 2133, 2134, 548, 138, 2138, 1518, 140, 1435, 2202, 182,
+ /* 110 */ 600, 1152, 2036, 2197, 594, 546, 2072, 544, 737, 323,
+ /* 120 */ 2038, 650, 2040, 2041, 645, 643, 640, 631, 2090, 1134,
+ /* 130 */ 1513, 1137, 1138, 1520, 1521, 629, 18, 479, 391, 1547,
+ /* 140 */ 484, 1706, 390, 1443, 1687, 1259, 672, 671, 670, 1263,
+ /* 150 */ 669, 1265, 1266, 668, 1268, 665, 176, 1274, 662, 1276,
+ /* 160 */ 1277, 659, 656, 1493, 1503, 1937, 605, 615, 14, 1519,
+ /* 170 */ 1522, 266, 2133, 604, 381, 133, 603, 369, 1921, 2196,
+ /* 180 */ 1934, 617, 161, 568, 1438, 616, 1436, 2196, 2005, 357,
+ /* 190 */ 737, 1820, 629, 269, 592, 182, 1548, 140, 1869, 2197,
+ /* 200 */ 594, 498, 2202, 182, 629, 1520, 1521, 2197, 594, 588,
+ /* 210 */ 1441, 1442, 246, 1492, 1495, 1496, 1497, 1498, 1499, 1500,
+ /* 220 */ 1501, 1502, 642, 638, 1511, 1512, 1514, 1515, 1516, 1517,
+ /* 230 */ 2, 61, 496, 92, 1930, 1493, 1503, 583, 106, 684,
+ /* 240 */ 122, 1519, 1522, 121, 120, 119, 118, 117, 116, 115,
+ /* 250 */ 114, 113, 141, 1592, 350, 166, 1438, 1676, 1436, 1462,
+ /* 260 */ 1810, 607, 180, 2133, 2134, 1461, 138, 2138, 48, 34,
+ /* 270 */ 376, 1542, 1543, 1544, 1545, 1546, 1550, 1551, 1552, 1553,
+ /* 280 */ 48, 61, 1441, 1442, 1219, 1492, 1495, 1496, 1497, 1498,
+ /* 290 */ 1499, 1500, 1501, 1502, 642, 638, 1511, 1512, 1514, 1515,
+ /* 300 */ 1516, 1517, 2, 2023, 11, 45, 43, 44, 42, 41,
+ /* 310 */ 40, 39, 1462, 378, 2019, 1437, 351, 740, 349, 348,
+ /* 320 */ 1221, 521, 589, 584, 577, 523, 1518, 1462, 1435, 488,
+ /* 330 */ 2037, 294, 484, 1706, 605, 35, 287, 38, 37, 601,
+ /* 340 */ 410, 44, 42, 41, 40, 39, 175, 522, 2015, 2021,
+ /* 350 */ 360, 1513, 730, 726, 722, 718, 292, 18, 86, 640,
+ /* 360 */ 486, 2055, 412, 408, 1443, 140, 482, 557, 415, 647,
+ /* 370 */ 414, 2140, 136, 1151, 2005, 1150, 646, 45, 43, 1523,
+ /* 380 */ 1463, 1813, 2201, 185, 11, 378, 9, 1437, 61, 14,
+ /* 390 */ 278, 279, 65, 107, 413, 277, 285, 2137, 1518, 1464,
+ /* 400 */ 1435, 632, 1494, 2097, 1152, 2036, 1733, 630, 1686, 2072,
+ /* 410 */ 630, 737, 168, 2038, 650, 2040, 2041, 645, 1665, 640,
+ /* 420 */ 185, 132, 676, 1513, 187, 1862, 1520, 1521, 519, 626,
+ /* 430 */ 183, 2133, 2134, 185, 138, 2138, 1443, 630, 1818, 122,
+ /* 440 */ 11, 1818, 121, 120, 119, 118, 117, 116, 115, 114,
+ /* 450 */ 113, 132, 2005, 569, 2162, 194, 1493, 1503, 524, 1871,
+ /* 460 */ 100, 46, 1519, 1522, 272, 634, 366, 2097, 1818, 271,
+ /* 470 */ 1357, 1358, 534, 533, 532, 1869, 1650, 1438, 2026, 1436,
+ /* 480 */ 137, 528, 1811, 737, 61, 527, 1401, 461, 240, 1901,
+ /* 490 */ 526, 531, 83, 1302, 1303, 82, 525, 236, 1520, 1521,
+ /* 500 */ 1865, 1866, 1463, 1441, 1442, 1657, 1492, 1495, 1496, 1497,
+ /* 510 */ 1498, 1499, 1500, 1501, 1502, 642, 638, 1511, 1512, 1514,
+ /* 520 */ 1515, 1516, 1517, 2, 534, 533, 532, 2028, 1493, 1503,
+ /* 530 */ 1664, 1871, 137, 528, 1519, 1522, 630, 527, 344, 630,
+ /* 540 */ 185, 1464, 526, 531, 268, 198, 197, 1869, 525, 1438,
+ /* 550 */ 54, 1436, 616, 421, 131, 130, 129, 128, 127, 126,
+ /* 560 */ 125, 124, 123, 1412, 1413, 417, 1181, 1818, 460, 416,
+ /* 570 */ 1818, 41, 40, 39, 2037, 1441, 1442, 616, 1492, 1495,
+ /* 580 */ 1496, 1497, 1498, 1499, 1500, 1501, 1502, 642, 638, 1511,
+ /* 590 */ 1512, 1514, 1515, 1516, 1517, 2, 45, 43, 1446, 614,
+ /* 600 */ 1916, 1930, 1182, 1656, 378, 2055, 1437, 630, 593, 630,
+ /* 610 */ 568, 190, 2196, 647, 2196, 1374, 1375, 1518, 2005, 1435,
+ /* 620 */ 646, 422, 221, 431, 625, 61, 1930, 592, 182, 2202,
+ /* 630 */ 182, 49, 2197, 594, 2197, 594, 185, 171, 1818, 1685,
+ /* 640 */ 1818, 441, 1513, 515, 511, 507, 503, 218, 630, 2036,
+ /* 650 */ 440, 1373, 1376, 2072, 1616, 1443, 110, 2038, 650, 2040,
+ /* 660 */ 2041, 645, 446, 640, 424, 370, 1528, 1684, 45, 43,
+ /* 670 */ 2125, 1465, 1462, 164, 2124, 2121, 378, 425, 1437, 1818,
+ /* 680 */ 46, 539, 1820, 2005, 87, 1683, 268, 216, 1443, 1518,
+ /* 690 */ 1682, 1435, 142, 38, 37, 2096, 549, 44, 42, 41,
+ /* 700 */ 40, 39, 737, 580, 579, 1614, 1615, 1617, 1618, 1619,
+ /* 710 */ 234, 2005, 1871, 1809, 1513, 38, 37, 1520, 1521, 44,
+ /* 720 */ 42, 41, 40, 39, 2019, 542, 33, 1443, 1870, 2005,
+ /* 730 */ 536, 1795, 38, 37, 2005, 233, 44, 42, 41, 40,
+ /* 740 */ 39, 1681, 593, 1680, 1679, 1549, 2196, 1493, 1503, 1449,
+ /* 750 */ 630, 27, 14, 1519, 1522, 215, 209, 675, 2015, 2021,
+ /* 760 */ 214, 592, 182, 494, 447, 1803, 2197, 594, 1438, 640,
+ /* 770 */ 1436, 164, 69, 1678, 737, 68, 2055, 185, 1675, 207,
+ /* 780 */ 1821, 1818, 1627, 185, 587, 2005, 1974, 2005, 2005, 1520,
+ /* 790 */ 1521, 1674, 13, 12, 1441, 1442, 696, 1492, 1495, 1496,
+ /* 800 */ 1497, 1498, 1499, 1500, 1501, 1502, 642, 638, 1511, 1512,
+ /* 810 */ 1514, 1515, 1516, 1517, 2, 1494, 191, 2005, 32, 1493,
+ /* 820 */ 1503, 332, 2005, 1460, 682, 1519, 1522, 235, 1554, 586,
+ /* 830 */ 454, 86, 237, 468, 1871, 2005, 467, 1137, 1138, 682,
+ /* 840 */ 1438, 371, 1436, 154, 153, 679, 678, 677, 151, 1673,
+ /* 850 */ 1869, 437, 1465, 469, 1814, 1794, 439, 1916, 154, 153,
+ /* 860 */ 679, 678, 677, 151, 530, 529, 1441, 1442, 192, 1492,
+ /* 870 */ 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 642, 638,
+ /* 880 */ 1511, 1512, 1514, 1515, 1516, 1517, 2, 381, 1561, 563,
+ /* 890 */ 89, 334, 165, 2005, 355, 164, 550, 307, 347, 1730,
+ /* 900 */ 630, 38, 37, 1793, 1820, 44, 42, 41, 40, 39,
+ /* 910 */ 427, 305, 72, 1805, 497, 71, 1672, 8, 684, 38,
+ /* 920 */ 37, 1871, 384, 44, 42, 41, 40, 39, 382, 301,
+ /* 930 */ 164, 1818, 1848, 203, 476, 474, 471, 1869, 2140, 1820,
+ /* 940 */ 465, 708, 706, 459, 458, 457, 456, 453, 452, 451,
+ /* 950 */ 450, 449, 445, 444, 443, 442, 331, 434, 433, 432,
+ /* 960 */ 2005, 429, 428, 345, 2136, 714, 713, 712, 711, 388,
+ /* 970 */ 61, 710, 709, 144, 704, 703, 702, 701, 700, 699,
+ /* 980 */ 698, 156, 694, 693, 692, 387, 386, 689, 688, 687,
+ /* 990 */ 686, 685, 630, 630, 1671, 38, 37, 245, 1998, 44,
+ /* 1000 */ 42, 41, 40, 39, 1437, 630, 1815, 238, 1604, 108,
+ /* 1010 */ 2037, 682, 2200, 630, 630, 630, 1585, 1435, 697, 627,
+ /* 1020 */ 1788, 1670, 1669, 1818, 1818, 1668, 1667, 628, 564, 609,
+ /* 1030 */ 154, 153, 679, 678, 677, 151, 1818, 1916, 2005, 523,
+ /* 1040 */ 51, 2055, 3, 568, 1818, 1818, 1818, 2196, 196, 608,
+ /* 1050 */ 80, 79, 420, 1443, 2005, 189, 646, 630, 163, 2037,
+ /* 1060 */ 2140, 522, 2202, 182, 152, 2005, 2005, 2197, 594, 2005,
+ /* 1070 */ 2005, 613, 680, 2023, 330, 1862, 1462, 406, 73, 404,
+ /* 1080 */ 400, 396, 393, 413, 2019, 2036, 2135, 244, 1818, 2072,
+ /* 1090 */ 2055, 2024, 109, 2038, 650, 2040, 2041, 645, 647, 640,
+ /* 1100 */ 737, 597, 2019, 2005, 179, 646, 2125, 2145, 1581, 630,
+ /* 1110 */ 372, 2121, 681, 1991, 146, 1862, 134, 53, 2015, 2021,
+ /* 1120 */ 373, 630, 185, 282, 184, 1581, 2037, 90, 81, 640,
+ /* 1130 */ 1999, 1801, 2151, 152, 2036, 288, 2015, 2021, 2072, 674,
+ /* 1140 */ 1818, 109, 2038, 650, 2040, 2041, 645, 640, 640, 630,
+ /* 1150 */ 152, 143, 1818, 149, 2096, 2125, 241, 2055, 2037, 372,
+ /* 1160 */ 2121, 398, 1720, 385, 226, 608, 1438, 224, 1436, 1713,
+ /* 1170 */ 2005, 228, 646, 230, 227, 568, 229, 63, 232, 2196,
+ /* 1180 */ 1818, 231, 63, 250, 535, 552, 1407, 551, 637, 2055,
+ /* 1190 */ 1677, 537, 1441, 1442, 2202, 182, 1711, 647, 641, 2197,
+ /* 1200 */ 594, 2036, 2005, 1410, 646, 2072, 1445, 2037, 109, 2038,
+ /* 1210 */ 650, 2040, 2041, 645, 52, 640, 1659, 1660, 540, 1494,
+ /* 1220 */ 179, 567, 2125, 152, 47, 1707, 372, 2121, 275, 2165,
+ /* 1230 */ 1613, 70, 150, 2036, 152, 1612, 252, 2072, 2055, 1773,
+ /* 1240 */ 109, 2038, 650, 2040, 2041, 645, 647, 640, 2152, 13,
+ /* 1250 */ 12, 2005, 2216, 646, 2125, 105, 63, 555, 372, 2121,
+ /* 1260 */ 47, 1584, 47, 654, 150, 102, 2037, 263, 581, 2159,
+ /* 1270 */ 219, 152, 135, 690, 732, 257, 612, 1371, 596, 150,
+ /* 1280 */ 2056, 280, 2036, 389, 622, 284, 2072, 1252, 1701, 109,
+ /* 1290 */ 2038, 650, 2040, 2041, 645, 1200, 640, 2055, 691, 1925,
+ /* 1300 */ 2037, 2216, 568, 2125, 1859, 647, 2196, 372, 2121, 1555,
+ /* 1310 */ 2005, 2155, 646, 1504, 606, 300, 1280, 1284, 2172, 265,
+ /* 1320 */ 1198, 2202, 182, 262, 1291, 1289, 2197, 594, 598, 1,
+ /* 1330 */ 4, 2055, 155, 392, 1539, 397, 1394, 295, 195, 647,
+ /* 1340 */ 343, 2036, 426, 1465, 2005, 2072, 646, 1926, 109, 2038,
+ /* 1350 */ 650, 2040, 2041, 645, 430, 640, 463, 1448, 435, 1460,
+ /* 1360 */ 2216, 448, 2125, 1918, 462, 455, 372, 2121, 464, 470,
+ /* 1370 */ 472, 200, 473, 2037, 475, 2036, 477, 575, 1466, 2072,
+ /* 1380 */ 478, 487, 109, 2038, 650, 2040, 2041, 645, 1468, 640,
+ /* 1390 */ 206, 490, 375, 374, 2216, 1463, 2125, 208, 491, 1467,
+ /* 1400 */ 372, 2121, 1451, 492, 2055, 1469, 493, 211, 495, 499,
+ /* 1410 */ 213, 2190, 647, 1518, 84, 1444, 1154, 2005, 518, 646,
+ /* 1420 */ 85, 217, 2037, 516, 517, 112, 333, 88, 520, 1808,
+ /* 1430 */ 1980, 554, 556, 1979, 148, 296, 223, 239, 1513, 1804,
+ /* 1440 */ 558, 225, 242, 559, 565, 2156, 157, 582, 2036, 158,
+ /* 1450 */ 1806, 1443, 2072, 2055, 1802, 109, 2038, 650, 2040, 2041,
+ /* 1460 */ 645, 647, 640, 159, 160, 2171, 2005, 2216, 646, 2125,
+ /* 1470 */ 620, 572, 562, 372, 2121, 2166, 7, 2170, 578, 361,
+ /* 1480 */ 591, 571, 585, 573, 2144, 2147, 2037, 248, 251, 256,
+ /* 1490 */ 172, 570, 258, 259, 2219, 139, 260, 2036, 636, 362,
+ /* 1500 */ 264, 2072, 602, 599, 109, 2038, 650, 2040, 2041, 645,
+ /* 1510 */ 1581, 640, 1464, 2195, 610, 270, 2100, 2055, 2125, 261,
+ /* 1520 */ 2141, 365, 372, 2121, 1470, 647, 95, 297, 1931, 623,
+ /* 1530 */ 2005, 618, 646, 619, 298, 1945, 1944, 624, 1943, 368,
+ /* 1540 */ 97, 99, 60, 299, 1819, 2106, 101, 1789, 652, 291,
+ /* 1550 */ 302, 1863, 733, 326, 2037, 734, 311, 335, 336, 736,
+ /* 1560 */ 325, 2036, 50, 315, 1452, 2072, 1447, 306, 109, 2038,
+ /* 1570 */ 650, 2040, 2041, 645, 1997, 640, 1996, 1995, 304, 77,
+ /* 1580 */ 2098, 1992, 2125, 394, 2037, 2055, 372, 2121, 395, 1428,
+ /* 1590 */ 1455, 1457, 1429, 647, 188, 399, 1990, 401, 2005, 402,
+ /* 1600 */ 646, 403, 1989, 638, 1511, 1512, 1514, 1515, 1516, 1517,
+ /* 1610 */ 405, 1988, 1987, 407, 2037, 2055, 409, 1986, 78, 411,
+ /* 1620 */ 1397, 1396, 1957, 647, 1956, 1955, 1954, 418, 2005, 2036,
+ /* 1630 */ 646, 419, 1953, 2072, 1348, 1909, 109, 2038, 650, 2040,
+ /* 1640 */ 2041, 645, 1908, 640, 2037, 2055, 1906, 145, 633, 1905,
+ /* 1650 */ 2125, 1904, 1907, 647, 372, 2121, 1903, 1902, 2005, 2036,
+ /* 1660 */ 646, 1900, 1899, 2072, 193, 436, 110, 2038, 650, 2040,
+ /* 1670 */ 2041, 645, 1898, 640, 1897, 2055, 438, 1911, 2037, 1896,
+ /* 1680 */ 2125, 1895, 1894, 647, 635, 2121, 1893, 1892, 2005, 648,
+ /* 1690 */ 646, 1891, 1890, 2072, 1889, 1888, 110, 2038, 650, 2040,
+ /* 1700 */ 2041, 645, 1887, 640, 1886, 2037, 1885, 1884, 1883, 2055,
+ /* 1710 */ 2125, 1882, 147, 1881, 338, 2121, 1880, 647, 1879, 2036,
+ /* 1720 */ 1910, 1878, 2005, 2072, 646, 1877, 169, 2038, 650, 2040,
+ /* 1730 */ 2041, 645, 1350, 640, 1876, 1875, 2055, 1874, 1873, 466,
+ /* 1740 */ 1872, 1736, 199, 1735, 647, 1734, 201, 1227, 202, 2005,
+ /* 1750 */ 1732, 646, 2025, 2036, 2037, 1696, 204, 2072, 75, 177,
+ /* 1760 */ 168, 2038, 650, 2040, 2041, 645, 1695, 640, 1140, 483,
+ /* 1770 */ 1139, 485, 205, 1970, 1964, 76, 1952, 1951, 595, 2217,
+ /* 1780 */ 2036, 210, 212, 1929, 2072, 2055, 1797, 110, 2038, 650,
+ /* 1790 */ 2040, 2041, 645, 647, 640, 1174, 1731, 1729, 2005, 500,
+ /* 1800 */ 646, 2125, 2163, 1727, 502, 501, 2122, 504, 505, 506,
+ /* 1810 */ 1725, 509, 1723, 508, 510, 512, 2037, 513, 1710, 1709,
+ /* 1820 */ 514, 1692, 1799, 1296, 1295, 1798, 1218, 1217, 62, 2036,
+ /* 1830 */ 222, 705, 1721, 2072, 1216, 1215, 317, 2038, 650, 2040,
+ /* 1840 */ 2041, 645, 707, 640, 1212, 1210, 1211, 2055, 2037, 1209,
+ /* 1850 */ 352, 1714, 353, 1712, 538, 647, 354, 1691, 1690, 541,
+ /* 1860 */ 2005, 543, 646, 1689, 545, 547, 111, 26, 1417, 1969,
+ /* 1870 */ 1418, 1416, 1403, 1963, 55, 1950, 560, 1948, 66, 2055,
+ /* 1880 */ 590, 1420, 561, 162, 367, 2201, 19, 647, 16, 28,
+ /* 1890 */ 247, 2036, 2005, 243, 646, 2072, 358, 2037, 169, 2038,
+ /* 1900 */ 650, 2040, 2041, 645, 1629, 640, 566, 574, 58, 576,
+ /* 1910 */ 249, 5, 59, 1611, 2037, 254, 6, 1603, 20, 255,
+ /* 1920 */ 30, 2026, 64, 2036, 1649, 17, 1644, 2072, 2055, 21,
+ /* 1930 */ 324, 2038, 650, 2040, 2041, 645, 644, 640, 1650, 1643,
+ /* 1940 */ 170, 2005, 363, 646, 253, 2055, 2037, 1648, 29, 1647,
+ /* 1950 */ 377, 2218, 91, 647, 57, 364, 1578, 1577, 2005, 1949,
+ /* 1960 */ 646, 1947, 1946, 267, 173, 1928, 93, 94, 273, 1927,
+ /* 1970 */ 96, 2037, 2036, 621, 56, 22, 2072, 2055, 23, 323,
+ /* 1980 */ 2038, 650, 2040, 2041, 645, 647, 640, 274, 2091, 2036,
+ /* 1990 */ 2005, 1609, 646, 2072, 102, 2037, 324, 2038, 650, 2040,
+ /* 2000 */ 2041, 645, 2055, 640, 276, 281, 283, 379, 12, 67,
+ /* 2010 */ 647, 286, 1453, 174, 98, 2005, 1530, 646, 1540, 2075,
+ /* 2020 */ 2037, 553, 10, 1508, 1506, 2072, 2055, 1505, 319, 2038,
+ /* 2030 */ 650, 2040, 2041, 645, 647, 640, 639, 1529, 36, 2005,
+ /* 2040 */ 15, 646, 24, 649, 186, 1477, 2036, 1485, 25, 653,
+ /* 2050 */ 2072, 2055, 651, 324, 2038, 650, 2040, 2041, 645, 647,
+ /* 2060 */ 640, 380, 657, 655, 2005, 1281, 646, 1278, 1275, 658,
+ /* 2070 */ 2036, 660, 661, 663, 2072, 1269, 664, 308, 2038, 650,
+ /* 2080 */ 2040, 2041, 645, 2037, 640, 1267, 666, 667, 1258, 103,
+ /* 2090 */ 673, 289, 1290, 1286, 1273, 2036, 104, 1272, 74, 2072,
+ /* 2100 */ 1172, 1271, 309, 2038, 650, 2040, 2041, 645, 683, 640,
+ /* 2110 */ 2037, 1206, 1270, 1205, 2055, 1204, 1203, 1202, 1201, 1225,
+ /* 2120 */ 1199, 1197, 647, 1196, 1195, 695, 1193, 2005, 1192, 646,
+ /* 2130 */ 1191, 290, 2037, 1189, 1190, 1188, 1187, 1220, 1222, 1184,
+ /* 2140 */ 1183, 2055, 1180, 1179, 1178, 1177, 1728, 716, 715, 647,
+ /* 2150 */ 1726, 719, 1724, 717, 2005, 1722, 646, 720, 2036, 721,
+ /* 2160 */ 723, 1708, 2072, 2055, 727, 310, 2038, 650, 2040, 2041,
+ /* 2170 */ 645, 647, 640, 725, 724, 728, 2005, 729, 646, 731,
+ /* 2180 */ 1129, 1688, 293, 735, 738, 2036, 1439, 303, 739, 2072,
+ /* 2190 */ 1663, 1663, 316, 2038, 650, 2040, 2041, 645, 1663, 640,
+ /* 2200 */ 1663, 1663, 1663, 1663, 1663, 1663, 1663, 2036, 1663, 1663,
+ /* 2210 */ 1663, 2072, 2037, 1663, 320, 2038, 650, 2040, 2041, 645,
+ /* 2220 */ 1663, 640, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 2037,
+ /* 2230 */ 1663, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 1663,
+ /* 2240 */ 1663, 1663, 1663, 2055, 1663, 1663, 2037, 1663, 1663, 1663,
+ /* 2250 */ 1663, 647, 1663, 1663, 1663, 1663, 2005, 1663, 646, 1663,
+ /* 2260 */ 2055, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 647, 1663,
+ /* 2270 */ 1663, 1663, 1663, 2005, 1663, 646, 1663, 2055, 2037, 1663,
+ /* 2280 */ 1663, 1663, 1663, 1663, 1663, 647, 1663, 2036, 1663, 1663,
+ /* 2290 */ 2005, 2072, 646, 1663, 312, 2038, 650, 2040, 2041, 645,
+ /* 2300 */ 1663, 640, 1663, 2037, 2036, 1663, 1663, 1663, 2072, 2055,
+ /* 2310 */ 1663, 321, 2038, 650, 2040, 2041, 645, 647, 640, 1663,
+ /* 2320 */ 1663, 2036, 2005, 1663, 646, 2072, 1663, 2037, 313, 2038,
+ /* 2330 */ 650, 2040, 2041, 645, 2055, 640, 1663, 1663, 1663, 1663,
+ /* 2340 */ 1663, 1663, 647, 1663, 1663, 1663, 1663, 2005, 1663, 646,
+ /* 2350 */ 1663, 1663, 2037, 2036, 1663, 1663, 1663, 2072, 2055, 1663,
+ /* 2360 */ 322, 2038, 650, 2040, 2041, 645, 647, 640, 1663, 1663,
+ /* 2370 */ 1663, 2005, 1663, 646, 1663, 1663, 1663, 1663, 2036, 1663,
+ /* 2380 */ 1663, 1663, 2072, 2055, 1663, 314, 2038, 650, 2040, 2041,
+ /* 2390 */ 645, 647, 640, 1663, 1663, 1663, 2005, 1663, 646, 1663,
+ /* 2400 */ 1663, 1663, 2036, 1663, 1663, 1663, 2072, 1663, 1663, 327,
+ /* 2410 */ 2038, 650, 2040, 2041, 645, 2037, 640, 1663, 1663, 1663,
+ /* 2420 */ 1663, 1663, 1663, 1663, 1663, 1663, 1663, 2036, 1663, 1663,
+ /* 2430 */ 1663, 2072, 1663, 1663, 328, 2038, 650, 2040, 2041, 645,
+ /* 2440 */ 1663, 640, 2037, 1663, 1663, 1663, 2055, 1663, 1663, 1663,
+ /* 2450 */ 1663, 1663, 1663, 1663, 647, 1663, 1663, 1663, 1663, 2005,
+ /* 2460 */ 1663, 646, 1663, 1663, 2037, 1663, 1663, 1663, 1663, 1663,
+ /* 2470 */ 1663, 1663, 1663, 2055, 1663, 1663, 1663, 1663, 1663, 1663,
+ /* 2480 */ 1663, 647, 1663, 1663, 1663, 1663, 2005, 1663, 646, 1663,
+ /* 2490 */ 2036, 1663, 1663, 1663, 2072, 2055, 1663, 2049, 2038, 650,
+ /* 2500 */ 2040, 2041, 645, 647, 640, 1663, 1663, 1663, 2005, 1663,
+ /* 2510 */ 646, 1663, 1663, 1663, 1663, 1663, 1663, 2036, 1663, 1663,
+ /* 2520 */ 1663, 2072, 1663, 1663, 2048, 2038, 650, 2040, 2041, 645,
+ /* 2530 */ 1663, 640, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 2036,
+ /* 2540 */ 1663, 1663, 1663, 2072, 2037, 1663, 2047, 2038, 650, 2040,
+ /* 2550 */ 2041, 645, 1663, 640, 1663, 1663, 1663, 1663, 1663, 1663,
+ /* 2560 */ 1663, 2037, 1663, 1663, 1663, 1663, 1663, 1663, 1663, 1663,
+ /* 2570 */ 1663, 1663, 1663, 1663, 1663, 2055, 1663, 1663, 2037, 1663,
+ /* 2580 */ 1663, 1663, 1663, 647, 1663, 1663, 1663, 1663, 2005, 1663,
+ /* 2590 */ 646, 1663, 2055, 1663, 1663, 1663, 1663, 1663, 1663, 1663,
+ /* 2600 */ 647, 1663, 1663, 1663, 1663, 2005, 1663, 646, 1663, 2055,
+ /* 2610 */ 2037, 1663, 1663, 1663, 1663, 1663, 1663, 647, 1663, 2036,
+ /* 2620 */ 1663, 1663, 2005, 2072, 646, 1663, 340, 2038, 650, 2040,
+ /* 2630 */ 2041, 645, 1663, 640, 1663, 2037, 2036, 1663, 1663, 1663,
+ /* 2640 */ 2072, 2055, 1663, 341, 2038, 650, 2040, 2041, 645, 647,
+ /* 2650 */ 640, 1663, 1663, 2036, 2005, 1663, 646, 2072, 1663, 2037,
+ /* 2660 */ 337, 2038, 650, 2040, 2041, 645, 2055, 640, 1663, 1663,
+ /* 2670 */ 1663, 1663, 1663, 1663, 647, 1663, 1663, 1663, 1663, 2005,
+ /* 2680 */ 1663, 646, 1663, 1663, 1663, 2036, 1663, 1663, 1663, 2072,
+ /* 2690 */ 2055, 1663, 342, 2038, 650, 2040, 2041, 645, 647, 640,
+ /* 2700 */ 1663, 1663, 1663, 2005, 1663, 646, 1663, 1663, 1663, 1663,
+ /* 2710 */ 648, 1663, 1663, 1663, 2072, 1663, 1663, 319, 2038, 650,
+ /* 2720 */ 2040, 2041, 645, 1663, 640, 1663, 1663, 1663, 1663, 1663,
+ /* 2730 */ 1663, 1663, 1663, 1663, 2036, 1663, 1663, 1663, 2072, 1663,
+ /* 2740 */ 1663, 318, 2038, 650, 2040, 2041, 645, 1663, 640,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 375, 436, 352, 337, 361, 440, 333, 362, 335, 336,
- /* 10 */ 360, 396, 12, 13, 14, 390, 391, 351, 373, 369,
- /* 20 */ 20, 456, 22, 8, 9, 460, 461, 12, 13, 14,
- /* 30 */ 15, 16, 337, 33, 368, 35, 0, 12, 13, 14,
- /* 40 */ 15, 16, 8, 9, 362, 360, 12, 13, 14, 15,
- /* 50 */ 16, 406, 407, 408, 33, 373, 352, 352, 58, 360,
- /* 60 */ 37, 329, 417, 63, 360, 360, 381, 382, 369, 48,
- /* 70 */ 70, 367, 377, 369, 369, 54, 55, 56, 57, 58,
- /* 80 */ 376, 337, 371, 12, 13, 374, 375, 20, 406, 407,
- /* 90 */ 408, 20, 360, 22, 20, 95, 3, 63, 95, 417,
- /* 100 */ 368, 65, 66, 67, 33, 373, 35, 375, 105, 73,
- /* 110 */ 74, 96, 368, 20, 78, 94, 14, 117, 97, 83,
- /* 120 */ 84, 98, 20, 100, 101, 89, 103, 95, 20, 58,
- /* 130 */ 107, 4, 132, 133, 63, 403, 337, 341, 104, 407,
- /* 140 */ 359, 70, 410, 411, 412, 413, 414, 415, 360, 417,
- /* 150 */ 351, 355, 129, 372, 422, 367, 424, 358, 22, 363,
- /* 160 */ 428, 429, 162, 163, 376, 35, 95, 368, 168, 169,
- /* 170 */ 43, 35, 45, 46, 442, 431, 432, 433, 434, 343,
- /* 180 */ 436, 437, 450, 183, 126, 185, 165, 166, 117, 96,
- /* 190 */ 4, 170, 8, 9, 173, 161, 12, 13, 14, 15,
- /* 200 */ 16, 20, 366, 132, 133, 328, 70, 330, 208, 209,
- /* 210 */ 189, 211, 212, 213, 214, 215, 216, 217, 218, 219,
- /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 95,
- /* 230 */ 20, 164, 22, 162, 163, 62, 162, 163, 21, 168,
- /* 240 */ 169, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- /* 250 */ 192, 193, 360, 117, 183, 20, 185, 164, 8, 9,
- /* 260 */ 368, 51, 12, 13, 14, 15, 16, 233, 234, 235,
- /* 270 */ 236, 237, 238, 239, 240, 241, 242, 243, 246, 208,
- /* 280 */ 209, 95, 211, 212, 213, 214, 215, 216, 217, 218,
- /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
- /* 300 */ 360, 230, 12, 13, 412, 333, 337, 335, 336, 79,
- /* 310 */ 20, 22, 22, 132, 133, 185, 182, 20, 184, 183,
- /* 320 */ 95, 185, 382, 33, 35, 35, 108, 109, 110, 111,
- /* 330 */ 112, 113, 114, 115, 116, 117, 118, 368, 120, 121,
- /* 340 */ 122, 123, 124, 125, 208, 209, 96, 20, 58, 168,
- /* 350 */ 169, 2, 58, 63, 14, 15, 16, 8, 9, 175,
- /* 360 */ 70, 12, 13, 14, 15, 16, 337, 137, 138, 65,
- /* 370 */ 66, 67, 409, 12, 13, 14, 0, 73, 74, 44,
- /* 380 */ 246, 20, 78, 22, 208, 95, 0, 83, 84, 95,
- /* 390 */ 160, 97, 95, 89, 33, 20, 35, 368, 435, 178,
- /* 400 */ 161, 432, 433, 434, 329, 436, 437, 117, 20, 440,
- /* 410 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 58,
- /* 420 */ 199, 200, 132, 133, 455, 456, 375, 425, 426, 460,
- /* 430 */ 461, 70, 246, 257, 258, 259, 260, 261, 387, 8,
- /* 440 */ 9, 390, 391, 12, 13, 14, 15, 16, 373, 20,
- /* 450 */ 344, 20, 162, 163, 270, 349, 95, 164, 168, 169,
- /* 460 */ 0, 432, 433, 434, 171, 436, 437, 360, 127, 20,
- /* 470 */ 95, 246, 233, 183, 367, 185, 334, 0, 117, 337,
- /* 480 */ 338, 21, 243, 376, 24, 25, 26, 27, 28, 29,
- /* 490 */ 30, 31, 32, 132, 133, 126, 127, 392, 208, 209,
- /* 500 */ 131, 211, 212, 213, 214, 215, 216, 217, 218, 219,
- /* 510 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 19,
- /* 520 */ 132, 133, 334, 162, 163, 337, 338, 151, 337, 168,
- /* 530 */ 169, 190, 191, 33, 20, 194, 160, 196, 21, 62,
- /* 540 */ 246, 436, 351, 436, 183, 440, 185, 440, 48, 0,
- /* 550 */ 62, 34, 337, 36, 54, 55, 56, 57, 58, 368,
- /* 560 */ 455, 456, 455, 456, 106, 460, 461, 460, 461, 208,
- /* 570 */ 209, 392, 211, 212, 213, 214, 215, 216, 217, 218,
- /* 580 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
- /* 590 */ 12, 13, 409, 4, 94, 164, 356, 97, 20, 384,
- /* 600 */ 22, 386, 326, 337, 269, 107, 167, 360, 19, 95,
- /* 610 */ 0, 33, 409, 35, 367, 436, 374, 375, 435, 440,
- /* 620 */ 329, 246, 33, 376, 126, 127, 128, 129, 130, 131,
- /* 630 */ 130, 230, 337, 232, 455, 456, 58, 48, 435, 460,
- /* 640 */ 461, 401, 53, 20, 329, 22, 351, 58, 70, 329,
- /* 650 */ 384, 360, 386, 358, 1, 2, 107, 230, 35, 368,
- /* 660 */ 58, 12, 13, 368, 373, 165, 375, 20, 392, 20,
- /* 670 */ 170, 22, 62, 95, 51, 126, 127, 128, 129, 130,
- /* 680 */ 131, 70, 33, 94, 35, 35, 97, 187, 373, 189,
- /* 690 */ 251, 252, 253, 373, 403, 117, 94, 420, 407, 97,
- /* 700 */ 423, 410, 411, 412, 413, 414, 415, 58, 417, 436,
- /* 710 */ 132, 133, 436, 440, 346, 347, 440, 8, 9, 70,
- /* 720 */ 70, 12, 13, 14, 15, 16, 337, 353, 455, 456,
- /* 730 */ 356, 455, 456, 460, 461, 0, 460, 461, 346, 347,
- /* 740 */ 162, 163, 451, 452, 95, 2, 168, 169, 337, 96,
- /* 750 */ 106, 8, 9, 44, 337, 12, 13, 14, 15, 16,
- /* 760 */ 246, 183, 351, 185, 8, 9, 117, 360, 12, 13,
- /* 770 */ 14, 15, 16, 384, 367, 386, 329, 70, 421, 368,
- /* 780 */ 423, 132, 133, 376, 49, 368, 208, 209, 0, 211,
- /* 790 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
- /* 800 */ 222, 223, 224, 225, 226, 227, 228, 343, 421, 162,
- /* 810 */ 423, 162, 163, 18, 361, 20, 368, 168, 169, 360,
- /* 820 */ 373, 357, 27, 352, 337, 30, 367, 379, 33, 3,
- /* 830 */ 366, 360, 183, 361, 185, 376, 392, 341, 351, 370,
- /* 840 */ 369, 362, 373, 48, 42, 50, 44, 329, 53, 432,
- /* 850 */ 433, 434, 373, 436, 437, 368, 361, 208, 209, 363,
- /* 860 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
- /* 870 */ 221, 222, 223, 224, 225, 226, 227, 228, 337, 337,
- /* 880 */ 436, 14, 4, 18, 440, 406, 407, 20, 23, 94,
- /* 890 */ 0, 373, 351, 351, 361, 107, 417, 337, 337, 455,
- /* 900 */ 456, 106, 37, 38, 460, 461, 41, 360, 39, 368,
- /* 910 */ 368, 351, 351, 20, 126, 127, 128, 129, 130, 131,
- /* 920 */ 164, 368, 368, 376, 59, 60, 61, 370, 368, 368,
- /* 930 */ 373, 136, 379, 379, 139, 140, 141, 142, 143, 144,
- /* 940 */ 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
- /* 950 */ 155, 329, 157, 158, 159, 65, 66, 67, 68, 69,
- /* 960 */ 95, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- /* 970 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- /* 980 */ 90, 91, 370, 392, 348, 373, 350, 44, 329, 337,
- /* 990 */ 14, 392, 12, 13, 436, 373, 20, 337, 440, 134,
- /* 1000 */ 8, 9, 22, 351, 12, 13, 14, 15, 16, 45,
- /* 1010 */ 46, 351, 337, 33, 456, 35, 132, 133, 460, 461,
- /* 1020 */ 368, 329, 337, 20, 244, 245, 351, 436, 368, 162,
- /* 1030 */ 337, 440, 373, 329, 329, 436, 351, 44, 58, 440,
- /* 1040 */ 175, 176, 177, 368, 351, 180, 455, 456, 337, 329,
- /* 1050 */ 70, 460, 461, 368, 455, 456, 0, 164, 329, 460,
- /* 1060 */ 461, 368, 351, 198, 362, 373, 201, 337, 203, 204,
- /* 1070 */ 205, 206, 207, 361, 106, 373, 329, 373, 373, 368,
- /* 1080 */ 360, 351, 337, 0, 329, 337, 337, 44, 368, 96,
- /* 1090 */ 330, 265, 329, 373, 63, 375, 351, 117, 368, 351,
- /* 1100 */ 351, 329, 373, 329, 48, 22, 35, 360, 406, 407,
- /* 1110 */ 349, 246, 329, 368, 245, 368, 368, 368, 99, 417,
- /* 1120 */ 373, 102, 375, 403, 156, 247, 329, 407, 373, 329,
- /* 1130 */ 410, 411, 412, 413, 414, 415, 373, 417, 162, 96,
- /* 1140 */ 420, 329, 422, 423, 424, 373, 107, 373, 428, 429,
- /* 1150 */ 403, 329, 99, 361, 407, 102, 373, 410, 411, 412,
- /* 1160 */ 413, 414, 415, 183, 417, 185, 44, 164, 129, 422,
- /* 1170 */ 373, 424, 360, 373, 0, 428, 429, 42, 99, 44,
- /* 1180 */ 368, 102, 58, 44, 383, 373, 0, 375, 208, 209,
- /* 1190 */ 44, 99, 44, 35, 102, 373, 22, 450, 47, 329,
- /* 1200 */ 44, 221, 222, 223, 224, 225, 226, 227, 22, 44,
- /* 1210 */ 267, 13, 44, 44, 44, 403, 1, 2, 96, 407,
- /* 1220 */ 44, 97, 410, 411, 412, 413, 414, 415, 70, 417,
- /* 1230 */ 360, 464, 329, 35, 422, 96, 424, 44, 368, 208,
- /* 1240 */ 428, 429, 96, 373, 96, 375, 95, 13, 44, 44,
- /* 1250 */ 44, 439, 96, 44, 339, 44, 185, 453, 447, 360,
- /* 1260 */ 44, 96, 339, 360, 96, 96, 96, 336, 383, 35,
- /* 1270 */ 372, 368, 96, 403, 383, 438, 373, 407, 375, 430,
- /* 1280 */ 410, 411, 412, 413, 414, 415, 457, 417, 441, 96,
- /* 1290 */ 329, 405, 422, 248, 424, 48, 404, 181, 428, 429,
- /* 1300 */ 96, 96, 96, 394, 42, 96, 403, 96, 380, 439,
- /* 1310 */ 407, 20, 96, 410, 411, 412, 413, 414, 415, 383,
- /* 1320 */ 417, 360, 380, 161, 378, 422, 20, 424, 337, 368,
- /* 1330 */ 380, 428, 429, 337, 373, 378, 375, 378, 93, 345,
- /* 1340 */ 20, 337, 439, 337, 337, 331, 331, 20, 343, 398,
- /* 1350 */ 20, 343, 375, 20, 338, 20, 393, 52, 338, 331,
- /* 1360 */ 343, 343, 337, 373, 403, 343, 343, 343, 407, 340,
- /* 1370 */ 329, 410, 411, 412, 413, 414, 415, 340, 417, 331,
- /* 1380 */ 197, 360, 373, 422, 337, 424, 360, 360, 402, 428,
- /* 1390 */ 429, 95, 360, 329, 360, 360, 360, 400, 360, 398,
- /* 1400 */ 439, 360, 360, 341, 360, 188, 360, 397, 375, 368,
- /* 1410 */ 341, 337, 446, 383, 373, 256, 375, 446, 255, 262,
- /* 1420 */ 174, 449, 373, 383, 360, 373, 448, 446, 373, 445,
- /* 1430 */ 373, 264, 368, 444, 263, 271, 249, 373, 388, 375,
- /* 1440 */ 465, 443, 388, 268, 403, 266, 459, 245, 407, 368,
- /* 1450 */ 20, 410, 411, 412, 413, 414, 415, 458, 417, 338,
- /* 1460 */ 329, 341, 337, 422, 405, 424, 20, 403, 341, 428,
- /* 1470 */ 429, 407, 409, 386, 410, 411, 412, 413, 414, 415,
- /* 1480 */ 439, 417, 388, 373, 329, 373, 422, 373, 424, 388,
- /* 1490 */ 373, 360, 428, 429, 166, 341, 373, 356, 385, 368,
- /* 1500 */ 368, 373, 341, 95, 373, 427, 375, 95, 364, 373,
- /* 1510 */ 350, 331, 36, 341, 337, 360, 332, 399, 389, 389,
- /* 1520 */ 354, 395, 327, 368, 342, 0, 0, 354, 373, 190,
- /* 1530 */ 375, 0, 329, 42, 403, 354, 0, 0, 407, 35,
- /* 1540 */ 202, 410, 411, 412, 413, 414, 415, 35, 417, 35,
- /* 1550 */ 35, 202, 0, 422, 35, 424, 329, 35, 403, 428,
- /* 1560 */ 429, 202, 407, 360, 0, 410, 411, 412, 413, 414,
- /* 1570 */ 415, 368, 417, 202, 0, 35, 373, 422, 375, 424,
- /* 1580 */ 0, 22, 0, 428, 429, 35, 185, 360, 183, 0,
- /* 1590 */ 0, 0, 179, 178, 0, 368, 47, 0, 0, 0,
- /* 1600 */ 373, 0, 375, 42, 0, 0, 403, 0, 0, 0,
- /* 1610 */ 407, 0, 0, 410, 411, 412, 413, 414, 415, 151,
- /* 1620 */ 417, 35, 329, 0, 151, 0, 0, 424, 0, 0,
- /* 1630 */ 403, 428, 429, 0, 407, 0, 0, 410, 411, 412,
- /* 1640 */ 413, 414, 415, 0, 417, 329, 0, 0, 0, 0,
- /* 1650 */ 0, 424, 0, 360, 0, 428, 429, 0, 42, 0,
- /* 1660 */ 0, 368, 0, 0, 0, 0, 373, 22, 375, 0,
- /* 1670 */ 0, 0, 0, 135, 0, 35, 360, 0, 58, 0,
- /* 1680 */ 58, 0, 0, 42, 368, 47, 44, 14, 0, 373,
- /* 1690 */ 39, 375, 14, 40, 0, 0, 403, 39, 0, 0,
- /* 1700 */ 407, 174, 47, 410, 411, 412, 413, 414, 415, 0,
- /* 1710 */ 417, 0, 0, 329, 47, 39, 0, 424, 35, 403,
- /* 1720 */ 0, 428, 429, 407, 39, 64, 410, 411, 412, 413,
- /* 1730 */ 414, 415, 416, 417, 418, 419, 35, 48, 48, 329,
- /* 1740 */ 0, 39, 35, 39, 360, 48, 0, 39, 35, 0,
- /* 1750 */ 0, 48, 368, 0, 0, 22, 35, 373, 0, 375,
- /* 1760 */ 35, 35, 35, 35, 35, 35, 44, 44, 102, 22,
- /* 1770 */ 360, 35, 104, 0, 22, 0, 0, 22, 368, 22,
- /* 1780 */ 35, 50, 0, 373, 0, 375, 35, 403, 0, 22,
- /* 1790 */ 20, 407, 96, 0, 410, 411, 412, 413, 414, 415,
- /* 1800 */ 35, 417, 0, 35, 329, 195, 35, 35, 164, 95,
- /* 1810 */ 95, 22, 0, 403, 3, 250, 186, 407, 0, 95,
- /* 1820 */ 410, 411, 412, 413, 414, 415, 254, 417, 96, 329,
- /* 1830 */ 44, 229, 95, 95, 424, 360, 44, 96, 96, 429,
- /* 1840 */ 96, 166, 44, 368, 164, 44, 462, 463, 373, 3,
- /* 1850 */ 375, 164, 47, 47, 95, 95, 172, 171, 95, 44,
- /* 1860 */ 360, 35, 329, 171, 250, 96, 35, 250, 368, 35,
- /* 1870 */ 96, 35, 35, 373, 35, 375, 96, 96, 403, 47,
- /* 1880 */ 47, 244, 407, 0, 44, 410, 411, 412, 413, 414,
- /* 1890 */ 415, 0, 417, 360, 0, 329, 0, 39, 95, 47,
- /* 1900 */ 96, 368, 95, 403, 96, 95, 373, 407, 375, 0,
- /* 1910 */ 410, 411, 412, 413, 414, 415, 95, 417, 95, 39,
- /* 1920 */ 95, 105, 47, 167, 231, 44, 360, 452, 2, 165,
- /* 1930 */ 22, 365, 47, 95, 368, 229, 403, 96, 95, 373,
- /* 1940 */ 407, 375, 95, 410, 411, 412, 413, 414, 415, 96,
- /* 1950 */ 417, 208, 96, 47, 454, 95, 95, 22, 96, 95,
- /* 1960 */ 329, 106, 96, 229, 35, 35, 95, 35, 96, 403,
- /* 1970 */ 119, 210, 95, 407, 96, 35, 410, 411, 412, 413,
- /* 1980 */ 414, 415, 95, 417, 96, 329, 35, 95, 35, 96,
- /* 1990 */ 95, 360, 119, 22, 95, 119, 463, 95, 119, 368,
- /* 2000 */ 44, 35, 22, 64, 373, 107, 375, 95, 63, 35,
- /* 2010 */ 35, 35, 35, 35, 35, 92, 360, 35, 35, 35,
- /* 2020 */ 35, 365, 70, 35, 368, 44, 35, 35, 22, 373,
- /* 2030 */ 35, 375, 35, 35, 403, 70, 35, 35, 407, 35,
- /* 2040 */ 35, 410, 411, 412, 413, 414, 415, 329, 417, 35,
- /* 2050 */ 419, 22, 35, 0, 35, 48, 0, 39, 35, 403,
- /* 2060 */ 48, 39, 0, 407, 329, 35, 410, 411, 412, 413,
- /* 2070 */ 414, 415, 48, 417, 39, 0, 35, 39, 360, 48,
- /* 2080 */ 0, 35, 35, 365, 0, 22, 368, 21, 466, 22,
- /* 2090 */ 22, 373, 21, 375, 20, 360, 466, 466, 466, 466,
- /* 2100 */ 466, 466, 466, 368, 466, 466, 466, 466, 373, 466,
- /* 2110 */ 375, 466, 466, 466, 466, 466, 466, 466, 466, 466,
- /* 2120 */ 466, 403, 466, 466, 329, 407, 466, 466, 410, 411,
- /* 2130 */ 412, 413, 414, 415, 466, 417, 466, 466, 403, 466,
- /* 2140 */ 466, 466, 407, 329, 466, 410, 411, 412, 413, 414,
- /* 2150 */ 415, 466, 417, 466, 466, 360, 466, 466, 466, 466,
- /* 2160 */ 466, 466, 466, 368, 466, 466, 466, 466, 373, 466,
- /* 2170 */ 375, 466, 466, 466, 360, 466, 466, 466, 466, 466,
- /* 2180 */ 466, 466, 368, 466, 466, 466, 466, 373, 466, 375,
- /* 2190 */ 466, 466, 466, 466, 466, 466, 466, 466, 403, 466,
- /* 2200 */ 466, 466, 407, 329, 466, 410, 411, 412, 413, 414,
- /* 2210 */ 415, 466, 417, 466, 466, 466, 466, 403, 466, 329,
- /* 2220 */ 466, 407, 466, 466, 410, 411, 412, 413, 414, 415,
- /* 2230 */ 466, 417, 466, 466, 360, 466, 329, 466, 466, 466,
- /* 2240 */ 466, 466, 368, 466, 466, 466, 466, 373, 466, 375,
- /* 2250 */ 360, 466, 466, 466, 466, 466, 466, 466, 368, 466,
- /* 2260 */ 466, 466, 466, 373, 466, 375, 466, 360, 466, 466,
- /* 2270 */ 466, 466, 466, 466, 466, 368, 466, 403, 466, 466,
- /* 2280 */ 373, 407, 375, 466, 410, 411, 412, 413, 414, 415,
- /* 2290 */ 466, 417, 466, 403, 466, 466, 466, 407, 466, 329,
- /* 2300 */ 410, 411, 412, 413, 414, 415, 466, 417, 466, 466,
- /* 2310 */ 403, 466, 466, 466, 407, 329, 466, 410, 411, 412,
- /* 2320 */ 413, 414, 415, 466, 417, 466, 466, 466, 466, 466,
- /* 2330 */ 360, 466, 466, 466, 466, 466, 466, 466, 368, 466,
- /* 2340 */ 466, 466, 466, 373, 466, 375, 360, 466, 466, 466,
- /* 2350 */ 466, 466, 466, 466, 368, 466, 466, 466, 466, 373,
- /* 2360 */ 466, 375, 466, 466, 466, 466, 466, 466, 466, 466,
- /* 2370 */ 466, 329, 466, 403, 466, 466, 466, 407, 466, 466,
- /* 2380 */ 410, 411, 412, 413, 414, 415, 466, 417, 466, 403,
- /* 2390 */ 466, 466, 466, 407, 329, 466, 410, 411, 412, 413,
- /* 2400 */ 414, 415, 360, 417, 466, 466, 466, 466, 466, 466,
- /* 2410 */ 368, 466, 466, 466, 466, 373, 466, 375, 466, 466,
- /* 2420 */ 466, 466, 466, 466, 466, 360, 466, 466, 466, 466,
- /* 2430 */ 466, 466, 466, 368, 466, 466, 466, 466, 373, 466,
- /* 2440 */ 375, 466, 466, 466, 466, 403, 466, 466, 466, 407,
- /* 2450 */ 466, 466, 410, 411, 412, 413, 414, 415, 329, 417,
- /* 2460 */ 466, 466, 466, 466, 466, 466, 466, 466, 403, 466,
- /* 2470 */ 466, 466, 407, 466, 466, 410, 411, 412, 413, 414,
- /* 2480 */ 415, 466, 417, 466, 466, 329, 466, 466, 466, 360,
- /* 2490 */ 466, 466, 466, 466, 466, 466, 466, 368, 466, 466,
- /* 2500 */ 466, 466, 373, 466, 375, 466, 466, 466, 466, 466,
- /* 2510 */ 466, 466, 466, 466, 466, 466, 360, 466, 466, 466,
- /* 2520 */ 466, 466, 466, 466, 368, 466, 466, 466, 466, 373,
- /* 2530 */ 466, 375, 403, 329, 466, 466, 407, 466, 466, 410,
- /* 2540 */ 411, 412, 413, 414, 415, 466, 417, 466, 466, 329,
- /* 2550 */ 466, 466, 466, 466, 466, 466, 466, 466, 466, 403,
- /* 2560 */ 466, 466, 466, 407, 360, 466, 410, 411, 412, 413,
- /* 2570 */ 414, 415, 368, 417, 466, 466, 466, 373, 466, 375,
- /* 2580 */ 360, 466, 466, 466, 466, 466, 466, 466, 368, 466,
- /* 2590 */ 466, 466, 466, 373, 466, 375, 466, 329, 466, 466,
- /* 2600 */ 466, 466, 466, 466, 466, 466, 466, 403, 466, 466,
- /* 2610 */ 466, 407, 466, 466, 410, 411, 412, 413, 414, 415,
- /* 2620 */ 466, 417, 466, 403, 466, 466, 466, 407, 360, 466,
- /* 2630 */ 410, 411, 412, 413, 414, 415, 368, 417, 466, 466,
- /* 2640 */ 466, 373, 466, 375, 466, 329, 466, 466, 466, 466,
- /* 2650 */ 466, 466, 466, 466, 466, 466, 466, 466, 466, 466,
- /* 2660 */ 466, 466, 466, 466, 466, 466, 466, 466, 329, 466,
- /* 2670 */ 466, 403, 466, 466, 466, 407, 360, 466, 410, 411,
- /* 2680 */ 412, 413, 414, 415, 368, 417, 466, 466, 466, 373,
- /* 2690 */ 466, 375, 466, 466, 466, 466, 466, 466, 466, 360,
- /* 2700 */ 466, 329, 466, 466, 466, 466, 466, 368, 466, 466,
- /* 2710 */ 466, 466, 373, 466, 375, 466, 466, 466, 466, 403,
- /* 2720 */ 466, 466, 466, 407, 329, 466, 410, 411, 412, 413,
- /* 2730 */ 414, 415, 360, 417, 466, 466, 466, 466, 466, 466,
- /* 2740 */ 368, 466, 403, 466, 466, 373, 407, 375, 466, 410,
- /* 2750 */ 411, 412, 413, 414, 415, 360, 417, 466, 466, 466,
- /* 2760 */ 466, 466, 466, 368, 466, 466, 466, 466, 373, 466,
- /* 2770 */ 375, 466, 466, 466, 466, 403, 466, 466, 466, 407,
- /* 2780 */ 466, 466, 410, 411, 412, 413, 414, 415, 329, 417,
- /* 2790 */ 466, 466, 466, 466, 466, 466, 466, 466, 403, 466,
- /* 2800 */ 466, 466, 407, 466, 466, 410, 411, 412, 413, 414,
- /* 2810 */ 415, 466, 417, 466, 466, 329, 466, 466, 466, 360,
- /* 2820 */ 466, 466, 466, 466, 466, 466, 466, 368, 466, 466,
- /* 2830 */ 466, 466, 373, 466, 375, 466, 466, 466, 466, 466,
- /* 2840 */ 466, 466, 466, 466, 466, 466, 360, 466, 466, 466,
- /* 2850 */ 466, 466, 466, 466, 368, 466, 466, 466, 466, 373,
- /* 2860 */ 466, 375, 403, 329, 466, 466, 407, 466, 466, 410,
- /* 2870 */ 411, 412, 413, 414, 415, 466, 417, 466, 466, 466,
- /* 2880 */ 466, 466, 466, 466, 466, 466, 466, 466, 466, 403,
- /* 2890 */ 466, 466, 466, 407, 360, 466, 410, 411, 412, 413,
- /* 2900 */ 414, 415, 368, 417, 466, 466, 466, 373, 466, 375,
- /* 2910 */ 466, 466, 466, 466, 466, 466, 466, 466, 466, 466,
- /* 2920 */ 466, 466, 466, 466, 466, 466, 466, 466, 466, 466,
- /* 2930 */ 466, 466, 466, 466, 466, 466, 466, 403, 466, 466,
- /* 2940 */ 466, 407, 466, 466, 410, 411, 412, 413, 414, 415,
- /* 2950 */ 466, 417,
+ /* 0 */ 377, 439, 0, 339, 335, 443, 337, 338, 335, 363,
+ /* 10 */ 337, 338, 12, 13, 14, 392, 393, 2, 362, 361,
+ /* 20 */ 20, 459, 22, 8, 9, 463, 464, 12, 13, 14,
+ /* 30 */ 15, 16, 374, 33, 370, 35, 20, 331, 362, 383,
+ /* 40 */ 384, 364, 8, 9, 394, 369, 12, 13, 14, 15,
+ /* 50 */ 16, 339, 375, 439, 378, 8, 9, 443, 58, 12,
+ /* 60 */ 13, 14, 15, 16, 64, 63, 373, 20, 362, 376,
+ /* 70 */ 377, 71, 328, 459, 346, 339, 370, 463, 464, 351,
+ /* 80 */ 20, 375, 22, 377, 12, 13, 409, 410, 411, 439,
+ /* 90 */ 4, 379, 20, 443, 22, 35, 96, 420, 64, 435,
+ /* 100 */ 436, 437, 21, 439, 440, 33, 370, 35, 458, 459,
+ /* 110 */ 44, 51, 406, 463, 464, 34, 410, 36, 118, 413,
+ /* 120 */ 414, 415, 416, 417, 418, 419, 420, 421, 422, 43,
+ /* 130 */ 58, 45, 46, 133, 134, 20, 64, 336, 394, 105,
+ /* 140 */ 339, 340, 398, 71, 331, 109, 110, 111, 112, 113,
+ /* 150 */ 114, 115, 116, 117, 118, 119, 362, 121, 122, 123,
+ /* 160 */ 124, 125, 126, 163, 164, 377, 339, 20, 96, 169,
+ /* 170 */ 170, 435, 436, 437, 354, 439, 440, 389, 384, 443,
+ /* 180 */ 392, 393, 362, 439, 184, 339, 186, 443, 375, 369,
+ /* 190 */ 118, 371, 20, 58, 458, 459, 162, 370, 378, 463,
+ /* 200 */ 464, 63, 458, 459, 20, 133, 134, 463, 464, 20,
+ /* 210 */ 210, 211, 165, 213, 214, 215, 216, 217, 218, 219,
+ /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
+ /* 230 */ 230, 96, 386, 98, 388, 163, 164, 168, 343, 63,
+ /* 240 */ 21, 169, 170, 24, 25, 26, 27, 28, 29, 30,
+ /* 250 */ 31, 32, 357, 14, 37, 330, 184, 332, 186, 20,
+ /* 260 */ 365, 434, 435, 436, 437, 20, 439, 440, 96, 235,
+ /* 270 */ 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
+ /* 280 */ 96, 96, 210, 211, 35, 213, 214, 215, 216, 217,
+ /* 290 */ 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+ /* 300 */ 228, 229, 230, 364, 232, 12, 13, 12, 13, 14,
+ /* 310 */ 15, 16, 20, 20, 375, 22, 99, 19, 101, 102,
+ /* 320 */ 71, 104, 253, 254, 255, 108, 33, 20, 35, 336,
+ /* 330 */ 331, 33, 339, 340, 339, 428, 429, 8, 9, 273,
+ /* 340 */ 179, 12, 13, 14, 15, 16, 48, 130, 409, 410,
+ /* 350 */ 411, 58, 54, 55, 56, 57, 58, 64, 345, 420,
+ /* 360 */ 14, 362, 201, 202, 71, 370, 20, 107, 183, 370,
+ /* 370 */ 185, 412, 359, 20, 375, 22, 377, 12, 13, 14,
+ /* 380 */ 20, 368, 3, 248, 232, 20, 234, 22, 96, 96,
+ /* 390 */ 127, 128, 4, 95, 209, 132, 98, 438, 33, 20,
+ /* 400 */ 35, 424, 163, 426, 51, 406, 0, 339, 331, 410,
+ /* 410 */ 339, 118, 413, 414, 415, 416, 417, 418, 0, 420,
+ /* 420 */ 248, 353, 372, 58, 353, 375, 133, 134, 360, 131,
+ /* 430 */ 435, 436, 437, 248, 439, 440, 71, 339, 370, 21,
+ /* 440 */ 232, 370, 24, 25, 26, 27, 28, 29, 30, 31,
+ /* 450 */ 32, 353, 375, 454, 455, 58, 163, 164, 360, 362,
+ /* 460 */ 343, 96, 169, 170, 166, 424, 369, 426, 370, 171,
+ /* 470 */ 163, 164, 66, 67, 68, 378, 97, 184, 47, 186,
+ /* 480 */ 74, 75, 365, 118, 96, 79, 188, 80, 190, 0,
+ /* 490 */ 84, 85, 95, 133, 134, 98, 90, 127, 133, 134,
+ /* 500 */ 376, 377, 20, 210, 211, 176, 213, 214, 215, 216,
+ /* 510 */ 217, 218, 219, 220, 221, 222, 223, 224, 225, 226,
+ /* 520 */ 227, 228, 229, 230, 66, 67, 68, 96, 163, 164,
+ /* 530 */ 0, 362, 74, 75, 169, 170, 339, 79, 369, 339,
+ /* 540 */ 248, 20, 84, 85, 165, 138, 139, 378, 90, 184,
+ /* 550 */ 353, 186, 339, 353, 24, 25, 26, 27, 28, 29,
+ /* 560 */ 30, 31, 32, 193, 194, 394, 35, 370, 161, 398,
+ /* 570 */ 370, 14, 15, 16, 331, 210, 211, 339, 213, 214,
+ /* 580 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+ /* 590 */ 225, 226, 227, 228, 229, 230, 12, 13, 35, 386,
+ /* 600 */ 370, 388, 71, 274, 20, 362, 22, 339, 439, 339,
+ /* 610 */ 439, 381, 443, 370, 443, 133, 134, 33, 375, 35,
+ /* 620 */ 377, 353, 33, 353, 386, 96, 388, 458, 459, 458,
+ /* 630 */ 459, 96, 463, 464, 463, 464, 248, 48, 370, 331,
+ /* 640 */ 370, 152, 58, 54, 55, 56, 57, 58, 339, 406,
+ /* 650 */ 161, 169, 170, 410, 210, 71, 413, 414, 415, 416,
+ /* 660 */ 417, 418, 353, 420, 22, 354, 14, 331, 12, 13,
+ /* 670 */ 427, 20, 20, 362, 431, 432, 20, 35, 22, 370,
+ /* 680 */ 96, 4, 371, 375, 95, 331, 165, 98, 71, 33,
+ /* 690 */ 331, 35, 423, 8, 9, 426, 19, 12, 13, 14,
+ /* 700 */ 15, 16, 118, 259, 260, 261, 262, 263, 264, 265,
+ /* 710 */ 33, 375, 362, 364, 58, 8, 9, 133, 134, 12,
+ /* 720 */ 13, 14, 15, 16, 375, 48, 2, 71, 378, 375,
+ /* 730 */ 53, 0, 8, 9, 375, 58, 12, 13, 14, 15,
+ /* 740 */ 16, 331, 439, 331, 331, 162, 443, 163, 164, 186,
+ /* 750 */ 339, 44, 96, 169, 170, 166, 167, 107, 409, 410,
+ /* 760 */ 171, 458, 459, 174, 353, 363, 463, 464, 184, 420,
+ /* 770 */ 186, 362, 95, 331, 118, 98, 362, 248, 331, 190,
+ /* 780 */ 371, 370, 97, 248, 370, 375, 358, 375, 375, 133,
+ /* 790 */ 134, 331, 1, 2, 210, 211, 71, 213, 214, 215,
+ /* 800 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
+ /* 810 */ 226, 227, 228, 229, 230, 163, 165, 375, 235, 163,
+ /* 820 */ 164, 18, 375, 20, 108, 169, 170, 128, 245, 415,
+ /* 830 */ 27, 345, 404, 30, 362, 375, 33, 45, 46, 108,
+ /* 840 */ 184, 369, 186, 127, 128, 129, 130, 131, 132, 331,
+ /* 850 */ 378, 48, 20, 50, 368, 0, 53, 370, 127, 128,
+ /* 860 */ 129, 130, 131, 132, 348, 349, 210, 211, 381, 213,
+ /* 870 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+ /* 880 */ 224, 225, 226, 227, 228, 229, 230, 354, 97, 399,
+ /* 890 */ 191, 192, 18, 375, 195, 362, 197, 23, 95, 0,
+ /* 900 */ 339, 8, 9, 0, 371, 12, 13, 14, 15, 16,
+ /* 910 */ 107, 37, 38, 363, 353, 41, 331, 39, 63, 8,
+ /* 920 */ 9, 362, 354, 12, 13, 14, 15, 16, 369, 355,
+ /* 930 */ 362, 370, 358, 59, 60, 61, 62, 378, 412, 371,
+ /* 940 */ 137, 348, 349, 140, 141, 142, 143, 144, 145, 146,
+ /* 950 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
+ /* 960 */ 375, 158, 159, 160, 438, 66, 67, 68, 69, 70,
+ /* 970 */ 96, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ /* 980 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
+ /* 990 */ 91, 92, 339, 339, 331, 8, 9, 165, 394, 12,
+ /* 1000 */ 13, 14, 15, 16, 22, 339, 353, 353, 97, 135,
+ /* 1010 */ 331, 108, 3, 339, 339, 339, 4, 35, 350, 353,
+ /* 1020 */ 352, 331, 331, 370, 370, 331, 331, 353, 353, 353,
+ /* 1030 */ 127, 128, 129, 130, 131, 132, 370, 370, 375, 108,
+ /* 1040 */ 42, 362, 44, 439, 370, 370, 370, 443, 381, 370,
+ /* 1050 */ 176, 177, 178, 71, 375, 181, 377, 339, 165, 331,
+ /* 1060 */ 412, 130, 458, 459, 44, 375, 375, 463, 464, 375,
+ /* 1070 */ 375, 353, 372, 364, 200, 375, 20, 203, 107, 205,
+ /* 1080 */ 206, 207, 208, 209, 375, 406, 438, 58, 370, 410,
+ /* 1090 */ 362, 364, 413, 414, 415, 416, 417, 418, 370, 420,
+ /* 1100 */ 118, 44, 375, 375, 425, 377, 427, 246, 247, 339,
+ /* 1110 */ 431, 432, 372, 0, 42, 375, 44, 97, 409, 410,
+ /* 1120 */ 411, 339, 248, 353, 445, 247, 331, 98, 157, 420,
+ /* 1130 */ 394, 363, 453, 44, 406, 353, 409, 410, 410, 363,
+ /* 1140 */ 370, 413, 414, 415, 416, 417, 418, 420, 420, 339,
+ /* 1150 */ 44, 423, 370, 425, 426, 427, 363, 362, 331, 431,
+ /* 1160 */ 432, 48, 0, 353, 100, 370, 184, 103, 186, 0,
+ /* 1170 */ 375, 100, 377, 100, 103, 439, 103, 44, 100, 443,
+ /* 1180 */ 370, 103, 44, 44, 22, 196, 97, 198, 64, 362,
+ /* 1190 */ 332, 22, 210, 211, 458, 459, 0, 370, 363, 463,
+ /* 1200 */ 464, 406, 375, 97, 377, 410, 35, 331, 413, 414,
+ /* 1210 */ 415, 416, 417, 418, 165, 420, 133, 134, 22, 163,
+ /* 1220 */ 425, 172, 427, 44, 44, 0, 431, 432, 44, 385,
+ /* 1230 */ 97, 44, 44, 406, 44, 97, 97, 410, 362, 351,
+ /* 1240 */ 413, 414, 415, 416, 417, 418, 370, 420, 453, 1,
+ /* 1250 */ 2, 375, 425, 377, 427, 96, 44, 394, 431, 432,
+ /* 1260 */ 44, 249, 44, 44, 44, 106, 331, 467, 456, 442,
+ /* 1270 */ 341, 44, 44, 13, 49, 450, 97, 97, 269, 44,
+ /* 1280 */ 362, 97, 406, 341, 97, 97, 410, 97, 338, 413,
+ /* 1290 */ 414, 415, 416, 417, 418, 35, 420, 362, 13, 385,
+ /* 1300 */ 331, 425, 439, 427, 374, 370, 443, 431, 432, 97,
+ /* 1310 */ 375, 385, 377, 97, 441, 97, 97, 97, 442, 460,
+ /* 1320 */ 35, 458, 459, 433, 97, 97, 463, 464, 271, 444,
+ /* 1330 */ 250, 362, 97, 408, 210, 48, 182, 396, 42, 370,
+ /* 1340 */ 407, 406, 382, 20, 375, 410, 377, 385, 413, 414,
+ /* 1350 */ 415, 416, 417, 418, 382, 420, 162, 186, 380, 20,
+ /* 1360 */ 425, 339, 427, 339, 380, 382, 431, 432, 380, 339,
+ /* 1370 */ 94, 339, 347, 331, 339, 406, 339, 442, 20, 410,
+ /* 1380 */ 333, 333, 413, 414, 415, 416, 417, 418, 20, 420,
+ /* 1390 */ 345, 401, 12, 13, 425, 20, 427, 345, 377, 20,
+ /* 1400 */ 431, 432, 22, 340, 362, 20, 395, 345, 340, 339,
+ /* 1410 */ 345, 442, 370, 33, 345, 35, 52, 375, 333, 377,
+ /* 1420 */ 345, 345, 331, 342, 342, 339, 333, 96, 362, 362,
+ /* 1430 */ 375, 199, 405, 375, 403, 401, 362, 343, 58, 362,
+ /* 1440 */ 189, 362, 343, 400, 339, 385, 362, 258, 406, 362,
+ /* 1450 */ 362, 71, 410, 362, 362, 413, 414, 415, 416, 417,
+ /* 1460 */ 418, 370, 420, 362, 362, 449, 375, 425, 377, 427,
+ /* 1470 */ 257, 375, 377, 431, 432, 385, 266, 449, 375, 375,
+ /* 1480 */ 175, 267, 375, 268, 442, 452, 331, 390, 390, 451,
+ /* 1490 */ 449, 251, 448, 447, 468, 370, 446, 406, 118, 275,
+ /* 1500 */ 461, 410, 272, 270, 413, 414, 415, 416, 417, 418,
+ /* 1510 */ 247, 420, 20, 462, 339, 343, 425, 362, 427, 408,
+ /* 1520 */ 412, 340, 431, 432, 20, 370, 343, 390, 388, 167,
+ /* 1530 */ 375, 375, 377, 375, 390, 375, 375, 387, 375, 375,
+ /* 1540 */ 343, 343, 96, 358, 370, 430, 96, 352, 366, 343,
+ /* 1550 */ 339, 375, 36, 402, 331, 334, 356, 391, 391, 333,
+ /* 1560 */ 356, 406, 397, 356, 184, 410, 186, 329, 413, 414,
+ /* 1570 */ 415, 416, 417, 418, 0, 420, 0, 0, 344, 42,
+ /* 1580 */ 425, 0, 427, 35, 331, 362, 431, 432, 204, 35,
+ /* 1590 */ 210, 211, 35, 370, 35, 204, 0, 35, 375, 35,
+ /* 1600 */ 377, 204, 0, 223, 224, 225, 226, 227, 228, 229,
+ /* 1610 */ 204, 0, 0, 35, 331, 362, 22, 0, 191, 35,
+ /* 1620 */ 186, 184, 0, 370, 0, 0, 0, 180, 375, 406,
+ /* 1630 */ 377, 179, 0, 410, 47, 0, 413, 414, 415, 416,
+ /* 1640 */ 417, 418, 0, 420, 331, 362, 0, 42, 425, 0,
+ /* 1650 */ 427, 0, 0, 370, 431, 432, 0, 0, 375, 406,
+ /* 1660 */ 377, 0, 0, 410, 152, 35, 413, 414, 415, 416,
+ /* 1670 */ 417, 418, 0, 420, 0, 362, 152, 0, 331, 0,
+ /* 1680 */ 427, 0, 0, 370, 431, 432, 0, 0, 375, 406,
+ /* 1690 */ 377, 0, 0, 410, 0, 0, 413, 414, 415, 416,
+ /* 1700 */ 417, 418, 0, 420, 0, 331, 0, 0, 0, 362,
+ /* 1710 */ 427, 0, 42, 0, 431, 432, 0, 370, 0, 406,
+ /* 1720 */ 0, 0, 375, 410, 377, 0, 413, 414, 415, 416,
+ /* 1730 */ 417, 418, 22, 420, 0, 0, 362, 0, 0, 136,
+ /* 1740 */ 0, 0, 58, 0, 370, 0, 58, 35, 58, 375,
+ /* 1750 */ 0, 377, 47, 406, 331, 0, 42, 410, 39, 44,
+ /* 1760 */ 413, 414, 415, 416, 417, 418, 0, 420, 14, 47,
+ /* 1770 */ 14, 47, 40, 0, 0, 39, 0, 0, 465, 466,
+ /* 1780 */ 406, 39, 175, 0, 410, 362, 0, 413, 414, 415,
+ /* 1790 */ 416, 417, 418, 370, 420, 65, 0, 0, 375, 35,
+ /* 1800 */ 377, 427, 455, 0, 39, 48, 432, 35, 48, 39,
+ /* 1810 */ 0, 48, 0, 35, 39, 35, 331, 48, 0, 0,
+ /* 1820 */ 39, 0, 0, 35, 22, 0, 35, 35, 105, 406,
+ /* 1830 */ 103, 44, 0, 410, 35, 35, 413, 414, 415, 416,
+ /* 1840 */ 417, 418, 44, 420, 35, 22, 35, 362, 331, 35,
+ /* 1850 */ 22, 0, 22, 0, 50, 370, 22, 0, 0, 35,
+ /* 1860 */ 375, 35, 377, 0, 35, 22, 20, 96, 35, 0,
+ /* 1870 */ 35, 35, 35, 0, 165, 0, 22, 0, 96, 362,
+ /* 1880 */ 457, 97, 165, 187, 367, 3, 44, 370, 252, 96,
+ /* 1890 */ 96, 406, 375, 167, 377, 410, 165, 331, 413, 414,
+ /* 1900 */ 415, 416, 417, 418, 97, 420, 173, 231, 44, 256,
+ /* 1910 */ 97, 172, 44, 97, 331, 44, 172, 97, 252, 47,
+ /* 1920 */ 44, 47, 3, 406, 97, 252, 35, 410, 362, 44,
+ /* 1930 */ 413, 414, 415, 416, 417, 418, 370, 420, 97, 35,
+ /* 1940 */ 96, 375, 35, 377, 96, 362, 331, 35, 96, 35,
+ /* 1950 */ 367, 466, 96, 370, 44, 35, 97, 97, 375, 0,
+ /* 1960 */ 377, 0, 0, 47, 47, 0, 96, 39, 47, 0,
+ /* 1970 */ 39, 331, 406, 168, 246, 96, 410, 362, 44, 413,
+ /* 1980 */ 414, 415, 416, 417, 418, 370, 420, 97, 422, 406,
+ /* 1990 */ 375, 97, 377, 410, 106, 331, 413, 414, 415, 416,
+ /* 2000 */ 417, 418, 362, 420, 96, 96, 166, 367, 2, 96,
+ /* 2010 */ 370, 47, 22, 47, 96, 375, 231, 377, 210, 96,
+ /* 2020 */ 331, 406, 233, 97, 97, 410, 362, 97, 413, 414,
+ /* 2030 */ 415, 416, 417, 418, 370, 420, 96, 231, 96, 375,
+ /* 2040 */ 96, 377, 96, 212, 47, 97, 406, 22, 96, 35,
+ /* 2050 */ 410, 362, 107, 413, 414, 415, 416, 417, 418, 370,
+ /* 2060 */ 420, 35, 35, 96, 375, 97, 377, 97, 97, 96,
+ /* 2070 */ 406, 35, 96, 35, 410, 97, 96, 413, 414, 415,
+ /* 2080 */ 416, 417, 418, 331, 420, 97, 35, 96, 22, 96,
+ /* 2090 */ 108, 44, 35, 22, 120, 406, 96, 120, 96, 410,
+ /* 2100 */ 65, 120, 413, 414, 415, 416, 417, 418, 64, 420,
+ /* 2110 */ 331, 35, 120, 35, 362, 35, 35, 35, 35, 71,
+ /* 2120 */ 35, 35, 370, 35, 35, 93, 35, 375, 35, 377,
+ /* 2130 */ 35, 44, 331, 35, 22, 35, 35, 35, 71, 35,
+ /* 2140 */ 35, 362, 35, 35, 22, 35, 0, 48, 35, 370,
+ /* 2150 */ 0, 35, 0, 39, 375, 0, 377, 48, 406, 39,
+ /* 2160 */ 35, 0, 410, 362, 35, 413, 414, 415, 416, 417,
+ /* 2170 */ 418, 370, 420, 39, 48, 48, 375, 39, 377, 35,
+ /* 2180 */ 35, 0, 22, 21, 21, 406, 22, 22, 20, 410,
+ /* 2190 */ 469, 469, 413, 414, 415, 416, 417, 418, 469, 420,
+ /* 2200 */ 469, 469, 469, 469, 469, 469, 469, 406, 469, 469,
+ /* 2210 */ 469, 410, 331, 469, 413, 414, 415, 416, 417, 418,
+ /* 2220 */ 469, 420, 469, 469, 469, 469, 469, 469, 469, 331,
+ /* 2230 */ 469, 469, 469, 469, 469, 469, 469, 469, 469, 469,
+ /* 2240 */ 469, 469, 469, 362, 469, 469, 331, 469, 469, 469,
+ /* 2250 */ 469, 370, 469, 469, 469, 469, 375, 469, 377, 469,
+ /* 2260 */ 362, 469, 469, 469, 469, 469, 469, 469, 370, 469,
+ /* 2270 */ 469, 469, 469, 375, 469, 377, 469, 362, 331, 469,
+ /* 2280 */ 469, 469, 469, 469, 469, 370, 469, 406, 469, 469,
+ /* 2290 */ 375, 410, 377, 469, 413, 414, 415, 416, 417, 418,
+ /* 2300 */ 469, 420, 469, 331, 406, 469, 469, 469, 410, 362,
+ /* 2310 */ 469, 413, 414, 415, 416, 417, 418, 370, 420, 469,
+ /* 2320 */ 469, 406, 375, 469, 377, 410, 469, 331, 413, 414,
+ /* 2330 */ 415, 416, 417, 418, 362, 420, 469, 469, 469, 469,
+ /* 2340 */ 469, 469, 370, 469, 469, 469, 469, 375, 469, 377,
+ /* 2350 */ 469, 469, 331, 406, 469, 469, 469, 410, 362, 469,
+ /* 2360 */ 413, 414, 415, 416, 417, 418, 370, 420, 469, 469,
+ /* 2370 */ 469, 375, 469, 377, 469, 469, 469, 469, 406, 469,
+ /* 2380 */ 469, 469, 410, 362, 469, 413, 414, 415, 416, 417,
+ /* 2390 */ 418, 370, 420, 469, 469, 469, 375, 469, 377, 469,
+ /* 2400 */ 469, 469, 406, 469, 469, 469, 410, 469, 469, 413,
+ /* 2410 */ 414, 415, 416, 417, 418, 331, 420, 469, 469, 469,
+ /* 2420 */ 469, 469, 469, 469, 469, 469, 469, 406, 469, 469,
+ /* 2430 */ 469, 410, 469, 469, 413, 414, 415, 416, 417, 418,
+ /* 2440 */ 469, 420, 331, 469, 469, 469, 362, 469, 469, 469,
+ /* 2450 */ 469, 469, 469, 469, 370, 469, 469, 469, 469, 375,
+ /* 2460 */ 469, 377, 469, 469, 331, 469, 469, 469, 469, 469,
+ /* 2470 */ 469, 469, 469, 362, 469, 469, 469, 469, 469, 469,
+ /* 2480 */ 469, 370, 469, 469, 469, 469, 375, 469, 377, 469,
+ /* 2490 */ 406, 469, 469, 469, 410, 362, 469, 413, 414, 415,
+ /* 2500 */ 416, 417, 418, 370, 420, 469, 469, 469, 375, 469,
+ /* 2510 */ 377, 469, 469, 469, 469, 469, 469, 406, 469, 469,
+ /* 2520 */ 469, 410, 469, 469, 413, 414, 415, 416, 417, 418,
+ /* 2530 */ 469, 420, 469, 469, 469, 469, 469, 469, 469, 406,
+ /* 2540 */ 469, 469, 469, 410, 331, 469, 413, 414, 415, 416,
+ /* 2550 */ 417, 418, 469, 420, 469, 469, 469, 469, 469, 469,
+ /* 2560 */ 469, 331, 469, 469, 469, 469, 469, 469, 469, 469,
+ /* 2570 */ 469, 469, 469, 469, 469, 362, 469, 469, 331, 469,
+ /* 2580 */ 469, 469, 469, 370, 469, 469, 469, 469, 375, 469,
+ /* 2590 */ 377, 469, 362, 469, 469, 469, 469, 469, 469, 469,
+ /* 2600 */ 370, 469, 469, 469, 469, 375, 469, 377, 469, 362,
+ /* 2610 */ 331, 469, 469, 469, 469, 469, 469, 370, 469, 406,
+ /* 2620 */ 469, 469, 375, 410, 377, 469, 413, 414, 415, 416,
+ /* 2630 */ 417, 418, 469, 420, 469, 331, 406, 469, 469, 469,
+ /* 2640 */ 410, 362, 469, 413, 414, 415, 416, 417, 418, 370,
+ /* 2650 */ 420, 469, 469, 406, 375, 469, 377, 410, 469, 331,
+ /* 2660 */ 413, 414, 415, 416, 417, 418, 362, 420, 469, 469,
+ /* 2670 */ 469, 469, 469, 469, 370, 469, 469, 469, 469, 375,
+ /* 2680 */ 469, 377, 469, 469, 469, 406, 469, 469, 469, 410,
+ /* 2690 */ 362, 469, 413, 414, 415, 416, 417, 418, 370, 420,
+ /* 2700 */ 469, 469, 469, 375, 469, 377, 469, 469, 469, 469,
+ /* 2710 */ 406, 469, 469, 469, 410, 469, 469, 413, 414, 415,
+ /* 2720 */ 416, 417, 418, 469, 420, 469, 469, 469, 469, 469,
+ /* 2730 */ 469, 469, 469, 469, 406, 469, 469, 469, 410, 469,
+ /* 2740 */ 469, 413, 414, 415, 416, 417, 418, 469, 420,
};
-#define YY_SHIFT_COUNT (733)
+#define YY_SHIFT_COUNT (740)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (2084)
+#define YY_SHIFT_MAX (2181)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 865, 0, 71, 0, 290, 290, 290, 290, 290, 290,
- /* 10 */ 290, 290, 290, 290, 290, 361, 578, 578, 649, 578,
- /* 20 */ 578, 578, 578, 578, 578, 578, 578, 578, 578, 578,
- /* 30 */ 578, 578, 578, 578, 578, 578, 578, 578, 578, 578,
- /* 40 */ 578, 578, 578, 578, 578, 578, 578, 578, 375, 514,
- /* 50 */ 297, 134, 294, 32, 225, 32, 297, 297, 980, 980,
- /* 60 */ 32, 980, 980, 186, 32, 108, 181, 235, 235, 181,
- /* 70 */ 127, 127, 74, 388, 102, 102, 235, 235, 235, 235,
- /* 80 */ 235, 235, 235, 327, 235, 235, 173, 108, 235, 235,
- /* 90 */ 429, 235, 108, 235, 327, 235, 327, 108, 235, 235,
- /* 100 */ 108, 235, 108, 108, 108, 235, 488, 795, 34, 34,
- /* 110 */ 217, 304, 136, 136, 136, 136, 136, 136, 136, 136,
- /* 120 */ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
- /* 130 */ 136, 23, 93, 74, 388, 477, 650, 67, 67, 67,
- /* 140 */ 610, 401, 401, 650, 449, 449, 449, 458, 427, 108,
- /* 150 */ 611, 108, 611, 611, 644, 707, 218, 218, 218, 218,
- /* 160 */ 218, 218, 218, 218, 500, 460, 36, 431, 184, 176,
- /* 170 */ 623, 439, 867, 976, 210, 893, 964, 1039, 1003, 780,
- /* 180 */ 869, 826, 780, 802, 878, 647, 1045, 1247, 1116, 1262,
- /* 190 */ 1291, 1262, 1162, 1306, 1306, 1262, 1162, 1162, 1245, 1306,
- /* 200 */ 1306, 1306, 1320, 1320, 1327, 173, 1330, 173, 1333, 1335,
- /* 210 */ 173, 1333, 173, 173, 173, 1306, 173, 1305, 1305, 1320,
- /* 220 */ 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
- /* 230 */ 108, 1306, 1320, 611, 611, 1183, 1296, 1327, 488, 1217,
- /* 240 */ 1330, 488, 1306, 1291, 1291, 611, 1159, 1163, 611, 1159,
- /* 250 */ 1163, 611, 611, 108, 1157, 1246, 1159, 1167, 1171, 1187,
- /* 260 */ 1045, 1164, 1175, 1179, 1202, 449, 1430, 1306, 1333, 488,
- /* 270 */ 488, 1446, 1163, 611, 611, 611, 611, 611, 1163, 611,
- /* 280 */ 1328, 488, 644, 488, 449, 1408, 1412, 611, 707, 1306,
- /* 290 */ 488, 1476, 1320, 2952, 2952, 2952, 2952, 2952, 2952, 2952,
- /* 300 */ 2952, 2952, 890, 21, 386, 589, 15, 709, 250, 549,
- /* 310 */ 349, 743, 756, 788, 992, 992, 992, 992, 992, 992,
- /* 320 */ 992, 992, 992, 498, 341, 25, 25, 230, 221, 376,
- /* 330 */ 602, 517, 58, 369, 369, 340, 653, 239, 340, 340,
- /* 340 */ 340, 993, 1056, 289, 1135, 968, 1019, 1053, 1079, 1092,
- /* 350 */ 1083, 1174, 1186, 1043, 1122, 1124, 1139, 1146, 884, 943,
- /* 360 */ 335, 293, 1148, 1156, 1165, 1168, 1169, 1170, 1215, 1176,
- /* 370 */ 130, 1071, 1031, 1193, 1151, 1204, 1205, 1206, 1209, 1211,
- /* 380 */ 1216, 3, 1198, 1234, 1158, 735, 1525, 1526, 1339, 1531,
- /* 390 */ 1536, 1491, 1537, 1504, 1338, 1512, 1514, 1515, 1349, 1552,
- /* 400 */ 1519, 1522, 1359, 1564, 1371, 1574, 1540, 1580, 1559, 1582,
- /* 410 */ 1550, 1401, 1405, 1589, 1590, 1413, 1415, 1591, 1594, 1549,
- /* 420 */ 1597, 1598, 1599, 1561, 1601, 1604, 1605, 1607, 1608, 1609,
- /* 430 */ 1611, 1612, 1468, 1586, 1623, 1473, 1625, 1626, 1628, 1629,
- /* 440 */ 1633, 1635, 1636, 1643, 1646, 1647, 1648, 1649, 1650, 1652,
- /* 450 */ 1654, 1657, 1616, 1659, 1660, 1662, 1663, 1664, 1665, 1645,
- /* 460 */ 1669, 1670, 1671, 1538, 1672, 1674, 1640, 1677, 1620, 1679,
- /* 470 */ 1622, 1681, 1682, 1641, 1651, 1642, 1638, 1673, 1655, 1678,
- /* 480 */ 1667, 1688, 1653, 1658, 1694, 1695, 1698, 1676, 1527, 1699,
- /* 490 */ 1709, 1711, 1661, 1712, 1716, 1683, 1689, 1685, 1720, 1701,
- /* 500 */ 1690, 1702, 1740, 1707, 1697, 1704, 1746, 1713, 1703, 1708,
- /* 510 */ 1749, 1750, 1753, 1754, 1668, 1666, 1721, 1733, 1758, 1725,
- /* 520 */ 1726, 1727, 1728, 1722, 1723, 1729, 1730, 1747, 1736, 1773,
- /* 530 */ 1752, 1775, 1755, 1731, 1776, 1757, 1745, 1782, 1751, 1784,
- /* 540 */ 1765, 1788, 1767, 1770, 1768, 1771, 1610, 1696, 1714, 1793,
- /* 550 */ 1644, 1715, 1772, 1802, 1630, 1789, 1680, 1675, 1812, 1818,
- /* 560 */ 1687, 1684, 1811, 1786, 1565, 1724, 1732, 1737, 1686, 1602,
- /* 570 */ 1692, 1572, 1741, 1792, 1742, 1738, 1759, 1760, 1744, 1798,
- /* 580 */ 1805, 1806, 1763, 1801, 1614, 1769, 1774, 1846, 1815, 1617,
- /* 590 */ 1826, 1831, 1834, 1836, 1837, 1839, 1780, 1781, 1832, 1637,
- /* 600 */ 1840, 1833, 1883, 1891, 1894, 1896, 1803, 1858, 1638, 1852,
- /* 610 */ 1807, 1804, 1808, 1810, 1821, 1756, 1823, 1909, 1880, 1764,
- /* 620 */ 1825, 1816, 1638, 1875, 1881, 1706, 1693, 1734, 1926, 1908,
- /* 630 */ 1743, 1838, 1841, 1843, 1853, 1847, 1856, 1885, 1860, 1861,
- /* 640 */ 1906, 1862, 1935, 1761, 1864, 1855, 1866, 1929, 1930, 1871,
- /* 650 */ 1872, 1932, 1877, 1878, 1940, 1887, 1888, 1951, 1892, 1893,
- /* 660 */ 1953, 1895, 1851, 1873, 1876, 1879, 1971, 1898, 1899, 1956,
- /* 670 */ 1902, 1966, 1912, 1956, 1956, 1980, 1939, 1945, 1974, 1975,
- /* 680 */ 1976, 1977, 1978, 1979, 1982, 1983, 1984, 1985, 1952, 1923,
- /* 690 */ 1981, 1988, 1991, 1992, 2006, 1995, 1997, 1998, 1965, 1722,
- /* 700 */ 2001, 1723, 2002, 2004, 2005, 2014, 2029, 2017, 2053, 2019,
- /* 710 */ 2007, 2018, 2056, 2023, 2012, 2022, 2062, 2030, 2024, 2035,
- /* 720 */ 2075, 2041, 2031, 2038, 2080, 2046, 2047, 2084, 2063, 2066,
- /* 730 */ 2067, 2068, 2071, 2074,
+ /* 0 */ 874, 0, 72, 0, 293, 293, 293, 293, 293, 293,
+ /* 10 */ 293, 293, 293, 293, 293, 365, 584, 584, 656, 584,
+ /* 20 */ 584, 584, 584, 584, 584, 584, 584, 584, 584, 584,
+ /* 30 */ 584, 584, 584, 584, 584, 584, 584, 584, 584, 584,
+ /* 40 */ 584, 584, 584, 584, 584, 584, 584, 584, 172, 292,
+ /* 50 */ 185, 184, 135, 529, 535, 529, 184, 184, 1380, 1380,
+ /* 60 */ 1380, 529, 1380, 1380, 388, 529, 16, 482, 115, 115,
+ /* 70 */ 482, 86, 86, 307, 360, 346, 346, 115, 115, 115,
+ /* 80 */ 115, 115, 115, 115, 147, 115, 115, 138, 16, 115,
+ /* 90 */ 115, 189, 115, 16, 115, 147, 115, 147, 16, 115,
+ /* 100 */ 115, 16, 115, 16, 16, 16, 115, 176, 803, 34,
+ /* 110 */ 34, 219, 458, 982, 982, 982, 982, 982, 982, 982,
+ /* 120 */ 982, 982, 982, 982, 982, 982, 982, 982, 982, 982,
+ /* 130 */ 982, 982, 217, 379, 307, 360, 2, 249, 521, 521,
+ /* 140 */ 521, 855, 152, 152, 249, 245, 245, 245, 260, 208,
+ /* 150 */ 16, 617, 16, 617, 617, 650, 725, 36, 36, 36,
+ /* 160 */ 36, 36, 36, 36, 36, 298, 418, 406, 47, 329,
+ /* 170 */ 444, 60, 69, 239, 652, 353, 651, 792, 931, 832,
+ /* 180 */ 861, 878, 1009, 861, 998, 1012, 1056, 1080, 1287, 1154,
+ /* 190 */ 1296, 1323, 1296, 1194, 1339, 1339, 1296, 1194, 1194, 1339,
+ /* 200 */ 1276, 1339, 1339, 1339, 1358, 1358, 1368, 138, 1375, 138,
+ /* 210 */ 1379, 1385, 138, 1379, 138, 138, 138, 1339, 138, 1364,
+ /* 220 */ 1364, 1358, 16, 16, 16, 16, 16, 16, 16, 16,
+ /* 230 */ 16, 16, 16, 1339, 1358, 617, 617, 1232, 1331, 1368,
+ /* 240 */ 176, 1251, 1375, 176, 1339, 1323, 1323, 617, 1189, 1213,
+ /* 250 */ 617, 1189, 1213, 617, 617, 16, 1210, 1305, 1189, 1215,
+ /* 260 */ 1214, 1240, 1080, 1224, 1230, 1233, 1263, 245, 1492, 1339,
+ /* 270 */ 1379, 176, 176, 1504, 1213, 617, 617, 617, 617, 617,
+ /* 280 */ 1213, 617, 1362, 176, 650, 176, 245, 1446, 1450, 617,
+ /* 290 */ 725, 1339, 176, 1516, 1358, 2749, 2749, 2749, 2749, 2749,
+ /* 300 */ 2749, 2749, 2749, 2749, 899, 589, 530, 677, 685, 707,
+ /* 310 */ 911, 731, 15, 724, 893, 903, 987, 987, 987, 987,
+ /* 320 */ 987, 987, 987, 987, 987, 716, 699, 295, 295, 407,
+ /* 330 */ 161, 489, 397, 81, 370, 263, 263, 557, 791, 583,
+ /* 340 */ 557, 557, 557, 1113, 1020, 642, 1072, 971, 1064, 1071,
+ /* 350 */ 1073, 1078, 1162, 1169, 1196, 989, 1089, 1106, 1029, 1133,
+ /* 360 */ 1138, 1139, 1083, 1057, 66, 1049, 1179, 1180, 1184, 1187,
+ /* 370 */ 1188, 1190, 1248, 1212, 563, 1171, 1124, 1216, 431, 1218,
+ /* 380 */ 1219, 1220, 1227, 1228, 1235, 1159, 1260, 1285, 531, 1225,
+ /* 390 */ 1574, 1576, 1577, 1537, 1581, 1548, 1384, 1554, 1557, 1559,
+ /* 400 */ 1391, 1596, 1562, 1564, 1397, 1602, 1406, 1611, 1578, 1612,
+ /* 410 */ 1594, 1617, 1584, 1427, 1434, 1437, 1622, 1624, 1625, 1447,
+ /* 420 */ 1452, 1626, 1632, 1587, 1635, 1642, 1646, 1605, 1649, 1651,
+ /* 430 */ 1652, 1656, 1657, 1661, 1662, 1672, 1512, 1630, 1674, 1524,
+ /* 440 */ 1677, 1679, 1681, 1682, 1686, 1687, 1691, 1692, 1694, 1695,
+ /* 450 */ 1702, 1704, 1706, 1707, 1708, 1711, 1670, 1713, 1716, 1718,
+ /* 460 */ 1720, 1721, 1725, 1710, 1734, 1735, 1737, 1603, 1738, 1740,
+ /* 470 */ 1741, 1684, 1712, 1743, 1688, 1745, 1690, 1750, 1755, 1714,
+ /* 480 */ 1719, 1715, 1705, 1754, 1722, 1756, 1724, 1766, 1732, 1736,
+ /* 490 */ 1773, 1774, 1776, 1742, 1607, 1777, 1783, 1786, 1730, 1796,
+ /* 500 */ 1797, 1764, 1757, 1765, 1803, 1772, 1760, 1770, 1810, 1778,
+ /* 510 */ 1763, 1775, 1812, 1780, 1769, 1781, 1818, 1819, 1821, 1822,
+ /* 520 */ 1723, 1727, 1788, 1802, 1825, 1791, 1792, 1799, 1800, 1787,
+ /* 530 */ 1798, 1809, 1811, 1823, 1814, 1832, 1828, 1851, 1830, 1804,
+ /* 540 */ 1853, 1834, 1824, 1857, 1826, 1858, 1829, 1863, 1843, 1846,
+ /* 550 */ 1833, 1835, 1836, 1784, 1771, 1869, 1709, 1782, 1837, 1873,
+ /* 560 */ 1696, 1854, 1717, 1726, 1875, 1877, 1731, 1733, 1882, 1842,
+ /* 570 */ 1636, 1793, 1807, 1794, 1739, 1676, 1744, 1653, 1813, 1864,
+ /* 580 */ 1868, 1816, 1844, 1848, 1852, 1820, 1871, 1872, 1874, 1856,
+ /* 590 */ 1876, 1666, 1827, 1841, 1919, 1885, 1673, 1891, 1904, 1907,
+ /* 600 */ 1912, 1914, 1920, 1859, 1860, 1916, 1728, 1910, 1917, 1959,
+ /* 610 */ 1961, 1962, 1965, 1870, 1928, 1705, 1921, 1879, 1890, 1894,
+ /* 620 */ 1908, 1909, 1805, 1913, 1969, 1931, 1840, 1918, 1888, 1705,
+ /* 630 */ 1964, 1934, 1785, 1789, 1806, 2006, 1990, 1808, 1923, 1926,
+ /* 640 */ 1940, 1927, 1942, 1930, 1966, 1944, 1946, 1997, 1948, 2025,
+ /* 650 */ 1831, 1952, 1945, 1968, 2014, 2026, 1967, 1970, 2027, 1973,
+ /* 660 */ 1971, 2036, 1976, 1978, 2038, 1980, 1988, 2051, 1991, 1974,
+ /* 670 */ 1977, 1981, 1992, 2066, 1982, 1993, 2047, 2000, 2057, 2002,
+ /* 680 */ 2047, 2047, 2071, 2035, 2044, 2076, 2078, 2080, 2081, 2082,
+ /* 690 */ 2083, 2085, 2086, 2088, 2089, 2048, 2032, 2087, 2091, 2093,
+ /* 700 */ 2095, 2112, 2098, 2100, 2101, 2067, 1787, 2102, 1798, 2104,
+ /* 710 */ 2105, 2107, 2108, 2122, 2110, 2146, 2113, 2099, 2114, 2150,
+ /* 720 */ 2116, 2109, 2120, 2152, 2125, 2126, 2134, 2155, 2129, 2127,
+ /* 730 */ 2138, 2161, 2144, 2145, 2181, 2160, 2162, 2164, 2165, 2163,
+ /* 740 */ 2168,
};
-#define YY_REDUCE_COUNT (301)
-#define YY_REDUCE_MIN (-435)
-#define YY_REDUCE_MAX (2534)
+#define YY_REDUCE_COUNT (303)
+#define YY_REDUCE_MIN (-438)
+#define YY_REDUCE_MAX (2328)
static const short yy_reduce_ofst[] = {
- /* 0 */ 276, -268, 720, 747, 812, 870, 903, 961, 1041, 1064,
- /* 10 */ 1131, 1155, 1203, 1227, 1293, 1316, 291, 1384, 1410, 1475,
- /* 20 */ 1500, 1533, 1566, 1631, 1656, 1718, 1735, 1795, 1814, 1874,
- /* 30 */ 1890, 1907, 1970, 1986, 2042, 2065, 2129, 2156, 2204, 2220,
- /* 40 */ 2268, 2316, 2339, 2372, 2395, 2459, 2486, 2534, -31, 107,
- /* 50 */ -256, 105, 179, 444, 591, 599, 29, 417, -355, -318,
- /* 60 */ 273, 479, 702, -435, 558, -296, 51, -201, 295, -375,
- /* 70 */ -327, -28, -315, -289, 142, 188, -334, 191, 411, 487,
- /* 80 */ 541, 542, 560, 215, 561, 652, 464, -212, 660, 675,
- /* 90 */ -108, 685, 247, 693, 266, 711, 389, -350, 730, 745,
- /* 100 */ 407, 748, -295, 459, 471, 749, -204, -305, 2, 2,
- /* 110 */ -123, 106, 75, 315, 320, 447, 518, 622, 659, 692,
- /* 120 */ 704, 705, 729, 755, 763, 772, 774, 783, 797, 800,
- /* 130 */ 822, -219, -37, -60, 242, -164, 368, -37, 183, 203,
- /* 140 */ 496, 357, 387, 392, 448, 553, 554, 240, 277, -301,
- /* 150 */ 469, 547, 557, 612, 374, 636, -357, 453, 472, 495,
- /* 160 */ 533, 712, 792, 533, -385, 760, 761, 801, 767, 804,
- /* 170 */ 915, 811, 899, 899, 923, 885, 931, 898, 891, 837,
- /* 180 */ 837, 829, 837, 849, 847, 899, 886, 892, 909, 928,
- /* 190 */ 936, 942, 946, 991, 996, 950, 957, 959, 994, 1004,
- /* 200 */ 1006, 1007, 1014, 1015, 951, 1005, 977, 1008, 1016, 963,
- /* 210 */ 1017, 1020, 1018, 1022, 1023, 1025, 1024, 1029, 1037, 1028,
- /* 220 */ 1021, 1026, 1027, 1032, 1034, 1035, 1036, 1038, 1042, 1044,
- /* 230 */ 1046, 1047, 1048, 990, 1009, 986, 997, 1001, 1062, 1010,
- /* 240 */ 1033, 1069, 1074, 1030, 1040, 1049, 966, 1050, 1052, 971,
- /* 250 */ 1054, 1055, 1057, 899, 972, 978, 981, 984, 989, 998,
- /* 260 */ 1059, 975, 987, 999, 837, 1081, 1063, 1125, 1121, 1120,
- /* 270 */ 1127, 1087, 1094, 1110, 1112, 1114, 1117, 1123, 1101, 1128,
- /* 280 */ 1113, 1154, 1141, 1161, 1132, 1078, 1144, 1136, 1160, 1177,
- /* 290 */ 1172, 1184, 1180, 1126, 1118, 1129, 1130, 1166, 1173, 1181,
- /* 300 */ 1182, 1195,
+ /* 0 */ -256, 679, 728, 795, 827, 876, 935, 969, 1042, 1091,
+ /* 10 */ 1155, 1223, 243, 1253, 1283, -294, -1, 1313, 1374, 1347,
+ /* 20 */ 1423, 1485, 1517, 1566, 1583, 1640, 1615, 1664, 1689, 1752,
+ /* 30 */ 1779, 1801, 1881, 1898, 1915, 1947, 1972, 1996, 2021, 2084,
+ /* 40 */ 2111, 2133, 2213, 2230, 2247, 2279, 2304, 2328, -264, 169,
+ /* 50 */ 171, -173, -350, 604, 736, 863, -336, -5, -323, -61,
+ /* 60 */ 709, 303, 349, 727, -438, -386, -180, -212, 68, 98,
+ /* 70 */ -377, -331, -327, -344, -307, -199, -7, 71, 197, 200,
+ /* 80 */ 268, 270, 309, 411, -154, 561, 653, 13, -324, 654,
+ /* 90 */ 675, 414, 676, 97, 718, 213, 770, 238, 311, 666,
+ /* 100 */ 674, 472, 782, 533, 559, 568, 810, -105, -288, -93,
+ /* 110 */ -93, -75, -272, -187, 77, 308, 336, 354, 359, 410,
+ /* 120 */ 412, 413, 442, 447, 460, 518, 585, 663, 690, 691,
+ /* 130 */ 694, 695, -342, -41, -206, 124, 486, 516, -41, 526,
+ /* 140 */ 648, 117, -23, 41, 593, 230, 487, 667, 428, 269,
+ /* 150 */ 409, 50, 350, 700, 740, 574, 668, -354, 402, 550,
+ /* 160 */ 768, 776, 793, 835, 776, 490, 858, 888, 844, 800,
+ /* 170 */ 812, 929, 825, 918, 918, 942, 914, 950, 930, 926,
+ /* 180 */ 873, 873, 859, 873, 890, 885, 918, 925, 933, 941,
+ /* 190 */ 960, 962, 972, 978, 1022, 1024, 983, 984, 988, 1030,
+ /* 200 */ 1025, 1032, 1035, 1037, 1047, 1048, 990, 1045, 1021, 1052,
+ /* 210 */ 1063, 1011, 1062, 1068, 1065, 1069, 1075, 1070, 1076, 1081,
+ /* 220 */ 1082, 1085, 1066, 1067, 1074, 1077, 1079, 1084, 1087, 1088,
+ /* 230 */ 1092, 1101, 1102, 1086, 1093, 1055, 1058, 1027, 1031, 1034,
+ /* 240 */ 1094, 1043, 1095, 1099, 1105, 1060, 1090, 1096, 1016, 1097,
+ /* 250 */ 1103, 1028, 1098, 1104, 1107, 918, 1033, 1038, 1041, 1044,
+ /* 260 */ 1046, 1050, 1111, 1026, 1051, 1039, 873, 1125, 1108, 1175,
+ /* 270 */ 1181, 1172, 1183, 1140, 1137, 1156, 1158, 1160, 1161, 1163,
+ /* 280 */ 1144, 1164, 1150, 1197, 1185, 1198, 1174, 1115, 1182, 1176,
+ /* 290 */ 1195, 1211, 1206, 1221, 1226, 1165, 1151, 1166, 1167, 1200,
+ /* 300 */ 1204, 1207, 1234, 1238,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 10 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 20 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 30 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 40 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 50 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 60 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 70 */ 1643, 1643, 1900, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 80 */ 1643, 1643, 1643, 1643, 1643, 1643, 1721, 1643, 1643, 1643,
- /* 90 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 100 */ 1643, 1643, 1643, 1643, 1643, 1643, 1719, 1893, 2105, 1643,
- /* 110 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 120 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 130 */ 1643, 1643, 2117, 1643, 1643, 1721, 1643, 2117, 2117, 2117,
- /* 140 */ 1719, 2077, 2077, 1643, 1643, 1643, 1643, 1953, 1643, 1643,
- /* 150 */ 1643, 1643, 1643, 1643, 1828, 1643, 1643, 1643, 1643, 1643,
- /* 160 */ 1852, 1643, 1643, 1643, 1945, 1643, 1643, 2142, 2196, 1643,
- /* 170 */ 1643, 2145, 1643, 1643, 1643, 1905, 1643, 1781, 2132, 2109,
- /* 180 */ 2123, 2180, 2110, 2107, 2126, 1643, 2136, 1643, 1938, 1898,
- /* 190 */ 1643, 1898, 1895, 1643, 1643, 1898, 1895, 1895, 1772, 1643,
- /* 200 */ 1643, 1643, 1643, 1643, 1643, 1721, 1643, 1721, 1643, 1643,
- /* 210 */ 1721, 1643, 1721, 1721, 1721, 1643, 1721, 1700, 1700, 1643,
- /* 220 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 230 */ 1643, 1643, 1643, 1643, 1643, 1963, 1951, 1643, 1719, 1947,
- /* 240 */ 1643, 1719, 1643, 1643, 1643, 1643, 2153, 2151, 1643, 2153,
- /* 250 */ 2151, 1643, 1643, 1643, 2165, 2161, 2153, 2169, 2167, 2138,
- /* 260 */ 2136, 2199, 2186, 2182, 2123, 1643, 1643, 1643, 1643, 1719,
- /* 270 */ 1719, 1643, 2151, 1643, 1643, 1643, 1643, 1643, 2151, 1643,
- /* 280 */ 1643, 1719, 1643, 1719, 1643, 1643, 1797, 1643, 1643, 1643,
- /* 290 */ 1719, 1675, 1643, 1940, 1956, 1923, 1923, 1831, 1831, 1831,
- /* 300 */ 1722, 1648, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 310 */ 1643, 1643, 1643, 1643, 2164, 2163, 2032, 1643, 2081, 2080,
- /* 320 */ 2079, 2070, 2031, 1793, 1643, 2030, 2029, 1643, 1643, 1643,
- /* 330 */ 1643, 1643, 1643, 1914, 1913, 2023, 1643, 1643, 2024, 2022,
- /* 340 */ 2021, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 350 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 2183,
- /* 360 */ 2187, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 2106, 1643,
- /* 370 */ 1643, 1643, 1643, 1643, 2005, 1643, 1643, 1643, 1643, 1643,
- /* 380 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 390 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 400 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 410 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 420 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 430 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 440 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 450 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 460 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 470 */ 1643, 1643, 1643, 1643, 1643, 1680, 2010, 1643, 1643, 1643,
- /* 480 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 490 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 500 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 510 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 520 */ 1643, 1643, 1643, 1760, 1759, 1643, 1643, 1643, 1643, 1643,
- /* 530 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 540 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 2014, 1643, 1643,
- /* 550 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 560 */ 1643, 1643, 2179, 2139, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 570 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 580 */ 1643, 2005, 1643, 2162, 1643, 1643, 2177, 1643, 2181, 1643,
- /* 590 */ 1643, 1643, 1643, 1643, 1643, 1643, 2116, 2112, 1643, 1643,
- /* 600 */ 2108, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 2013, 1643,
- /* 610 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 620 */ 1643, 1643, 2004, 1643, 2067, 1643, 1643, 1643, 2101, 1643,
- /* 630 */ 1643, 2052, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 640 */ 1643, 2014, 1643, 2017, 1643, 1643, 1643, 1643, 1643, 1825,
- /* 650 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 660 */ 1643, 1643, 1810, 1808, 1807, 1806, 1643, 1803, 1643, 1838,
- /* 670 */ 1643, 1643, 1643, 1834, 1833, 1643, 1643, 1643, 1643, 1643,
- /* 680 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 690 */ 1740, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1732,
- /* 700 */ 1643, 1731, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 710 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 720 */ 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643,
- /* 730 */ 1643, 1643, 1643, 1643,
+ /* 0 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 10 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 20 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 30 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 40 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 50 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 60 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 70 */ 1661, 1661, 1661, 1919, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 80 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1740, 1661, 1661,
+ /* 90 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 100 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1738, 1912, 2127,
+ /* 110 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 120 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 130 */ 1661, 1661, 1661, 2139, 1661, 1661, 1740, 1661, 2139, 2139,
+ /* 140 */ 2139, 1738, 2099, 2099, 1661, 1661, 1661, 1661, 1973, 1661,
+ /* 150 */ 1661, 1661, 1661, 1661, 1661, 1847, 1661, 1661, 1661, 1661,
+ /* 160 */ 1661, 1871, 1661, 1661, 1661, 1965, 1661, 1661, 2164, 2220,
+ /* 170 */ 1661, 1661, 2167, 1661, 1661, 1661, 1924, 1661, 1800, 2154,
+ /* 180 */ 2131, 2145, 2204, 2132, 2129, 2148, 1661, 2158, 1661, 1958,
+ /* 190 */ 1917, 1661, 1917, 1914, 1661, 1661, 1917, 1914, 1914, 1661,
+ /* 200 */ 1791, 1661, 1661, 1661, 1661, 1661, 1661, 1740, 1661, 1740,
+ /* 210 */ 1661, 1661, 1740, 1661, 1740, 1740, 1740, 1661, 1740, 1718,
+ /* 220 */ 1718, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 230 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1984, 1971, 1661,
+ /* 240 */ 1738, 1967, 1661, 1738, 1661, 1661, 1661, 1661, 2175, 2173,
+ /* 250 */ 1661, 2175, 2173, 1661, 1661, 1661, 2189, 2185, 2175, 2193,
+ /* 260 */ 2191, 2160, 2158, 2223, 2210, 2206, 2145, 1661, 1661, 1661,
+ /* 270 */ 1661, 1738, 1738, 1661, 2173, 1661, 1661, 1661, 1661, 1661,
+ /* 280 */ 2173, 1661, 1661, 1738, 1661, 1738, 1661, 1661, 1816, 1661,
+ /* 290 */ 1661, 1661, 1738, 1693, 1661, 1960, 1976, 1942, 1942, 1850,
+ /* 300 */ 1850, 1850, 1741, 1666, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 310 */ 1661, 1661, 1661, 1661, 1661, 1661, 2188, 2187, 2054, 1661,
+ /* 320 */ 2103, 2102, 2101, 2092, 2053, 1812, 1661, 2052, 2051, 1661,
+ /* 330 */ 1661, 1661, 1661, 1661, 1661, 1933, 1932, 2045, 1661, 1661,
+ /* 340 */ 2046, 2044, 2043, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 350 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 360 */ 1661, 1661, 1661, 2207, 2211, 1661, 1661, 1661, 1661, 1661,
+ /* 370 */ 1661, 1661, 2128, 1661, 1661, 1661, 1661, 1661, 2027, 1661,
+ /* 380 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 390 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 400 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 410 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 420 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 430 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 440 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 450 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 460 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 470 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 480 */ 1661, 1698, 2032, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 490 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 500 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 510 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 520 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1779,
+ /* 530 */ 1778, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 540 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 550 */ 1661, 1661, 1661, 2036, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 560 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 2203, 2161,
+ /* 570 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 580 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 2027, 1661,
+ /* 590 */ 2186, 1661, 1661, 2201, 1661, 2205, 1661, 1661, 1661, 1661,
+ /* 600 */ 1661, 1661, 1661, 2138, 2134, 1661, 1661, 2130, 1661, 1661,
+ /* 610 */ 1661, 1661, 1661, 1661, 1661, 2035, 1661, 1661, 1661, 1661,
+ /* 620 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 2026,
+ /* 630 */ 1661, 2089, 1661, 1661, 1661, 2123, 1661, 1661, 2074, 1661,
+ /* 640 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 2036, 1661,
+ /* 650 */ 2039, 1661, 1661, 1661, 1661, 1661, 1844, 1661, 1661, 1661,
+ /* 660 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1829,
+ /* 670 */ 1827, 1826, 1825, 1661, 1822, 1661, 1857, 1661, 1661, 1661,
+ /* 680 */ 1853, 1852, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 690 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1759, 1661, 1661,
+ /* 700 */ 1661, 1661, 1661, 1661, 1661, 1661, 1751, 1661, 1750, 1661,
+ /* 710 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 720 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 730 */ 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661,
+ /* 740 */ 1661,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -1084,6 +1044,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* USE => nothing */
0, /* FLUSH => nothing */
0, /* TRIM => nothing */
+ 0, /* COMPACT => nothing */
0, /* IF => nothing */
0, /* NOT => nothing */
0, /* EXISTS => nothing */
@@ -1219,6 +1180,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* IGNORE => nothing */
0, /* EXPIRED => nothing */
0, /* FILL_HISTORY => nothing */
+ 0, /* UPDATE => nothing */
0, /* SUBTABLE => nothing */
0, /* KILL => nothing */
0, /* CONNECTION => nothing */
@@ -1251,7 +1213,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* SERVER_STATUS => nothing */
0, /* CURRENT_USER => nothing */
0, /* CASE => nothing */
- 272, /* END => ABORT */
+ 276, /* END => ABORT */
0, /* WHEN => nothing */
0, /* THEN => nothing */
0, /* ELSE => nothing */
@@ -1280,8 +1242,10 @@ static const YYCODETYPE yyFallback[] = {
0, /* SLIDING => nothing */
0, /* FILL => nothing */
0, /* VALUE => nothing */
+ 0, /* VALUE_F => nothing */
0, /* NONE => nothing */
0, /* PREV => nothing */
+ 0, /* NULL_F => nothing */
0, /* LINEAR => nothing */
0, /* NEXT => nothing */
0, /* HAVING => nothing */
@@ -1295,59 +1259,57 @@ static const YYCODETYPE yyFallback[] = {
0, /* ASC => nothing */
0, /* NULLS => nothing */
0, /* ABORT => nothing */
- 272, /* AFTER => ABORT */
- 272, /* ATTACH => ABORT */
- 272, /* BEFORE => ABORT */
- 272, /* BEGIN => ABORT */
- 272, /* BITAND => ABORT */
- 272, /* BITNOT => ABORT */
- 272, /* BITOR => ABORT */
- 272, /* BLOCKS => ABORT */
- 272, /* CHANGE => ABORT */
- 272, /* COMMA => ABORT */
- 272, /* COMPACT => ABORT */
- 272, /* CONCAT => ABORT */
- 272, /* CONFLICT => ABORT */
- 272, /* COPY => ABORT */
- 272, /* DEFERRED => ABORT */
- 272, /* DELIMITERS => ABORT */
- 272, /* DETACH => ABORT */
- 272, /* DIVIDE => ABORT */
- 272, /* DOT => ABORT */
- 272, /* EACH => ABORT */
- 272, /* FAIL => ABORT */
- 272, /* FILE => ABORT */
- 272, /* FOR => ABORT */
- 272, /* GLOB => ABORT */
- 272, /* ID => ABORT */
- 272, /* IMMEDIATE => ABORT */
- 272, /* IMPORT => ABORT */
- 272, /* INITIALLY => ABORT */
- 272, /* INSTEAD => ABORT */
- 272, /* ISNULL => ABORT */
- 272, /* KEY => ABORT */
- 272, /* MODULES => ABORT */
- 272, /* NK_BITNOT => ABORT */
- 272, /* NK_SEMI => ABORT */
- 272, /* NOTNULL => ABORT */
- 272, /* OF => ABORT */
- 272, /* PLUS => ABORT */
- 272, /* PRIVILEGE => ABORT */
- 272, /* RAISE => ABORT */
- 272, /* REPLACE => ABORT */
- 272, /* RESTRICT => ABORT */
- 272, /* ROW => ABORT */
- 272, /* SEMI => ABORT */
- 272, /* STAR => ABORT */
- 272, /* STATEMENT => ABORT */
- 272, /* STRICT => ABORT */
- 272, /* STRING => ABORT */
- 272, /* TIMES => ABORT */
- 272, /* UPDATE => ABORT */
- 272, /* VALUES => ABORT */
- 272, /* VARIABLE => ABORT */
- 272, /* VIEW => ABORT */
- 272, /* WAL => ABORT */
+ 276, /* AFTER => ABORT */
+ 276, /* ATTACH => ABORT */
+ 276, /* BEFORE => ABORT */
+ 276, /* BEGIN => ABORT */
+ 276, /* BITAND => ABORT */
+ 276, /* BITNOT => ABORT */
+ 276, /* BITOR => ABORT */
+ 276, /* BLOCKS => ABORT */
+ 276, /* CHANGE => ABORT */
+ 276, /* COMMA => ABORT */
+ 276, /* CONCAT => ABORT */
+ 276, /* CONFLICT => ABORT */
+ 276, /* COPY => ABORT */
+ 276, /* DEFERRED => ABORT */
+ 276, /* DELIMITERS => ABORT */
+ 276, /* DETACH => ABORT */
+ 276, /* DIVIDE => ABORT */
+ 276, /* DOT => ABORT */
+ 276, /* EACH => ABORT */
+ 276, /* FAIL => ABORT */
+ 276, /* FILE => ABORT */
+ 276, /* FOR => ABORT */
+ 276, /* GLOB => ABORT */
+ 276, /* ID => ABORT */
+ 276, /* IMMEDIATE => ABORT */
+ 276, /* IMPORT => ABORT */
+ 276, /* INITIALLY => ABORT */
+ 276, /* INSTEAD => ABORT */
+ 276, /* ISNULL => ABORT */
+ 276, /* KEY => ABORT */
+ 276, /* MODULES => ABORT */
+ 276, /* NK_BITNOT => ABORT */
+ 276, /* NK_SEMI => ABORT */
+ 276, /* NOTNULL => ABORT */
+ 276, /* OF => ABORT */
+ 276, /* PLUS => ABORT */
+ 276, /* PRIVILEGE => ABORT */
+ 276, /* RAISE => ABORT */
+ 276, /* REPLACE => ABORT */
+ 276, /* RESTRICT => ABORT */
+ 276, /* ROW => ABORT */
+ 276, /* SEMI => ABORT */
+ 276, /* STAR => ABORT */
+ 276, /* STATEMENT => ABORT */
+ 276, /* STRICT => ABORT */
+ 276, /* STRING => ABORT */
+ 276, /* TIMES => ABORT */
+ 276, /* VALUES => ABORT */
+ 276, /* VARIABLE => ABORT */
+ 276, /* VIEW => ABORT */
+ 276, /* WAL => ABORT */
};
#endif /* YYFALLBACK */
@@ -1497,410 +1459,413 @@ static const char *const yyTokenName[] = {
/* 59 */ "USE",
/* 60 */ "FLUSH",
/* 61 */ "TRIM",
- /* 62 */ "IF",
- /* 63 */ "NOT",
- /* 64 */ "EXISTS",
- /* 65 */ "BUFFER",
- /* 66 */ "CACHEMODEL",
- /* 67 */ "CACHESIZE",
- /* 68 */ "COMP",
- /* 69 */ "DURATION",
- /* 70 */ "NK_VARIABLE",
- /* 71 */ "MAXROWS",
- /* 72 */ "MINROWS",
- /* 73 */ "KEEP",
- /* 74 */ "PAGES",
- /* 75 */ "PAGESIZE",
- /* 76 */ "TSDB_PAGESIZE",
- /* 77 */ "PRECISION",
- /* 78 */ "REPLICA",
- /* 79 */ "VGROUPS",
- /* 80 */ "SINGLE_STABLE",
- /* 81 */ "RETENTIONS",
- /* 82 */ "SCHEMALESS",
- /* 83 */ "WAL_LEVEL",
- /* 84 */ "WAL_FSYNC_PERIOD",
- /* 85 */ "WAL_RETENTION_PERIOD",
- /* 86 */ "WAL_RETENTION_SIZE",
- /* 87 */ "WAL_ROLL_PERIOD",
- /* 88 */ "WAL_SEGMENT_SIZE",
- /* 89 */ "STT_TRIGGER",
- /* 90 */ "TABLE_PREFIX",
- /* 91 */ "TABLE_SUFFIX",
- /* 92 */ "NK_COLON",
- /* 93 */ "MAX_SPEED",
- /* 94 */ "TABLE",
- /* 95 */ "NK_LP",
- /* 96 */ "NK_RP",
- /* 97 */ "STABLE",
- /* 98 */ "ADD",
- /* 99 */ "COLUMN",
- /* 100 */ "MODIFY",
- /* 101 */ "RENAME",
- /* 102 */ "TAG",
- /* 103 */ "SET",
- /* 104 */ "NK_EQ",
- /* 105 */ "USING",
- /* 106 */ "TAGS",
- /* 107 */ "COMMENT",
- /* 108 */ "BOOL",
- /* 109 */ "TINYINT",
- /* 110 */ "SMALLINT",
- /* 111 */ "INT",
- /* 112 */ "INTEGER",
- /* 113 */ "BIGINT",
- /* 114 */ "FLOAT",
- /* 115 */ "DOUBLE",
- /* 116 */ "BINARY",
- /* 117 */ "TIMESTAMP",
- /* 118 */ "NCHAR",
- /* 119 */ "UNSIGNED",
- /* 120 */ "JSON",
- /* 121 */ "VARCHAR",
- /* 122 */ "MEDIUMBLOB",
- /* 123 */ "BLOB",
- /* 124 */ "VARBINARY",
- /* 125 */ "DECIMAL",
- /* 126 */ "MAX_DELAY",
- /* 127 */ "WATERMARK",
- /* 128 */ "ROLLUP",
- /* 129 */ "TTL",
- /* 130 */ "SMA",
- /* 131 */ "DELETE_MARK",
- /* 132 */ "FIRST",
- /* 133 */ "LAST",
- /* 134 */ "SHOW",
- /* 135 */ "PRIVILEGES",
- /* 136 */ "DATABASES",
- /* 137 */ "TABLES",
- /* 138 */ "STABLES",
- /* 139 */ "MNODES",
- /* 140 */ "QNODES",
- /* 141 */ "FUNCTIONS",
- /* 142 */ "INDEXES",
- /* 143 */ "ACCOUNTS",
- /* 144 */ "APPS",
- /* 145 */ "CONNECTIONS",
- /* 146 */ "LICENCES",
- /* 147 */ "GRANTS",
- /* 148 */ "QUERIES",
- /* 149 */ "SCORES",
- /* 150 */ "TOPICS",
- /* 151 */ "VARIABLES",
- /* 152 */ "CLUSTER",
- /* 153 */ "BNODES",
- /* 154 */ "SNODES",
- /* 155 */ "TRANSACTIONS",
- /* 156 */ "DISTRIBUTED",
- /* 157 */ "CONSUMERS",
- /* 158 */ "SUBSCRIPTIONS",
- /* 159 */ "VNODES",
- /* 160 */ "ALIVE",
- /* 161 */ "LIKE",
- /* 162 */ "TBNAME",
- /* 163 */ "QTAGS",
- /* 164 */ "AS",
- /* 165 */ "INDEX",
- /* 166 */ "FUNCTION",
- /* 167 */ "INTERVAL",
- /* 168 */ "COUNT",
- /* 169 */ "LAST_ROW",
- /* 170 */ "TOPIC",
- /* 171 */ "WITH",
- /* 172 */ "META",
- /* 173 */ "CONSUMER",
- /* 174 */ "GROUP",
- /* 175 */ "DESC",
- /* 176 */ "DESCRIBE",
- /* 177 */ "RESET",
- /* 178 */ "QUERY",
- /* 179 */ "CACHE",
- /* 180 */ "EXPLAIN",
- /* 181 */ "ANALYZE",
- /* 182 */ "VERBOSE",
- /* 183 */ "NK_BOOL",
- /* 184 */ "RATIO",
- /* 185 */ "NK_FLOAT",
- /* 186 */ "OUTPUTTYPE",
- /* 187 */ "AGGREGATE",
- /* 188 */ "BUFSIZE",
- /* 189 */ "STREAM",
- /* 190 */ "INTO",
- /* 191 */ "TRIGGER",
- /* 192 */ "AT_ONCE",
- /* 193 */ "WINDOW_CLOSE",
- /* 194 */ "IGNORE",
- /* 195 */ "EXPIRED",
- /* 196 */ "FILL_HISTORY",
- /* 197 */ "SUBTABLE",
- /* 198 */ "KILL",
- /* 199 */ "CONNECTION",
- /* 200 */ "TRANSACTION",
- /* 201 */ "BALANCE",
- /* 202 */ "VGROUP",
- /* 203 */ "MERGE",
- /* 204 */ "REDISTRIBUTE",
- /* 205 */ "SPLIT",
- /* 206 */ "DELETE",
- /* 207 */ "INSERT",
- /* 208 */ "NULL",
- /* 209 */ "NK_QUESTION",
- /* 210 */ "NK_ARROW",
- /* 211 */ "ROWTS",
- /* 212 */ "QSTART",
- /* 213 */ "QEND",
- /* 214 */ "QDURATION",
- /* 215 */ "WSTART",
- /* 216 */ "WEND",
- /* 217 */ "WDURATION",
- /* 218 */ "IROWTS",
- /* 219 */ "ISFILLED",
- /* 220 */ "CAST",
- /* 221 */ "NOW",
- /* 222 */ "TODAY",
- /* 223 */ "TIMEZONE",
- /* 224 */ "CLIENT_VERSION",
- /* 225 */ "SERVER_VERSION",
- /* 226 */ "SERVER_STATUS",
- /* 227 */ "CURRENT_USER",
- /* 228 */ "CASE",
- /* 229 */ "END",
- /* 230 */ "WHEN",
- /* 231 */ "THEN",
- /* 232 */ "ELSE",
- /* 233 */ "BETWEEN",
- /* 234 */ "IS",
- /* 235 */ "NK_LT",
- /* 236 */ "NK_GT",
- /* 237 */ "NK_LE",
- /* 238 */ "NK_GE",
- /* 239 */ "NK_NE",
- /* 240 */ "MATCH",
- /* 241 */ "NMATCH",
- /* 242 */ "CONTAINS",
- /* 243 */ "IN",
- /* 244 */ "JOIN",
- /* 245 */ "INNER",
- /* 246 */ "SELECT",
- /* 247 */ "DISTINCT",
- /* 248 */ "WHERE",
- /* 249 */ "PARTITION",
- /* 250 */ "BY",
- /* 251 */ "SESSION",
- /* 252 */ "STATE_WINDOW",
- /* 253 */ "EVENT_WINDOW",
- /* 254 */ "START",
- /* 255 */ "SLIDING",
- /* 256 */ "FILL",
- /* 257 */ "VALUE",
- /* 258 */ "NONE",
- /* 259 */ "PREV",
- /* 260 */ "LINEAR",
- /* 261 */ "NEXT",
- /* 262 */ "HAVING",
- /* 263 */ "RANGE",
- /* 264 */ "EVERY",
- /* 265 */ "ORDER",
- /* 266 */ "SLIMIT",
- /* 267 */ "SOFFSET",
- /* 268 */ "LIMIT",
- /* 269 */ "OFFSET",
- /* 270 */ "ASC",
- /* 271 */ "NULLS",
- /* 272 */ "ABORT",
- /* 273 */ "AFTER",
- /* 274 */ "ATTACH",
- /* 275 */ "BEFORE",
- /* 276 */ "BEGIN",
- /* 277 */ "BITAND",
- /* 278 */ "BITNOT",
- /* 279 */ "BITOR",
- /* 280 */ "BLOCKS",
- /* 281 */ "CHANGE",
- /* 282 */ "COMMA",
- /* 283 */ "COMPACT",
- /* 284 */ "CONCAT",
- /* 285 */ "CONFLICT",
- /* 286 */ "COPY",
- /* 287 */ "DEFERRED",
- /* 288 */ "DELIMITERS",
- /* 289 */ "DETACH",
- /* 290 */ "DIVIDE",
- /* 291 */ "DOT",
- /* 292 */ "EACH",
- /* 293 */ "FAIL",
- /* 294 */ "FILE",
- /* 295 */ "FOR",
- /* 296 */ "GLOB",
- /* 297 */ "ID",
- /* 298 */ "IMMEDIATE",
- /* 299 */ "IMPORT",
- /* 300 */ "INITIALLY",
- /* 301 */ "INSTEAD",
- /* 302 */ "ISNULL",
- /* 303 */ "KEY",
- /* 304 */ "MODULES",
- /* 305 */ "NK_BITNOT",
- /* 306 */ "NK_SEMI",
- /* 307 */ "NOTNULL",
- /* 308 */ "OF",
- /* 309 */ "PLUS",
- /* 310 */ "PRIVILEGE",
- /* 311 */ "RAISE",
- /* 312 */ "REPLACE",
- /* 313 */ "RESTRICT",
- /* 314 */ "ROW",
- /* 315 */ "SEMI",
- /* 316 */ "STAR",
- /* 317 */ "STATEMENT",
- /* 318 */ "STRICT",
- /* 319 */ "STRING",
- /* 320 */ "TIMES",
- /* 321 */ "UPDATE",
- /* 322 */ "VALUES",
- /* 323 */ "VARIABLE",
- /* 324 */ "VIEW",
- /* 325 */ "WAL",
- /* 326 */ "cmd",
- /* 327 */ "account_options",
- /* 328 */ "alter_account_options",
- /* 329 */ "literal",
- /* 330 */ "alter_account_option",
- /* 331 */ "user_name",
- /* 332 */ "sysinfo_opt",
- /* 333 */ "privileges",
- /* 334 */ "priv_level",
- /* 335 */ "priv_type_list",
- /* 336 */ "priv_type",
- /* 337 */ "db_name",
- /* 338 */ "topic_name",
- /* 339 */ "dnode_endpoint",
- /* 340 */ "force_opt",
- /* 341 */ "not_exists_opt",
- /* 342 */ "db_options",
- /* 343 */ "exists_opt",
- /* 344 */ "alter_db_options",
- /* 345 */ "speed_opt",
- /* 346 */ "integer_list",
- /* 347 */ "variable_list",
- /* 348 */ "retention_list",
- /* 349 */ "alter_db_option",
- /* 350 */ "retention",
- /* 351 */ "full_table_name",
- /* 352 */ "column_def_list",
- /* 353 */ "tags_def_opt",
- /* 354 */ "table_options",
- /* 355 */ "multi_create_clause",
- /* 356 */ "tags_def",
- /* 357 */ "multi_drop_clause",
- /* 358 */ "alter_table_clause",
- /* 359 */ "alter_table_options",
- /* 360 */ "column_name",
- /* 361 */ "type_name",
- /* 362 */ "signed_literal",
- /* 363 */ "create_subtable_clause",
- /* 364 */ "specific_cols_opt",
- /* 365 */ "expression_list",
- /* 366 */ "drop_table_clause",
- /* 367 */ "col_name_list",
- /* 368 */ "table_name",
- /* 369 */ "column_def",
- /* 370 */ "duration_list",
- /* 371 */ "rollup_func_list",
- /* 372 */ "alter_table_option",
- /* 373 */ "duration_literal",
- /* 374 */ "rollup_func_name",
- /* 375 */ "function_name",
- /* 376 */ "col_name",
- /* 377 */ "db_name_cond_opt",
- /* 378 */ "like_pattern_opt",
- /* 379 */ "table_name_cond",
- /* 380 */ "from_db_opt",
- /* 381 */ "tag_list_opt",
- /* 382 */ "tag_item",
- /* 383 */ "column_alias",
- /* 384 */ "full_index_name",
- /* 385 */ "index_options",
- /* 386 */ "index_name",
- /* 387 */ "func_list",
- /* 388 */ "sliding_opt",
- /* 389 */ "sma_stream_opt",
- /* 390 */ "func",
- /* 391 */ "sma_func_name",
- /* 392 */ "query_or_subquery",
- /* 393 */ "cgroup_name",
- /* 394 */ "analyze_opt",
- /* 395 */ "explain_options",
- /* 396 */ "agg_func_opt",
- /* 397 */ "bufsize_opt",
- /* 398 */ "stream_name",
- /* 399 */ "stream_options",
- /* 400 */ "col_list_opt",
- /* 401 */ "tag_def_or_ref_opt",
- /* 402 */ "subtable_opt",
- /* 403 */ "expression",
- /* 404 */ "dnode_list",
- /* 405 */ "where_clause_opt",
- /* 406 */ "signed",
- /* 407 */ "literal_func",
- /* 408 */ "literal_list",
- /* 409 */ "table_alias",
- /* 410 */ "expr_or_subquery",
- /* 411 */ "pseudo_column",
- /* 412 */ "column_reference",
- /* 413 */ "function_expression",
- /* 414 */ "case_when_expression",
- /* 415 */ "star_func",
- /* 416 */ "star_func_para_list",
- /* 417 */ "noarg_func",
- /* 418 */ "other_para_list",
- /* 419 */ "star_func_para",
- /* 420 */ "when_then_list",
- /* 421 */ "case_when_else_opt",
- /* 422 */ "common_expression",
- /* 423 */ "when_then_expr",
- /* 424 */ "predicate",
- /* 425 */ "compare_op",
- /* 426 */ "in_op",
- /* 427 */ "in_predicate_value",
- /* 428 */ "boolean_value_expression",
- /* 429 */ "boolean_primary",
- /* 430 */ "from_clause_opt",
- /* 431 */ "table_reference_list",
- /* 432 */ "table_reference",
- /* 433 */ "table_primary",
- /* 434 */ "joined_table",
- /* 435 */ "alias_opt",
- /* 436 */ "subquery",
- /* 437 */ "parenthesized_joined_table",
- /* 438 */ "join_type",
- /* 439 */ "search_condition",
- /* 440 */ "query_specification",
- /* 441 */ "set_quantifier_opt",
- /* 442 */ "select_list",
- /* 443 */ "partition_by_clause_opt",
- /* 444 */ "range_opt",
- /* 445 */ "every_opt",
- /* 446 */ "fill_opt",
- /* 447 */ "twindow_clause_opt",
- /* 448 */ "group_by_clause_opt",
- /* 449 */ "having_clause_opt",
- /* 450 */ "select_item",
- /* 451 */ "partition_list",
- /* 452 */ "partition_item",
- /* 453 */ "fill_mode",
- /* 454 */ "group_by_list",
- /* 455 */ "query_expression",
- /* 456 */ "query_simple",
- /* 457 */ "order_by_clause_opt",
- /* 458 */ "slimit_clause_opt",
- /* 459 */ "limit_clause_opt",
- /* 460 */ "union_query_expression",
- /* 461 */ "query_simple_or_subquery",
- /* 462 */ "sort_specification_list",
- /* 463 */ "sort_specification",
- /* 464 */ "ordering_specification_opt",
- /* 465 */ "null_ordering_opt",
+ /* 62 */ "COMPACT",
+ /* 63 */ "IF",
+ /* 64 */ "NOT",
+ /* 65 */ "EXISTS",
+ /* 66 */ "BUFFER",
+ /* 67 */ "CACHEMODEL",
+ /* 68 */ "CACHESIZE",
+ /* 69 */ "COMP",
+ /* 70 */ "DURATION",
+ /* 71 */ "NK_VARIABLE",
+ /* 72 */ "MAXROWS",
+ /* 73 */ "MINROWS",
+ /* 74 */ "KEEP",
+ /* 75 */ "PAGES",
+ /* 76 */ "PAGESIZE",
+ /* 77 */ "TSDB_PAGESIZE",
+ /* 78 */ "PRECISION",
+ /* 79 */ "REPLICA",
+ /* 80 */ "VGROUPS",
+ /* 81 */ "SINGLE_STABLE",
+ /* 82 */ "RETENTIONS",
+ /* 83 */ "SCHEMALESS",
+ /* 84 */ "WAL_LEVEL",
+ /* 85 */ "WAL_FSYNC_PERIOD",
+ /* 86 */ "WAL_RETENTION_PERIOD",
+ /* 87 */ "WAL_RETENTION_SIZE",
+ /* 88 */ "WAL_ROLL_PERIOD",
+ /* 89 */ "WAL_SEGMENT_SIZE",
+ /* 90 */ "STT_TRIGGER",
+ /* 91 */ "TABLE_PREFIX",
+ /* 92 */ "TABLE_SUFFIX",
+ /* 93 */ "NK_COLON",
+ /* 94 */ "MAX_SPEED",
+ /* 95 */ "TABLE",
+ /* 96 */ "NK_LP",
+ /* 97 */ "NK_RP",
+ /* 98 */ "STABLE",
+ /* 99 */ "ADD",
+ /* 100 */ "COLUMN",
+ /* 101 */ "MODIFY",
+ /* 102 */ "RENAME",
+ /* 103 */ "TAG",
+ /* 104 */ "SET",
+ /* 105 */ "NK_EQ",
+ /* 106 */ "USING",
+ /* 107 */ "TAGS",
+ /* 108 */ "COMMENT",
+ /* 109 */ "BOOL",
+ /* 110 */ "TINYINT",
+ /* 111 */ "SMALLINT",
+ /* 112 */ "INT",
+ /* 113 */ "INTEGER",
+ /* 114 */ "BIGINT",
+ /* 115 */ "FLOAT",
+ /* 116 */ "DOUBLE",
+ /* 117 */ "BINARY",
+ /* 118 */ "TIMESTAMP",
+ /* 119 */ "NCHAR",
+ /* 120 */ "UNSIGNED",
+ /* 121 */ "JSON",
+ /* 122 */ "VARCHAR",
+ /* 123 */ "MEDIUMBLOB",
+ /* 124 */ "BLOB",
+ /* 125 */ "VARBINARY",
+ /* 126 */ "DECIMAL",
+ /* 127 */ "MAX_DELAY",
+ /* 128 */ "WATERMARK",
+ /* 129 */ "ROLLUP",
+ /* 130 */ "TTL",
+ /* 131 */ "SMA",
+ /* 132 */ "DELETE_MARK",
+ /* 133 */ "FIRST",
+ /* 134 */ "LAST",
+ /* 135 */ "SHOW",
+ /* 136 */ "PRIVILEGES",
+ /* 137 */ "DATABASES",
+ /* 138 */ "TABLES",
+ /* 139 */ "STABLES",
+ /* 140 */ "MNODES",
+ /* 141 */ "QNODES",
+ /* 142 */ "FUNCTIONS",
+ /* 143 */ "INDEXES",
+ /* 144 */ "ACCOUNTS",
+ /* 145 */ "APPS",
+ /* 146 */ "CONNECTIONS",
+ /* 147 */ "LICENCES",
+ /* 148 */ "GRANTS",
+ /* 149 */ "QUERIES",
+ /* 150 */ "SCORES",
+ /* 151 */ "TOPICS",
+ /* 152 */ "VARIABLES",
+ /* 153 */ "CLUSTER",
+ /* 154 */ "BNODES",
+ /* 155 */ "SNODES",
+ /* 156 */ "TRANSACTIONS",
+ /* 157 */ "DISTRIBUTED",
+ /* 158 */ "CONSUMERS",
+ /* 159 */ "SUBSCRIPTIONS",
+ /* 160 */ "VNODES",
+ /* 161 */ "ALIVE",
+ /* 162 */ "LIKE",
+ /* 163 */ "TBNAME",
+ /* 164 */ "QTAGS",
+ /* 165 */ "AS",
+ /* 166 */ "INDEX",
+ /* 167 */ "FUNCTION",
+ /* 168 */ "INTERVAL",
+ /* 169 */ "COUNT",
+ /* 170 */ "LAST_ROW",
+ /* 171 */ "TOPIC",
+ /* 172 */ "WITH",
+ /* 173 */ "META",
+ /* 174 */ "CONSUMER",
+ /* 175 */ "GROUP",
+ /* 176 */ "DESC",
+ /* 177 */ "DESCRIBE",
+ /* 178 */ "RESET",
+ /* 179 */ "QUERY",
+ /* 180 */ "CACHE",
+ /* 181 */ "EXPLAIN",
+ /* 182 */ "ANALYZE",
+ /* 183 */ "VERBOSE",
+ /* 184 */ "NK_BOOL",
+ /* 185 */ "RATIO",
+ /* 186 */ "NK_FLOAT",
+ /* 187 */ "OUTPUTTYPE",
+ /* 188 */ "AGGREGATE",
+ /* 189 */ "BUFSIZE",
+ /* 190 */ "STREAM",
+ /* 191 */ "INTO",
+ /* 192 */ "TRIGGER",
+ /* 193 */ "AT_ONCE",
+ /* 194 */ "WINDOW_CLOSE",
+ /* 195 */ "IGNORE",
+ /* 196 */ "EXPIRED",
+ /* 197 */ "FILL_HISTORY",
+ /* 198 */ "UPDATE",
+ /* 199 */ "SUBTABLE",
+ /* 200 */ "KILL",
+ /* 201 */ "CONNECTION",
+ /* 202 */ "TRANSACTION",
+ /* 203 */ "BALANCE",
+ /* 204 */ "VGROUP",
+ /* 205 */ "MERGE",
+ /* 206 */ "REDISTRIBUTE",
+ /* 207 */ "SPLIT",
+ /* 208 */ "DELETE",
+ /* 209 */ "INSERT",
+ /* 210 */ "NULL",
+ /* 211 */ "NK_QUESTION",
+ /* 212 */ "NK_ARROW",
+ /* 213 */ "ROWTS",
+ /* 214 */ "QSTART",
+ /* 215 */ "QEND",
+ /* 216 */ "QDURATION",
+ /* 217 */ "WSTART",
+ /* 218 */ "WEND",
+ /* 219 */ "WDURATION",
+ /* 220 */ "IROWTS",
+ /* 221 */ "ISFILLED",
+ /* 222 */ "CAST",
+ /* 223 */ "NOW",
+ /* 224 */ "TODAY",
+ /* 225 */ "TIMEZONE",
+ /* 226 */ "CLIENT_VERSION",
+ /* 227 */ "SERVER_VERSION",
+ /* 228 */ "SERVER_STATUS",
+ /* 229 */ "CURRENT_USER",
+ /* 230 */ "CASE",
+ /* 231 */ "END",
+ /* 232 */ "WHEN",
+ /* 233 */ "THEN",
+ /* 234 */ "ELSE",
+ /* 235 */ "BETWEEN",
+ /* 236 */ "IS",
+ /* 237 */ "NK_LT",
+ /* 238 */ "NK_GT",
+ /* 239 */ "NK_LE",
+ /* 240 */ "NK_GE",
+ /* 241 */ "NK_NE",
+ /* 242 */ "MATCH",
+ /* 243 */ "NMATCH",
+ /* 244 */ "CONTAINS",
+ /* 245 */ "IN",
+ /* 246 */ "JOIN",
+ /* 247 */ "INNER",
+ /* 248 */ "SELECT",
+ /* 249 */ "DISTINCT",
+ /* 250 */ "WHERE",
+ /* 251 */ "PARTITION",
+ /* 252 */ "BY",
+ /* 253 */ "SESSION",
+ /* 254 */ "STATE_WINDOW",
+ /* 255 */ "EVENT_WINDOW",
+ /* 256 */ "START",
+ /* 257 */ "SLIDING",
+ /* 258 */ "FILL",
+ /* 259 */ "VALUE",
+ /* 260 */ "VALUE_F",
+ /* 261 */ "NONE",
+ /* 262 */ "PREV",
+ /* 263 */ "NULL_F",
+ /* 264 */ "LINEAR",
+ /* 265 */ "NEXT",
+ /* 266 */ "HAVING",
+ /* 267 */ "RANGE",
+ /* 268 */ "EVERY",
+ /* 269 */ "ORDER",
+ /* 270 */ "SLIMIT",
+ /* 271 */ "SOFFSET",
+ /* 272 */ "LIMIT",
+ /* 273 */ "OFFSET",
+ /* 274 */ "ASC",
+ /* 275 */ "NULLS",
+ /* 276 */ "ABORT",
+ /* 277 */ "AFTER",
+ /* 278 */ "ATTACH",
+ /* 279 */ "BEFORE",
+ /* 280 */ "BEGIN",
+ /* 281 */ "BITAND",
+ /* 282 */ "BITNOT",
+ /* 283 */ "BITOR",
+ /* 284 */ "BLOCKS",
+ /* 285 */ "CHANGE",
+ /* 286 */ "COMMA",
+ /* 287 */ "CONCAT",
+ /* 288 */ "CONFLICT",
+ /* 289 */ "COPY",
+ /* 290 */ "DEFERRED",
+ /* 291 */ "DELIMITERS",
+ /* 292 */ "DETACH",
+ /* 293 */ "DIVIDE",
+ /* 294 */ "DOT",
+ /* 295 */ "EACH",
+ /* 296 */ "FAIL",
+ /* 297 */ "FILE",
+ /* 298 */ "FOR",
+ /* 299 */ "GLOB",
+ /* 300 */ "ID",
+ /* 301 */ "IMMEDIATE",
+ /* 302 */ "IMPORT",
+ /* 303 */ "INITIALLY",
+ /* 304 */ "INSTEAD",
+ /* 305 */ "ISNULL",
+ /* 306 */ "KEY",
+ /* 307 */ "MODULES",
+ /* 308 */ "NK_BITNOT",
+ /* 309 */ "NK_SEMI",
+ /* 310 */ "NOTNULL",
+ /* 311 */ "OF",
+ /* 312 */ "PLUS",
+ /* 313 */ "PRIVILEGE",
+ /* 314 */ "RAISE",
+ /* 315 */ "REPLACE",
+ /* 316 */ "RESTRICT",
+ /* 317 */ "ROW",
+ /* 318 */ "SEMI",
+ /* 319 */ "STAR",
+ /* 320 */ "STATEMENT",
+ /* 321 */ "STRICT",
+ /* 322 */ "STRING",
+ /* 323 */ "TIMES",
+ /* 324 */ "VALUES",
+ /* 325 */ "VARIABLE",
+ /* 326 */ "VIEW",
+ /* 327 */ "WAL",
+ /* 328 */ "cmd",
+ /* 329 */ "account_options",
+ /* 330 */ "alter_account_options",
+ /* 331 */ "literal",
+ /* 332 */ "alter_account_option",
+ /* 333 */ "user_name",
+ /* 334 */ "sysinfo_opt",
+ /* 335 */ "privileges",
+ /* 336 */ "priv_level",
+ /* 337 */ "priv_type_list",
+ /* 338 */ "priv_type",
+ /* 339 */ "db_name",
+ /* 340 */ "topic_name",
+ /* 341 */ "dnode_endpoint",
+ /* 342 */ "force_opt",
+ /* 343 */ "not_exists_opt",
+ /* 344 */ "db_options",
+ /* 345 */ "exists_opt",
+ /* 346 */ "alter_db_options",
+ /* 347 */ "speed_opt",
+ /* 348 */ "integer_list",
+ /* 349 */ "variable_list",
+ /* 350 */ "retention_list",
+ /* 351 */ "alter_db_option",
+ /* 352 */ "retention",
+ /* 353 */ "full_table_name",
+ /* 354 */ "column_def_list",
+ /* 355 */ "tags_def_opt",
+ /* 356 */ "table_options",
+ /* 357 */ "multi_create_clause",
+ /* 358 */ "tags_def",
+ /* 359 */ "multi_drop_clause",
+ /* 360 */ "alter_table_clause",
+ /* 361 */ "alter_table_options",
+ /* 362 */ "column_name",
+ /* 363 */ "type_name",
+ /* 364 */ "signed_literal",
+ /* 365 */ "create_subtable_clause",
+ /* 366 */ "specific_cols_opt",
+ /* 367 */ "expression_list",
+ /* 368 */ "drop_table_clause",
+ /* 369 */ "col_name_list",
+ /* 370 */ "table_name",
+ /* 371 */ "column_def",
+ /* 372 */ "duration_list",
+ /* 373 */ "rollup_func_list",
+ /* 374 */ "alter_table_option",
+ /* 375 */ "duration_literal",
+ /* 376 */ "rollup_func_name",
+ /* 377 */ "function_name",
+ /* 378 */ "col_name",
+ /* 379 */ "db_name_cond_opt",
+ /* 380 */ "like_pattern_opt",
+ /* 381 */ "table_name_cond",
+ /* 382 */ "from_db_opt",
+ /* 383 */ "tag_list_opt",
+ /* 384 */ "tag_item",
+ /* 385 */ "column_alias",
+ /* 386 */ "full_index_name",
+ /* 387 */ "index_options",
+ /* 388 */ "index_name",
+ /* 389 */ "func_list",
+ /* 390 */ "sliding_opt",
+ /* 391 */ "sma_stream_opt",
+ /* 392 */ "func",
+ /* 393 */ "sma_func_name",
+ /* 394 */ "query_or_subquery",
+ /* 395 */ "cgroup_name",
+ /* 396 */ "analyze_opt",
+ /* 397 */ "explain_options",
+ /* 398 */ "insert_query",
+ /* 399 */ "agg_func_opt",
+ /* 400 */ "bufsize_opt",
+ /* 401 */ "stream_name",
+ /* 402 */ "stream_options",
+ /* 403 */ "col_list_opt",
+ /* 404 */ "tag_def_or_ref_opt",
+ /* 405 */ "subtable_opt",
+ /* 406 */ "expression",
+ /* 407 */ "dnode_list",
+ /* 408 */ "where_clause_opt",
+ /* 409 */ "signed",
+ /* 410 */ "literal_func",
+ /* 411 */ "literal_list",
+ /* 412 */ "table_alias",
+ /* 413 */ "expr_or_subquery",
+ /* 414 */ "pseudo_column",
+ /* 415 */ "column_reference",
+ /* 416 */ "function_expression",
+ /* 417 */ "case_when_expression",
+ /* 418 */ "star_func",
+ /* 419 */ "star_func_para_list",
+ /* 420 */ "noarg_func",
+ /* 421 */ "other_para_list",
+ /* 422 */ "star_func_para",
+ /* 423 */ "when_then_list",
+ /* 424 */ "case_when_else_opt",
+ /* 425 */ "common_expression",
+ /* 426 */ "when_then_expr",
+ /* 427 */ "predicate",
+ /* 428 */ "compare_op",
+ /* 429 */ "in_op",
+ /* 430 */ "in_predicate_value",
+ /* 431 */ "boolean_value_expression",
+ /* 432 */ "boolean_primary",
+ /* 433 */ "from_clause_opt",
+ /* 434 */ "table_reference_list",
+ /* 435 */ "table_reference",
+ /* 436 */ "table_primary",
+ /* 437 */ "joined_table",
+ /* 438 */ "alias_opt",
+ /* 439 */ "subquery",
+ /* 440 */ "parenthesized_joined_table",
+ /* 441 */ "join_type",
+ /* 442 */ "search_condition",
+ /* 443 */ "query_specification",
+ /* 444 */ "set_quantifier_opt",
+ /* 445 */ "select_list",
+ /* 446 */ "partition_by_clause_opt",
+ /* 447 */ "range_opt",
+ /* 448 */ "every_opt",
+ /* 449 */ "fill_opt",
+ /* 450 */ "twindow_clause_opt",
+ /* 451 */ "group_by_clause_opt",
+ /* 452 */ "having_clause_opt",
+ /* 453 */ "select_item",
+ /* 454 */ "partition_list",
+ /* 455 */ "partition_item",
+ /* 456 */ "fill_mode",
+ /* 457 */ "group_by_list",
+ /* 458 */ "query_expression",
+ /* 459 */ "query_simple",
+ /* 460 */ "order_by_clause_opt",
+ /* 461 */ "slimit_clause_opt",
+ /* 462 */ "limit_clause_opt",
+ /* 463 */ "union_query_expression",
+ /* 464 */ "query_simple_or_subquery",
+ /* 465 */ "sort_specification_list",
+ /* 466 */ "sort_specification",
+ /* 467 */ "ordering_specification_opt",
+ /* 468 */ "null_ordering_opt",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -1980,490 +1945,496 @@ static const char *const yyRuleName[] = {
/* 69 */ "cmd ::= ALTER DATABASE db_name alter_db_options",
/* 70 */ "cmd ::= FLUSH DATABASE db_name",
/* 71 */ "cmd ::= TRIM DATABASE db_name speed_opt",
- /* 72 */ "not_exists_opt ::= IF NOT EXISTS",
- /* 73 */ "not_exists_opt ::=",
- /* 74 */ "exists_opt ::= IF EXISTS",
- /* 75 */ "exists_opt ::=",
- /* 76 */ "db_options ::=",
- /* 77 */ "db_options ::= db_options BUFFER NK_INTEGER",
- /* 78 */ "db_options ::= db_options CACHEMODEL NK_STRING",
- /* 79 */ "db_options ::= db_options CACHESIZE NK_INTEGER",
- /* 80 */ "db_options ::= db_options COMP NK_INTEGER",
- /* 81 */ "db_options ::= db_options DURATION NK_INTEGER",
- /* 82 */ "db_options ::= db_options DURATION NK_VARIABLE",
- /* 83 */ "db_options ::= db_options MAXROWS NK_INTEGER",
- /* 84 */ "db_options ::= db_options MINROWS NK_INTEGER",
- /* 85 */ "db_options ::= db_options KEEP integer_list",
- /* 86 */ "db_options ::= db_options KEEP variable_list",
- /* 87 */ "db_options ::= db_options PAGES NK_INTEGER",
- /* 88 */ "db_options ::= db_options PAGESIZE NK_INTEGER",
- /* 89 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER",
- /* 90 */ "db_options ::= db_options PRECISION NK_STRING",
- /* 91 */ "db_options ::= db_options REPLICA NK_INTEGER",
- /* 92 */ "db_options ::= db_options VGROUPS NK_INTEGER",
- /* 93 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER",
- /* 94 */ "db_options ::= db_options RETENTIONS retention_list",
- /* 95 */ "db_options ::= db_options SCHEMALESS NK_INTEGER",
- /* 96 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER",
- /* 97 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER",
- /* 98 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER",
- /* 99 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER",
- /* 100 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER",
- /* 101 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER",
- /* 102 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER",
- /* 103 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER",
- /* 104 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER",
- /* 105 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER",
- /* 106 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER",
- /* 107 */ "alter_db_options ::= alter_db_option",
- /* 108 */ "alter_db_options ::= alter_db_options alter_db_option",
- /* 109 */ "alter_db_option ::= BUFFER NK_INTEGER",
- /* 110 */ "alter_db_option ::= CACHEMODEL NK_STRING",
- /* 111 */ "alter_db_option ::= CACHESIZE NK_INTEGER",
- /* 112 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER",
- /* 113 */ "alter_db_option ::= KEEP integer_list",
- /* 114 */ "alter_db_option ::= KEEP variable_list",
- /* 115 */ "alter_db_option ::= PAGES NK_INTEGER",
- /* 116 */ "alter_db_option ::= REPLICA NK_INTEGER",
- /* 117 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER",
- /* 118 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER",
- /* 119 */ "integer_list ::= NK_INTEGER",
- /* 120 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER",
- /* 121 */ "variable_list ::= NK_VARIABLE",
- /* 122 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE",
- /* 123 */ "retention_list ::= retention",
- /* 124 */ "retention_list ::= retention_list NK_COMMA retention",
- /* 125 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE",
- /* 126 */ "speed_opt ::=",
- /* 127 */ "speed_opt ::= MAX_SPEED NK_INTEGER",
- /* 128 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options",
- /* 129 */ "cmd ::= CREATE TABLE multi_create_clause",
- /* 130 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options",
- /* 131 */ "cmd ::= DROP TABLE multi_drop_clause",
- /* 132 */ "cmd ::= DROP STABLE exists_opt full_table_name",
- /* 133 */ "cmd ::= ALTER TABLE alter_table_clause",
- /* 134 */ "cmd ::= ALTER STABLE alter_table_clause",
- /* 135 */ "alter_table_clause ::= full_table_name alter_table_options",
- /* 136 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name",
- /* 137 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name",
- /* 138 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name",
- /* 139 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name",
- /* 140 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name",
- /* 141 */ "alter_table_clause ::= full_table_name DROP TAG column_name",
- /* 142 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name",
- /* 143 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name",
- /* 144 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal",
- /* 145 */ "multi_create_clause ::= create_subtable_clause",
- /* 146 */ "multi_create_clause ::= multi_create_clause create_subtable_clause",
- /* 147 */ "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",
- /* 148 */ "multi_drop_clause ::= drop_table_clause",
- /* 149 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause",
- /* 150 */ "drop_table_clause ::= exists_opt full_table_name",
- /* 151 */ "specific_cols_opt ::=",
- /* 152 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP",
- /* 153 */ "full_table_name ::= table_name",
- /* 154 */ "full_table_name ::= db_name NK_DOT table_name",
- /* 155 */ "column_def_list ::= column_def",
- /* 156 */ "column_def_list ::= column_def_list NK_COMMA column_def",
- /* 157 */ "column_def ::= column_name type_name",
- /* 158 */ "column_def ::= column_name type_name COMMENT NK_STRING",
- /* 159 */ "type_name ::= BOOL",
- /* 160 */ "type_name ::= TINYINT",
- /* 161 */ "type_name ::= SMALLINT",
- /* 162 */ "type_name ::= INT",
- /* 163 */ "type_name ::= INTEGER",
- /* 164 */ "type_name ::= BIGINT",
- /* 165 */ "type_name ::= FLOAT",
- /* 166 */ "type_name ::= DOUBLE",
- /* 167 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP",
- /* 168 */ "type_name ::= TIMESTAMP",
- /* 169 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP",
- /* 170 */ "type_name ::= TINYINT UNSIGNED",
- /* 171 */ "type_name ::= SMALLINT UNSIGNED",
- /* 172 */ "type_name ::= INT UNSIGNED",
- /* 173 */ "type_name ::= BIGINT UNSIGNED",
- /* 174 */ "type_name ::= JSON",
- /* 175 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP",
- /* 176 */ "type_name ::= MEDIUMBLOB",
- /* 177 */ "type_name ::= BLOB",
- /* 178 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP",
- /* 179 */ "type_name ::= DECIMAL",
- /* 180 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP",
- /* 181 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP",
- /* 182 */ "tags_def_opt ::=",
- /* 183 */ "tags_def_opt ::= tags_def",
- /* 184 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP",
- /* 185 */ "table_options ::=",
- /* 186 */ "table_options ::= table_options COMMENT NK_STRING",
- /* 187 */ "table_options ::= table_options MAX_DELAY duration_list",
- /* 188 */ "table_options ::= table_options WATERMARK duration_list",
- /* 189 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP",
- /* 190 */ "table_options ::= table_options TTL NK_INTEGER",
- /* 191 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP",
- /* 192 */ "table_options ::= table_options DELETE_MARK duration_list",
- /* 193 */ "alter_table_options ::= alter_table_option",
- /* 194 */ "alter_table_options ::= alter_table_options alter_table_option",
- /* 195 */ "alter_table_option ::= COMMENT NK_STRING",
- /* 196 */ "alter_table_option ::= TTL NK_INTEGER",
- /* 197 */ "duration_list ::= duration_literal",
- /* 198 */ "duration_list ::= duration_list NK_COMMA duration_literal",
- /* 199 */ "rollup_func_list ::= rollup_func_name",
- /* 200 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name",
- /* 201 */ "rollup_func_name ::= function_name",
- /* 202 */ "rollup_func_name ::= FIRST",
- /* 203 */ "rollup_func_name ::= LAST",
- /* 204 */ "col_name_list ::= col_name",
- /* 205 */ "col_name_list ::= col_name_list NK_COMMA col_name",
- /* 206 */ "col_name ::= column_name",
- /* 207 */ "cmd ::= SHOW DNODES",
- /* 208 */ "cmd ::= SHOW USERS",
- /* 209 */ "cmd ::= SHOW USER PRIVILEGES",
- /* 210 */ "cmd ::= SHOW DATABASES",
- /* 211 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt",
- /* 212 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt",
- /* 213 */ "cmd ::= SHOW db_name_cond_opt VGROUPS",
- /* 214 */ "cmd ::= SHOW MNODES",
- /* 215 */ "cmd ::= SHOW QNODES",
- /* 216 */ "cmd ::= SHOW FUNCTIONS",
- /* 217 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt",
- /* 218 */ "cmd ::= SHOW STREAMS",
- /* 219 */ "cmd ::= SHOW ACCOUNTS",
- /* 220 */ "cmd ::= SHOW APPS",
- /* 221 */ "cmd ::= SHOW CONNECTIONS",
- /* 222 */ "cmd ::= SHOW LICENCES",
- /* 223 */ "cmd ::= SHOW GRANTS",
- /* 224 */ "cmd ::= SHOW CREATE DATABASE db_name",
- /* 225 */ "cmd ::= SHOW CREATE TABLE full_table_name",
- /* 226 */ "cmd ::= SHOW CREATE STABLE full_table_name",
- /* 227 */ "cmd ::= SHOW QUERIES",
- /* 228 */ "cmd ::= SHOW SCORES",
- /* 229 */ "cmd ::= SHOW TOPICS",
- /* 230 */ "cmd ::= SHOW VARIABLES",
- /* 231 */ "cmd ::= SHOW CLUSTER VARIABLES",
- /* 232 */ "cmd ::= SHOW LOCAL VARIABLES",
- /* 233 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt",
- /* 234 */ "cmd ::= SHOW BNODES",
- /* 235 */ "cmd ::= SHOW SNODES",
- /* 236 */ "cmd ::= SHOW CLUSTER",
- /* 237 */ "cmd ::= SHOW TRANSACTIONS",
- /* 238 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name",
- /* 239 */ "cmd ::= SHOW CONSUMERS",
- /* 240 */ "cmd ::= SHOW SUBSCRIPTIONS",
- /* 241 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt",
- /* 242 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt",
- /* 243 */ "cmd ::= SHOW VNODES NK_INTEGER",
- /* 244 */ "cmd ::= SHOW VNODES NK_STRING",
- /* 245 */ "cmd ::= SHOW db_name_cond_opt ALIVE",
- /* 246 */ "cmd ::= SHOW CLUSTER ALIVE",
- /* 247 */ "db_name_cond_opt ::=",
- /* 248 */ "db_name_cond_opt ::= db_name NK_DOT",
- /* 249 */ "like_pattern_opt ::=",
- /* 250 */ "like_pattern_opt ::= LIKE NK_STRING",
- /* 251 */ "table_name_cond ::= table_name",
- /* 252 */ "from_db_opt ::=",
- /* 253 */ "from_db_opt ::= FROM db_name",
- /* 254 */ "tag_list_opt ::=",
- /* 255 */ "tag_list_opt ::= tag_item",
- /* 256 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item",
- /* 257 */ "tag_item ::= TBNAME",
- /* 258 */ "tag_item ::= QTAGS",
- /* 259 */ "tag_item ::= column_name",
- /* 260 */ "tag_item ::= column_name column_alias",
- /* 261 */ "tag_item ::= column_name AS column_alias",
- /* 262 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options",
- /* 263 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP",
- /* 264 */ "cmd ::= DROP INDEX exists_opt full_index_name",
- /* 265 */ "full_index_name ::= index_name",
- /* 266 */ "full_index_name ::= db_name NK_DOT index_name",
- /* 267 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt",
- /* 268 */ "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",
- /* 269 */ "func_list ::= func",
- /* 270 */ "func_list ::= func_list NK_COMMA func",
- /* 271 */ "func ::= sma_func_name NK_LP expression_list NK_RP",
- /* 272 */ "sma_func_name ::= function_name",
- /* 273 */ "sma_func_name ::= COUNT",
- /* 274 */ "sma_func_name ::= FIRST",
- /* 275 */ "sma_func_name ::= LAST",
- /* 276 */ "sma_func_name ::= LAST_ROW",
- /* 277 */ "sma_stream_opt ::=",
- /* 278 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal",
- /* 279 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal",
- /* 280 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal",
- /* 281 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery",
- /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name",
- /* 283 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name",
- /* 284 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name",
- /* 285 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name",
- /* 286 */ "cmd ::= DROP TOPIC exists_opt topic_name",
- /* 287 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name",
- /* 288 */ "cmd ::= DESC full_table_name",
- /* 289 */ "cmd ::= DESCRIBE full_table_name",
- /* 290 */ "cmd ::= RESET QUERY CACHE",
- /* 291 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery",
- /* 292 */ "analyze_opt ::=",
- /* 293 */ "analyze_opt ::= ANALYZE",
- /* 294 */ "explain_options ::=",
- /* 295 */ "explain_options ::= explain_options VERBOSE NK_BOOL",
- /* 296 */ "explain_options ::= explain_options RATIO NK_FLOAT",
- /* 297 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt",
- /* 298 */ "cmd ::= DROP FUNCTION exists_opt function_name",
- /* 299 */ "agg_func_opt ::=",
- /* 300 */ "agg_func_opt ::= AGGREGATE",
- /* 301 */ "bufsize_opt ::=",
- /* 302 */ "bufsize_opt ::= BUFSIZE NK_INTEGER",
- /* 303 */ "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",
- /* 304 */ "cmd ::= DROP STREAM exists_opt stream_name",
- /* 305 */ "col_list_opt ::=",
- /* 306 */ "col_list_opt ::= NK_LP col_name_list NK_RP",
- /* 307 */ "tag_def_or_ref_opt ::=",
- /* 308 */ "tag_def_or_ref_opt ::= tags_def",
- /* 309 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP",
- /* 310 */ "stream_options ::=",
- /* 311 */ "stream_options ::= stream_options TRIGGER AT_ONCE",
- /* 312 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE",
- /* 313 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal",
- /* 314 */ "stream_options ::= stream_options WATERMARK duration_literal",
- /* 315 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER",
- /* 316 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER",
- /* 317 */ "subtable_opt ::=",
- /* 318 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP",
- /* 319 */ "cmd ::= KILL CONNECTION NK_INTEGER",
- /* 320 */ "cmd ::= KILL QUERY NK_STRING",
- /* 321 */ "cmd ::= KILL TRANSACTION NK_INTEGER",
- /* 322 */ "cmd ::= BALANCE VGROUP",
- /* 323 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER",
- /* 324 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list",
- /* 325 */ "cmd ::= SPLIT VGROUP NK_INTEGER",
- /* 326 */ "dnode_list ::= DNODE NK_INTEGER",
- /* 327 */ "dnode_list ::= dnode_list DNODE NK_INTEGER",
- /* 328 */ "cmd ::= DELETE FROM full_table_name where_clause_opt",
- /* 329 */ "cmd ::= query_or_subquery",
- /* 330 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery",
- /* 331 */ "cmd ::= INSERT INTO full_table_name query_or_subquery",
- /* 332 */ "literal ::= NK_INTEGER",
- /* 333 */ "literal ::= NK_FLOAT",
- /* 334 */ "literal ::= NK_STRING",
- /* 335 */ "literal ::= NK_BOOL",
- /* 336 */ "literal ::= TIMESTAMP NK_STRING",
- /* 337 */ "literal ::= duration_literal",
- /* 338 */ "literal ::= NULL",
- /* 339 */ "literal ::= NK_QUESTION",
- /* 340 */ "duration_literal ::= NK_VARIABLE",
- /* 341 */ "signed ::= NK_INTEGER",
- /* 342 */ "signed ::= NK_PLUS NK_INTEGER",
- /* 343 */ "signed ::= NK_MINUS NK_INTEGER",
- /* 344 */ "signed ::= NK_FLOAT",
- /* 345 */ "signed ::= NK_PLUS NK_FLOAT",
- /* 346 */ "signed ::= NK_MINUS NK_FLOAT",
- /* 347 */ "signed_literal ::= signed",
- /* 348 */ "signed_literal ::= NK_STRING",
- /* 349 */ "signed_literal ::= NK_BOOL",
- /* 350 */ "signed_literal ::= TIMESTAMP NK_STRING",
- /* 351 */ "signed_literal ::= duration_literal",
- /* 352 */ "signed_literal ::= NULL",
- /* 353 */ "signed_literal ::= literal_func",
- /* 354 */ "signed_literal ::= NK_QUESTION",
- /* 355 */ "literal_list ::= signed_literal",
- /* 356 */ "literal_list ::= literal_list NK_COMMA signed_literal",
- /* 357 */ "db_name ::= NK_ID",
- /* 358 */ "table_name ::= NK_ID",
- /* 359 */ "column_name ::= NK_ID",
- /* 360 */ "function_name ::= NK_ID",
- /* 361 */ "table_alias ::= NK_ID",
- /* 362 */ "column_alias ::= NK_ID",
- /* 363 */ "user_name ::= NK_ID",
- /* 364 */ "topic_name ::= NK_ID",
- /* 365 */ "stream_name ::= NK_ID",
- /* 366 */ "cgroup_name ::= NK_ID",
- /* 367 */ "index_name ::= NK_ID",
- /* 368 */ "expr_or_subquery ::= expression",
- /* 369 */ "expression ::= literal",
- /* 370 */ "expression ::= pseudo_column",
- /* 371 */ "expression ::= column_reference",
- /* 372 */ "expression ::= function_expression",
- /* 373 */ "expression ::= case_when_expression",
- /* 374 */ "expression ::= NK_LP expression NK_RP",
- /* 375 */ "expression ::= NK_PLUS expr_or_subquery",
- /* 376 */ "expression ::= NK_MINUS expr_or_subquery",
- /* 377 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery",
- /* 378 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery",
- /* 379 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery",
- /* 380 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery",
- /* 381 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery",
- /* 382 */ "expression ::= column_reference NK_ARROW NK_STRING",
- /* 383 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery",
- /* 384 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery",
- /* 385 */ "expression_list ::= expr_or_subquery",
- /* 386 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery",
- /* 387 */ "column_reference ::= column_name",
- /* 388 */ "column_reference ::= table_name NK_DOT column_name",
- /* 389 */ "pseudo_column ::= ROWTS",
- /* 390 */ "pseudo_column ::= TBNAME",
- /* 391 */ "pseudo_column ::= table_name NK_DOT TBNAME",
- /* 392 */ "pseudo_column ::= QSTART",
- /* 393 */ "pseudo_column ::= QEND",
- /* 394 */ "pseudo_column ::= QDURATION",
- /* 395 */ "pseudo_column ::= WSTART",
- /* 396 */ "pseudo_column ::= WEND",
- /* 397 */ "pseudo_column ::= WDURATION",
- /* 398 */ "pseudo_column ::= IROWTS",
- /* 399 */ "pseudo_column ::= ISFILLED",
- /* 400 */ "pseudo_column ::= QTAGS",
- /* 401 */ "function_expression ::= function_name NK_LP expression_list NK_RP",
- /* 402 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP",
- /* 403 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP",
- /* 404 */ "function_expression ::= literal_func",
- /* 405 */ "literal_func ::= noarg_func NK_LP NK_RP",
- /* 406 */ "literal_func ::= NOW",
- /* 407 */ "noarg_func ::= NOW",
- /* 408 */ "noarg_func ::= TODAY",
- /* 409 */ "noarg_func ::= TIMEZONE",
- /* 410 */ "noarg_func ::= DATABASE",
- /* 411 */ "noarg_func ::= CLIENT_VERSION",
- /* 412 */ "noarg_func ::= SERVER_VERSION",
- /* 413 */ "noarg_func ::= SERVER_STATUS",
- /* 414 */ "noarg_func ::= CURRENT_USER",
- /* 415 */ "noarg_func ::= USER",
- /* 416 */ "star_func ::= COUNT",
- /* 417 */ "star_func ::= FIRST",
- /* 418 */ "star_func ::= LAST",
- /* 419 */ "star_func ::= LAST_ROW",
- /* 420 */ "star_func_para_list ::= NK_STAR",
- /* 421 */ "star_func_para_list ::= other_para_list",
- /* 422 */ "other_para_list ::= star_func_para",
- /* 423 */ "other_para_list ::= other_para_list NK_COMMA star_func_para",
- /* 424 */ "star_func_para ::= expr_or_subquery",
- /* 425 */ "star_func_para ::= table_name NK_DOT NK_STAR",
- /* 426 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END",
- /* 427 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END",
- /* 428 */ "when_then_list ::= when_then_expr",
- /* 429 */ "when_then_list ::= when_then_list when_then_expr",
- /* 430 */ "when_then_expr ::= WHEN common_expression THEN common_expression",
- /* 431 */ "case_when_else_opt ::=",
- /* 432 */ "case_when_else_opt ::= ELSE common_expression",
- /* 433 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery",
- /* 434 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery",
- /* 435 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery",
- /* 436 */ "predicate ::= expr_or_subquery IS NULL",
- /* 437 */ "predicate ::= expr_or_subquery IS NOT NULL",
- /* 438 */ "predicate ::= expr_or_subquery in_op in_predicate_value",
- /* 439 */ "compare_op ::= NK_LT",
- /* 440 */ "compare_op ::= NK_GT",
- /* 441 */ "compare_op ::= NK_LE",
- /* 442 */ "compare_op ::= NK_GE",
- /* 443 */ "compare_op ::= NK_NE",
- /* 444 */ "compare_op ::= NK_EQ",
- /* 445 */ "compare_op ::= LIKE",
- /* 446 */ "compare_op ::= NOT LIKE",
- /* 447 */ "compare_op ::= MATCH",
- /* 448 */ "compare_op ::= NMATCH",
- /* 449 */ "compare_op ::= CONTAINS",
- /* 450 */ "in_op ::= IN",
- /* 451 */ "in_op ::= NOT IN",
- /* 452 */ "in_predicate_value ::= NK_LP literal_list NK_RP",
- /* 453 */ "boolean_value_expression ::= boolean_primary",
- /* 454 */ "boolean_value_expression ::= NOT boolean_primary",
- /* 455 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
- /* 456 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
- /* 457 */ "boolean_primary ::= predicate",
- /* 458 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
- /* 459 */ "common_expression ::= expr_or_subquery",
- /* 460 */ "common_expression ::= boolean_value_expression",
- /* 461 */ "from_clause_opt ::=",
- /* 462 */ "from_clause_opt ::= FROM table_reference_list",
- /* 463 */ "table_reference_list ::= table_reference",
- /* 464 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
- /* 465 */ "table_reference ::= table_primary",
- /* 466 */ "table_reference ::= joined_table",
- /* 467 */ "table_primary ::= table_name alias_opt",
- /* 468 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
- /* 469 */ "table_primary ::= subquery alias_opt",
- /* 470 */ "table_primary ::= parenthesized_joined_table",
- /* 471 */ "alias_opt ::=",
- /* 472 */ "alias_opt ::= table_alias",
- /* 473 */ "alias_opt ::= AS table_alias",
- /* 474 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
- /* 475 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
- /* 476 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
- /* 477 */ "join_type ::=",
- /* 478 */ "join_type ::= INNER",
- /* 479 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
- /* 480 */ "set_quantifier_opt ::=",
- /* 481 */ "set_quantifier_opt ::= DISTINCT",
- /* 482 */ "set_quantifier_opt ::= ALL",
- /* 483 */ "select_list ::= select_item",
- /* 484 */ "select_list ::= select_list NK_COMMA select_item",
- /* 485 */ "select_item ::= NK_STAR",
- /* 486 */ "select_item ::= common_expression",
- /* 487 */ "select_item ::= common_expression column_alias",
- /* 488 */ "select_item ::= common_expression AS column_alias",
- /* 489 */ "select_item ::= table_name NK_DOT NK_STAR",
- /* 490 */ "where_clause_opt ::=",
- /* 491 */ "where_clause_opt ::= WHERE search_condition",
- /* 492 */ "partition_by_clause_opt ::=",
- /* 493 */ "partition_by_clause_opt ::= PARTITION BY partition_list",
- /* 494 */ "partition_list ::= partition_item",
- /* 495 */ "partition_list ::= partition_list NK_COMMA partition_item",
- /* 496 */ "partition_item ::= expr_or_subquery",
- /* 497 */ "partition_item ::= expr_or_subquery column_alias",
- /* 498 */ "partition_item ::= expr_or_subquery AS column_alias",
- /* 499 */ "twindow_clause_opt ::=",
- /* 500 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP",
- /* 501 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP",
- /* 502 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
- /* 503 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
- /* 504 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition",
- /* 505 */ "sliding_opt ::=",
- /* 506 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
- /* 507 */ "fill_opt ::=",
- /* 508 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
- /* 509 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
- /* 510 */ "fill_mode ::= NONE",
- /* 511 */ "fill_mode ::= PREV",
- /* 512 */ "fill_mode ::= NULL",
- /* 513 */ "fill_mode ::= LINEAR",
- /* 514 */ "fill_mode ::= NEXT",
- /* 515 */ "group_by_clause_opt ::=",
- /* 516 */ "group_by_clause_opt ::= GROUP BY group_by_list",
- /* 517 */ "group_by_list ::= expr_or_subquery",
- /* 518 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery",
- /* 519 */ "having_clause_opt ::=",
- /* 520 */ "having_clause_opt ::= HAVING search_condition",
- /* 521 */ "range_opt ::=",
- /* 522 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP",
- /* 523 */ "every_opt ::=",
- /* 524 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP",
- /* 525 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt",
- /* 526 */ "query_simple ::= query_specification",
- /* 527 */ "query_simple ::= union_query_expression",
- /* 528 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery",
- /* 529 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery",
- /* 530 */ "query_simple_or_subquery ::= query_simple",
- /* 531 */ "query_simple_or_subquery ::= subquery",
- /* 532 */ "query_or_subquery ::= query_expression",
- /* 533 */ "query_or_subquery ::= subquery",
- /* 534 */ "order_by_clause_opt ::=",
- /* 535 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
- /* 536 */ "slimit_clause_opt ::=",
- /* 537 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
- /* 538 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
- /* 539 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 540 */ "limit_clause_opt ::=",
- /* 541 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
- /* 542 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
- /* 543 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 544 */ "subquery ::= NK_LP query_expression NK_RP",
- /* 545 */ "subquery ::= NK_LP subquery NK_RP",
- /* 546 */ "search_condition ::= common_expression",
- /* 547 */ "sort_specification_list ::= sort_specification",
- /* 548 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
- /* 549 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt",
- /* 550 */ "ordering_specification_opt ::=",
- /* 551 */ "ordering_specification_opt ::= ASC",
- /* 552 */ "ordering_specification_opt ::= DESC",
- /* 553 */ "null_ordering_opt ::=",
- /* 554 */ "null_ordering_opt ::= NULLS FIRST",
- /* 555 */ "null_ordering_opt ::= NULLS LAST",
+ /* 72 */ "cmd ::= COMPACT DATABASE db_name",
+ /* 73 */ "not_exists_opt ::= IF NOT EXISTS",
+ /* 74 */ "not_exists_opt ::=",
+ /* 75 */ "exists_opt ::= IF EXISTS",
+ /* 76 */ "exists_opt ::=",
+ /* 77 */ "db_options ::=",
+ /* 78 */ "db_options ::= db_options BUFFER NK_INTEGER",
+ /* 79 */ "db_options ::= db_options CACHEMODEL NK_STRING",
+ /* 80 */ "db_options ::= db_options CACHESIZE NK_INTEGER",
+ /* 81 */ "db_options ::= db_options COMP NK_INTEGER",
+ /* 82 */ "db_options ::= db_options DURATION NK_INTEGER",
+ /* 83 */ "db_options ::= db_options DURATION NK_VARIABLE",
+ /* 84 */ "db_options ::= db_options MAXROWS NK_INTEGER",
+ /* 85 */ "db_options ::= db_options MINROWS NK_INTEGER",
+ /* 86 */ "db_options ::= db_options KEEP integer_list",
+ /* 87 */ "db_options ::= db_options KEEP variable_list",
+ /* 88 */ "db_options ::= db_options PAGES NK_INTEGER",
+ /* 89 */ "db_options ::= db_options PAGESIZE NK_INTEGER",
+ /* 90 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER",
+ /* 91 */ "db_options ::= db_options PRECISION NK_STRING",
+ /* 92 */ "db_options ::= db_options REPLICA NK_INTEGER",
+ /* 93 */ "db_options ::= db_options VGROUPS NK_INTEGER",
+ /* 94 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER",
+ /* 95 */ "db_options ::= db_options RETENTIONS retention_list",
+ /* 96 */ "db_options ::= db_options SCHEMALESS NK_INTEGER",
+ /* 97 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER",
+ /* 98 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER",
+ /* 99 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER",
+ /* 100 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER",
+ /* 101 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER",
+ /* 102 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER",
+ /* 103 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER",
+ /* 104 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER",
+ /* 105 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER",
+ /* 106 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER",
+ /* 107 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER",
+ /* 108 */ "alter_db_options ::= alter_db_option",
+ /* 109 */ "alter_db_options ::= alter_db_options alter_db_option",
+ /* 110 */ "alter_db_option ::= BUFFER NK_INTEGER",
+ /* 111 */ "alter_db_option ::= CACHEMODEL NK_STRING",
+ /* 112 */ "alter_db_option ::= CACHESIZE NK_INTEGER",
+ /* 113 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER",
+ /* 114 */ "alter_db_option ::= KEEP integer_list",
+ /* 115 */ "alter_db_option ::= KEEP variable_list",
+ /* 116 */ "alter_db_option ::= PAGES NK_INTEGER",
+ /* 117 */ "alter_db_option ::= REPLICA NK_INTEGER",
+ /* 118 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER",
+ /* 119 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER",
+ /* 120 */ "integer_list ::= NK_INTEGER",
+ /* 121 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER",
+ /* 122 */ "variable_list ::= NK_VARIABLE",
+ /* 123 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE",
+ /* 124 */ "retention_list ::= retention",
+ /* 125 */ "retention_list ::= retention_list NK_COMMA retention",
+ /* 126 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE",
+ /* 127 */ "speed_opt ::=",
+ /* 128 */ "speed_opt ::= MAX_SPEED NK_INTEGER",
+ /* 129 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options",
+ /* 130 */ "cmd ::= CREATE TABLE multi_create_clause",
+ /* 131 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options",
+ /* 132 */ "cmd ::= DROP TABLE multi_drop_clause",
+ /* 133 */ "cmd ::= DROP STABLE exists_opt full_table_name",
+ /* 134 */ "cmd ::= ALTER TABLE alter_table_clause",
+ /* 135 */ "cmd ::= ALTER STABLE alter_table_clause",
+ /* 136 */ "alter_table_clause ::= full_table_name alter_table_options",
+ /* 137 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name",
+ /* 138 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name",
+ /* 139 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name",
+ /* 140 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name",
+ /* 141 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name",
+ /* 142 */ "alter_table_clause ::= full_table_name DROP TAG column_name",
+ /* 143 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name",
+ /* 144 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name",
+ /* 145 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal",
+ /* 146 */ "multi_create_clause ::= create_subtable_clause",
+ /* 147 */ "multi_create_clause ::= multi_create_clause create_subtable_clause",
+ /* 148 */ "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",
+ /* 149 */ "multi_drop_clause ::= drop_table_clause",
+ /* 150 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause",
+ /* 151 */ "drop_table_clause ::= exists_opt full_table_name",
+ /* 152 */ "specific_cols_opt ::=",
+ /* 153 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP",
+ /* 154 */ "full_table_name ::= table_name",
+ /* 155 */ "full_table_name ::= db_name NK_DOT table_name",
+ /* 156 */ "column_def_list ::= column_def",
+ /* 157 */ "column_def_list ::= column_def_list NK_COMMA column_def",
+ /* 158 */ "column_def ::= column_name type_name",
+ /* 159 */ "column_def ::= column_name type_name COMMENT NK_STRING",
+ /* 160 */ "type_name ::= BOOL",
+ /* 161 */ "type_name ::= TINYINT",
+ /* 162 */ "type_name ::= SMALLINT",
+ /* 163 */ "type_name ::= INT",
+ /* 164 */ "type_name ::= INTEGER",
+ /* 165 */ "type_name ::= BIGINT",
+ /* 166 */ "type_name ::= FLOAT",
+ /* 167 */ "type_name ::= DOUBLE",
+ /* 168 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP",
+ /* 169 */ "type_name ::= TIMESTAMP",
+ /* 170 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP",
+ /* 171 */ "type_name ::= TINYINT UNSIGNED",
+ /* 172 */ "type_name ::= SMALLINT UNSIGNED",
+ /* 173 */ "type_name ::= INT UNSIGNED",
+ /* 174 */ "type_name ::= BIGINT UNSIGNED",
+ /* 175 */ "type_name ::= JSON",
+ /* 176 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP",
+ /* 177 */ "type_name ::= MEDIUMBLOB",
+ /* 178 */ "type_name ::= BLOB",
+ /* 179 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP",
+ /* 180 */ "type_name ::= DECIMAL",
+ /* 181 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP",
+ /* 182 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP",
+ /* 183 */ "tags_def_opt ::=",
+ /* 184 */ "tags_def_opt ::= tags_def",
+ /* 185 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP",
+ /* 186 */ "table_options ::=",
+ /* 187 */ "table_options ::= table_options COMMENT NK_STRING",
+ /* 188 */ "table_options ::= table_options MAX_DELAY duration_list",
+ /* 189 */ "table_options ::= table_options WATERMARK duration_list",
+ /* 190 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP",
+ /* 191 */ "table_options ::= table_options TTL NK_INTEGER",
+ /* 192 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP",
+ /* 193 */ "table_options ::= table_options DELETE_MARK duration_list",
+ /* 194 */ "alter_table_options ::= alter_table_option",
+ /* 195 */ "alter_table_options ::= alter_table_options alter_table_option",
+ /* 196 */ "alter_table_option ::= COMMENT NK_STRING",
+ /* 197 */ "alter_table_option ::= TTL NK_INTEGER",
+ /* 198 */ "duration_list ::= duration_literal",
+ /* 199 */ "duration_list ::= duration_list NK_COMMA duration_literal",
+ /* 200 */ "rollup_func_list ::= rollup_func_name",
+ /* 201 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name",
+ /* 202 */ "rollup_func_name ::= function_name",
+ /* 203 */ "rollup_func_name ::= FIRST",
+ /* 204 */ "rollup_func_name ::= LAST",
+ /* 205 */ "col_name_list ::= col_name",
+ /* 206 */ "col_name_list ::= col_name_list NK_COMMA col_name",
+ /* 207 */ "col_name ::= column_name",
+ /* 208 */ "cmd ::= SHOW DNODES",
+ /* 209 */ "cmd ::= SHOW USERS",
+ /* 210 */ "cmd ::= SHOW USER PRIVILEGES",
+ /* 211 */ "cmd ::= SHOW DATABASES",
+ /* 212 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt",
+ /* 213 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt",
+ /* 214 */ "cmd ::= SHOW db_name_cond_opt VGROUPS",
+ /* 215 */ "cmd ::= SHOW MNODES",
+ /* 216 */ "cmd ::= SHOW QNODES",
+ /* 217 */ "cmd ::= SHOW FUNCTIONS",
+ /* 218 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt",
+ /* 219 */ "cmd ::= SHOW STREAMS",
+ /* 220 */ "cmd ::= SHOW ACCOUNTS",
+ /* 221 */ "cmd ::= SHOW APPS",
+ /* 222 */ "cmd ::= SHOW CONNECTIONS",
+ /* 223 */ "cmd ::= SHOW LICENCES",
+ /* 224 */ "cmd ::= SHOW GRANTS",
+ /* 225 */ "cmd ::= SHOW CREATE DATABASE db_name",
+ /* 226 */ "cmd ::= SHOW CREATE TABLE full_table_name",
+ /* 227 */ "cmd ::= SHOW CREATE STABLE full_table_name",
+ /* 228 */ "cmd ::= SHOW QUERIES",
+ /* 229 */ "cmd ::= SHOW SCORES",
+ /* 230 */ "cmd ::= SHOW TOPICS",
+ /* 231 */ "cmd ::= SHOW VARIABLES",
+ /* 232 */ "cmd ::= SHOW CLUSTER VARIABLES",
+ /* 233 */ "cmd ::= SHOW LOCAL VARIABLES",
+ /* 234 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt",
+ /* 235 */ "cmd ::= SHOW BNODES",
+ /* 236 */ "cmd ::= SHOW SNODES",
+ /* 237 */ "cmd ::= SHOW CLUSTER",
+ /* 238 */ "cmd ::= SHOW TRANSACTIONS",
+ /* 239 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name",
+ /* 240 */ "cmd ::= SHOW CONSUMERS",
+ /* 241 */ "cmd ::= SHOW SUBSCRIPTIONS",
+ /* 242 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt",
+ /* 243 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt",
+ /* 244 */ "cmd ::= SHOW VNODES NK_INTEGER",
+ /* 245 */ "cmd ::= SHOW VNODES NK_STRING",
+ /* 246 */ "cmd ::= SHOW db_name_cond_opt ALIVE",
+ /* 247 */ "cmd ::= SHOW CLUSTER ALIVE",
+ /* 248 */ "db_name_cond_opt ::=",
+ /* 249 */ "db_name_cond_opt ::= db_name NK_DOT",
+ /* 250 */ "like_pattern_opt ::=",
+ /* 251 */ "like_pattern_opt ::= LIKE NK_STRING",
+ /* 252 */ "table_name_cond ::= table_name",
+ /* 253 */ "from_db_opt ::=",
+ /* 254 */ "from_db_opt ::= FROM db_name",
+ /* 255 */ "tag_list_opt ::=",
+ /* 256 */ "tag_list_opt ::= tag_item",
+ /* 257 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item",
+ /* 258 */ "tag_item ::= TBNAME",
+ /* 259 */ "tag_item ::= QTAGS",
+ /* 260 */ "tag_item ::= column_name",
+ /* 261 */ "tag_item ::= column_name column_alias",
+ /* 262 */ "tag_item ::= column_name AS column_alias",
+ /* 263 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options",
+ /* 264 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP",
+ /* 265 */ "cmd ::= DROP INDEX exists_opt full_index_name",
+ /* 266 */ "full_index_name ::= index_name",
+ /* 267 */ "full_index_name ::= db_name NK_DOT index_name",
+ /* 268 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt",
+ /* 269 */ "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",
+ /* 270 */ "func_list ::= func",
+ /* 271 */ "func_list ::= func_list NK_COMMA func",
+ /* 272 */ "func ::= sma_func_name NK_LP expression_list NK_RP",
+ /* 273 */ "sma_func_name ::= function_name",
+ /* 274 */ "sma_func_name ::= COUNT",
+ /* 275 */ "sma_func_name ::= FIRST",
+ /* 276 */ "sma_func_name ::= LAST",
+ /* 277 */ "sma_func_name ::= LAST_ROW",
+ /* 278 */ "sma_stream_opt ::=",
+ /* 279 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal",
+ /* 280 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal",
+ /* 281 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal",
+ /* 282 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery",
+ /* 283 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name",
+ /* 284 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name",
+ /* 285 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name",
+ /* 286 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name",
+ /* 287 */ "cmd ::= DROP TOPIC exists_opt topic_name",
+ /* 288 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name",
+ /* 289 */ "cmd ::= DESC full_table_name",
+ /* 290 */ "cmd ::= DESCRIBE full_table_name",
+ /* 291 */ "cmd ::= RESET QUERY CACHE",
+ /* 292 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery",
+ /* 293 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query",
+ /* 294 */ "analyze_opt ::=",
+ /* 295 */ "analyze_opt ::= ANALYZE",
+ /* 296 */ "explain_options ::=",
+ /* 297 */ "explain_options ::= explain_options VERBOSE NK_BOOL",
+ /* 298 */ "explain_options ::= explain_options RATIO NK_FLOAT",
+ /* 299 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt",
+ /* 300 */ "cmd ::= DROP FUNCTION exists_opt function_name",
+ /* 301 */ "agg_func_opt ::=",
+ /* 302 */ "agg_func_opt ::= AGGREGATE",
+ /* 303 */ "bufsize_opt ::=",
+ /* 304 */ "bufsize_opt ::= BUFSIZE NK_INTEGER",
+ /* 305 */ "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",
+ /* 306 */ "cmd ::= DROP STREAM exists_opt stream_name",
+ /* 307 */ "col_list_opt ::=",
+ /* 308 */ "col_list_opt ::= NK_LP col_name_list NK_RP",
+ /* 309 */ "tag_def_or_ref_opt ::=",
+ /* 310 */ "tag_def_or_ref_opt ::= tags_def",
+ /* 311 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP",
+ /* 312 */ "stream_options ::=",
+ /* 313 */ "stream_options ::= stream_options TRIGGER AT_ONCE",
+ /* 314 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE",
+ /* 315 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal",
+ /* 316 */ "stream_options ::= stream_options WATERMARK duration_literal",
+ /* 317 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER",
+ /* 318 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER",
+ /* 319 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER",
+ /* 320 */ "subtable_opt ::=",
+ /* 321 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP",
+ /* 322 */ "cmd ::= KILL CONNECTION NK_INTEGER",
+ /* 323 */ "cmd ::= KILL QUERY NK_STRING",
+ /* 324 */ "cmd ::= KILL TRANSACTION NK_INTEGER",
+ /* 325 */ "cmd ::= BALANCE VGROUP",
+ /* 326 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER",
+ /* 327 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list",
+ /* 328 */ "cmd ::= SPLIT VGROUP NK_INTEGER",
+ /* 329 */ "dnode_list ::= DNODE NK_INTEGER",
+ /* 330 */ "dnode_list ::= dnode_list DNODE NK_INTEGER",
+ /* 331 */ "cmd ::= DELETE FROM full_table_name where_clause_opt",
+ /* 332 */ "cmd ::= query_or_subquery",
+ /* 333 */ "cmd ::= insert_query",
+ /* 334 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery",
+ /* 335 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery",
+ /* 336 */ "literal ::= NK_INTEGER",
+ /* 337 */ "literal ::= NK_FLOAT",
+ /* 338 */ "literal ::= NK_STRING",
+ /* 339 */ "literal ::= NK_BOOL",
+ /* 340 */ "literal ::= TIMESTAMP NK_STRING",
+ /* 341 */ "literal ::= duration_literal",
+ /* 342 */ "literal ::= NULL",
+ /* 343 */ "literal ::= NK_QUESTION",
+ /* 344 */ "duration_literal ::= NK_VARIABLE",
+ /* 345 */ "signed ::= NK_INTEGER",
+ /* 346 */ "signed ::= NK_PLUS NK_INTEGER",
+ /* 347 */ "signed ::= NK_MINUS NK_INTEGER",
+ /* 348 */ "signed ::= NK_FLOAT",
+ /* 349 */ "signed ::= NK_PLUS NK_FLOAT",
+ /* 350 */ "signed ::= NK_MINUS NK_FLOAT",
+ /* 351 */ "signed_literal ::= signed",
+ /* 352 */ "signed_literal ::= NK_STRING",
+ /* 353 */ "signed_literal ::= NK_BOOL",
+ /* 354 */ "signed_literal ::= TIMESTAMP NK_STRING",
+ /* 355 */ "signed_literal ::= duration_literal",
+ /* 356 */ "signed_literal ::= NULL",
+ /* 357 */ "signed_literal ::= literal_func",
+ /* 358 */ "signed_literal ::= NK_QUESTION",
+ /* 359 */ "literal_list ::= signed_literal",
+ /* 360 */ "literal_list ::= literal_list NK_COMMA signed_literal",
+ /* 361 */ "db_name ::= NK_ID",
+ /* 362 */ "table_name ::= NK_ID",
+ /* 363 */ "column_name ::= NK_ID",
+ /* 364 */ "function_name ::= NK_ID",
+ /* 365 */ "table_alias ::= NK_ID",
+ /* 366 */ "column_alias ::= NK_ID",
+ /* 367 */ "user_name ::= NK_ID",
+ /* 368 */ "topic_name ::= NK_ID",
+ /* 369 */ "stream_name ::= NK_ID",
+ /* 370 */ "cgroup_name ::= NK_ID",
+ /* 371 */ "index_name ::= NK_ID",
+ /* 372 */ "expr_or_subquery ::= expression",
+ /* 373 */ "expression ::= literal",
+ /* 374 */ "expression ::= pseudo_column",
+ /* 375 */ "expression ::= column_reference",
+ /* 376 */ "expression ::= function_expression",
+ /* 377 */ "expression ::= case_when_expression",
+ /* 378 */ "expression ::= NK_LP expression NK_RP",
+ /* 379 */ "expression ::= NK_PLUS expr_or_subquery",
+ /* 380 */ "expression ::= NK_MINUS expr_or_subquery",
+ /* 381 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery",
+ /* 382 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery",
+ /* 383 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery",
+ /* 384 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery",
+ /* 385 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery",
+ /* 386 */ "expression ::= column_reference NK_ARROW NK_STRING",
+ /* 387 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery",
+ /* 388 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery",
+ /* 389 */ "expression_list ::= expr_or_subquery",
+ /* 390 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery",
+ /* 391 */ "column_reference ::= column_name",
+ /* 392 */ "column_reference ::= table_name NK_DOT column_name",
+ /* 393 */ "pseudo_column ::= ROWTS",
+ /* 394 */ "pseudo_column ::= TBNAME",
+ /* 395 */ "pseudo_column ::= table_name NK_DOT TBNAME",
+ /* 396 */ "pseudo_column ::= QSTART",
+ /* 397 */ "pseudo_column ::= QEND",
+ /* 398 */ "pseudo_column ::= QDURATION",
+ /* 399 */ "pseudo_column ::= WSTART",
+ /* 400 */ "pseudo_column ::= WEND",
+ /* 401 */ "pseudo_column ::= WDURATION",
+ /* 402 */ "pseudo_column ::= IROWTS",
+ /* 403 */ "pseudo_column ::= ISFILLED",
+ /* 404 */ "pseudo_column ::= QTAGS",
+ /* 405 */ "function_expression ::= function_name NK_LP expression_list NK_RP",
+ /* 406 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP",
+ /* 407 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP",
+ /* 408 */ "function_expression ::= literal_func",
+ /* 409 */ "literal_func ::= noarg_func NK_LP NK_RP",
+ /* 410 */ "literal_func ::= NOW",
+ /* 411 */ "noarg_func ::= NOW",
+ /* 412 */ "noarg_func ::= TODAY",
+ /* 413 */ "noarg_func ::= TIMEZONE",
+ /* 414 */ "noarg_func ::= DATABASE",
+ /* 415 */ "noarg_func ::= CLIENT_VERSION",
+ /* 416 */ "noarg_func ::= SERVER_VERSION",
+ /* 417 */ "noarg_func ::= SERVER_STATUS",
+ /* 418 */ "noarg_func ::= CURRENT_USER",
+ /* 419 */ "noarg_func ::= USER",
+ /* 420 */ "star_func ::= COUNT",
+ /* 421 */ "star_func ::= FIRST",
+ /* 422 */ "star_func ::= LAST",
+ /* 423 */ "star_func ::= LAST_ROW",
+ /* 424 */ "star_func_para_list ::= NK_STAR",
+ /* 425 */ "star_func_para_list ::= other_para_list",
+ /* 426 */ "other_para_list ::= star_func_para",
+ /* 427 */ "other_para_list ::= other_para_list NK_COMMA star_func_para",
+ /* 428 */ "star_func_para ::= expr_or_subquery",
+ /* 429 */ "star_func_para ::= table_name NK_DOT NK_STAR",
+ /* 430 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END",
+ /* 431 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END",
+ /* 432 */ "when_then_list ::= when_then_expr",
+ /* 433 */ "when_then_list ::= when_then_list when_then_expr",
+ /* 434 */ "when_then_expr ::= WHEN common_expression THEN common_expression",
+ /* 435 */ "case_when_else_opt ::=",
+ /* 436 */ "case_when_else_opt ::= ELSE common_expression",
+ /* 437 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery",
+ /* 438 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery",
+ /* 439 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery",
+ /* 440 */ "predicate ::= expr_or_subquery IS NULL",
+ /* 441 */ "predicate ::= expr_or_subquery IS NOT NULL",
+ /* 442 */ "predicate ::= expr_or_subquery in_op in_predicate_value",
+ /* 443 */ "compare_op ::= NK_LT",
+ /* 444 */ "compare_op ::= NK_GT",
+ /* 445 */ "compare_op ::= NK_LE",
+ /* 446 */ "compare_op ::= NK_GE",
+ /* 447 */ "compare_op ::= NK_NE",
+ /* 448 */ "compare_op ::= NK_EQ",
+ /* 449 */ "compare_op ::= LIKE",
+ /* 450 */ "compare_op ::= NOT LIKE",
+ /* 451 */ "compare_op ::= MATCH",
+ /* 452 */ "compare_op ::= NMATCH",
+ /* 453 */ "compare_op ::= CONTAINS",
+ /* 454 */ "in_op ::= IN",
+ /* 455 */ "in_op ::= NOT IN",
+ /* 456 */ "in_predicate_value ::= NK_LP literal_list NK_RP",
+ /* 457 */ "boolean_value_expression ::= boolean_primary",
+ /* 458 */ "boolean_value_expression ::= NOT boolean_primary",
+ /* 459 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
+ /* 460 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
+ /* 461 */ "boolean_primary ::= predicate",
+ /* 462 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
+ /* 463 */ "common_expression ::= expr_or_subquery",
+ /* 464 */ "common_expression ::= boolean_value_expression",
+ /* 465 */ "from_clause_opt ::=",
+ /* 466 */ "from_clause_opt ::= FROM table_reference_list",
+ /* 467 */ "table_reference_list ::= table_reference",
+ /* 468 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
+ /* 469 */ "table_reference ::= table_primary",
+ /* 470 */ "table_reference ::= joined_table",
+ /* 471 */ "table_primary ::= table_name alias_opt",
+ /* 472 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
+ /* 473 */ "table_primary ::= subquery alias_opt",
+ /* 474 */ "table_primary ::= parenthesized_joined_table",
+ /* 475 */ "alias_opt ::=",
+ /* 476 */ "alias_opt ::= table_alias",
+ /* 477 */ "alias_opt ::= AS table_alias",
+ /* 478 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
+ /* 479 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
+ /* 480 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
+ /* 481 */ "join_type ::=",
+ /* 482 */ "join_type ::= INNER",
+ /* 483 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
+ /* 484 */ "set_quantifier_opt ::=",
+ /* 485 */ "set_quantifier_opt ::= DISTINCT",
+ /* 486 */ "set_quantifier_opt ::= ALL",
+ /* 487 */ "select_list ::= select_item",
+ /* 488 */ "select_list ::= select_list NK_COMMA select_item",
+ /* 489 */ "select_item ::= NK_STAR",
+ /* 490 */ "select_item ::= common_expression",
+ /* 491 */ "select_item ::= common_expression column_alias",
+ /* 492 */ "select_item ::= common_expression AS column_alias",
+ /* 493 */ "select_item ::= table_name NK_DOT NK_STAR",
+ /* 494 */ "where_clause_opt ::=",
+ /* 495 */ "where_clause_opt ::= WHERE search_condition",
+ /* 496 */ "partition_by_clause_opt ::=",
+ /* 497 */ "partition_by_clause_opt ::= PARTITION BY partition_list",
+ /* 498 */ "partition_list ::= partition_item",
+ /* 499 */ "partition_list ::= partition_list NK_COMMA partition_item",
+ /* 500 */ "partition_item ::= expr_or_subquery",
+ /* 501 */ "partition_item ::= expr_or_subquery column_alias",
+ /* 502 */ "partition_item ::= expr_or_subquery AS column_alias",
+ /* 503 */ "twindow_clause_opt ::=",
+ /* 504 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP",
+ /* 505 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP",
+ /* 506 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
+ /* 507 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
+ /* 508 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition",
+ /* 509 */ "sliding_opt ::=",
+ /* 510 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
+ /* 511 */ "fill_opt ::=",
+ /* 512 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
+ /* 513 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
+ /* 514 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP",
+ /* 515 */ "fill_mode ::= NONE",
+ /* 516 */ "fill_mode ::= PREV",
+ /* 517 */ "fill_mode ::= NULL",
+ /* 518 */ "fill_mode ::= NULL_F",
+ /* 519 */ "fill_mode ::= LINEAR",
+ /* 520 */ "fill_mode ::= NEXT",
+ /* 521 */ "group_by_clause_opt ::=",
+ /* 522 */ "group_by_clause_opt ::= GROUP BY group_by_list",
+ /* 523 */ "group_by_list ::= expr_or_subquery",
+ /* 524 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery",
+ /* 525 */ "having_clause_opt ::=",
+ /* 526 */ "having_clause_opt ::= HAVING search_condition",
+ /* 527 */ "range_opt ::=",
+ /* 528 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP",
+ /* 529 */ "every_opt ::=",
+ /* 530 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP",
+ /* 531 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt",
+ /* 532 */ "query_simple ::= query_specification",
+ /* 533 */ "query_simple ::= union_query_expression",
+ /* 534 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery",
+ /* 535 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery",
+ /* 536 */ "query_simple_or_subquery ::= query_simple",
+ /* 537 */ "query_simple_or_subquery ::= subquery",
+ /* 538 */ "query_or_subquery ::= query_expression",
+ /* 539 */ "query_or_subquery ::= subquery",
+ /* 540 */ "order_by_clause_opt ::=",
+ /* 541 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
+ /* 542 */ "slimit_clause_opt ::=",
+ /* 543 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
+ /* 544 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
+ /* 545 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 546 */ "limit_clause_opt ::=",
+ /* 547 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
+ /* 548 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
+ /* 549 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 550 */ "subquery ::= NK_LP query_expression NK_RP",
+ /* 551 */ "subquery ::= NK_LP subquery NK_RP",
+ /* 552 */ "search_condition ::= common_expression",
+ /* 553 */ "sort_specification_list ::= sort_specification",
+ /* 554 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
+ /* 555 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt",
+ /* 556 */ "ordering_specification_opt ::=",
+ /* 557 */ "ordering_specification_opt ::= ASC",
+ /* 558 */ "ordering_specification_opt ::= DESC",
+ /* 559 */ "null_ordering_opt ::=",
+ /* 560 */ "null_ordering_opt ::= NULLS FIRST",
+ /* 561 */ "null_ordering_opt ::= NULLS LAST",
};
#endif /* NDEBUG */
@@ -2590,198 +2561,199 @@ static void yy_destructor(
*/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
- case 326: /* cmd */
- case 329: /* literal */
- case 342: /* db_options */
- case 344: /* alter_db_options */
- case 350: /* retention */
- case 351: /* full_table_name */
- case 354: /* table_options */
- case 358: /* alter_table_clause */
- case 359: /* alter_table_options */
- case 362: /* signed_literal */
- case 363: /* create_subtable_clause */
- case 366: /* drop_table_clause */
- case 369: /* column_def */
- case 373: /* duration_literal */
- case 374: /* rollup_func_name */
- case 376: /* col_name */
- case 377: /* db_name_cond_opt */
- case 378: /* like_pattern_opt */
- case 379: /* table_name_cond */
- case 380: /* from_db_opt */
- case 382: /* tag_item */
- case 384: /* full_index_name */
- case 385: /* index_options */
- case 388: /* sliding_opt */
- case 389: /* sma_stream_opt */
- case 390: /* func */
- case 392: /* query_or_subquery */
- case 395: /* explain_options */
- case 399: /* stream_options */
- case 402: /* subtable_opt */
- case 403: /* expression */
- case 405: /* where_clause_opt */
- case 406: /* signed */
- case 407: /* literal_func */
- case 410: /* expr_or_subquery */
- case 411: /* pseudo_column */
- case 412: /* column_reference */
- case 413: /* function_expression */
- case 414: /* case_when_expression */
- case 419: /* star_func_para */
- case 421: /* case_when_else_opt */
- case 422: /* common_expression */
- case 423: /* when_then_expr */
- case 424: /* predicate */
- case 427: /* in_predicate_value */
- case 428: /* boolean_value_expression */
- case 429: /* boolean_primary */
- case 430: /* from_clause_opt */
- case 431: /* table_reference_list */
- case 432: /* table_reference */
- case 433: /* table_primary */
- case 434: /* joined_table */
- case 436: /* subquery */
- case 437: /* parenthesized_joined_table */
- case 439: /* search_condition */
- case 440: /* query_specification */
- case 444: /* range_opt */
- case 445: /* every_opt */
- case 446: /* fill_opt */
- case 447: /* twindow_clause_opt */
- case 449: /* having_clause_opt */
- case 450: /* select_item */
- case 452: /* partition_item */
- case 455: /* query_expression */
- case 456: /* query_simple */
- case 458: /* slimit_clause_opt */
- case 459: /* limit_clause_opt */
- case 460: /* union_query_expression */
- case 461: /* query_simple_or_subquery */
- case 463: /* sort_specification */
+ case 328: /* cmd */
+ case 331: /* literal */
+ case 344: /* db_options */
+ case 346: /* alter_db_options */
+ case 352: /* retention */
+ case 353: /* full_table_name */
+ case 356: /* table_options */
+ case 360: /* alter_table_clause */
+ case 361: /* alter_table_options */
+ case 364: /* signed_literal */
+ case 365: /* create_subtable_clause */
+ case 368: /* drop_table_clause */
+ case 371: /* column_def */
+ case 375: /* duration_literal */
+ case 376: /* rollup_func_name */
+ case 378: /* col_name */
+ case 379: /* db_name_cond_opt */
+ case 380: /* like_pattern_opt */
+ case 381: /* table_name_cond */
+ case 382: /* from_db_opt */
+ case 384: /* tag_item */
+ case 386: /* full_index_name */
+ case 387: /* index_options */
+ case 390: /* sliding_opt */
+ case 391: /* sma_stream_opt */
+ case 392: /* func */
+ case 394: /* query_or_subquery */
+ case 397: /* explain_options */
+ case 398: /* insert_query */
+ case 402: /* stream_options */
+ case 405: /* subtable_opt */
+ case 406: /* expression */
+ case 408: /* where_clause_opt */
+ case 409: /* signed */
+ case 410: /* literal_func */
+ case 413: /* expr_or_subquery */
+ case 414: /* pseudo_column */
+ case 415: /* column_reference */
+ case 416: /* function_expression */
+ case 417: /* case_when_expression */
+ case 422: /* star_func_para */
+ case 424: /* case_when_else_opt */
+ case 425: /* common_expression */
+ case 426: /* when_then_expr */
+ case 427: /* predicate */
+ case 430: /* in_predicate_value */
+ case 431: /* boolean_value_expression */
+ case 432: /* boolean_primary */
+ case 433: /* from_clause_opt */
+ case 434: /* table_reference_list */
+ case 435: /* table_reference */
+ case 436: /* table_primary */
+ case 437: /* joined_table */
+ case 439: /* subquery */
+ case 440: /* parenthesized_joined_table */
+ case 442: /* search_condition */
+ case 443: /* query_specification */
+ case 447: /* range_opt */
+ case 448: /* every_opt */
+ case 449: /* fill_opt */
+ case 450: /* twindow_clause_opt */
+ case 452: /* having_clause_opt */
+ case 453: /* select_item */
+ case 455: /* partition_item */
+ case 458: /* query_expression */
+ case 459: /* query_simple */
+ case 461: /* slimit_clause_opt */
+ case 462: /* limit_clause_opt */
+ case 463: /* union_query_expression */
+ case 464: /* query_simple_or_subquery */
+ case 466: /* sort_specification */
{
- nodesDestroyNode((yypminor->yy924));
+ nodesDestroyNode((yypminor->yy42));
}
break;
- case 327: /* account_options */
- case 328: /* alter_account_options */
- case 330: /* alter_account_option */
- case 345: /* speed_opt */
- case 397: /* bufsize_opt */
+ case 329: /* account_options */
+ case 330: /* alter_account_options */
+ case 332: /* alter_account_option */
+ case 347: /* speed_opt */
+ case 400: /* bufsize_opt */
{
}
break;
- case 331: /* user_name */
- case 334: /* priv_level */
- case 337: /* db_name */
- case 338: /* topic_name */
- case 339: /* dnode_endpoint */
- case 360: /* column_name */
- case 368: /* table_name */
- case 375: /* function_name */
- case 383: /* column_alias */
- case 386: /* index_name */
- case 391: /* sma_func_name */
- case 393: /* cgroup_name */
- case 398: /* stream_name */
- case 409: /* table_alias */
- case 415: /* star_func */
- case 417: /* noarg_func */
- case 435: /* alias_opt */
+ case 333: /* user_name */
+ case 336: /* priv_level */
+ case 339: /* db_name */
+ case 340: /* topic_name */
+ case 341: /* dnode_endpoint */
+ case 362: /* column_name */
+ case 370: /* table_name */
+ case 377: /* function_name */
+ case 385: /* column_alias */
+ case 388: /* index_name */
+ case 393: /* sma_func_name */
+ case 395: /* cgroup_name */
+ case 401: /* stream_name */
+ case 412: /* table_alias */
+ case 418: /* star_func */
+ case 420: /* noarg_func */
+ case 438: /* alias_opt */
{
}
break;
- case 332: /* sysinfo_opt */
+ case 334: /* sysinfo_opt */
{
}
break;
- case 333: /* privileges */
- case 335: /* priv_type_list */
- case 336: /* priv_type */
+ case 335: /* privileges */
+ case 337: /* priv_type_list */
+ case 338: /* priv_type */
{
}
break;
- case 340: /* force_opt */
- case 341: /* not_exists_opt */
- case 343: /* exists_opt */
- case 394: /* analyze_opt */
- case 396: /* agg_func_opt */
- case 441: /* set_quantifier_opt */
+ case 342: /* force_opt */
+ case 343: /* not_exists_opt */
+ case 345: /* exists_opt */
+ case 396: /* analyze_opt */
+ case 399: /* agg_func_opt */
+ case 444: /* set_quantifier_opt */
{
}
break;
- case 346: /* integer_list */
- case 347: /* variable_list */
- case 348: /* retention_list */
- case 352: /* column_def_list */
- case 353: /* tags_def_opt */
- case 355: /* multi_create_clause */
- case 356: /* tags_def */
- case 357: /* multi_drop_clause */
- case 364: /* specific_cols_opt */
- case 365: /* expression_list */
- case 367: /* col_name_list */
- case 370: /* duration_list */
- case 371: /* rollup_func_list */
- case 381: /* tag_list_opt */
- case 387: /* func_list */
- case 400: /* col_list_opt */
- case 401: /* tag_def_or_ref_opt */
- case 404: /* dnode_list */
- case 408: /* literal_list */
- case 416: /* star_func_para_list */
- case 418: /* other_para_list */
- case 420: /* when_then_list */
- case 442: /* select_list */
- case 443: /* partition_by_clause_opt */
- case 448: /* group_by_clause_opt */
- case 451: /* partition_list */
- case 454: /* group_by_list */
- case 457: /* order_by_clause_opt */
- case 462: /* sort_specification_list */
+ case 348: /* integer_list */
+ case 349: /* variable_list */
+ case 350: /* retention_list */
+ case 354: /* column_def_list */
+ case 355: /* tags_def_opt */
+ case 357: /* multi_create_clause */
+ case 358: /* tags_def */
+ case 359: /* multi_drop_clause */
+ case 366: /* specific_cols_opt */
+ case 367: /* expression_list */
+ case 369: /* col_name_list */
+ case 372: /* duration_list */
+ case 373: /* rollup_func_list */
+ case 383: /* tag_list_opt */
+ case 389: /* func_list */
+ case 403: /* col_list_opt */
+ case 404: /* tag_def_or_ref_opt */
+ case 407: /* dnode_list */
+ case 411: /* literal_list */
+ case 419: /* star_func_para_list */
+ case 421: /* other_para_list */
+ case 423: /* when_then_list */
+ case 445: /* select_list */
+ case 446: /* partition_by_clause_opt */
+ case 451: /* group_by_clause_opt */
+ case 454: /* partition_list */
+ case 457: /* group_by_list */
+ case 460: /* order_by_clause_opt */
+ case 465: /* sort_specification_list */
{
- nodesDestroyList((yypminor->yy776));
+ nodesDestroyList((yypminor->yy110));
}
break;
- case 349: /* alter_db_option */
- case 372: /* alter_table_option */
+ case 351: /* alter_db_option */
+ case 374: /* alter_table_option */
{
}
break;
- case 361: /* type_name */
+ case 363: /* type_name */
{
}
break;
- case 425: /* compare_op */
- case 426: /* in_op */
+ case 428: /* compare_op */
+ case 429: /* in_op */
{
}
break;
- case 438: /* join_type */
+ case 441: /* join_type */
{
}
break;
- case 453: /* fill_mode */
+ case 456: /* fill_mode */
{
}
break;
- case 464: /* ordering_specification_opt */
+ case 467: /* ordering_specification_opt */
{
}
break;
- case 465: /* null_ordering_opt */
+ case 468: /* null_ordering_opt */
{
}
@@ -3080,562 +3052,568 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 326, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
- { 326, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
- { 327, 0 }, /* (2) account_options ::= */
- { 327, -3 }, /* (3) account_options ::= account_options PPS literal */
- { 327, -3 }, /* (4) account_options ::= account_options TSERIES literal */
- { 327, -3 }, /* (5) account_options ::= account_options STORAGE literal */
- { 327, -3 }, /* (6) account_options ::= account_options STREAMS literal */
- { 327, -3 }, /* (7) account_options ::= account_options QTIME literal */
- { 327, -3 }, /* (8) account_options ::= account_options DBS literal */
- { 327, -3 }, /* (9) account_options ::= account_options USERS literal */
- { 327, -3 }, /* (10) account_options ::= account_options CONNS literal */
- { 327, -3 }, /* (11) account_options ::= account_options STATE literal */
- { 328, -1 }, /* (12) alter_account_options ::= alter_account_option */
- { 328, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */
- { 330, -2 }, /* (14) alter_account_option ::= PASS literal */
- { 330, -2 }, /* (15) alter_account_option ::= PPS literal */
- { 330, -2 }, /* (16) alter_account_option ::= TSERIES literal */
- { 330, -2 }, /* (17) alter_account_option ::= STORAGE literal */
- { 330, -2 }, /* (18) alter_account_option ::= STREAMS literal */
- { 330, -2 }, /* (19) alter_account_option ::= QTIME literal */
- { 330, -2 }, /* (20) alter_account_option ::= DBS literal */
- { 330, -2 }, /* (21) alter_account_option ::= USERS literal */
- { 330, -2 }, /* (22) alter_account_option ::= CONNS literal */
- { 330, -2 }, /* (23) alter_account_option ::= STATE literal */
- { 326, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
- { 326, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
- { 326, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
- { 326, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
- { 326, -3 }, /* (28) cmd ::= DROP USER user_name */
- { 332, 0 }, /* (29) sysinfo_opt ::= */
- { 332, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */
- { 326, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */
- { 326, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */
- { 333, -1 }, /* (33) privileges ::= ALL */
- { 333, -1 }, /* (34) privileges ::= priv_type_list */
- { 333, -1 }, /* (35) privileges ::= SUBSCRIBE */
- { 335, -1 }, /* (36) priv_type_list ::= priv_type */
- { 335, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */
- { 336, -1 }, /* (38) priv_type ::= READ */
- { 336, -1 }, /* (39) priv_type ::= WRITE */
- { 334, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */
- { 334, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */
- { 334, -1 }, /* (42) priv_level ::= topic_name */
- { 326, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */
- { 326, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
- { 326, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */
- { 326, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */
- { 326, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
- { 326, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
- { 326, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */
- { 326, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
- { 339, -1 }, /* (51) dnode_endpoint ::= NK_STRING */
- { 339, -1 }, /* (52) dnode_endpoint ::= NK_ID */
- { 339, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */
- { 340, 0 }, /* (54) force_opt ::= */
- { 340, -1 }, /* (55) force_opt ::= FORCE */
- { 326, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */
- { 326, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
- { 326, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
- { 326, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
- { 326, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */
- { 326, -2 }, /* (68) cmd ::= USE db_name */
- { 326, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */
- { 326, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */
- { 326, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */
- { 341, -3 }, /* (72) not_exists_opt ::= IF NOT EXISTS */
- { 341, 0 }, /* (73) not_exists_opt ::= */
- { 343, -2 }, /* (74) exists_opt ::= IF EXISTS */
- { 343, 0 }, /* (75) exists_opt ::= */
- { 342, 0 }, /* (76) db_options ::= */
- { 342, -3 }, /* (77) db_options ::= db_options BUFFER NK_INTEGER */
- { 342, -3 }, /* (78) db_options ::= db_options CACHEMODEL NK_STRING */
- { 342, -3 }, /* (79) db_options ::= db_options CACHESIZE NK_INTEGER */
- { 342, -3 }, /* (80) db_options ::= db_options COMP NK_INTEGER */
- { 342, -3 }, /* (81) db_options ::= db_options DURATION NK_INTEGER */
- { 342, -3 }, /* (82) db_options ::= db_options DURATION NK_VARIABLE */
- { 342, -3 }, /* (83) db_options ::= db_options MAXROWS NK_INTEGER */
- { 342, -3 }, /* (84) db_options ::= db_options MINROWS NK_INTEGER */
- { 342, -3 }, /* (85) db_options ::= db_options KEEP integer_list */
- { 342, -3 }, /* (86) db_options ::= db_options KEEP variable_list */
- { 342, -3 }, /* (87) db_options ::= db_options PAGES NK_INTEGER */
- { 342, -3 }, /* (88) db_options ::= db_options PAGESIZE NK_INTEGER */
- { 342, -3 }, /* (89) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */
- { 342, -3 }, /* (90) db_options ::= db_options PRECISION NK_STRING */
- { 342, -3 }, /* (91) db_options ::= db_options REPLICA NK_INTEGER */
- { 342, -3 }, /* (92) db_options ::= db_options VGROUPS NK_INTEGER */
- { 342, -3 }, /* (93) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
- { 342, -3 }, /* (94) db_options ::= db_options RETENTIONS retention_list */
- { 342, -3 }, /* (95) db_options ::= db_options SCHEMALESS NK_INTEGER */
- { 342, -3 }, /* (96) db_options ::= db_options WAL_LEVEL NK_INTEGER */
- { 342, -3 }, /* (97) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
- { 342, -3 }, /* (98) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
- { 342, -4 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
- { 342, -3 }, /* (100) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
- { 342, -4 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
- { 342, -3 }, /* (102) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
- { 342, -3 }, /* (103) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
- { 342, -3 }, /* (104) db_options ::= db_options STT_TRIGGER NK_INTEGER */
- { 342, -3 }, /* (105) db_options ::= db_options TABLE_PREFIX NK_INTEGER */
- { 342, -3 }, /* (106) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
- { 344, -1 }, /* (107) alter_db_options ::= alter_db_option */
- { 344, -2 }, /* (108) alter_db_options ::= alter_db_options alter_db_option */
- { 349, -2 }, /* (109) alter_db_option ::= BUFFER NK_INTEGER */
- { 349, -2 }, /* (110) alter_db_option ::= CACHEMODEL NK_STRING */
- { 349, -2 }, /* (111) alter_db_option ::= CACHESIZE NK_INTEGER */
- { 349, -2 }, /* (112) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
- { 349, -2 }, /* (113) alter_db_option ::= KEEP integer_list */
- { 349, -2 }, /* (114) alter_db_option ::= KEEP variable_list */
- { 349, -2 }, /* (115) alter_db_option ::= PAGES NK_INTEGER */
- { 349, -2 }, /* (116) alter_db_option ::= REPLICA NK_INTEGER */
- { 349, -2 }, /* (117) alter_db_option ::= WAL_LEVEL NK_INTEGER */
- { 349, -2 }, /* (118) alter_db_option ::= STT_TRIGGER NK_INTEGER */
- { 346, -1 }, /* (119) integer_list ::= NK_INTEGER */
- { 346, -3 }, /* (120) integer_list ::= integer_list NK_COMMA NK_INTEGER */
- { 347, -1 }, /* (121) variable_list ::= NK_VARIABLE */
- { 347, -3 }, /* (122) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
- { 348, -1 }, /* (123) retention_list ::= retention */
- { 348, -3 }, /* (124) retention_list ::= retention_list NK_COMMA retention */
- { 350, -3 }, /* (125) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
- { 345, 0 }, /* (126) speed_opt ::= */
- { 345, -2 }, /* (127) speed_opt ::= MAX_SPEED NK_INTEGER */
- { 326, -9 }, /* (128) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
- { 326, -3 }, /* (129) cmd ::= CREATE TABLE multi_create_clause */
- { 326, -9 }, /* (130) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
- { 326, -3 }, /* (131) cmd ::= DROP TABLE multi_drop_clause */
- { 326, -4 }, /* (132) cmd ::= DROP STABLE exists_opt full_table_name */
- { 326, -3 }, /* (133) cmd ::= ALTER TABLE alter_table_clause */
- { 326, -3 }, /* (134) cmd ::= ALTER STABLE alter_table_clause */
- { 358, -2 }, /* (135) alter_table_clause ::= full_table_name alter_table_options */
- { 358, -5 }, /* (136) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
- { 358, -4 }, /* (137) alter_table_clause ::= full_table_name DROP COLUMN column_name */
- { 358, -5 }, /* (138) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
- { 358, -5 }, /* (139) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
- { 358, -5 }, /* (140) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
- { 358, -4 }, /* (141) alter_table_clause ::= full_table_name DROP TAG column_name */
- { 358, -5 }, /* (142) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
- { 358, -5 }, /* (143) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
- { 358, -6 }, /* (144) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
- { 355, -1 }, /* (145) multi_create_clause ::= create_subtable_clause */
- { 355, -2 }, /* (146) multi_create_clause ::= multi_create_clause create_subtable_clause */
- { 363, -10 }, /* (147) 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 */
- { 357, -1 }, /* (148) multi_drop_clause ::= drop_table_clause */
- { 357, -2 }, /* (149) multi_drop_clause ::= multi_drop_clause drop_table_clause */
- { 366, -2 }, /* (150) drop_table_clause ::= exists_opt full_table_name */
- { 364, 0 }, /* (151) specific_cols_opt ::= */
- { 364, -3 }, /* (152) specific_cols_opt ::= NK_LP col_name_list NK_RP */
- { 351, -1 }, /* (153) full_table_name ::= table_name */
- { 351, -3 }, /* (154) full_table_name ::= db_name NK_DOT table_name */
- { 352, -1 }, /* (155) column_def_list ::= column_def */
- { 352, -3 }, /* (156) column_def_list ::= column_def_list NK_COMMA column_def */
- { 369, -2 }, /* (157) column_def ::= column_name type_name */
- { 369, -4 }, /* (158) column_def ::= column_name type_name COMMENT NK_STRING */
- { 361, -1 }, /* (159) type_name ::= BOOL */
- { 361, -1 }, /* (160) type_name ::= TINYINT */
- { 361, -1 }, /* (161) type_name ::= SMALLINT */
- { 361, -1 }, /* (162) type_name ::= INT */
- { 361, -1 }, /* (163) type_name ::= INTEGER */
- { 361, -1 }, /* (164) type_name ::= BIGINT */
- { 361, -1 }, /* (165) type_name ::= FLOAT */
- { 361, -1 }, /* (166) type_name ::= DOUBLE */
- { 361, -4 }, /* (167) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
- { 361, -1 }, /* (168) type_name ::= TIMESTAMP */
- { 361, -4 }, /* (169) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
- { 361, -2 }, /* (170) type_name ::= TINYINT UNSIGNED */
- { 361, -2 }, /* (171) type_name ::= SMALLINT UNSIGNED */
- { 361, -2 }, /* (172) type_name ::= INT UNSIGNED */
- { 361, -2 }, /* (173) type_name ::= BIGINT UNSIGNED */
- { 361, -1 }, /* (174) type_name ::= JSON */
- { 361, -4 }, /* (175) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
- { 361, -1 }, /* (176) type_name ::= MEDIUMBLOB */
- { 361, -1 }, /* (177) type_name ::= BLOB */
- { 361, -4 }, /* (178) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
- { 361, -1 }, /* (179) type_name ::= DECIMAL */
- { 361, -4 }, /* (180) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
- { 361, -6 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
- { 353, 0 }, /* (182) tags_def_opt ::= */
- { 353, -1 }, /* (183) tags_def_opt ::= tags_def */
- { 356, -4 }, /* (184) tags_def ::= TAGS NK_LP column_def_list NK_RP */
- { 354, 0 }, /* (185) table_options ::= */
- { 354, -3 }, /* (186) table_options ::= table_options COMMENT NK_STRING */
- { 354, -3 }, /* (187) table_options ::= table_options MAX_DELAY duration_list */
- { 354, -3 }, /* (188) table_options ::= table_options WATERMARK duration_list */
- { 354, -5 }, /* (189) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
- { 354, -3 }, /* (190) table_options ::= table_options TTL NK_INTEGER */
- { 354, -5 }, /* (191) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
- { 354, -3 }, /* (192) table_options ::= table_options DELETE_MARK duration_list */
- { 359, -1 }, /* (193) alter_table_options ::= alter_table_option */
- { 359, -2 }, /* (194) alter_table_options ::= alter_table_options alter_table_option */
- { 372, -2 }, /* (195) alter_table_option ::= COMMENT NK_STRING */
- { 372, -2 }, /* (196) alter_table_option ::= TTL NK_INTEGER */
- { 370, -1 }, /* (197) duration_list ::= duration_literal */
- { 370, -3 }, /* (198) duration_list ::= duration_list NK_COMMA duration_literal */
- { 371, -1 }, /* (199) rollup_func_list ::= rollup_func_name */
- { 371, -3 }, /* (200) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */
- { 374, -1 }, /* (201) rollup_func_name ::= function_name */
- { 374, -1 }, /* (202) rollup_func_name ::= FIRST */
- { 374, -1 }, /* (203) rollup_func_name ::= LAST */
- { 367, -1 }, /* (204) col_name_list ::= col_name */
- { 367, -3 }, /* (205) col_name_list ::= col_name_list NK_COMMA col_name */
- { 376, -1 }, /* (206) col_name ::= column_name */
- { 326, -2 }, /* (207) cmd ::= SHOW DNODES */
- { 326, -2 }, /* (208) cmd ::= SHOW USERS */
- { 326, -3 }, /* (209) cmd ::= SHOW USER PRIVILEGES */
- { 326, -2 }, /* (210) cmd ::= SHOW DATABASES */
- { 326, -4 }, /* (211) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
- { 326, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
- { 326, -3 }, /* (213) cmd ::= SHOW db_name_cond_opt VGROUPS */
- { 326, -2 }, /* (214) cmd ::= SHOW MNODES */
- { 326, -2 }, /* (215) cmd ::= SHOW QNODES */
- { 326, -2 }, /* (216) cmd ::= SHOW FUNCTIONS */
- { 326, -5 }, /* (217) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
- { 326, -2 }, /* (218) cmd ::= SHOW STREAMS */
- { 326, -2 }, /* (219) cmd ::= SHOW ACCOUNTS */
- { 326, -2 }, /* (220) cmd ::= SHOW APPS */
- { 326, -2 }, /* (221) cmd ::= SHOW CONNECTIONS */
- { 326, -2 }, /* (222) cmd ::= SHOW LICENCES */
- { 326, -2 }, /* (223) cmd ::= SHOW GRANTS */
- { 326, -4 }, /* (224) cmd ::= SHOW CREATE DATABASE db_name */
- { 326, -4 }, /* (225) cmd ::= SHOW CREATE TABLE full_table_name */
- { 326, -4 }, /* (226) cmd ::= SHOW CREATE STABLE full_table_name */
- { 326, -2 }, /* (227) cmd ::= SHOW QUERIES */
- { 326, -2 }, /* (228) cmd ::= SHOW SCORES */
- { 326, -2 }, /* (229) cmd ::= SHOW TOPICS */
- { 326, -2 }, /* (230) cmd ::= SHOW VARIABLES */
- { 326, -3 }, /* (231) cmd ::= SHOW CLUSTER VARIABLES */
- { 326, -3 }, /* (232) cmd ::= SHOW LOCAL VARIABLES */
- { 326, -5 }, /* (233) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */
- { 326, -2 }, /* (234) cmd ::= SHOW BNODES */
- { 326, -2 }, /* (235) cmd ::= SHOW SNODES */
- { 326, -2 }, /* (236) cmd ::= SHOW CLUSTER */
- { 326, -2 }, /* (237) cmd ::= SHOW TRANSACTIONS */
- { 326, -4 }, /* (238) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
- { 326, -2 }, /* (239) cmd ::= SHOW CONSUMERS */
- { 326, -2 }, /* (240) cmd ::= SHOW SUBSCRIPTIONS */
- { 326, -5 }, /* (241) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
- { 326, -7 }, /* (242) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */
- { 326, -3 }, /* (243) cmd ::= SHOW VNODES NK_INTEGER */
- { 326, -3 }, /* (244) cmd ::= SHOW VNODES NK_STRING */
- { 326, -3 }, /* (245) cmd ::= SHOW db_name_cond_opt ALIVE */
- { 326, -3 }, /* (246) cmd ::= SHOW CLUSTER ALIVE */
- { 377, 0 }, /* (247) db_name_cond_opt ::= */
- { 377, -2 }, /* (248) db_name_cond_opt ::= db_name NK_DOT */
- { 378, 0 }, /* (249) like_pattern_opt ::= */
- { 378, -2 }, /* (250) like_pattern_opt ::= LIKE NK_STRING */
- { 379, -1 }, /* (251) table_name_cond ::= table_name */
- { 380, 0 }, /* (252) from_db_opt ::= */
- { 380, -2 }, /* (253) from_db_opt ::= FROM db_name */
- { 381, 0 }, /* (254) tag_list_opt ::= */
- { 381, -1 }, /* (255) tag_list_opt ::= tag_item */
- { 381, -3 }, /* (256) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */
- { 382, -1 }, /* (257) tag_item ::= TBNAME */
- { 382, -1 }, /* (258) tag_item ::= QTAGS */
- { 382, -1 }, /* (259) tag_item ::= column_name */
- { 382, -2 }, /* (260) tag_item ::= column_name column_alias */
- { 382, -3 }, /* (261) tag_item ::= column_name AS column_alias */
- { 326, -8 }, /* (262) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */
- { 326, -9 }, /* (263) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */
- { 326, -4 }, /* (264) cmd ::= DROP INDEX exists_opt full_index_name */
- { 384, -1 }, /* (265) full_index_name ::= index_name */
- { 384, -3 }, /* (266) full_index_name ::= db_name NK_DOT index_name */
- { 385, -10 }, /* (267) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
- { 385, -12 }, /* (268) 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 */
- { 387, -1 }, /* (269) func_list ::= func */
- { 387, -3 }, /* (270) func_list ::= func_list NK_COMMA func */
- { 390, -4 }, /* (271) func ::= sma_func_name NK_LP expression_list NK_RP */
- { 391, -1 }, /* (272) sma_func_name ::= function_name */
- { 391, -1 }, /* (273) sma_func_name ::= COUNT */
- { 391, -1 }, /* (274) sma_func_name ::= FIRST */
- { 391, -1 }, /* (275) sma_func_name ::= LAST */
- { 391, -1 }, /* (276) sma_func_name ::= LAST_ROW */
- { 389, 0 }, /* (277) sma_stream_opt ::= */
- { 389, -3 }, /* (278) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */
- { 389, -3 }, /* (279) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */
- { 389, -3 }, /* (280) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */
- { 326, -6 }, /* (281) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */
- { 326, -7 }, /* (282) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
- { 326, -9 }, /* (283) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
- { 326, -7 }, /* (284) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
- { 326, -9 }, /* (285) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
- { 326, -4 }, /* (286) cmd ::= DROP TOPIC exists_opt topic_name */
- { 326, -7 }, /* (287) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
- { 326, -2 }, /* (288) cmd ::= DESC full_table_name */
- { 326, -2 }, /* (289) cmd ::= DESCRIBE full_table_name */
- { 326, -3 }, /* (290) cmd ::= RESET QUERY CACHE */
- { 326, -4 }, /* (291) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */
- { 394, 0 }, /* (292) analyze_opt ::= */
- { 394, -1 }, /* (293) analyze_opt ::= ANALYZE */
- { 395, 0 }, /* (294) explain_options ::= */
- { 395, -3 }, /* (295) explain_options ::= explain_options VERBOSE NK_BOOL */
- { 395, -3 }, /* (296) explain_options ::= explain_options RATIO NK_FLOAT */
- { 326, -10 }, /* (297) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
- { 326, -4 }, /* (298) cmd ::= DROP FUNCTION exists_opt function_name */
- { 396, 0 }, /* (299) agg_func_opt ::= */
- { 396, -1 }, /* (300) agg_func_opt ::= AGGREGATE */
- { 397, 0 }, /* (301) bufsize_opt ::= */
- { 397, -2 }, /* (302) bufsize_opt ::= BUFSIZE NK_INTEGER */
- { 326, -12 }, /* (303) 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 */
- { 326, -4 }, /* (304) cmd ::= DROP STREAM exists_opt stream_name */
- { 400, 0 }, /* (305) col_list_opt ::= */
- { 400, -3 }, /* (306) col_list_opt ::= NK_LP col_name_list NK_RP */
- { 401, 0 }, /* (307) tag_def_or_ref_opt ::= */
- { 401, -1 }, /* (308) tag_def_or_ref_opt ::= tags_def */
- { 401, -4 }, /* (309) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */
- { 399, 0 }, /* (310) stream_options ::= */
- { 399, -3 }, /* (311) stream_options ::= stream_options TRIGGER AT_ONCE */
- { 399, -3 }, /* (312) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
- { 399, -4 }, /* (313) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
- { 399, -3 }, /* (314) stream_options ::= stream_options WATERMARK duration_literal */
- { 399, -4 }, /* (315) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
- { 399, -3 }, /* (316) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */
- { 402, 0 }, /* (317) subtable_opt ::= */
- { 402, -4 }, /* (318) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */
- { 326, -3 }, /* (319) cmd ::= KILL CONNECTION NK_INTEGER */
- { 326, -3 }, /* (320) cmd ::= KILL QUERY NK_STRING */
- { 326, -3 }, /* (321) cmd ::= KILL TRANSACTION NK_INTEGER */
- { 326, -2 }, /* (322) cmd ::= BALANCE VGROUP */
- { 326, -4 }, /* (323) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
- { 326, -4 }, /* (324) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
- { 326, -3 }, /* (325) cmd ::= SPLIT VGROUP NK_INTEGER */
- { 404, -2 }, /* (326) dnode_list ::= DNODE NK_INTEGER */
- { 404, -3 }, /* (327) dnode_list ::= dnode_list DNODE NK_INTEGER */
- { 326, -4 }, /* (328) cmd ::= DELETE FROM full_table_name where_clause_opt */
- { 326, -1 }, /* (329) cmd ::= query_or_subquery */
- { 326, -7 }, /* (330) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */
- { 326, -4 }, /* (331) cmd ::= INSERT INTO full_table_name query_or_subquery */
- { 329, -1 }, /* (332) literal ::= NK_INTEGER */
- { 329, -1 }, /* (333) literal ::= NK_FLOAT */
- { 329, -1 }, /* (334) literal ::= NK_STRING */
- { 329, -1 }, /* (335) literal ::= NK_BOOL */
- { 329, -2 }, /* (336) literal ::= TIMESTAMP NK_STRING */
- { 329, -1 }, /* (337) literal ::= duration_literal */
- { 329, -1 }, /* (338) literal ::= NULL */
- { 329, -1 }, /* (339) literal ::= NK_QUESTION */
- { 373, -1 }, /* (340) duration_literal ::= NK_VARIABLE */
- { 406, -1 }, /* (341) signed ::= NK_INTEGER */
- { 406, -2 }, /* (342) signed ::= NK_PLUS NK_INTEGER */
- { 406, -2 }, /* (343) signed ::= NK_MINUS NK_INTEGER */
- { 406, -1 }, /* (344) signed ::= NK_FLOAT */
- { 406, -2 }, /* (345) signed ::= NK_PLUS NK_FLOAT */
- { 406, -2 }, /* (346) signed ::= NK_MINUS NK_FLOAT */
- { 362, -1 }, /* (347) signed_literal ::= signed */
- { 362, -1 }, /* (348) signed_literal ::= NK_STRING */
- { 362, -1 }, /* (349) signed_literal ::= NK_BOOL */
- { 362, -2 }, /* (350) signed_literal ::= TIMESTAMP NK_STRING */
- { 362, -1 }, /* (351) signed_literal ::= duration_literal */
- { 362, -1 }, /* (352) signed_literal ::= NULL */
- { 362, -1 }, /* (353) signed_literal ::= literal_func */
- { 362, -1 }, /* (354) signed_literal ::= NK_QUESTION */
- { 408, -1 }, /* (355) literal_list ::= signed_literal */
- { 408, -3 }, /* (356) literal_list ::= literal_list NK_COMMA signed_literal */
- { 337, -1 }, /* (357) db_name ::= NK_ID */
- { 368, -1 }, /* (358) table_name ::= NK_ID */
- { 360, -1 }, /* (359) column_name ::= NK_ID */
- { 375, -1 }, /* (360) function_name ::= NK_ID */
- { 409, -1 }, /* (361) table_alias ::= NK_ID */
- { 383, -1 }, /* (362) column_alias ::= NK_ID */
- { 331, -1 }, /* (363) user_name ::= NK_ID */
- { 338, -1 }, /* (364) topic_name ::= NK_ID */
- { 398, -1 }, /* (365) stream_name ::= NK_ID */
- { 393, -1 }, /* (366) cgroup_name ::= NK_ID */
- { 386, -1 }, /* (367) index_name ::= NK_ID */
- { 410, -1 }, /* (368) expr_or_subquery ::= expression */
- { 403, -1 }, /* (369) expression ::= literal */
- { 403, -1 }, /* (370) expression ::= pseudo_column */
- { 403, -1 }, /* (371) expression ::= column_reference */
- { 403, -1 }, /* (372) expression ::= function_expression */
- { 403, -1 }, /* (373) expression ::= case_when_expression */
- { 403, -3 }, /* (374) expression ::= NK_LP expression NK_RP */
- { 403, -2 }, /* (375) expression ::= NK_PLUS expr_or_subquery */
- { 403, -2 }, /* (376) expression ::= NK_MINUS expr_or_subquery */
- { 403, -3 }, /* (377) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */
- { 403, -3 }, /* (378) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */
- { 403, -3 }, /* (379) expression ::= expr_or_subquery NK_STAR expr_or_subquery */
- { 403, -3 }, /* (380) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */
- { 403, -3 }, /* (381) expression ::= expr_or_subquery NK_REM expr_or_subquery */
- { 403, -3 }, /* (382) expression ::= column_reference NK_ARROW NK_STRING */
- { 403, -3 }, /* (383) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */
- { 403, -3 }, /* (384) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */
- { 365, -1 }, /* (385) expression_list ::= expr_or_subquery */
- { 365, -3 }, /* (386) expression_list ::= expression_list NK_COMMA expr_or_subquery */
- { 412, -1 }, /* (387) column_reference ::= column_name */
- { 412, -3 }, /* (388) column_reference ::= table_name NK_DOT column_name */
- { 411, -1 }, /* (389) pseudo_column ::= ROWTS */
- { 411, -1 }, /* (390) pseudo_column ::= TBNAME */
- { 411, -3 }, /* (391) pseudo_column ::= table_name NK_DOT TBNAME */
- { 411, -1 }, /* (392) pseudo_column ::= QSTART */
- { 411, -1 }, /* (393) pseudo_column ::= QEND */
- { 411, -1 }, /* (394) pseudo_column ::= QDURATION */
- { 411, -1 }, /* (395) pseudo_column ::= WSTART */
- { 411, -1 }, /* (396) pseudo_column ::= WEND */
- { 411, -1 }, /* (397) pseudo_column ::= WDURATION */
- { 411, -1 }, /* (398) pseudo_column ::= IROWTS */
- { 411, -1 }, /* (399) pseudo_column ::= ISFILLED */
- { 411, -1 }, /* (400) pseudo_column ::= QTAGS */
- { 413, -4 }, /* (401) function_expression ::= function_name NK_LP expression_list NK_RP */
- { 413, -4 }, /* (402) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
- { 413, -6 }, /* (403) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */
- { 413, -1 }, /* (404) function_expression ::= literal_func */
- { 407, -3 }, /* (405) literal_func ::= noarg_func NK_LP NK_RP */
- { 407, -1 }, /* (406) literal_func ::= NOW */
- { 417, -1 }, /* (407) noarg_func ::= NOW */
- { 417, -1 }, /* (408) noarg_func ::= TODAY */
- { 417, -1 }, /* (409) noarg_func ::= TIMEZONE */
- { 417, -1 }, /* (410) noarg_func ::= DATABASE */
- { 417, -1 }, /* (411) noarg_func ::= CLIENT_VERSION */
- { 417, -1 }, /* (412) noarg_func ::= SERVER_VERSION */
- { 417, -1 }, /* (413) noarg_func ::= SERVER_STATUS */
- { 417, -1 }, /* (414) noarg_func ::= CURRENT_USER */
- { 417, -1 }, /* (415) noarg_func ::= USER */
- { 415, -1 }, /* (416) star_func ::= COUNT */
- { 415, -1 }, /* (417) star_func ::= FIRST */
- { 415, -1 }, /* (418) star_func ::= LAST */
- { 415, -1 }, /* (419) star_func ::= LAST_ROW */
- { 416, -1 }, /* (420) star_func_para_list ::= NK_STAR */
- { 416, -1 }, /* (421) star_func_para_list ::= other_para_list */
- { 418, -1 }, /* (422) other_para_list ::= star_func_para */
- { 418, -3 }, /* (423) other_para_list ::= other_para_list NK_COMMA star_func_para */
- { 419, -1 }, /* (424) star_func_para ::= expr_or_subquery */
- { 419, -3 }, /* (425) star_func_para ::= table_name NK_DOT NK_STAR */
- { 414, -4 }, /* (426) case_when_expression ::= CASE when_then_list case_when_else_opt END */
- { 414, -5 }, /* (427) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */
- { 420, -1 }, /* (428) when_then_list ::= when_then_expr */
- { 420, -2 }, /* (429) when_then_list ::= when_then_list when_then_expr */
- { 423, -4 }, /* (430) when_then_expr ::= WHEN common_expression THEN common_expression */
- { 421, 0 }, /* (431) case_when_else_opt ::= */
- { 421, -2 }, /* (432) case_when_else_opt ::= ELSE common_expression */
- { 424, -3 }, /* (433) predicate ::= expr_or_subquery compare_op expr_or_subquery */
- { 424, -5 }, /* (434) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */
- { 424, -6 }, /* (435) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */
- { 424, -3 }, /* (436) predicate ::= expr_or_subquery IS NULL */
- { 424, -4 }, /* (437) predicate ::= expr_or_subquery IS NOT NULL */
- { 424, -3 }, /* (438) predicate ::= expr_or_subquery in_op in_predicate_value */
- { 425, -1 }, /* (439) compare_op ::= NK_LT */
- { 425, -1 }, /* (440) compare_op ::= NK_GT */
- { 425, -1 }, /* (441) compare_op ::= NK_LE */
- { 425, -1 }, /* (442) compare_op ::= NK_GE */
- { 425, -1 }, /* (443) compare_op ::= NK_NE */
- { 425, -1 }, /* (444) compare_op ::= NK_EQ */
- { 425, -1 }, /* (445) compare_op ::= LIKE */
- { 425, -2 }, /* (446) compare_op ::= NOT LIKE */
- { 425, -1 }, /* (447) compare_op ::= MATCH */
- { 425, -1 }, /* (448) compare_op ::= NMATCH */
- { 425, -1 }, /* (449) compare_op ::= CONTAINS */
- { 426, -1 }, /* (450) in_op ::= IN */
- { 426, -2 }, /* (451) in_op ::= NOT IN */
- { 427, -3 }, /* (452) in_predicate_value ::= NK_LP literal_list NK_RP */
- { 428, -1 }, /* (453) boolean_value_expression ::= boolean_primary */
- { 428, -2 }, /* (454) boolean_value_expression ::= NOT boolean_primary */
- { 428, -3 }, /* (455) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
- { 428, -3 }, /* (456) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
- { 429, -1 }, /* (457) boolean_primary ::= predicate */
- { 429, -3 }, /* (458) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
- { 422, -1 }, /* (459) common_expression ::= expr_or_subquery */
- { 422, -1 }, /* (460) common_expression ::= boolean_value_expression */
- { 430, 0 }, /* (461) from_clause_opt ::= */
- { 430, -2 }, /* (462) from_clause_opt ::= FROM table_reference_list */
- { 431, -1 }, /* (463) table_reference_list ::= table_reference */
- { 431, -3 }, /* (464) table_reference_list ::= table_reference_list NK_COMMA table_reference */
- { 432, -1 }, /* (465) table_reference ::= table_primary */
- { 432, -1 }, /* (466) table_reference ::= joined_table */
- { 433, -2 }, /* (467) table_primary ::= table_name alias_opt */
- { 433, -4 }, /* (468) table_primary ::= db_name NK_DOT table_name alias_opt */
- { 433, -2 }, /* (469) table_primary ::= subquery alias_opt */
- { 433, -1 }, /* (470) table_primary ::= parenthesized_joined_table */
- { 435, 0 }, /* (471) alias_opt ::= */
- { 435, -1 }, /* (472) alias_opt ::= table_alias */
- { 435, -2 }, /* (473) alias_opt ::= AS table_alias */
- { 437, -3 }, /* (474) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- { 437, -3 }, /* (475) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
- { 434, -6 }, /* (476) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
- { 438, 0 }, /* (477) join_type ::= */
- { 438, -1 }, /* (478) join_type ::= INNER */
- { 440, -12 }, /* (479) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
- { 441, 0 }, /* (480) set_quantifier_opt ::= */
- { 441, -1 }, /* (481) set_quantifier_opt ::= DISTINCT */
- { 441, -1 }, /* (482) set_quantifier_opt ::= ALL */
- { 442, -1 }, /* (483) select_list ::= select_item */
- { 442, -3 }, /* (484) select_list ::= select_list NK_COMMA select_item */
- { 450, -1 }, /* (485) select_item ::= NK_STAR */
- { 450, -1 }, /* (486) select_item ::= common_expression */
- { 450, -2 }, /* (487) select_item ::= common_expression column_alias */
- { 450, -3 }, /* (488) select_item ::= common_expression AS column_alias */
- { 450, -3 }, /* (489) select_item ::= table_name NK_DOT NK_STAR */
- { 405, 0 }, /* (490) where_clause_opt ::= */
- { 405, -2 }, /* (491) where_clause_opt ::= WHERE search_condition */
- { 443, 0 }, /* (492) partition_by_clause_opt ::= */
- { 443, -3 }, /* (493) partition_by_clause_opt ::= PARTITION BY partition_list */
- { 451, -1 }, /* (494) partition_list ::= partition_item */
- { 451, -3 }, /* (495) partition_list ::= partition_list NK_COMMA partition_item */
- { 452, -1 }, /* (496) partition_item ::= expr_or_subquery */
- { 452, -2 }, /* (497) partition_item ::= expr_or_subquery column_alias */
- { 452, -3 }, /* (498) partition_item ::= expr_or_subquery AS column_alias */
- { 447, 0 }, /* (499) twindow_clause_opt ::= */
- { 447, -6 }, /* (500) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
- { 447, -4 }, /* (501) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */
- { 447, -6 }, /* (502) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
- { 447, -8 }, /* (503) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
- { 447, -7 }, /* (504) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */
- { 388, 0 }, /* (505) sliding_opt ::= */
- { 388, -4 }, /* (506) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
- { 446, 0 }, /* (507) fill_opt ::= */
- { 446, -4 }, /* (508) fill_opt ::= FILL NK_LP fill_mode NK_RP */
- { 446, -6 }, /* (509) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
- { 453, -1 }, /* (510) fill_mode ::= NONE */
- { 453, -1 }, /* (511) fill_mode ::= PREV */
- { 453, -1 }, /* (512) fill_mode ::= NULL */
- { 453, -1 }, /* (513) fill_mode ::= LINEAR */
- { 453, -1 }, /* (514) fill_mode ::= NEXT */
- { 448, 0 }, /* (515) group_by_clause_opt ::= */
- { 448, -3 }, /* (516) group_by_clause_opt ::= GROUP BY group_by_list */
- { 454, -1 }, /* (517) group_by_list ::= expr_or_subquery */
- { 454, -3 }, /* (518) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */
- { 449, 0 }, /* (519) having_clause_opt ::= */
- { 449, -2 }, /* (520) having_clause_opt ::= HAVING search_condition */
- { 444, 0 }, /* (521) range_opt ::= */
- { 444, -6 }, /* (522) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */
- { 445, 0 }, /* (523) every_opt ::= */
- { 445, -4 }, /* (524) every_opt ::= EVERY NK_LP duration_literal NK_RP */
- { 455, -4 }, /* (525) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */
- { 456, -1 }, /* (526) query_simple ::= query_specification */
- { 456, -1 }, /* (527) query_simple ::= union_query_expression */
- { 460, -4 }, /* (528) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */
- { 460, -3 }, /* (529) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */
- { 461, -1 }, /* (530) query_simple_or_subquery ::= query_simple */
- { 461, -1 }, /* (531) query_simple_or_subquery ::= subquery */
- { 392, -1 }, /* (532) query_or_subquery ::= query_expression */
- { 392, -1 }, /* (533) query_or_subquery ::= subquery */
- { 457, 0 }, /* (534) order_by_clause_opt ::= */
- { 457, -3 }, /* (535) order_by_clause_opt ::= ORDER BY sort_specification_list */
- { 458, 0 }, /* (536) slimit_clause_opt ::= */
- { 458, -2 }, /* (537) slimit_clause_opt ::= SLIMIT NK_INTEGER */
- { 458, -4 }, /* (538) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- { 458, -4 }, /* (539) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 459, 0 }, /* (540) limit_clause_opt ::= */
- { 459, -2 }, /* (541) limit_clause_opt ::= LIMIT NK_INTEGER */
- { 459, -4 }, /* (542) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
- { 459, -4 }, /* (543) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 436, -3 }, /* (544) subquery ::= NK_LP query_expression NK_RP */
- { 436, -3 }, /* (545) subquery ::= NK_LP subquery NK_RP */
- { 439, -1 }, /* (546) search_condition ::= common_expression */
- { 462, -1 }, /* (547) sort_specification_list ::= sort_specification */
- { 462, -3 }, /* (548) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
- { 463, -3 }, /* (549) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */
- { 464, 0 }, /* (550) ordering_specification_opt ::= */
- { 464, -1 }, /* (551) ordering_specification_opt ::= ASC */
- { 464, -1 }, /* (552) ordering_specification_opt ::= DESC */
- { 465, 0 }, /* (553) null_ordering_opt ::= */
- { 465, -2 }, /* (554) null_ordering_opt ::= NULLS FIRST */
- { 465, -2 }, /* (555) null_ordering_opt ::= NULLS LAST */
+ { 328, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
+ { 328, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
+ { 329, 0 }, /* (2) account_options ::= */
+ { 329, -3 }, /* (3) account_options ::= account_options PPS literal */
+ { 329, -3 }, /* (4) account_options ::= account_options TSERIES literal */
+ { 329, -3 }, /* (5) account_options ::= account_options STORAGE literal */
+ { 329, -3 }, /* (6) account_options ::= account_options STREAMS literal */
+ { 329, -3 }, /* (7) account_options ::= account_options QTIME literal */
+ { 329, -3 }, /* (8) account_options ::= account_options DBS literal */
+ { 329, -3 }, /* (9) account_options ::= account_options USERS literal */
+ { 329, -3 }, /* (10) account_options ::= account_options CONNS literal */
+ { 329, -3 }, /* (11) account_options ::= account_options STATE literal */
+ { 330, -1 }, /* (12) alter_account_options ::= alter_account_option */
+ { 330, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */
+ { 332, -2 }, /* (14) alter_account_option ::= PASS literal */
+ { 332, -2 }, /* (15) alter_account_option ::= PPS literal */
+ { 332, -2 }, /* (16) alter_account_option ::= TSERIES literal */
+ { 332, -2 }, /* (17) alter_account_option ::= STORAGE literal */
+ { 332, -2 }, /* (18) alter_account_option ::= STREAMS literal */
+ { 332, -2 }, /* (19) alter_account_option ::= QTIME literal */
+ { 332, -2 }, /* (20) alter_account_option ::= DBS literal */
+ { 332, -2 }, /* (21) alter_account_option ::= USERS literal */
+ { 332, -2 }, /* (22) alter_account_option ::= CONNS literal */
+ { 332, -2 }, /* (23) alter_account_option ::= STATE literal */
+ { 328, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
+ { 328, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
+ { 328, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
+ { 328, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
+ { 328, -3 }, /* (28) cmd ::= DROP USER user_name */
+ { 334, 0 }, /* (29) sysinfo_opt ::= */
+ { 334, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */
+ { 328, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */
+ { 328, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */
+ { 335, -1 }, /* (33) privileges ::= ALL */
+ { 335, -1 }, /* (34) privileges ::= priv_type_list */
+ { 335, -1 }, /* (35) privileges ::= SUBSCRIBE */
+ { 337, -1 }, /* (36) priv_type_list ::= priv_type */
+ { 337, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */
+ { 338, -1 }, /* (38) priv_type ::= READ */
+ { 338, -1 }, /* (39) priv_type ::= WRITE */
+ { 336, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */
+ { 336, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */
+ { 336, -1 }, /* (42) priv_level ::= topic_name */
+ { 328, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */
+ { 328, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
+ { 328, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */
+ { 328, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */
+ { 328, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
+ { 328, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
+ { 328, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */
+ { 328, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
+ { 341, -1 }, /* (51) dnode_endpoint ::= NK_STRING */
+ { 341, -1 }, /* (52) dnode_endpoint ::= NK_ID */
+ { 341, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */
+ { 342, 0 }, /* (54) force_opt ::= */
+ { 342, -1 }, /* (55) force_opt ::= FORCE */
+ { 328, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */
+ { 328, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
+ { 328, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
+ { 328, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
+ { 328, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */
+ { 328, -2 }, /* (68) cmd ::= USE db_name */
+ { 328, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */
+ { 328, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */
+ { 328, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */
+ { 328, -3 }, /* (72) cmd ::= COMPACT DATABASE db_name */
+ { 343, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */
+ { 343, 0 }, /* (74) not_exists_opt ::= */
+ { 345, -2 }, /* (75) exists_opt ::= IF EXISTS */
+ { 345, 0 }, /* (76) exists_opt ::= */
+ { 344, 0 }, /* (77) db_options ::= */
+ { 344, -3 }, /* (78) db_options ::= db_options BUFFER NK_INTEGER */
+ { 344, -3 }, /* (79) db_options ::= db_options CACHEMODEL NK_STRING */
+ { 344, -3 }, /* (80) db_options ::= db_options CACHESIZE NK_INTEGER */
+ { 344, -3 }, /* (81) db_options ::= db_options COMP NK_INTEGER */
+ { 344, -3 }, /* (82) db_options ::= db_options DURATION NK_INTEGER */
+ { 344, -3 }, /* (83) db_options ::= db_options DURATION NK_VARIABLE */
+ { 344, -3 }, /* (84) db_options ::= db_options MAXROWS NK_INTEGER */
+ { 344, -3 }, /* (85) db_options ::= db_options MINROWS NK_INTEGER */
+ { 344, -3 }, /* (86) db_options ::= db_options KEEP integer_list */
+ { 344, -3 }, /* (87) db_options ::= db_options KEEP variable_list */
+ { 344, -3 }, /* (88) db_options ::= db_options PAGES NK_INTEGER */
+ { 344, -3 }, /* (89) db_options ::= db_options PAGESIZE NK_INTEGER */
+ { 344, -3 }, /* (90) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */
+ { 344, -3 }, /* (91) db_options ::= db_options PRECISION NK_STRING */
+ { 344, -3 }, /* (92) db_options ::= db_options REPLICA NK_INTEGER */
+ { 344, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */
+ { 344, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
+ { 344, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */
+ { 344, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */
+ { 344, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */
+ { 344, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
+ { 344, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
+ { 344, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
+ { 344, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
+ { 344, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
+ { 344, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
+ { 344, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
+ { 344, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */
+ { 344, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */
+ { 344, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
+ { 346, -1 }, /* (108) alter_db_options ::= alter_db_option */
+ { 346, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */
+ { 351, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */
+ { 351, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */
+ { 351, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */
+ { 351, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
+ { 351, -2 }, /* (114) alter_db_option ::= KEEP integer_list */
+ { 351, -2 }, /* (115) alter_db_option ::= KEEP variable_list */
+ { 351, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */
+ { 351, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */
+ { 351, -2 }, /* (118) alter_db_option ::= WAL_LEVEL NK_INTEGER */
+ { 351, -2 }, /* (119) alter_db_option ::= STT_TRIGGER NK_INTEGER */
+ { 348, -1 }, /* (120) integer_list ::= NK_INTEGER */
+ { 348, -3 }, /* (121) integer_list ::= integer_list NK_COMMA NK_INTEGER */
+ { 349, -1 }, /* (122) variable_list ::= NK_VARIABLE */
+ { 349, -3 }, /* (123) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
+ { 350, -1 }, /* (124) retention_list ::= retention */
+ { 350, -3 }, /* (125) retention_list ::= retention_list NK_COMMA retention */
+ { 352, -3 }, /* (126) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
+ { 347, 0 }, /* (127) speed_opt ::= */
+ { 347, -2 }, /* (128) speed_opt ::= MAX_SPEED NK_INTEGER */
+ { 328, -9 }, /* (129) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
+ { 328, -3 }, /* (130) cmd ::= CREATE TABLE multi_create_clause */
+ { 328, -9 }, /* (131) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
+ { 328, -3 }, /* (132) cmd ::= DROP TABLE multi_drop_clause */
+ { 328, -4 }, /* (133) cmd ::= DROP STABLE exists_opt full_table_name */
+ { 328, -3 }, /* (134) cmd ::= ALTER TABLE alter_table_clause */
+ { 328, -3 }, /* (135) cmd ::= ALTER STABLE alter_table_clause */
+ { 360, -2 }, /* (136) alter_table_clause ::= full_table_name alter_table_options */
+ { 360, -5 }, /* (137) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
+ { 360, -4 }, /* (138) alter_table_clause ::= full_table_name DROP COLUMN column_name */
+ { 360, -5 }, /* (139) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
+ { 360, -5 }, /* (140) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
+ { 360, -5 }, /* (141) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
+ { 360, -4 }, /* (142) alter_table_clause ::= full_table_name DROP TAG column_name */
+ { 360, -5 }, /* (143) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
+ { 360, -5 }, /* (144) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
+ { 360, -6 }, /* (145) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
+ { 357, -1 }, /* (146) multi_create_clause ::= create_subtable_clause */
+ { 357, -2 }, /* (147) multi_create_clause ::= multi_create_clause create_subtable_clause */
+ { 365, -10 }, /* (148) 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 */
+ { 359, -1 }, /* (149) multi_drop_clause ::= drop_table_clause */
+ { 359, -2 }, /* (150) multi_drop_clause ::= multi_drop_clause drop_table_clause */
+ { 368, -2 }, /* (151) drop_table_clause ::= exists_opt full_table_name */
+ { 366, 0 }, /* (152) specific_cols_opt ::= */
+ { 366, -3 }, /* (153) specific_cols_opt ::= NK_LP col_name_list NK_RP */
+ { 353, -1 }, /* (154) full_table_name ::= table_name */
+ { 353, -3 }, /* (155) full_table_name ::= db_name NK_DOT table_name */
+ { 354, -1 }, /* (156) column_def_list ::= column_def */
+ { 354, -3 }, /* (157) column_def_list ::= column_def_list NK_COMMA column_def */
+ { 371, -2 }, /* (158) column_def ::= column_name type_name */
+ { 371, -4 }, /* (159) column_def ::= column_name type_name COMMENT NK_STRING */
+ { 363, -1 }, /* (160) type_name ::= BOOL */
+ { 363, -1 }, /* (161) type_name ::= TINYINT */
+ { 363, -1 }, /* (162) type_name ::= SMALLINT */
+ { 363, -1 }, /* (163) type_name ::= INT */
+ { 363, -1 }, /* (164) type_name ::= INTEGER */
+ { 363, -1 }, /* (165) type_name ::= BIGINT */
+ { 363, -1 }, /* (166) type_name ::= FLOAT */
+ { 363, -1 }, /* (167) type_name ::= DOUBLE */
+ { 363, -4 }, /* (168) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+ { 363, -1 }, /* (169) type_name ::= TIMESTAMP */
+ { 363, -4 }, /* (170) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+ { 363, -2 }, /* (171) type_name ::= TINYINT UNSIGNED */
+ { 363, -2 }, /* (172) type_name ::= SMALLINT UNSIGNED */
+ { 363, -2 }, /* (173) type_name ::= INT UNSIGNED */
+ { 363, -2 }, /* (174) type_name ::= BIGINT UNSIGNED */
+ { 363, -1 }, /* (175) type_name ::= JSON */
+ { 363, -4 }, /* (176) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+ { 363, -1 }, /* (177) type_name ::= MEDIUMBLOB */
+ { 363, -1 }, /* (178) type_name ::= BLOB */
+ { 363, -4 }, /* (179) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+ { 363, -1 }, /* (180) type_name ::= DECIMAL */
+ { 363, -4 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+ { 363, -6 }, /* (182) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+ { 355, 0 }, /* (183) tags_def_opt ::= */
+ { 355, -1 }, /* (184) tags_def_opt ::= tags_def */
+ { 358, -4 }, /* (185) tags_def ::= TAGS NK_LP column_def_list NK_RP */
+ { 356, 0 }, /* (186) table_options ::= */
+ { 356, -3 }, /* (187) table_options ::= table_options COMMENT NK_STRING */
+ { 356, -3 }, /* (188) table_options ::= table_options MAX_DELAY duration_list */
+ { 356, -3 }, /* (189) table_options ::= table_options WATERMARK duration_list */
+ { 356, -5 }, /* (190) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
+ { 356, -3 }, /* (191) table_options ::= table_options TTL NK_INTEGER */
+ { 356, -5 }, /* (192) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
+ { 356, -3 }, /* (193) table_options ::= table_options DELETE_MARK duration_list */
+ { 361, -1 }, /* (194) alter_table_options ::= alter_table_option */
+ { 361, -2 }, /* (195) alter_table_options ::= alter_table_options alter_table_option */
+ { 374, -2 }, /* (196) alter_table_option ::= COMMENT NK_STRING */
+ { 374, -2 }, /* (197) alter_table_option ::= TTL NK_INTEGER */
+ { 372, -1 }, /* (198) duration_list ::= duration_literal */
+ { 372, -3 }, /* (199) duration_list ::= duration_list NK_COMMA duration_literal */
+ { 373, -1 }, /* (200) rollup_func_list ::= rollup_func_name */
+ { 373, -3 }, /* (201) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */
+ { 376, -1 }, /* (202) rollup_func_name ::= function_name */
+ { 376, -1 }, /* (203) rollup_func_name ::= FIRST */
+ { 376, -1 }, /* (204) rollup_func_name ::= LAST */
+ { 369, -1 }, /* (205) col_name_list ::= col_name */
+ { 369, -3 }, /* (206) col_name_list ::= col_name_list NK_COMMA col_name */
+ { 378, -1 }, /* (207) col_name ::= column_name */
+ { 328, -2 }, /* (208) cmd ::= SHOW DNODES */
+ { 328, -2 }, /* (209) cmd ::= SHOW USERS */
+ { 328, -3 }, /* (210) cmd ::= SHOW USER PRIVILEGES */
+ { 328, -2 }, /* (211) cmd ::= SHOW DATABASES */
+ { 328, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
+ { 328, -4 }, /* (213) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
+ { 328, -3 }, /* (214) cmd ::= SHOW db_name_cond_opt VGROUPS */
+ { 328, -2 }, /* (215) cmd ::= SHOW MNODES */
+ { 328, -2 }, /* (216) cmd ::= SHOW QNODES */
+ { 328, -2 }, /* (217) cmd ::= SHOW FUNCTIONS */
+ { 328, -5 }, /* (218) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
+ { 328, -2 }, /* (219) cmd ::= SHOW STREAMS */
+ { 328, -2 }, /* (220) cmd ::= SHOW ACCOUNTS */
+ { 328, -2 }, /* (221) cmd ::= SHOW APPS */
+ { 328, -2 }, /* (222) cmd ::= SHOW CONNECTIONS */
+ { 328, -2 }, /* (223) cmd ::= SHOW LICENCES */
+ { 328, -2 }, /* (224) cmd ::= SHOW GRANTS */
+ { 328, -4 }, /* (225) cmd ::= SHOW CREATE DATABASE db_name */
+ { 328, -4 }, /* (226) cmd ::= SHOW CREATE TABLE full_table_name */
+ { 328, -4 }, /* (227) cmd ::= SHOW CREATE STABLE full_table_name */
+ { 328, -2 }, /* (228) cmd ::= SHOW QUERIES */
+ { 328, -2 }, /* (229) cmd ::= SHOW SCORES */
+ { 328, -2 }, /* (230) cmd ::= SHOW TOPICS */
+ { 328, -2 }, /* (231) cmd ::= SHOW VARIABLES */
+ { 328, -3 }, /* (232) cmd ::= SHOW CLUSTER VARIABLES */
+ { 328, -3 }, /* (233) cmd ::= SHOW LOCAL VARIABLES */
+ { 328, -5 }, /* (234) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */
+ { 328, -2 }, /* (235) cmd ::= SHOW BNODES */
+ { 328, -2 }, /* (236) cmd ::= SHOW SNODES */
+ { 328, -2 }, /* (237) cmd ::= SHOW CLUSTER */
+ { 328, -2 }, /* (238) cmd ::= SHOW TRANSACTIONS */
+ { 328, -4 }, /* (239) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
+ { 328, -2 }, /* (240) cmd ::= SHOW CONSUMERS */
+ { 328, -2 }, /* (241) cmd ::= SHOW SUBSCRIPTIONS */
+ { 328, -5 }, /* (242) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
+ { 328, -7 }, /* (243) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */
+ { 328, -3 }, /* (244) cmd ::= SHOW VNODES NK_INTEGER */
+ { 328, -3 }, /* (245) cmd ::= SHOW VNODES NK_STRING */
+ { 328, -3 }, /* (246) cmd ::= SHOW db_name_cond_opt ALIVE */
+ { 328, -3 }, /* (247) cmd ::= SHOW CLUSTER ALIVE */
+ { 379, 0 }, /* (248) db_name_cond_opt ::= */
+ { 379, -2 }, /* (249) db_name_cond_opt ::= db_name NK_DOT */
+ { 380, 0 }, /* (250) like_pattern_opt ::= */
+ { 380, -2 }, /* (251) like_pattern_opt ::= LIKE NK_STRING */
+ { 381, -1 }, /* (252) table_name_cond ::= table_name */
+ { 382, 0 }, /* (253) from_db_opt ::= */
+ { 382, -2 }, /* (254) from_db_opt ::= FROM db_name */
+ { 383, 0 }, /* (255) tag_list_opt ::= */
+ { 383, -1 }, /* (256) tag_list_opt ::= tag_item */
+ { 383, -3 }, /* (257) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */
+ { 384, -1 }, /* (258) tag_item ::= TBNAME */
+ { 384, -1 }, /* (259) tag_item ::= QTAGS */
+ { 384, -1 }, /* (260) tag_item ::= column_name */
+ { 384, -2 }, /* (261) tag_item ::= column_name column_alias */
+ { 384, -3 }, /* (262) tag_item ::= column_name AS column_alias */
+ { 328, -8 }, /* (263) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */
+ { 328, -9 }, /* (264) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */
+ { 328, -4 }, /* (265) cmd ::= DROP INDEX exists_opt full_index_name */
+ { 386, -1 }, /* (266) full_index_name ::= index_name */
+ { 386, -3 }, /* (267) full_index_name ::= db_name NK_DOT index_name */
+ { 387, -10 }, /* (268) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
+ { 387, -12 }, /* (269) 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 */
+ { 389, -1 }, /* (270) func_list ::= func */
+ { 389, -3 }, /* (271) func_list ::= func_list NK_COMMA func */
+ { 392, -4 }, /* (272) func ::= sma_func_name NK_LP expression_list NK_RP */
+ { 393, -1 }, /* (273) sma_func_name ::= function_name */
+ { 393, -1 }, /* (274) sma_func_name ::= COUNT */
+ { 393, -1 }, /* (275) sma_func_name ::= FIRST */
+ { 393, -1 }, /* (276) sma_func_name ::= LAST */
+ { 393, -1 }, /* (277) sma_func_name ::= LAST_ROW */
+ { 391, 0 }, /* (278) sma_stream_opt ::= */
+ { 391, -3 }, /* (279) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */
+ { 391, -3 }, /* (280) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */
+ { 391, -3 }, /* (281) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */
+ { 328, -6 }, /* (282) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */
+ { 328, -7 }, /* (283) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
+ { 328, -9 }, /* (284) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
+ { 328, -7 }, /* (285) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
+ { 328, -9 }, /* (286) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
+ { 328, -4 }, /* (287) cmd ::= DROP TOPIC exists_opt topic_name */
+ { 328, -7 }, /* (288) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
+ { 328, -2 }, /* (289) cmd ::= DESC full_table_name */
+ { 328, -2 }, /* (290) cmd ::= DESCRIBE full_table_name */
+ { 328, -3 }, /* (291) cmd ::= RESET QUERY CACHE */
+ { 328, -4 }, /* (292) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */
+ { 328, -4 }, /* (293) cmd ::= EXPLAIN analyze_opt explain_options insert_query */
+ { 396, 0 }, /* (294) analyze_opt ::= */
+ { 396, -1 }, /* (295) analyze_opt ::= ANALYZE */
+ { 397, 0 }, /* (296) explain_options ::= */
+ { 397, -3 }, /* (297) explain_options ::= explain_options VERBOSE NK_BOOL */
+ { 397, -3 }, /* (298) explain_options ::= explain_options RATIO NK_FLOAT */
+ { 328, -10 }, /* (299) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
+ { 328, -4 }, /* (300) cmd ::= DROP FUNCTION exists_opt function_name */
+ { 399, 0 }, /* (301) agg_func_opt ::= */
+ { 399, -1 }, /* (302) agg_func_opt ::= AGGREGATE */
+ { 400, 0 }, /* (303) bufsize_opt ::= */
+ { 400, -2 }, /* (304) bufsize_opt ::= BUFSIZE NK_INTEGER */
+ { 328, -12 }, /* (305) 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 */
+ { 328, -4 }, /* (306) cmd ::= DROP STREAM exists_opt stream_name */
+ { 403, 0 }, /* (307) col_list_opt ::= */
+ { 403, -3 }, /* (308) col_list_opt ::= NK_LP col_name_list NK_RP */
+ { 404, 0 }, /* (309) tag_def_or_ref_opt ::= */
+ { 404, -1 }, /* (310) tag_def_or_ref_opt ::= tags_def */
+ { 404, -4 }, /* (311) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */
+ { 402, 0 }, /* (312) stream_options ::= */
+ { 402, -3 }, /* (313) stream_options ::= stream_options TRIGGER AT_ONCE */
+ { 402, -3 }, /* (314) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
+ { 402, -4 }, /* (315) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
+ { 402, -3 }, /* (316) stream_options ::= stream_options WATERMARK duration_literal */
+ { 402, -4 }, /* (317) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
+ { 402, -3 }, /* (318) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */
+ { 402, -4 }, /* (319) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */
+ { 405, 0 }, /* (320) subtable_opt ::= */
+ { 405, -4 }, /* (321) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */
+ { 328, -3 }, /* (322) cmd ::= KILL CONNECTION NK_INTEGER */
+ { 328, -3 }, /* (323) cmd ::= KILL QUERY NK_STRING */
+ { 328, -3 }, /* (324) cmd ::= KILL TRANSACTION NK_INTEGER */
+ { 328, -2 }, /* (325) cmd ::= BALANCE VGROUP */
+ { 328, -4 }, /* (326) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
+ { 328, -4 }, /* (327) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
+ { 328, -3 }, /* (328) cmd ::= SPLIT VGROUP NK_INTEGER */
+ { 407, -2 }, /* (329) dnode_list ::= DNODE NK_INTEGER */
+ { 407, -3 }, /* (330) dnode_list ::= dnode_list DNODE NK_INTEGER */
+ { 328, -4 }, /* (331) cmd ::= DELETE FROM full_table_name where_clause_opt */
+ { 328, -1 }, /* (332) cmd ::= query_or_subquery */
+ { 328, -1 }, /* (333) cmd ::= insert_query */
+ { 398, -7 }, /* (334) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */
+ { 398, -4 }, /* (335) insert_query ::= INSERT INTO full_table_name query_or_subquery */
+ { 331, -1 }, /* (336) literal ::= NK_INTEGER */
+ { 331, -1 }, /* (337) literal ::= NK_FLOAT */
+ { 331, -1 }, /* (338) literal ::= NK_STRING */
+ { 331, -1 }, /* (339) literal ::= NK_BOOL */
+ { 331, -2 }, /* (340) literal ::= TIMESTAMP NK_STRING */
+ { 331, -1 }, /* (341) literal ::= duration_literal */
+ { 331, -1 }, /* (342) literal ::= NULL */
+ { 331, -1 }, /* (343) literal ::= NK_QUESTION */
+ { 375, -1 }, /* (344) duration_literal ::= NK_VARIABLE */
+ { 409, -1 }, /* (345) signed ::= NK_INTEGER */
+ { 409, -2 }, /* (346) signed ::= NK_PLUS NK_INTEGER */
+ { 409, -2 }, /* (347) signed ::= NK_MINUS NK_INTEGER */
+ { 409, -1 }, /* (348) signed ::= NK_FLOAT */
+ { 409, -2 }, /* (349) signed ::= NK_PLUS NK_FLOAT */
+ { 409, -2 }, /* (350) signed ::= NK_MINUS NK_FLOAT */
+ { 364, -1 }, /* (351) signed_literal ::= signed */
+ { 364, -1 }, /* (352) signed_literal ::= NK_STRING */
+ { 364, -1 }, /* (353) signed_literal ::= NK_BOOL */
+ { 364, -2 }, /* (354) signed_literal ::= TIMESTAMP NK_STRING */
+ { 364, -1 }, /* (355) signed_literal ::= duration_literal */
+ { 364, -1 }, /* (356) signed_literal ::= NULL */
+ { 364, -1 }, /* (357) signed_literal ::= literal_func */
+ { 364, -1 }, /* (358) signed_literal ::= NK_QUESTION */
+ { 411, -1 }, /* (359) literal_list ::= signed_literal */
+ { 411, -3 }, /* (360) literal_list ::= literal_list NK_COMMA signed_literal */
+ { 339, -1 }, /* (361) db_name ::= NK_ID */
+ { 370, -1 }, /* (362) table_name ::= NK_ID */
+ { 362, -1 }, /* (363) column_name ::= NK_ID */
+ { 377, -1 }, /* (364) function_name ::= NK_ID */
+ { 412, -1 }, /* (365) table_alias ::= NK_ID */
+ { 385, -1 }, /* (366) column_alias ::= NK_ID */
+ { 333, -1 }, /* (367) user_name ::= NK_ID */
+ { 340, -1 }, /* (368) topic_name ::= NK_ID */
+ { 401, -1 }, /* (369) stream_name ::= NK_ID */
+ { 395, -1 }, /* (370) cgroup_name ::= NK_ID */
+ { 388, -1 }, /* (371) index_name ::= NK_ID */
+ { 413, -1 }, /* (372) expr_or_subquery ::= expression */
+ { 406, -1 }, /* (373) expression ::= literal */
+ { 406, -1 }, /* (374) expression ::= pseudo_column */
+ { 406, -1 }, /* (375) expression ::= column_reference */
+ { 406, -1 }, /* (376) expression ::= function_expression */
+ { 406, -1 }, /* (377) expression ::= case_when_expression */
+ { 406, -3 }, /* (378) expression ::= NK_LP expression NK_RP */
+ { 406, -2 }, /* (379) expression ::= NK_PLUS expr_or_subquery */
+ { 406, -2 }, /* (380) expression ::= NK_MINUS expr_or_subquery */
+ { 406, -3 }, /* (381) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */
+ { 406, -3 }, /* (382) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */
+ { 406, -3 }, /* (383) expression ::= expr_or_subquery NK_STAR expr_or_subquery */
+ { 406, -3 }, /* (384) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */
+ { 406, -3 }, /* (385) expression ::= expr_or_subquery NK_REM expr_or_subquery */
+ { 406, -3 }, /* (386) expression ::= column_reference NK_ARROW NK_STRING */
+ { 406, -3 }, /* (387) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */
+ { 406, -3 }, /* (388) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */
+ { 367, -1 }, /* (389) expression_list ::= expr_or_subquery */
+ { 367, -3 }, /* (390) expression_list ::= expression_list NK_COMMA expr_or_subquery */
+ { 415, -1 }, /* (391) column_reference ::= column_name */
+ { 415, -3 }, /* (392) column_reference ::= table_name NK_DOT column_name */
+ { 414, -1 }, /* (393) pseudo_column ::= ROWTS */
+ { 414, -1 }, /* (394) pseudo_column ::= TBNAME */
+ { 414, -3 }, /* (395) pseudo_column ::= table_name NK_DOT TBNAME */
+ { 414, -1 }, /* (396) pseudo_column ::= QSTART */
+ { 414, -1 }, /* (397) pseudo_column ::= QEND */
+ { 414, -1 }, /* (398) pseudo_column ::= QDURATION */
+ { 414, -1 }, /* (399) pseudo_column ::= WSTART */
+ { 414, -1 }, /* (400) pseudo_column ::= WEND */
+ { 414, -1 }, /* (401) pseudo_column ::= WDURATION */
+ { 414, -1 }, /* (402) pseudo_column ::= IROWTS */
+ { 414, -1 }, /* (403) pseudo_column ::= ISFILLED */
+ { 414, -1 }, /* (404) pseudo_column ::= QTAGS */
+ { 416, -4 }, /* (405) function_expression ::= function_name NK_LP expression_list NK_RP */
+ { 416, -4 }, /* (406) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
+ { 416, -6 }, /* (407) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */
+ { 416, -1 }, /* (408) function_expression ::= literal_func */
+ { 410, -3 }, /* (409) literal_func ::= noarg_func NK_LP NK_RP */
+ { 410, -1 }, /* (410) literal_func ::= NOW */
+ { 420, -1 }, /* (411) noarg_func ::= NOW */
+ { 420, -1 }, /* (412) noarg_func ::= TODAY */
+ { 420, -1 }, /* (413) noarg_func ::= TIMEZONE */
+ { 420, -1 }, /* (414) noarg_func ::= DATABASE */
+ { 420, -1 }, /* (415) noarg_func ::= CLIENT_VERSION */
+ { 420, -1 }, /* (416) noarg_func ::= SERVER_VERSION */
+ { 420, -1 }, /* (417) noarg_func ::= SERVER_STATUS */
+ { 420, -1 }, /* (418) noarg_func ::= CURRENT_USER */
+ { 420, -1 }, /* (419) noarg_func ::= USER */
+ { 418, -1 }, /* (420) star_func ::= COUNT */
+ { 418, -1 }, /* (421) star_func ::= FIRST */
+ { 418, -1 }, /* (422) star_func ::= LAST */
+ { 418, -1 }, /* (423) star_func ::= LAST_ROW */
+ { 419, -1 }, /* (424) star_func_para_list ::= NK_STAR */
+ { 419, -1 }, /* (425) star_func_para_list ::= other_para_list */
+ { 421, -1 }, /* (426) other_para_list ::= star_func_para */
+ { 421, -3 }, /* (427) other_para_list ::= other_para_list NK_COMMA star_func_para */
+ { 422, -1 }, /* (428) star_func_para ::= expr_or_subquery */
+ { 422, -3 }, /* (429) star_func_para ::= table_name NK_DOT NK_STAR */
+ { 417, -4 }, /* (430) case_when_expression ::= CASE when_then_list case_when_else_opt END */
+ { 417, -5 }, /* (431) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */
+ { 423, -1 }, /* (432) when_then_list ::= when_then_expr */
+ { 423, -2 }, /* (433) when_then_list ::= when_then_list when_then_expr */
+ { 426, -4 }, /* (434) when_then_expr ::= WHEN common_expression THEN common_expression */
+ { 424, 0 }, /* (435) case_when_else_opt ::= */
+ { 424, -2 }, /* (436) case_when_else_opt ::= ELSE common_expression */
+ { 427, -3 }, /* (437) predicate ::= expr_or_subquery compare_op expr_or_subquery */
+ { 427, -5 }, /* (438) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */
+ { 427, -6 }, /* (439) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */
+ { 427, -3 }, /* (440) predicate ::= expr_or_subquery IS NULL */
+ { 427, -4 }, /* (441) predicate ::= expr_or_subquery IS NOT NULL */
+ { 427, -3 }, /* (442) predicate ::= expr_or_subquery in_op in_predicate_value */
+ { 428, -1 }, /* (443) compare_op ::= NK_LT */
+ { 428, -1 }, /* (444) compare_op ::= NK_GT */
+ { 428, -1 }, /* (445) compare_op ::= NK_LE */
+ { 428, -1 }, /* (446) compare_op ::= NK_GE */
+ { 428, -1 }, /* (447) compare_op ::= NK_NE */
+ { 428, -1 }, /* (448) compare_op ::= NK_EQ */
+ { 428, -1 }, /* (449) compare_op ::= LIKE */
+ { 428, -2 }, /* (450) compare_op ::= NOT LIKE */
+ { 428, -1 }, /* (451) compare_op ::= MATCH */
+ { 428, -1 }, /* (452) compare_op ::= NMATCH */
+ { 428, -1 }, /* (453) compare_op ::= CONTAINS */
+ { 429, -1 }, /* (454) in_op ::= IN */
+ { 429, -2 }, /* (455) in_op ::= NOT IN */
+ { 430, -3 }, /* (456) in_predicate_value ::= NK_LP literal_list NK_RP */
+ { 431, -1 }, /* (457) boolean_value_expression ::= boolean_primary */
+ { 431, -2 }, /* (458) boolean_value_expression ::= NOT boolean_primary */
+ { 431, -3 }, /* (459) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ { 431, -3 }, /* (460) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ { 432, -1 }, /* (461) boolean_primary ::= predicate */
+ { 432, -3 }, /* (462) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
+ { 425, -1 }, /* (463) common_expression ::= expr_or_subquery */
+ { 425, -1 }, /* (464) common_expression ::= boolean_value_expression */
+ { 433, 0 }, /* (465) from_clause_opt ::= */
+ { 433, -2 }, /* (466) from_clause_opt ::= FROM table_reference_list */
+ { 434, -1 }, /* (467) table_reference_list ::= table_reference */
+ { 434, -3 }, /* (468) table_reference_list ::= table_reference_list NK_COMMA table_reference */
+ { 435, -1 }, /* (469) table_reference ::= table_primary */
+ { 435, -1 }, /* (470) table_reference ::= joined_table */
+ { 436, -2 }, /* (471) table_primary ::= table_name alias_opt */
+ { 436, -4 }, /* (472) table_primary ::= db_name NK_DOT table_name alias_opt */
+ { 436, -2 }, /* (473) table_primary ::= subquery alias_opt */
+ { 436, -1 }, /* (474) table_primary ::= parenthesized_joined_table */
+ { 438, 0 }, /* (475) alias_opt ::= */
+ { 438, -1 }, /* (476) alias_opt ::= table_alias */
+ { 438, -2 }, /* (477) alias_opt ::= AS table_alias */
+ { 440, -3 }, /* (478) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ { 440, -3 }, /* (479) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
+ { 437, -6 }, /* (480) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+ { 441, 0 }, /* (481) join_type ::= */
+ { 441, -1 }, /* (482) join_type ::= INNER */
+ { 443, -12 }, /* (483) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ { 444, 0 }, /* (484) set_quantifier_opt ::= */
+ { 444, -1 }, /* (485) set_quantifier_opt ::= DISTINCT */
+ { 444, -1 }, /* (486) set_quantifier_opt ::= ALL */
+ { 445, -1 }, /* (487) select_list ::= select_item */
+ { 445, -3 }, /* (488) select_list ::= select_list NK_COMMA select_item */
+ { 453, -1 }, /* (489) select_item ::= NK_STAR */
+ { 453, -1 }, /* (490) select_item ::= common_expression */
+ { 453, -2 }, /* (491) select_item ::= common_expression column_alias */
+ { 453, -3 }, /* (492) select_item ::= common_expression AS column_alias */
+ { 453, -3 }, /* (493) select_item ::= table_name NK_DOT NK_STAR */
+ { 408, 0 }, /* (494) where_clause_opt ::= */
+ { 408, -2 }, /* (495) where_clause_opt ::= WHERE search_condition */
+ { 446, 0 }, /* (496) partition_by_clause_opt ::= */
+ { 446, -3 }, /* (497) partition_by_clause_opt ::= PARTITION BY partition_list */
+ { 454, -1 }, /* (498) partition_list ::= partition_item */
+ { 454, -3 }, /* (499) partition_list ::= partition_list NK_COMMA partition_item */
+ { 455, -1 }, /* (500) partition_item ::= expr_or_subquery */
+ { 455, -2 }, /* (501) partition_item ::= expr_or_subquery column_alias */
+ { 455, -3 }, /* (502) partition_item ::= expr_or_subquery AS column_alias */
+ { 450, 0 }, /* (503) twindow_clause_opt ::= */
+ { 450, -6 }, /* (504) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
+ { 450, -4 }, /* (505) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */
+ { 450, -6 }, /* (506) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+ { 450, -8 }, /* (507) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+ { 450, -7 }, /* (508) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */
+ { 390, 0 }, /* (509) sliding_opt ::= */
+ { 390, -4 }, /* (510) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
+ { 449, 0 }, /* (511) fill_opt ::= */
+ { 449, -4 }, /* (512) fill_opt ::= FILL NK_LP fill_mode NK_RP */
+ { 449, -6 }, /* (513) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+ { 449, -6 }, /* (514) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */
+ { 456, -1 }, /* (515) fill_mode ::= NONE */
+ { 456, -1 }, /* (516) fill_mode ::= PREV */
+ { 456, -1 }, /* (517) fill_mode ::= NULL */
+ { 456, -1 }, /* (518) fill_mode ::= NULL_F */
+ { 456, -1 }, /* (519) fill_mode ::= LINEAR */
+ { 456, -1 }, /* (520) fill_mode ::= NEXT */
+ { 451, 0 }, /* (521) group_by_clause_opt ::= */
+ { 451, -3 }, /* (522) group_by_clause_opt ::= GROUP BY group_by_list */
+ { 457, -1 }, /* (523) group_by_list ::= expr_or_subquery */
+ { 457, -3 }, /* (524) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */
+ { 452, 0 }, /* (525) having_clause_opt ::= */
+ { 452, -2 }, /* (526) having_clause_opt ::= HAVING search_condition */
+ { 447, 0 }, /* (527) range_opt ::= */
+ { 447, -6 }, /* (528) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */
+ { 448, 0 }, /* (529) every_opt ::= */
+ { 448, -4 }, /* (530) every_opt ::= EVERY NK_LP duration_literal NK_RP */
+ { 458, -4 }, /* (531) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ { 459, -1 }, /* (532) query_simple ::= query_specification */
+ { 459, -1 }, /* (533) query_simple ::= union_query_expression */
+ { 463, -4 }, /* (534) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */
+ { 463, -3 }, /* (535) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */
+ { 464, -1 }, /* (536) query_simple_or_subquery ::= query_simple */
+ { 464, -1 }, /* (537) query_simple_or_subquery ::= subquery */
+ { 394, -1 }, /* (538) query_or_subquery ::= query_expression */
+ { 394, -1 }, /* (539) query_or_subquery ::= subquery */
+ { 460, 0 }, /* (540) order_by_clause_opt ::= */
+ { 460, -3 }, /* (541) order_by_clause_opt ::= ORDER BY sort_specification_list */
+ { 461, 0 }, /* (542) slimit_clause_opt ::= */
+ { 461, -2 }, /* (543) slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ { 461, -4 }, /* (544) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ { 461, -4 }, /* (545) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 462, 0 }, /* (546) limit_clause_opt ::= */
+ { 462, -2 }, /* (547) limit_clause_opt ::= LIMIT NK_INTEGER */
+ { 462, -4 }, /* (548) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
+ { 462, -4 }, /* (549) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 439, -3 }, /* (550) subquery ::= NK_LP query_expression NK_RP */
+ { 439, -3 }, /* (551) subquery ::= NK_LP subquery NK_RP */
+ { 442, -1 }, /* (552) search_condition ::= common_expression */
+ { 465, -1 }, /* (553) sort_specification_list ::= sort_specification */
+ { 465, -3 }, /* (554) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
+ { 466, -3 }, /* (555) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */
+ { 467, 0 }, /* (556) ordering_specification_opt ::= */
+ { 467, -1 }, /* (557) ordering_specification_opt ::= ASC */
+ { 467, -1 }, /* (558) ordering_specification_opt ::= DESC */
+ { 468, 0 }, /* (559) null_ordering_opt ::= */
+ { 468, -2 }, /* (560) null_ordering_opt ::= NULLS FIRST */
+ { 468, -2 }, /* (561) null_ordering_opt ::= NULLS LAST */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -3724,11 +3702,11 @@ static YYACTIONTYPE yy_reduce(
YYMINORTYPE yylhsminor;
case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
- yy_destructor(yypParser,327,&yymsp[0].minor);
+ yy_destructor(yypParser,329,&yymsp[0].minor);
break;
case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
- yy_destructor(yypParser,328,&yymsp[0].minor);
+ yy_destructor(yypParser,330,&yymsp[0].minor);
break;
case 2: /* account_options ::= */
{ }
@@ -3742,20 +3720,20 @@ static YYACTIONTYPE yy_reduce(
case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9);
case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10);
case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11);
-{ yy_destructor(yypParser,327,&yymsp[-2].minor);
+{ yy_destructor(yypParser,329,&yymsp[-2].minor);
{ }
- yy_destructor(yypParser,329,&yymsp[0].minor);
+ yy_destructor(yypParser,331,&yymsp[0].minor);
}
break;
case 12: /* alter_account_options ::= alter_account_option */
-{ yy_destructor(yypParser,330,&yymsp[0].minor);
+{ yy_destructor(yypParser,332,&yymsp[0].minor);
{ }
}
break;
case 13: /* alter_account_options ::= alter_account_options alter_account_option */
-{ yy_destructor(yypParser,328,&yymsp[-1].minor);
+{ yy_destructor(yypParser,330,&yymsp[-1].minor);
{ }
- yy_destructor(yypParser,330,&yymsp[0].minor);
+ yy_destructor(yypParser,332,&yymsp[0].minor);
}
break;
case 14: /* alter_account_option ::= PASS literal */
@@ -3769,81 +3747,81 @@ static YYACTIONTYPE yy_reduce(
case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22);
case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23);
{ }
- yy_destructor(yypParser,329,&yymsp[0].minor);
+ yy_destructor(yypParser,331,&yymsp[0].minor);
break;
case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
-{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy233, &yymsp[-1].minor.yy0, yymsp[0].minor.yy27); }
+{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy225, &yymsp[-1].minor.yy0, yymsp[0].minor.yy705); }
break;
case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy233, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy225, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); }
break;
case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy233, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy225, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); }
break;
case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy233, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy225, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); }
break;
case 28: /* cmd ::= DROP USER user_name */
-{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy225); }
break;
case 29: /* sysinfo_opt ::= */
-{ yymsp[1].minor.yy27 = 1; }
+{ yymsp[1].minor.yy705 = 1; }
break;
case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */
-{ yymsp[-1].minor.yy27 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); }
+{ yymsp[-1].minor.yy705 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */
-{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy641, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225); }
break;
case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */
-{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy641, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225); }
break;
case 33: /* privileges ::= ALL */
-{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_ALL; }
+{ yymsp[0].minor.yy641 = PRIVILEGE_TYPE_ALL; }
break;
case 34: /* privileges ::= priv_type_list */
case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36);
-{ yylhsminor.yy129 = yymsp[0].minor.yy129; }
- yymsp[0].minor.yy129 = yylhsminor.yy129;
+{ yylhsminor.yy641 = yymsp[0].minor.yy641; }
+ yymsp[0].minor.yy641 = yylhsminor.yy641;
break;
case 35: /* privileges ::= SUBSCRIBE */
-{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_SUBSCRIBE; }
+{ yymsp[0].minor.yy641 = PRIVILEGE_TYPE_SUBSCRIBE; }
break;
case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */
-{ yylhsminor.yy129 = yymsp[-2].minor.yy129 | yymsp[0].minor.yy129; }
- yymsp[-2].minor.yy129 = yylhsminor.yy129;
+{ yylhsminor.yy641 = yymsp[-2].minor.yy641 | yymsp[0].minor.yy641; }
+ yymsp[-2].minor.yy641 = yylhsminor.yy641;
break;
case 38: /* priv_type ::= READ */
-{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_READ; }
+{ yymsp[0].minor.yy641 = PRIVILEGE_TYPE_READ; }
break;
case 39: /* priv_type ::= WRITE */
-{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_WRITE; }
+{ yymsp[0].minor.yy641 = PRIVILEGE_TYPE_WRITE; }
break;
case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */
-{ yylhsminor.yy233 = yymsp[-2].minor.yy0; }
- yymsp[-2].minor.yy233 = yylhsminor.yy233;
+{ yylhsminor.yy225 = yymsp[-2].minor.yy0; }
+ yymsp[-2].minor.yy225 = yylhsminor.yy225;
break;
case 41: /* priv_level ::= db_name NK_DOT NK_STAR */
-{ yylhsminor.yy233 = yymsp[-2].minor.yy233; }
- yymsp[-2].minor.yy233 = yylhsminor.yy233;
+{ yylhsminor.yy225 = yymsp[-2].minor.yy225; }
+ yymsp[-2].minor.yy225 = yylhsminor.yy225;
break;
case 42: /* priv_level ::= topic_name */
- case 272: /* sma_func_name ::= function_name */ yytestcase(yyruleno==272);
- case 472: /* alias_opt ::= table_alias */ yytestcase(yyruleno==472);
-{ yylhsminor.yy233 = yymsp[0].minor.yy233; }
- yymsp[0].minor.yy233 = yylhsminor.yy233;
+ case 273: /* sma_func_name ::= function_name */ yytestcase(yyruleno==273);
+ case 476: /* alias_opt ::= table_alias */ yytestcase(yyruleno==476);
+{ yylhsminor.yy225 = yymsp[0].minor.yy225; }
+ yymsp[0].minor.yy225 = yylhsminor.yy225;
break;
case 43: /* cmd ::= CREATE DNODE dnode_endpoint */
-{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy233, NULL); }
+{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy225, NULL); }
break;
case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
-{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); }
break;
case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */
-{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy397); }
+{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy103); }
break;
case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */
-{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy233, yymsp[0].minor.yy397); }
+{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy103); }
break;
case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); }
@@ -3860,50 +3838,50 @@ static YYACTIONTYPE yy_reduce(
case 51: /* dnode_endpoint ::= NK_STRING */
case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52);
case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53);
- case 273: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==273);
- case 274: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==274);
- case 275: /* sma_func_name ::= LAST */ yytestcase(yyruleno==275);
- case 276: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==276);
- case 357: /* db_name ::= NK_ID */ yytestcase(yyruleno==357);
- case 358: /* table_name ::= NK_ID */ yytestcase(yyruleno==358);
- case 359: /* column_name ::= NK_ID */ yytestcase(yyruleno==359);
- case 360: /* function_name ::= NK_ID */ yytestcase(yyruleno==360);
- case 361: /* table_alias ::= NK_ID */ yytestcase(yyruleno==361);
- case 362: /* column_alias ::= NK_ID */ yytestcase(yyruleno==362);
- case 363: /* user_name ::= NK_ID */ yytestcase(yyruleno==363);
- case 364: /* topic_name ::= NK_ID */ yytestcase(yyruleno==364);
- case 365: /* stream_name ::= NK_ID */ yytestcase(yyruleno==365);
- case 366: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==366);
- case 367: /* index_name ::= NK_ID */ yytestcase(yyruleno==367);
- case 407: /* noarg_func ::= NOW */ yytestcase(yyruleno==407);
- case 408: /* noarg_func ::= TODAY */ yytestcase(yyruleno==408);
- case 409: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==409);
- case 410: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==410);
- case 411: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==411);
- case 412: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==412);
- case 413: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==413);
- case 414: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==414);
- case 415: /* noarg_func ::= USER */ yytestcase(yyruleno==415);
- case 416: /* star_func ::= COUNT */ yytestcase(yyruleno==416);
- case 417: /* star_func ::= FIRST */ yytestcase(yyruleno==417);
- case 418: /* star_func ::= LAST */ yytestcase(yyruleno==418);
- case 419: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==419);
-{ yylhsminor.yy233 = yymsp[0].minor.yy0; }
- yymsp[0].minor.yy233 = yylhsminor.yy233;
+ case 274: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==274);
+ case 275: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==275);
+ case 276: /* sma_func_name ::= LAST */ yytestcase(yyruleno==276);
+ case 277: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==277);
+ case 361: /* db_name ::= NK_ID */ yytestcase(yyruleno==361);
+ case 362: /* table_name ::= NK_ID */ yytestcase(yyruleno==362);
+ case 363: /* column_name ::= NK_ID */ yytestcase(yyruleno==363);
+ case 364: /* function_name ::= NK_ID */ yytestcase(yyruleno==364);
+ case 365: /* table_alias ::= NK_ID */ yytestcase(yyruleno==365);
+ case 366: /* column_alias ::= NK_ID */ yytestcase(yyruleno==366);
+ case 367: /* user_name ::= NK_ID */ yytestcase(yyruleno==367);
+ case 368: /* topic_name ::= NK_ID */ yytestcase(yyruleno==368);
+ case 369: /* stream_name ::= NK_ID */ yytestcase(yyruleno==369);
+ case 370: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==370);
+ case 371: /* index_name ::= NK_ID */ yytestcase(yyruleno==371);
+ case 411: /* noarg_func ::= NOW */ yytestcase(yyruleno==411);
+ case 412: /* noarg_func ::= TODAY */ yytestcase(yyruleno==412);
+ case 413: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==413);
+ case 414: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==414);
+ case 415: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==415);
+ case 416: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==416);
+ case 417: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==417);
+ case 418: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==418);
+ case 419: /* noarg_func ::= USER */ yytestcase(yyruleno==419);
+ case 420: /* star_func ::= COUNT */ yytestcase(yyruleno==420);
+ case 421: /* star_func ::= FIRST */ yytestcase(yyruleno==421);
+ case 422: /* star_func ::= LAST */ yytestcase(yyruleno==422);
+ case 423: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==423);
+{ yylhsminor.yy225 = yymsp[0].minor.yy0; }
+ yymsp[0].minor.yy225 = yylhsminor.yy225;
break;
case 54: /* force_opt ::= */
- case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73);
- case 75: /* exists_opt ::= */ yytestcase(yyruleno==75);
- case 292: /* analyze_opt ::= */ yytestcase(yyruleno==292);
- case 299: /* agg_func_opt ::= */ yytestcase(yyruleno==299);
- case 480: /* set_quantifier_opt ::= */ yytestcase(yyruleno==480);
-{ yymsp[1].minor.yy397 = false; }
+ case 74: /* not_exists_opt ::= */ yytestcase(yyruleno==74);
+ case 76: /* exists_opt ::= */ yytestcase(yyruleno==76);
+ case 294: /* analyze_opt ::= */ yytestcase(yyruleno==294);
+ case 301: /* agg_func_opt ::= */ yytestcase(yyruleno==301);
+ case 484: /* set_quantifier_opt ::= */ yytestcase(yyruleno==484);
+{ yymsp[1].minor.yy103 = false; }
break;
case 55: /* force_opt ::= FORCE */
- case 293: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==293);
- case 300: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==300);
- case 481: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==481);
-{ yymsp[0].minor.yy397 = true; }
+ case 295: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==295);
+ case 302: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==302);
+ case 485: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==485);
+{ yymsp[0].minor.yy103 = true; }
break;
case 56: /* cmd ::= ALTER LOCAL NK_STRING */
{ pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); }
@@ -3936,1361 +3914,1376 @@ static YYACTIONTYPE yy_reduce(
{ pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); }
break;
case 66: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
-{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy397, &yymsp[-1].minor.yy233, yymsp[0].minor.yy924); }
+{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy103, &yymsp[-1].minor.yy225, yymsp[0].minor.yy42); }
break;
case 67: /* cmd ::= DROP DATABASE exists_opt db_name */
-{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy103, &yymsp[0].minor.yy225); }
break;
case 68: /* cmd ::= USE db_name */
-{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy225); }
break;
case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */
-{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy233, yymsp[0].minor.yy924); }
+{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy42); }
break;
case 70: /* cmd ::= FLUSH DATABASE db_name */
-{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy233); }
+{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy225); }
break;
case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */
-{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy233, yymsp[0].minor.yy832); }
+{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy508); }
break;
- case 72: /* not_exists_opt ::= IF NOT EXISTS */
-{ yymsp[-2].minor.yy397 = true; }
+ case 72: /* cmd ::= COMPACT DATABASE db_name */
+{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[0].minor.yy225); }
break;
- case 74: /* exists_opt ::= IF EXISTS */
-{ yymsp[-1].minor.yy397 = true; }
+ case 73: /* not_exists_opt ::= IF NOT EXISTS */
+{ yymsp[-2].minor.yy103 = true; }
break;
- case 76: /* db_options ::= */
-{ yymsp[1].minor.yy924 = createDefaultDatabaseOptions(pCxt); }
+ case 75: /* exists_opt ::= IF EXISTS */
+{ yymsp[-1].minor.yy103 = true; }
break;
- case 77: /* db_options ::= db_options BUFFER NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 77: /* db_options ::= */
+{ yymsp[1].minor.yy42 = createDefaultDatabaseOptions(pCxt); }
break;
- case 78: /* db_options ::= db_options CACHEMODEL NK_STRING */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 78: /* db_options ::= db_options BUFFER NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 79: /* db_options ::= db_options CACHESIZE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 79: /* db_options ::= db_options CACHEMODEL NK_STRING */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 80: /* db_options ::= db_options COMP NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 80: /* db_options ::= db_options CACHESIZE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 81: /* db_options ::= db_options DURATION NK_INTEGER */
- case 82: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==82);
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 81: /* db_options ::= db_options COMP NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 83: /* db_options ::= db_options MAXROWS NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 82: /* db_options ::= db_options DURATION NK_INTEGER */
+ case 83: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==83);
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 84: /* db_options ::= db_options MINROWS NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 84: /* db_options ::= db_options MAXROWS NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 85: /* db_options ::= db_options KEEP integer_list */
- case 86: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==86);
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_KEEP, yymsp[0].minor.yy776); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 85: /* db_options ::= db_options MINROWS NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 87: /* db_options ::= db_options PAGES NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_PAGES, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 86: /* db_options ::= db_options KEEP integer_list */
+ case 87: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==87);
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_KEEP, yymsp[0].minor.yy110); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 88: /* db_options ::= db_options PAGESIZE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 88: /* db_options ::= db_options PAGES NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_PAGES, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 89: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 89: /* db_options ::= db_options PAGESIZE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 90: /* db_options ::= db_options PRECISION NK_STRING */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 90: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 91: /* db_options ::= db_options REPLICA NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 91: /* db_options ::= db_options PRECISION NK_STRING */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 92: /* db_options ::= db_options VGROUPS NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 92: /* db_options ::= db_options REPLICA NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 93: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 93: /* db_options ::= db_options VGROUPS NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 94: /* db_options ::= db_options RETENTIONS retention_list */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_RETENTIONS, yymsp[0].minor.yy776); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 94: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 95: /* db_options ::= db_options SCHEMALESS NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 95: /* db_options ::= db_options RETENTIONS retention_list */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_RETENTIONS, yymsp[0].minor.yy110); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 96: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 96: /* db_options ::= db_options SCHEMALESS NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 97: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 97: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 98: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 98: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
+ case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 100: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-3].minor.yy924, DB_OPTION_WAL_RETENTION_PERIOD, &t);
+ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-3].minor.yy42, DB_OPTION_WAL_RETENTION_PERIOD, &t);
}
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 100: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
+ case 102: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-3].minor.yy924, DB_OPTION_WAL_RETENTION_SIZE, &t);
+ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-3].minor.yy42, DB_OPTION_WAL_RETENTION_SIZE, &t);
}
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
- break;
- case 102: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 103: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 104: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 105: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 106: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
-{ yylhsminor.yy924 = setDatabaseOption(pCxt, yymsp[-2].minor.yy924, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 107: /* alter_db_options ::= alter_db_option */
-{ yylhsminor.yy924 = createAlterDatabaseOptions(pCxt); yylhsminor.yy924 = setAlterDatabaseOption(pCxt, yylhsminor.yy924, &yymsp[0].minor.yy257); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 108: /* alter_db_options ::= alter_db_options alter_db_option */
-{ yylhsminor.yy924 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy924, &yymsp[0].minor.yy257); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
- break;
- case 109: /* alter_db_option ::= BUFFER NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 110: /* alter_db_option ::= CACHEMODEL NK_STRING */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 111: /* alter_db_option ::= CACHESIZE NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 112: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 113: /* alter_db_option ::= KEEP integer_list */
- case 114: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==114);
-{ yymsp[-1].minor.yy257.type = DB_OPTION_KEEP; yymsp[-1].minor.yy257.pList = yymsp[0].minor.yy776; }
- break;
- case 115: /* alter_db_option ::= PAGES NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_PAGES; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 116: /* alter_db_option ::= REPLICA NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 117: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_WAL; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 118: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
- break;
- case 119: /* integer_list ::= NK_INTEGER */
-{ yylhsminor.yy776 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
- break;
- case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */
- case 327: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==327);
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-2].minor.yy776, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy776 = yylhsminor.yy776;
- break;
- case 121: /* variable_list ::= NK_VARIABLE */
-{ yylhsminor.yy776 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
- break;
- case 122: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-2].minor.yy776, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy776 = yylhsminor.yy776;
- break;
- case 123: /* retention_list ::= retention */
- case 145: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==145);
- case 148: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==148);
- case 155: /* column_def_list ::= column_def */ yytestcase(yyruleno==155);
- case 199: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==199);
- case 204: /* col_name_list ::= col_name */ yytestcase(yyruleno==204);
- case 255: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==255);
- case 269: /* func_list ::= func */ yytestcase(yyruleno==269);
- case 355: /* literal_list ::= signed_literal */ yytestcase(yyruleno==355);
- case 422: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==422);
- case 428: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==428);
- case 483: /* select_list ::= select_item */ yytestcase(yyruleno==483);
- case 494: /* partition_list ::= partition_item */ yytestcase(yyruleno==494);
- case 547: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==547);
-{ yylhsminor.yy776 = createNodeList(pCxt, yymsp[0].minor.yy924); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
- break;
- case 124: /* retention_list ::= retention_list NK_COMMA retention */
- case 156: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==156);
- case 200: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==200);
- case 205: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==205);
- case 256: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==256);
- case 270: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==270);
- case 356: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==356);
- case 423: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==423);
- case 484: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==484);
- case 495: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==495);
- case 548: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==548);
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-2].minor.yy776, yymsp[0].minor.yy924); }
- yymsp[-2].minor.yy776 = yylhsminor.yy776;
- break;
- case 125: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
-{ yylhsminor.yy924 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 126: /* speed_opt ::= */
- case 301: /* bufsize_opt ::= */ yytestcase(yyruleno==301);
-{ yymsp[1].minor.yy832 = 0; }
- break;
- case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */
- case 302: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==302);
-{ yymsp[-1].minor.yy832 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); }
- break;
- case 128: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
- case 130: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==130);
-{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy397, yymsp[-5].minor.yy924, yymsp[-3].minor.yy776, yymsp[-1].minor.yy776, yymsp[0].minor.yy924); }
- break;
- case 129: /* cmd ::= CREATE TABLE multi_create_clause */
-{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy776); }
- break;
- case 131: /* cmd ::= DROP TABLE multi_drop_clause */
-{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy776); }
- break;
- case 132: /* cmd ::= DROP STABLE exists_opt full_table_name */
-{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy397, yymsp[0].minor.yy924); }
- break;
- case 133: /* cmd ::= ALTER TABLE alter_table_clause */
- case 329: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==329);
-{ pCxt->pRootNode = yymsp[0].minor.yy924; }
- break;
- case 134: /* cmd ::= ALTER STABLE alter_table_clause */
-{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy924); }
- break;
- case 135: /* alter_table_clause ::= full_table_name alter_table_options */
-{ yylhsminor.yy924 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
- break;
- case 136: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
-{ yylhsminor.yy924 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy233, yymsp[0].minor.yy852); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 137: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */
-{ yylhsminor.yy924 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy924, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy233); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
- break;
- case 138: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
-{ yylhsminor.yy924 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy233, yymsp[0].minor.yy852); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 139: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
-{ yylhsminor.yy924 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy233, &yymsp[0].minor.yy233); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 140: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */
-{ yylhsminor.yy924 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy233, yymsp[0].minor.yy852); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 141: /* alter_table_clause ::= full_table_name DROP TAG column_name */
-{ yylhsminor.yy924 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy924, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy233); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
- break;
- case 142: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
-{ yylhsminor.yy924 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy233, yymsp[0].minor.yy852); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 143: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
-{ yylhsminor.yy924 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy924, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy233, &yymsp[0].minor.yy233); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 144: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
-{ yylhsminor.yy924 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy924, &yymsp[-2].minor.yy233, yymsp[0].minor.yy924); }
- yymsp[-5].minor.yy924 = yylhsminor.yy924;
- break;
- case 146: /* multi_create_clause ::= multi_create_clause create_subtable_clause */
- case 149: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==149);
- case 429: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==429);
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-1].minor.yy776, yymsp[0].minor.yy924); }
- yymsp[-1].minor.yy776 = yylhsminor.yy776;
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 103: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 104: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 105: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 106: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 107: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
+{ yylhsminor.yy42 = setDatabaseOption(pCxt, yymsp[-2].minor.yy42, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 108: /* alter_db_options ::= alter_db_option */
+{ yylhsminor.yy42 = createAlterDatabaseOptions(pCxt); yylhsminor.yy42 = setAlterDatabaseOption(pCxt, yylhsminor.yy42, &yymsp[0].minor.yy459); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 109: /* alter_db_options ::= alter_db_options alter_db_option */
+{ yylhsminor.yy42 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy42, &yymsp[0].minor.yy459); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 110: /* alter_db_option ::= BUFFER NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 111: /* alter_db_option ::= CACHEMODEL NK_STRING */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 112: /* alter_db_option ::= CACHESIZE NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 113: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 114: /* alter_db_option ::= KEEP integer_list */
+ case 115: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==115);
+{ yymsp[-1].minor.yy459.type = DB_OPTION_KEEP; yymsp[-1].minor.yy459.pList = yymsp[0].minor.yy110; }
+ break;
+ case 116: /* alter_db_option ::= PAGES NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_PAGES; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 117: /* alter_db_option ::= REPLICA NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 118: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_WAL; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 119: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
+ break;
+ case 120: /* integer_list ::= NK_INTEGER */
+{ yylhsminor.yy110 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 121: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */
+ case 330: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==330);
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-2].minor.yy110, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 122: /* variable_list ::= NK_VARIABLE */
+{ yylhsminor.yy110 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 123: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-2].minor.yy110, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 124: /* retention_list ::= retention */
+ case 146: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==146);
+ case 149: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==149);
+ case 156: /* column_def_list ::= column_def */ yytestcase(yyruleno==156);
+ case 200: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==200);
+ case 205: /* col_name_list ::= col_name */ yytestcase(yyruleno==205);
+ case 256: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==256);
+ case 270: /* func_list ::= func */ yytestcase(yyruleno==270);
+ case 359: /* literal_list ::= signed_literal */ yytestcase(yyruleno==359);
+ case 426: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==426);
+ case 432: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==432);
+ case 487: /* select_list ::= select_item */ yytestcase(yyruleno==487);
+ case 498: /* partition_list ::= partition_item */ yytestcase(yyruleno==498);
+ case 553: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==553);
+{ yylhsminor.yy110 = createNodeList(pCxt, yymsp[0].minor.yy42); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 125: /* retention_list ::= retention_list NK_COMMA retention */
+ case 157: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==157);
+ case 201: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==201);
+ case 206: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==206);
+ case 257: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==257);
+ case 271: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==271);
+ case 360: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==360);
+ case 427: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==427);
+ case 488: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==488);
+ case 499: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==499);
+ case 554: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==554);
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-2].minor.yy110, yymsp[0].minor.yy42); }
+ yymsp[-2].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 126: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
+{ yylhsminor.yy42 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 127: /* speed_opt ::= */
+ case 303: /* bufsize_opt ::= */ yytestcase(yyruleno==303);
+{ yymsp[1].minor.yy508 = 0; }
+ break;
+ case 128: /* speed_opt ::= MAX_SPEED NK_INTEGER */
+ case 304: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==304);
+{ yymsp[-1].minor.yy508 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); }
+ break;
+ case 129: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
+ case 131: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==131);
+{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy103, yymsp[-5].minor.yy42, yymsp[-3].minor.yy110, yymsp[-1].minor.yy110, yymsp[0].minor.yy42); }
+ break;
+ case 130: /* cmd ::= CREATE TABLE multi_create_clause */
+{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy110); }
+ break;
+ case 132: /* cmd ::= DROP TABLE multi_drop_clause */
+{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy110); }
+ break;
+ case 133: /* cmd ::= DROP STABLE exists_opt full_table_name */
+{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy103, yymsp[0].minor.yy42); }
+ break;
+ case 134: /* cmd ::= ALTER TABLE alter_table_clause */
+ case 332: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==332);
+ case 333: /* cmd ::= insert_query */ yytestcase(yyruleno==333);
+{ pCxt->pRootNode = yymsp[0].minor.yy42; }
+ break;
+ case 135: /* cmd ::= ALTER STABLE alter_table_clause */
+{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy42); }
+ break;
+ case 136: /* alter_table_clause ::= full_table_name alter_table_options */
+{ yylhsminor.yy42 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 137: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
+{ yylhsminor.yy42 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 138: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */
+{ yylhsminor.yy42 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy42, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy225); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 139: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
+{ yylhsminor.yy42 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 140: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
+{ yylhsminor.yy42 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 141: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */
+{ yylhsminor.yy42 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 142: /* alter_table_clause ::= full_table_name DROP TAG column_name */
+{ yylhsminor.yy42 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy42, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy225); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 143: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
+{ yylhsminor.yy42 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 144: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
+{ yylhsminor.yy42 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy42, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 145: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
+{ yylhsminor.yy42 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy42, &yymsp[-2].minor.yy225, yymsp[0].minor.yy42); }
+ yymsp[-5].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 147: /* multi_create_clause ::= multi_create_clause create_subtable_clause */
+ case 150: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==150);
+ case 433: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==433);
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-1].minor.yy110, yymsp[0].minor.yy42); }
+ yymsp[-1].minor.yy110 = yylhsminor.yy110;
break;
- case 147: /* 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.yy924 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy397, yymsp[-8].minor.yy924, yymsp[-6].minor.yy924, yymsp[-5].minor.yy776, yymsp[-2].minor.yy776, yymsp[0].minor.yy924); }
- yymsp[-9].minor.yy924 = yylhsminor.yy924;
+ case 148: /* 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.yy42 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy103, yymsp[-8].minor.yy42, yymsp[-6].minor.yy42, yymsp[-5].minor.yy110, yymsp[-2].minor.yy110, yymsp[0].minor.yy42); }
+ yymsp[-9].minor.yy42 = yylhsminor.yy42;
break;
- case 150: /* drop_table_clause ::= exists_opt full_table_name */
-{ yylhsminor.yy924 = createDropTableClause(pCxt, yymsp[-1].minor.yy397, yymsp[0].minor.yy924); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 151: /* drop_table_clause ::= exists_opt full_table_name */
+{ yylhsminor.yy42 = createDropTableClause(pCxt, yymsp[-1].minor.yy103, yymsp[0].minor.yy42); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 151: /* specific_cols_opt ::= */
- case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182);
- case 254: /* tag_list_opt ::= */ yytestcase(yyruleno==254);
- case 305: /* col_list_opt ::= */ yytestcase(yyruleno==305);
- case 307: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==307);
- case 492: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==492);
- case 515: /* group_by_clause_opt ::= */ yytestcase(yyruleno==515);
- case 534: /* order_by_clause_opt ::= */ yytestcase(yyruleno==534);
-{ yymsp[1].minor.yy776 = NULL; }
+ case 152: /* specific_cols_opt ::= */
+ case 183: /* tags_def_opt ::= */ yytestcase(yyruleno==183);
+ case 255: /* tag_list_opt ::= */ yytestcase(yyruleno==255);
+ case 307: /* col_list_opt ::= */ yytestcase(yyruleno==307);
+ case 309: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==309);
+ case 496: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==496);
+ case 521: /* group_by_clause_opt ::= */ yytestcase(yyruleno==521);
+ case 540: /* order_by_clause_opt ::= */ yytestcase(yyruleno==540);
+{ yymsp[1].minor.yy110 = NULL; }
break;
- case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */
- case 306: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==306);
-{ yymsp[-2].minor.yy776 = yymsp[-1].minor.yy776; }
+ case 153: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */
+ case 308: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==308);
+{ yymsp[-2].minor.yy110 = yymsp[-1].minor.yy110; }
break;
- case 153: /* full_table_name ::= table_name */
-{ yylhsminor.yy924 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy233, NULL); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 154: /* full_table_name ::= table_name */
+{ yylhsminor.yy42 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy225, NULL); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 154: /* full_table_name ::= db_name NK_DOT table_name */
-{ yylhsminor.yy924 = createRealTableNode(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233, NULL); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 155: /* full_table_name ::= db_name NK_DOT table_name */
+{ yylhsminor.yy42 = createRealTableNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225, NULL); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 157: /* column_def ::= column_name type_name */
-{ yylhsminor.yy924 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy233, yymsp[0].minor.yy852, NULL); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 158: /* column_def ::= column_name type_name */
+{ yylhsminor.yy42 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy225, yymsp[0].minor.yy448, NULL); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 158: /* column_def ::= column_name type_name COMMENT NK_STRING */
-{ yylhsminor.yy924 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy233, yymsp[-2].minor.yy852, &yymsp[0].minor.yy0); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 159: /* column_def ::= column_name type_name COMMENT NK_STRING */
+{ yylhsminor.yy42 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-2].minor.yy448, &yymsp[0].minor.yy0); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 159: /* type_name ::= BOOL */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_BOOL); }
+ case 160: /* type_name ::= BOOL */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); }
break;
- case 160: /* type_name ::= TINYINT */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_TINYINT); }
+ case 161: /* type_name ::= TINYINT */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); }
break;
- case 161: /* type_name ::= SMALLINT */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_SMALLINT); }
+ case 162: /* type_name ::= SMALLINT */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); }
break;
- case 162: /* type_name ::= INT */
- case 163: /* type_name ::= INTEGER */ yytestcase(yyruleno==163);
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_INT); }
+ case 163: /* type_name ::= INT */
+ case 164: /* type_name ::= INTEGER */ yytestcase(yyruleno==164);
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); }
break;
- case 164: /* type_name ::= BIGINT */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_BIGINT); }
+ case 165: /* type_name ::= BIGINT */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); }
break;
- case 165: /* type_name ::= FLOAT */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_FLOAT); }
+ case 166: /* type_name ::= FLOAT */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); }
break;
- case 166: /* type_name ::= DOUBLE */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_DOUBLE); }
+ case 167: /* type_name ::= DOUBLE */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); }
break;
- case 167: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy852 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); }
+ case 168: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); }
break;
- case 168: /* type_name ::= TIMESTAMP */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
+ case 169: /* type_name ::= TIMESTAMP */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
break;
- case 169: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy852 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); }
+ case 170: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); }
break;
- case 170: /* type_name ::= TINYINT UNSIGNED */
-{ yymsp[-1].minor.yy852 = createDataType(TSDB_DATA_TYPE_UTINYINT); }
+ case 171: /* type_name ::= TINYINT UNSIGNED */
+{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); }
break;
- case 171: /* type_name ::= SMALLINT UNSIGNED */
-{ yymsp[-1].minor.yy852 = createDataType(TSDB_DATA_TYPE_USMALLINT); }
+ case 172: /* type_name ::= SMALLINT UNSIGNED */
+{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); }
break;
- case 172: /* type_name ::= INT UNSIGNED */
-{ yymsp[-1].minor.yy852 = createDataType(TSDB_DATA_TYPE_UINT); }
+ case 173: /* type_name ::= INT UNSIGNED */
+{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); }
break;
- case 173: /* type_name ::= BIGINT UNSIGNED */
-{ yymsp[-1].minor.yy852 = createDataType(TSDB_DATA_TYPE_UBIGINT); }
+ case 174: /* type_name ::= BIGINT UNSIGNED */
+{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); }
break;
- case 174: /* type_name ::= JSON */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_JSON); }
+ case 175: /* type_name ::= JSON */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); }
break;
- case 175: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy852 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); }
+ case 176: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); }
break;
- case 176: /* type_name ::= MEDIUMBLOB */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
+ case 177: /* type_name ::= MEDIUMBLOB */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
break;
- case 177: /* type_name ::= BLOB */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_BLOB); }
+ case 178: /* type_name ::= BLOB */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); }
break;
- case 178: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy852 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); }
+ case 179: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); }
break;
- case 179: /* type_name ::= DECIMAL */
-{ yymsp[0].minor.yy852 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 180: /* type_name ::= DECIMAL */
+{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 180: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy852 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
-{ yymsp[-5].minor.yy852 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 182: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+{ yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 183: /* tags_def_opt ::= tags_def */
- case 308: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==308);
- case 421: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==421);
-{ yylhsminor.yy776 = yymsp[0].minor.yy776; }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
+ case 184: /* tags_def_opt ::= tags_def */
+ case 310: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==310);
+ case 425: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==425);
+{ yylhsminor.yy110 = yymsp[0].minor.yy110; }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
break;
- case 184: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */
- case 309: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==309);
-{ yymsp[-3].minor.yy776 = yymsp[-1].minor.yy776; }
+ case 185: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */
+ case 311: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==311);
+{ yymsp[-3].minor.yy110 = yymsp[-1].minor.yy110; }
break;
- case 185: /* table_options ::= */
-{ yymsp[1].minor.yy924 = createDefaultTableOptions(pCxt); }
+ case 186: /* table_options ::= */
+{ yymsp[1].minor.yy42 = createDefaultTableOptions(pCxt); }
break;
- case 186: /* table_options ::= table_options COMMENT NK_STRING */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-2].minor.yy924, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 187: /* table_options ::= table_options COMMENT NK_STRING */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-2].minor.yy42, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 187: /* table_options ::= table_options MAX_DELAY duration_list */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-2].minor.yy924, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy776); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 188: /* table_options ::= table_options MAX_DELAY duration_list */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-2].minor.yy42, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy110); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 188: /* table_options ::= table_options WATERMARK duration_list */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-2].minor.yy924, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy776); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 189: /* table_options ::= table_options WATERMARK duration_list */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-2].minor.yy42, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy110); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 189: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-4].minor.yy924, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy776); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
+ case 190: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-4].minor.yy42, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy110); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
break;
- case 190: /* table_options ::= table_options TTL NK_INTEGER */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-2].minor.yy924, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 191: /* table_options ::= table_options TTL NK_INTEGER */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-2].minor.yy42, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 191: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-4].minor.yy924, TABLE_OPTION_SMA, yymsp[-1].minor.yy776); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
+ case 192: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-4].minor.yy42, TABLE_OPTION_SMA, yymsp[-1].minor.yy110); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
break;
- case 192: /* table_options ::= table_options DELETE_MARK duration_list */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-2].minor.yy924, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy776); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 193: /* table_options ::= table_options DELETE_MARK duration_list */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-2].minor.yy42, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy110); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 193: /* alter_table_options ::= alter_table_option */
-{ yylhsminor.yy924 = createAlterTableOptions(pCxt); yylhsminor.yy924 = setTableOption(pCxt, yylhsminor.yy924, yymsp[0].minor.yy257.type, &yymsp[0].minor.yy257.val); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 194: /* alter_table_options ::= alter_table_option */
+{ yylhsminor.yy42 = createAlterTableOptions(pCxt); yylhsminor.yy42 = setTableOption(pCxt, yylhsminor.yy42, yymsp[0].minor.yy459.type, &yymsp[0].minor.yy459.val); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 194: /* alter_table_options ::= alter_table_options alter_table_option */
-{ yylhsminor.yy924 = setTableOption(pCxt, yymsp[-1].minor.yy924, yymsp[0].minor.yy257.type, &yymsp[0].minor.yy257.val); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 195: /* alter_table_options ::= alter_table_options alter_table_option */
+{ yylhsminor.yy42 = setTableOption(pCxt, yymsp[-1].minor.yy42, yymsp[0].minor.yy459.type, &yymsp[0].minor.yy459.val); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 195: /* alter_table_option ::= COMMENT NK_STRING */
-{ yymsp[-1].minor.yy257.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
+ case 196: /* alter_table_option ::= COMMENT NK_STRING */
+{ yymsp[-1].minor.yy459.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
break;
- case 196: /* alter_table_option ::= TTL NK_INTEGER */
-{ yymsp[-1].minor.yy257.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy257.val = yymsp[0].minor.yy0; }
+ case 197: /* alter_table_option ::= TTL NK_INTEGER */
+{ yymsp[-1].minor.yy459.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy459.val = yymsp[0].minor.yy0; }
break;
- case 197: /* duration_list ::= duration_literal */
- case 385: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==385);
-{ yylhsminor.yy776 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy924)); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
+ case 198: /* duration_list ::= duration_literal */
+ case 389: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==389);
+{ yylhsminor.yy110 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy42)); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
break;
- case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */
- case 386: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==386);
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-2].minor.yy776, releaseRawExprNode(pCxt, yymsp[0].minor.yy924)); }
- yymsp[-2].minor.yy776 = yylhsminor.yy776;
+ case 199: /* duration_list ::= duration_list NK_COMMA duration_literal */
+ case 390: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==390);
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-2].minor.yy110, releaseRawExprNode(pCxt, yymsp[0].minor.yy42)); }
+ yymsp[-2].minor.yy110 = yylhsminor.yy110;
break;
- case 201: /* rollup_func_name ::= function_name */
-{ yylhsminor.yy924 = createFunctionNode(pCxt, &yymsp[0].minor.yy233, NULL); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 202: /* rollup_func_name ::= function_name */
+{ yylhsminor.yy42 = createFunctionNode(pCxt, &yymsp[0].minor.yy225, NULL); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 202: /* rollup_func_name ::= FIRST */
- case 203: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==203);
- case 258: /* tag_item ::= QTAGS */ yytestcase(yyruleno==258);
-{ yylhsminor.yy924 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 203: /* rollup_func_name ::= FIRST */
+ case 204: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==204);
+ case 259: /* tag_item ::= QTAGS */ yytestcase(yyruleno==259);
+{ yylhsminor.yy42 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 206: /* col_name ::= column_name */
- case 259: /* tag_item ::= column_name */ yytestcase(yyruleno==259);
-{ yylhsminor.yy924 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy233); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 207: /* col_name ::= column_name */
+ case 260: /* tag_item ::= column_name */ yytestcase(yyruleno==260);
+{ yylhsminor.yy42 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy225); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 207: /* cmd ::= SHOW DNODES */
+ case 208: /* cmd ::= SHOW DNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); }
break;
- case 208: /* cmd ::= SHOW USERS */
+ case 209: /* cmd ::= SHOW USERS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); }
break;
- case 209: /* cmd ::= SHOW USER PRIVILEGES */
+ case 210: /* cmd ::= SHOW USER PRIVILEGES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); }
break;
- case 210: /* cmd ::= SHOW DATABASES */
+ case 211: /* cmd ::= SHOW DATABASES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
break;
- case 211: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy924, yymsp[0].minor.yy924, OP_TYPE_LIKE); }
+ case 212: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy42, yymsp[0].minor.yy42, OP_TYPE_LIKE); }
break;
- case 212: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy924, yymsp[0].minor.yy924, OP_TYPE_LIKE); }
+ case 213: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy42, yymsp[0].minor.yy42, OP_TYPE_LIKE); }
break;
- case 213: /* cmd ::= SHOW db_name_cond_opt VGROUPS */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy924, NULL, OP_TYPE_LIKE); }
+ case 214: /* cmd ::= SHOW db_name_cond_opt VGROUPS */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy42, NULL, OP_TYPE_LIKE); }
break;
- case 214: /* cmd ::= SHOW MNODES */
+ case 215: /* cmd ::= SHOW MNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); }
break;
- case 215: /* cmd ::= SHOW QNODES */
+ case 216: /* cmd ::= SHOW QNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); }
break;
- case 216: /* cmd ::= SHOW FUNCTIONS */
+ case 217: /* cmd ::= SHOW FUNCTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); }
break;
- case 217: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy924, yymsp[-1].minor.yy924, OP_TYPE_EQUAL); }
+ case 218: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy42, yymsp[-1].minor.yy42, OP_TYPE_EQUAL); }
break;
- case 218: /* cmd ::= SHOW STREAMS */
+ case 219: /* cmd ::= SHOW STREAMS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); }
break;
- case 219: /* cmd ::= SHOW ACCOUNTS */
+ case 220: /* cmd ::= SHOW ACCOUNTS */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
break;
- case 220: /* cmd ::= SHOW APPS */
+ case 221: /* cmd ::= SHOW APPS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); }
break;
- case 221: /* cmd ::= SHOW CONNECTIONS */
+ case 222: /* cmd ::= SHOW CONNECTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
break;
- case 222: /* cmd ::= SHOW LICENCES */
- case 223: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==223);
+ case 223: /* cmd ::= SHOW LICENCES */
+ case 224: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==224);
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
break;
- case 224: /* cmd ::= SHOW CREATE DATABASE db_name */
-{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy233); }
+ case 225: /* cmd ::= SHOW CREATE DATABASE db_name */
+{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy225); }
break;
- case 225: /* cmd ::= SHOW CREATE TABLE full_table_name */
-{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy924); }
+ case 226: /* cmd ::= SHOW CREATE TABLE full_table_name */
+{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy42); }
break;
- case 226: /* cmd ::= SHOW CREATE STABLE full_table_name */
-{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy924); }
+ case 227: /* cmd ::= SHOW CREATE STABLE full_table_name */
+{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy42); }
break;
- case 227: /* cmd ::= SHOW QUERIES */
+ case 228: /* cmd ::= SHOW QUERIES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
break;
- case 228: /* cmd ::= SHOW SCORES */
+ case 229: /* cmd ::= SHOW SCORES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
break;
- case 229: /* cmd ::= SHOW TOPICS */
+ case 230: /* cmd ::= SHOW TOPICS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
break;
- case 230: /* cmd ::= SHOW VARIABLES */
- case 231: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==231);
+ case 231: /* cmd ::= SHOW VARIABLES */
+ case 232: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==232);
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); }
break;
- case 232: /* cmd ::= SHOW LOCAL VARIABLES */
+ case 233: /* cmd ::= SHOW LOCAL VARIABLES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); }
break;
- case 233: /* 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.yy924); }
+ case 234: /* 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.yy42); }
break;
- case 234: /* cmd ::= SHOW BNODES */
+ case 235: /* cmd ::= SHOW BNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); }
break;
- case 235: /* cmd ::= SHOW SNODES */
+ case 236: /* cmd ::= SHOW SNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); }
break;
- case 236: /* cmd ::= SHOW CLUSTER */
+ case 237: /* cmd ::= SHOW CLUSTER */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
break;
- case 237: /* cmd ::= SHOW TRANSACTIONS */
+ case 238: /* cmd ::= SHOW TRANSACTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
break;
- case 238: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
-{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy924); }
+ case 239: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
+{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy42); }
break;
- case 239: /* cmd ::= SHOW CONSUMERS */
+ case 240: /* cmd ::= SHOW CONSUMERS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
break;
- case 240: /* cmd ::= SHOW SUBSCRIPTIONS */
+ case 241: /* cmd ::= SHOW SUBSCRIPTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
break;
- case 241: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy924, yymsp[-1].minor.yy924, OP_TYPE_EQUAL); }
+ case 242: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy42, yymsp[-1].minor.yy42, OP_TYPE_EQUAL); }
break;
- case 242: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */
-{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy924, yymsp[0].minor.yy924, yymsp[-3].minor.yy776); }
+ case 243: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */
+{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy42, yymsp[0].minor.yy42, yymsp[-3].minor.yy110); }
break;
- case 243: /* cmd ::= SHOW VNODES NK_INTEGER */
+ case 244: /* cmd ::= SHOW VNODES NK_INTEGER */
{ pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); }
break;
- case 244: /* cmd ::= SHOW VNODES NK_STRING */
+ case 245: /* cmd ::= SHOW VNODES NK_STRING */
{ pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); }
break;
- case 245: /* cmd ::= SHOW db_name_cond_opt ALIVE */
-{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy924, QUERY_NODE_SHOW_DB_ALIVE_STMT); }
+ case 246: /* cmd ::= SHOW db_name_cond_opt ALIVE */
+{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy42, QUERY_NODE_SHOW_DB_ALIVE_STMT); }
break;
- case 246: /* cmd ::= SHOW CLUSTER ALIVE */
+ case 247: /* cmd ::= SHOW CLUSTER ALIVE */
{ pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); }
break;
- case 247: /* db_name_cond_opt ::= */
- case 252: /* from_db_opt ::= */ yytestcase(yyruleno==252);
-{ yymsp[1].minor.yy924 = createDefaultDatabaseCondValue(pCxt); }
+ case 248: /* db_name_cond_opt ::= */
+ case 253: /* from_db_opt ::= */ yytestcase(yyruleno==253);
+{ yymsp[1].minor.yy42 = createDefaultDatabaseCondValue(pCxt); }
break;
- case 248: /* db_name_cond_opt ::= db_name NK_DOT */
-{ yylhsminor.yy924 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy233); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 249: /* db_name_cond_opt ::= db_name NK_DOT */
+{ yylhsminor.yy42 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy225); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 249: /* like_pattern_opt ::= */
- case 317: /* subtable_opt ::= */ yytestcase(yyruleno==317);
- case 431: /* case_when_else_opt ::= */ yytestcase(yyruleno==431);
- case 461: /* from_clause_opt ::= */ yytestcase(yyruleno==461);
- case 490: /* where_clause_opt ::= */ yytestcase(yyruleno==490);
- case 499: /* twindow_clause_opt ::= */ yytestcase(yyruleno==499);
- case 505: /* sliding_opt ::= */ yytestcase(yyruleno==505);
- case 507: /* fill_opt ::= */ yytestcase(yyruleno==507);
- case 519: /* having_clause_opt ::= */ yytestcase(yyruleno==519);
- case 521: /* range_opt ::= */ yytestcase(yyruleno==521);
- case 523: /* every_opt ::= */ yytestcase(yyruleno==523);
- case 536: /* slimit_clause_opt ::= */ yytestcase(yyruleno==536);
- case 540: /* limit_clause_opt ::= */ yytestcase(yyruleno==540);
-{ yymsp[1].minor.yy924 = NULL; }
+ case 250: /* like_pattern_opt ::= */
+ case 320: /* subtable_opt ::= */ yytestcase(yyruleno==320);
+ case 435: /* case_when_else_opt ::= */ yytestcase(yyruleno==435);
+ case 465: /* from_clause_opt ::= */ yytestcase(yyruleno==465);
+ case 494: /* where_clause_opt ::= */ yytestcase(yyruleno==494);
+ case 503: /* twindow_clause_opt ::= */ yytestcase(yyruleno==503);
+ case 509: /* sliding_opt ::= */ yytestcase(yyruleno==509);
+ case 511: /* fill_opt ::= */ yytestcase(yyruleno==511);
+ case 525: /* having_clause_opt ::= */ yytestcase(yyruleno==525);
+ case 527: /* range_opt ::= */ yytestcase(yyruleno==527);
+ case 529: /* every_opt ::= */ yytestcase(yyruleno==529);
+ case 542: /* slimit_clause_opt ::= */ yytestcase(yyruleno==542);
+ case 546: /* limit_clause_opt ::= */ yytestcase(yyruleno==546);
+{ yymsp[1].minor.yy42 = NULL; }
break;
- case 250: /* like_pattern_opt ::= LIKE NK_STRING */
-{ yymsp[-1].minor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
+ case 251: /* like_pattern_opt ::= LIKE NK_STRING */
+{ yymsp[-1].minor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
break;
- case 251: /* table_name_cond ::= table_name */
-{ yylhsminor.yy924 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy233); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 252: /* table_name_cond ::= table_name */
+{ yylhsminor.yy42 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy225); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 253: /* from_db_opt ::= FROM db_name */
-{ yymsp[-1].minor.yy924 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy233); }
+ case 254: /* from_db_opt ::= FROM db_name */
+{ yymsp[-1].minor.yy42 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy225); }
break;
- case 257: /* tag_item ::= TBNAME */
-{ yylhsminor.yy924 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 258: /* tag_item ::= TBNAME */
+{ yylhsminor.yy42 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 260: /* tag_item ::= column_name column_alias */
-{ yylhsminor.yy924 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy233), &yymsp[0].minor.yy233); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 261: /* tag_item ::= column_name column_alias */
+{ yylhsminor.yy42 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy225), &yymsp[0].minor.yy225); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 261: /* tag_item ::= column_name AS column_alias */
-{ yylhsminor.yy924 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy233), &yymsp[0].minor.yy233); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 262: /* tag_item ::= column_name AS column_alias */
+{ yylhsminor.yy42 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy225), &yymsp[0].minor.yy225); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 262: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */
-{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy397, yymsp[-3].minor.yy924, yymsp[-1].minor.yy924, NULL, yymsp[0].minor.yy924); }
+ case 263: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */
+{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy103, yymsp[-3].minor.yy42, yymsp[-1].minor.yy42, NULL, yymsp[0].minor.yy42); }
break;
- case 263: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */
-{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy397, yymsp[-5].minor.yy924, yymsp[-3].minor.yy924, yymsp[-1].minor.yy776, NULL); }
+ case 264: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */
+{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy103, yymsp[-5].minor.yy42, yymsp[-3].minor.yy42, yymsp[-1].minor.yy110, NULL); }
break;
- case 264: /* cmd ::= DROP INDEX exists_opt full_index_name */
-{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy397, yymsp[0].minor.yy924); }
+ case 265: /* cmd ::= DROP INDEX exists_opt full_index_name */
+{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy103, yymsp[0].minor.yy42); }
break;
- case 265: /* full_index_name ::= index_name */
-{ yylhsminor.yy924 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy233); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 266: /* full_index_name ::= index_name */
+{ yylhsminor.yy42 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy225); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 266: /* full_index_name ::= db_name NK_DOT index_name */
-{ yylhsminor.yy924 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 267: /* full_index_name ::= db_name NK_DOT index_name */
+{ yylhsminor.yy42 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 267: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
-{ yymsp[-9].minor.yy924 = createIndexOption(pCxt, yymsp[-7].minor.yy776, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), NULL, yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
+ case 268: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
+{ yymsp[-9].minor.yy42 = createIndexOption(pCxt, yymsp[-7].minor.yy110, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), NULL, yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
break;
- case 268: /* 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.yy924 = createIndexOption(pCxt, yymsp[-9].minor.yy776, releaseRawExprNode(pCxt, yymsp[-5].minor.yy924), releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
+ case 269: /* 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.yy42 = createIndexOption(pCxt, yymsp[-9].minor.yy110, releaseRawExprNode(pCxt, yymsp[-5].minor.yy42), releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
break;
- case 271: /* func ::= sma_func_name NK_LP expression_list NK_RP */
-{ yylhsminor.yy924 = createFunctionNode(pCxt, &yymsp[-3].minor.yy233, yymsp[-1].minor.yy776); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 272: /* func ::= sma_func_name NK_LP expression_list NK_RP */
+{ yylhsminor.yy42 = createFunctionNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-1].minor.yy110); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 277: /* sma_stream_opt ::= */
- case 310: /* stream_options ::= */ yytestcase(yyruleno==310);
-{ yymsp[1].minor.yy924 = createStreamOptions(pCxt); }
+ case 278: /* sma_stream_opt ::= */
+ case 312: /* stream_options ::= */ yytestcase(yyruleno==312);
+{ yymsp[1].minor.yy42 = createStreamOptions(pCxt); }
break;
- case 278: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */
- case 314: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==314);
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 279: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */
+ case 316: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==316);
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 279: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 280: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 280: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 281: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 281: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */
-{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy397, &yymsp[-2].minor.yy233, yymsp[0].minor.yy924); }
+ case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */
+{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy103, &yymsp[-2].minor.yy225, yymsp[0].minor.yy42); }
break;
- case 282: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy397, &yymsp[-3].minor.yy233, &yymsp[0].minor.yy233, false); }
+ case 283: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy103, &yymsp[-3].minor.yy225, &yymsp[0].minor.yy225, false); }
break;
- case 283: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy397, &yymsp[-5].minor.yy233, &yymsp[0].minor.yy233, true); }
+ case 284: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy103, &yymsp[-5].minor.yy225, &yymsp[0].minor.yy225, true); }
break;
- case 284: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy397, &yymsp[-3].minor.yy233, yymsp[0].minor.yy924, false); }
+ case 285: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy103, &yymsp[-3].minor.yy225, yymsp[0].minor.yy42, false); }
break;
- case 285: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy397, &yymsp[-5].minor.yy233, yymsp[0].minor.yy924, true); }
+ case 286: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy103, &yymsp[-5].minor.yy225, yymsp[0].minor.yy42, true); }
break;
- case 286: /* cmd ::= DROP TOPIC exists_opt topic_name */
-{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy233); }
+ case 287: /* cmd ::= DROP TOPIC exists_opt topic_name */
+{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy103, &yymsp[0].minor.yy225); }
break;
- case 287: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
-{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy397, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233); }
+ case 288: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
+{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy103, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225); }
break;
- case 288: /* cmd ::= DESC full_table_name */
- case 289: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==289);
-{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy924); }
+ case 289: /* cmd ::= DESC full_table_name */
+ case 290: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==290);
+{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy42); }
break;
- case 290: /* cmd ::= RESET QUERY CACHE */
+ case 291: /* cmd ::= RESET QUERY CACHE */
{ pCxt->pRootNode = createResetQueryCacheStmt(pCxt); }
break;
- case 291: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */
-{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy397, yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
+ case 292: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */
+ case 293: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==293);
+{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy103, yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
+ break;
+ case 296: /* explain_options ::= */
+{ yymsp[1].minor.yy42 = createDefaultExplainOptions(pCxt); }
break;
- case 294: /* explain_options ::= */
-{ yymsp[1].minor.yy924 = createDefaultExplainOptions(pCxt); }
+ case 297: /* explain_options ::= explain_options VERBOSE NK_BOOL */
+{ yylhsminor.yy42 = setExplainVerbose(pCxt, yymsp[-2].minor.yy42, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 295: /* explain_options ::= explain_options VERBOSE NK_BOOL */
-{ yylhsminor.yy924 = setExplainVerbose(pCxt, yymsp[-2].minor.yy924, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 298: /* explain_options ::= explain_options RATIO NK_FLOAT */
+{ yylhsminor.yy42 = setExplainRatio(pCxt, yymsp[-2].minor.yy42, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 296: /* explain_options ::= explain_options RATIO NK_FLOAT */
-{ yylhsminor.yy924 = setExplainRatio(pCxt, yymsp[-2].minor.yy924, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 299: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
+{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy103, yymsp[-8].minor.yy103, &yymsp[-5].minor.yy225, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy448, yymsp[0].minor.yy508); }
break;
- case 297: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
-{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy397, yymsp[-8].minor.yy397, &yymsp[-5].minor.yy233, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy852, yymsp[0].minor.yy832); }
+ case 300: /* cmd ::= DROP FUNCTION exists_opt function_name */
+{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy103, &yymsp[0].minor.yy225); }
break;
- case 298: /* cmd ::= DROP FUNCTION exists_opt function_name */
-{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy233); }
+ case 305: /* 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.yy103, &yymsp[-8].minor.yy225, yymsp[-5].minor.yy42, yymsp[-7].minor.yy42, yymsp[-3].minor.yy110, yymsp[-2].minor.yy42, yymsp[0].minor.yy42, yymsp[-4].minor.yy110); }
break;
- case 303: /* 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.yy397, &yymsp[-8].minor.yy233, yymsp[-5].minor.yy924, yymsp[-7].minor.yy924, yymsp[-3].minor.yy776, yymsp[-2].minor.yy924, yymsp[0].minor.yy924, yymsp[-4].minor.yy776); }
+ case 306: /* cmd ::= DROP STREAM exists_opt stream_name */
+{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy103, &yymsp[0].minor.yy225); }
break;
- case 304: /* cmd ::= DROP STREAM exists_opt stream_name */
-{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy397, &yymsp[0].minor.yy233); }
+ case 313: /* stream_options ::= stream_options TRIGGER AT_ONCE */
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 311: /* stream_options ::= stream_options TRIGGER AT_ONCE */
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 314: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 312: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 315: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
+{ ((SStreamOptions*)yymsp[-3].minor.yy42)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy42)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); yylhsminor.yy42 = yymsp[-3].minor.yy42; }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 313: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
-{ ((SStreamOptions*)yymsp[-3].minor.yy924)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy924)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); yylhsminor.yy924 = yymsp[-3].minor.yy924; }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 317: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
+{ ((SStreamOptions*)yymsp[-3].minor.yy42)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy42 = yymsp[-3].minor.yy42; }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 315: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
-{ ((SStreamOptions*)yymsp[-3].minor.yy924)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy924 = yymsp[-3].minor.yy924; }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 318: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */
+{ ((SStreamOptions*)yymsp[-2].minor.yy42)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy42 = yymsp[-2].minor.yy42; }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 316: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */
-{ ((SStreamOptions*)yymsp[-2].minor.yy924)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy924 = yymsp[-2].minor.yy924; }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 319: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */
+{ ((SStreamOptions*)yymsp[-3].minor.yy42)->ignoreUpdate = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy42 = yymsp[-3].minor.yy42; }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 318: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */
- case 506: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==506);
- case 524: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==524);
-{ yymsp[-3].minor.yy924 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy924); }
+ case 321: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */
+ case 510: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==510);
+ case 530: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==530);
+{ yymsp[-3].minor.yy42 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy42); }
break;
- case 319: /* cmd ::= KILL CONNECTION NK_INTEGER */
+ case 322: /* cmd ::= KILL CONNECTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); }
break;
- case 320: /* cmd ::= KILL QUERY NK_STRING */
+ case 323: /* cmd ::= KILL QUERY NK_STRING */
{ pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); }
break;
- case 321: /* cmd ::= KILL TRANSACTION NK_INTEGER */
+ case 324: /* cmd ::= KILL TRANSACTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); }
break;
- case 322: /* cmd ::= BALANCE VGROUP */
+ case 325: /* cmd ::= BALANCE VGROUP */
{ pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
break;
- case 323: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
+ case 326: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
{ pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
- case 324: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
-{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy776); }
+ case 327: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
+{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy110); }
break;
- case 325: /* cmd ::= SPLIT VGROUP NK_INTEGER */
+ case 328: /* cmd ::= SPLIT VGROUP NK_INTEGER */
{ pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); }
break;
- case 326: /* dnode_list ::= DNODE NK_INTEGER */
-{ yymsp[-1].minor.yy776 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- break;
- case 328: /* cmd ::= DELETE FROM full_table_name where_clause_opt */
-{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
- break;
- case 330: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */
-{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy924, yymsp[-2].minor.yy776, yymsp[0].minor.yy924); }
- break;
- case 331: /* cmd ::= INSERT INTO full_table_name query_or_subquery */
-{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy924, NULL, yymsp[0].minor.yy924); }
- break;
- case 332: /* literal ::= NK_INTEGER */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 333: /* literal ::= NK_FLOAT */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 334: /* literal ::= NK_STRING */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 335: /* literal ::= NK_BOOL */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 336: /* literal ::= TIMESTAMP NK_STRING */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
- break;
- case 337: /* literal ::= duration_literal */
- case 347: /* signed_literal ::= signed */ yytestcase(yyruleno==347);
- case 368: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==368);
- case 369: /* expression ::= literal */ yytestcase(yyruleno==369);
- case 370: /* expression ::= pseudo_column */ yytestcase(yyruleno==370);
- case 371: /* expression ::= column_reference */ yytestcase(yyruleno==371);
- case 372: /* expression ::= function_expression */ yytestcase(yyruleno==372);
- case 373: /* expression ::= case_when_expression */ yytestcase(yyruleno==373);
- case 404: /* function_expression ::= literal_func */ yytestcase(yyruleno==404);
- case 453: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==453);
- case 457: /* boolean_primary ::= predicate */ yytestcase(yyruleno==457);
- case 459: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==459);
- case 460: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==460);
- case 463: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==463);
- case 465: /* table_reference ::= table_primary */ yytestcase(yyruleno==465);
- case 466: /* table_reference ::= joined_table */ yytestcase(yyruleno==466);
- case 470: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==470);
- case 526: /* query_simple ::= query_specification */ yytestcase(yyruleno==526);
- case 527: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==527);
- case 530: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==530);
- case 532: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==532);
-{ yylhsminor.yy924 = yymsp[0].minor.yy924; }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 338: /* literal ::= NULL */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 339: /* literal ::= NK_QUESTION */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 340: /* duration_literal ::= NK_VARIABLE */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 341: /* signed ::= NK_INTEGER */
-{ yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 342: /* signed ::= NK_PLUS NK_INTEGER */
-{ yymsp[-1].minor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
- break;
- case 343: /* signed ::= NK_MINUS NK_INTEGER */
+ case 329: /* dnode_list ::= DNODE NK_INTEGER */
+{ yymsp[-1].minor.yy110 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ break;
+ case 331: /* cmd ::= DELETE FROM full_table_name where_clause_opt */
+{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
+ break;
+ case 334: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */
+{ yymsp[-6].minor.yy42 = createInsertStmt(pCxt, yymsp[-4].minor.yy42, yymsp[-2].minor.yy110, yymsp[0].minor.yy42); }
+ break;
+ case 335: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */
+{ yymsp[-3].minor.yy42 = createInsertStmt(pCxt, yymsp[-1].minor.yy42, NULL, yymsp[0].minor.yy42); }
+ break;
+ case 336: /* literal ::= NK_INTEGER */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 337: /* literal ::= NK_FLOAT */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 338: /* literal ::= NK_STRING */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 339: /* literal ::= NK_BOOL */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 340: /* literal ::= TIMESTAMP NK_STRING */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 341: /* literal ::= duration_literal */
+ case 351: /* signed_literal ::= signed */ yytestcase(yyruleno==351);
+ case 372: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==372);
+ case 373: /* expression ::= literal */ yytestcase(yyruleno==373);
+ case 374: /* expression ::= pseudo_column */ yytestcase(yyruleno==374);
+ case 375: /* expression ::= column_reference */ yytestcase(yyruleno==375);
+ case 376: /* expression ::= function_expression */ yytestcase(yyruleno==376);
+ case 377: /* expression ::= case_when_expression */ yytestcase(yyruleno==377);
+ case 408: /* function_expression ::= literal_func */ yytestcase(yyruleno==408);
+ case 457: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==457);
+ case 461: /* boolean_primary ::= predicate */ yytestcase(yyruleno==461);
+ case 463: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==463);
+ case 464: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==464);
+ case 467: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==467);
+ case 469: /* table_reference ::= table_primary */ yytestcase(yyruleno==469);
+ case 470: /* table_reference ::= joined_table */ yytestcase(yyruleno==470);
+ case 474: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==474);
+ case 532: /* query_simple ::= query_specification */ yytestcase(yyruleno==532);
+ case 533: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==533);
+ case 536: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==536);
+ case 538: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==538);
+{ yylhsminor.yy42 = yymsp[0].minor.yy42; }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 342: /* literal ::= NULL */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 343: /* literal ::= NK_QUESTION */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 344: /* duration_literal ::= NK_VARIABLE */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 345: /* signed ::= NK_INTEGER */
+{ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 346: /* signed ::= NK_PLUS NK_INTEGER */
+{ yymsp[-1].minor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
+ break;
+ case 347: /* signed ::= NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t);
+ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t);
}
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 344: /* signed ::= NK_FLOAT */
-{ yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 348: /* signed ::= NK_FLOAT */
+{ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
break;
- case 345: /* signed ::= NK_PLUS NK_FLOAT */
-{ yymsp[-1].minor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
+ case 349: /* signed ::= NK_PLUS NK_FLOAT */
+{ yymsp[-1].minor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
break;
- case 346: /* signed ::= NK_MINUS NK_FLOAT */
+ case 350: /* signed ::= NK_MINUS NK_FLOAT */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t);
+ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t);
}
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
- break;
- case 348: /* signed_literal ::= NK_STRING */
-{ yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 349: /* signed_literal ::= NK_BOOL */
-{ yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 350: /* signed_literal ::= TIMESTAMP NK_STRING */
-{ yymsp[-1].minor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
- break;
- case 351: /* signed_literal ::= duration_literal */
- case 353: /* signed_literal ::= literal_func */ yytestcase(yyruleno==353);
- case 424: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==424);
- case 486: /* select_item ::= common_expression */ yytestcase(yyruleno==486);
- case 496: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==496);
- case 531: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==531);
- case 533: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==533);
- case 546: /* search_condition ::= common_expression */ yytestcase(yyruleno==546);
-{ yylhsminor.yy924 = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 352: /* signed_literal ::= NULL */
-{ yylhsminor.yy924 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 354: /* signed_literal ::= NK_QUESTION */
-{ yylhsminor.yy924 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 374: /* expression ::= NK_LP expression NK_RP */
- case 458: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==458);
- case 545: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==545);
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy924)); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 375: /* expression ::= NK_PLUS expr_or_subquery */
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 352: /* signed_literal ::= NK_STRING */
+{ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 353: /* signed_literal ::= NK_BOOL */
+{ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 354: /* signed_literal ::= TIMESTAMP NK_STRING */
+{ yymsp[-1].minor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
+ break;
+ case 355: /* signed_literal ::= duration_literal */
+ case 357: /* signed_literal ::= literal_func */ yytestcase(yyruleno==357);
+ case 428: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==428);
+ case 490: /* select_item ::= common_expression */ yytestcase(yyruleno==490);
+ case 500: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==500);
+ case 537: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==537);
+ case 539: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==539);
+ case 552: /* search_condition ::= common_expression */ yytestcase(yyruleno==552);
+{ yylhsminor.yy42 = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 356: /* signed_literal ::= NULL */
+{ yylhsminor.yy42 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 358: /* signed_literal ::= NK_QUESTION */
+{ yylhsminor.yy42 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 378: /* expression ::= NK_LP expression NK_RP */
+ case 462: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==462);
+ case 551: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==551);
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy42)); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 379: /* expression ::= NK_PLUS expr_or_subquery */
{
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy924));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy42));
}
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 376: /* expression ::= NK_MINUS expr_or_subquery */
+ case 380: /* expression ::= NK_MINUS expr_or_subquery */
{
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy924), NULL));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy42), NULL));
}
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 377: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */
+ case 381: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 378: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */
+ case 382: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 379: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */
+ case 383: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 380: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */
+ case 384: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 381: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */
+ case 385: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 382: /* expression ::= column_reference NK_ARROW NK_STRING */
+ case 386: /* expression ::= column_reference NK_ARROW NK_STRING */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 383: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */
+ case 387: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 384: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */
+ case 388: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 387: /* column_reference ::= column_name */
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy233, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy233)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 388: /* column_reference ::= table_name NK_DOT column_name */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233, createColumnNode(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy233)); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 389: /* pseudo_column ::= ROWTS */
- case 390: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==390);
- case 392: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==392);
- case 393: /* pseudo_column ::= QEND */ yytestcase(yyruleno==393);
- case 394: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==394);
- case 395: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==395);
- case 396: /* pseudo_column ::= WEND */ yytestcase(yyruleno==396);
- case 397: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==397);
- case 398: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==398);
- case 399: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==399);
- case 400: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==400);
- case 406: /* literal_func ::= NOW */ yytestcase(yyruleno==406);
-{ yylhsminor.yy924 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
- break;
- case 391: /* pseudo_column ::= table_name NK_DOT TBNAME */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy233)))); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 401: /* function_expression ::= function_name NK_LP expression_list NK_RP */
- case 402: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==402);
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy233, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy233, yymsp[-1].minor.yy776)); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
- break;
- case 403: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), yymsp[-1].minor.yy852)); }
- yymsp[-5].minor.yy924 = yylhsminor.yy924;
- break;
- case 405: /* literal_func ::= noarg_func NK_LP NK_RP */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy233, NULL)); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 420: /* star_func_para_list ::= NK_STAR */
-{ yylhsminor.yy776 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
- break;
- case 425: /* star_func_para ::= table_name NK_DOT NK_STAR */
- case 489: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==489);
-{ yylhsminor.yy924 = createColumnNode(pCxt, &yymsp[-2].minor.yy233, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
- break;
- case 426: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy776, yymsp[-1].minor.yy924)); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
- break;
- case 427: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), yymsp[-2].minor.yy776, yymsp[-1].minor.yy924)); }
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
- break;
- case 430: /* when_then_expr ::= WHEN common_expression THEN common_expression */
-{ yymsp[-3].minor.yy924 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)); }
- break;
- case 432: /* case_when_else_opt ::= ELSE common_expression */
-{ yymsp[-1].minor.yy924 = releaseRawExprNode(pCxt, yymsp[0].minor.yy924); }
- break;
- case 433: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */
- case 438: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==438);
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 391: /* column_reference ::= column_name */
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy225, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy225)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 392: /* column_reference ::= table_name NK_DOT column_name */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225, createColumnNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy225)); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 393: /* pseudo_column ::= ROWTS */
+ case 394: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==394);
+ case 396: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==396);
+ case 397: /* pseudo_column ::= QEND */ yytestcase(yyruleno==397);
+ case 398: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==398);
+ case 399: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==399);
+ case 400: /* pseudo_column ::= WEND */ yytestcase(yyruleno==400);
+ case 401: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==401);
+ case 402: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==402);
+ case 403: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==403);
+ case 404: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==404);
+ case 410: /* literal_func ::= NOW */ yytestcase(yyruleno==410);
+{ yylhsminor.yy42 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 395: /* pseudo_column ::= table_name NK_DOT TBNAME */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy225)))); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 405: /* function_expression ::= function_name NK_LP expression_list NK_RP */
+ case 406: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==406);
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy225, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy225, yymsp[-1].minor.yy110)); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 407: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), yymsp[-1].minor.yy448)); }
+ yymsp[-5].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 409: /* literal_func ::= noarg_func NK_LP NK_RP */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy225, NULL)); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 424: /* star_func_para_list ::= NK_STAR */
+{ yylhsminor.yy110 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
+ break;
+ case 429: /* star_func_para ::= table_name NK_DOT NK_STAR */
+ case 493: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==493);
+{ yylhsminor.yy42 = createColumnNode(pCxt, &yymsp[-2].minor.yy225, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 430: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy110, yymsp[-1].minor.yy42)); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 431: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), yymsp[-2].minor.yy110, yymsp[-1].minor.yy42)); }
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 434: /* when_then_expr ::= WHEN common_expression THEN common_expression */
+{ yymsp[-3].minor.yy42 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)); }
+ break;
+ case 436: /* case_when_else_opt ::= ELSE common_expression */
+{ yymsp[-1].minor.yy42 = releaseRawExprNode(pCxt, yymsp[0].minor.yy42); }
+ break;
+ case 437: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */
+ case 442: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==442);
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy856, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy2, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 434: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */
+ case 438: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy924), releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy42), releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-4].minor.yy924 = yylhsminor.yy924;
+ yymsp[-4].minor.yy42 = yylhsminor.yy42;
break;
- case 435: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */
+ case 439: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy924), releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy42), releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-5].minor.yy924 = yylhsminor.yy924;
+ yymsp[-5].minor.yy42 = yylhsminor.yy42;
break;
- case 436: /* predicate ::= expr_or_subquery IS NULL */
+ case 440: /* predicate ::= expr_or_subquery IS NULL */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), NULL));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 437: /* predicate ::= expr_or_subquery IS NOT NULL */
+ case 441: /* predicate ::= expr_or_subquery IS NOT NULL */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), NULL));
}
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 439: /* compare_op ::= NK_LT */
-{ yymsp[0].minor.yy856 = OP_TYPE_LOWER_THAN; }
+ case 443: /* compare_op ::= NK_LT */
+{ yymsp[0].minor.yy2 = OP_TYPE_LOWER_THAN; }
break;
- case 440: /* compare_op ::= NK_GT */
-{ yymsp[0].minor.yy856 = OP_TYPE_GREATER_THAN; }
+ case 444: /* compare_op ::= NK_GT */
+{ yymsp[0].minor.yy2 = OP_TYPE_GREATER_THAN; }
break;
- case 441: /* compare_op ::= NK_LE */
-{ yymsp[0].minor.yy856 = OP_TYPE_LOWER_EQUAL; }
+ case 445: /* compare_op ::= NK_LE */
+{ yymsp[0].minor.yy2 = OP_TYPE_LOWER_EQUAL; }
break;
- case 442: /* compare_op ::= NK_GE */
-{ yymsp[0].minor.yy856 = OP_TYPE_GREATER_EQUAL; }
+ case 446: /* compare_op ::= NK_GE */
+{ yymsp[0].minor.yy2 = OP_TYPE_GREATER_EQUAL; }
break;
- case 443: /* compare_op ::= NK_NE */
-{ yymsp[0].minor.yy856 = OP_TYPE_NOT_EQUAL; }
+ case 447: /* compare_op ::= NK_NE */
+{ yymsp[0].minor.yy2 = OP_TYPE_NOT_EQUAL; }
break;
- case 444: /* compare_op ::= NK_EQ */
-{ yymsp[0].minor.yy856 = OP_TYPE_EQUAL; }
+ case 448: /* compare_op ::= NK_EQ */
+{ yymsp[0].minor.yy2 = OP_TYPE_EQUAL; }
break;
- case 445: /* compare_op ::= LIKE */
-{ yymsp[0].minor.yy856 = OP_TYPE_LIKE; }
+ case 449: /* compare_op ::= LIKE */
+{ yymsp[0].minor.yy2 = OP_TYPE_LIKE; }
break;
- case 446: /* compare_op ::= NOT LIKE */
-{ yymsp[-1].minor.yy856 = OP_TYPE_NOT_LIKE; }
+ case 450: /* compare_op ::= NOT LIKE */
+{ yymsp[-1].minor.yy2 = OP_TYPE_NOT_LIKE; }
break;
- case 447: /* compare_op ::= MATCH */
-{ yymsp[0].minor.yy856 = OP_TYPE_MATCH; }
+ case 451: /* compare_op ::= MATCH */
+{ yymsp[0].minor.yy2 = OP_TYPE_MATCH; }
break;
- case 448: /* compare_op ::= NMATCH */
-{ yymsp[0].minor.yy856 = OP_TYPE_NMATCH; }
+ case 452: /* compare_op ::= NMATCH */
+{ yymsp[0].minor.yy2 = OP_TYPE_NMATCH; }
break;
- case 449: /* compare_op ::= CONTAINS */
-{ yymsp[0].minor.yy856 = OP_TYPE_JSON_CONTAINS; }
+ case 453: /* compare_op ::= CONTAINS */
+{ yymsp[0].minor.yy2 = OP_TYPE_JSON_CONTAINS; }
break;
- case 450: /* in_op ::= IN */
-{ yymsp[0].minor.yy856 = OP_TYPE_IN; }
+ case 454: /* in_op ::= IN */
+{ yymsp[0].minor.yy2 = OP_TYPE_IN; }
break;
- case 451: /* in_op ::= NOT IN */
-{ yymsp[-1].minor.yy856 = OP_TYPE_NOT_IN; }
+ case 455: /* in_op ::= NOT IN */
+{ yymsp[-1].minor.yy2 = OP_TYPE_NOT_IN; }
break;
- case 452: /* in_predicate_value ::= NK_LP literal_list NK_RP */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy776)); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 456: /* in_predicate_value ::= NK_LP literal_list NK_RP */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy110)); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 454: /* boolean_value_expression ::= NOT boolean_primary */
+ case 458: /* boolean_value_expression ::= NOT boolean_primary */
{
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy924), NULL));
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy42), NULL));
}
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 455: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ case 459: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 456: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ case 460: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy924);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy924);
- yylhsminor.yy924 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), releaseRawExprNode(pCxt, yymsp[0].minor.yy924)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy42);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy42);
+ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), releaseRawExprNode(pCxt, yymsp[0].minor.yy42)));
}
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 462: /* from_clause_opt ::= FROM table_reference_list */
- case 491: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==491);
- case 520: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==520);
-{ yymsp[-1].minor.yy924 = yymsp[0].minor.yy924; }
+ case 466: /* from_clause_opt ::= FROM table_reference_list */
+ case 495: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==495);
+ case 526: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==526);
+{ yymsp[-1].minor.yy42 = yymsp[0].minor.yy42; }
break;
- case 464: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
-{ yylhsminor.yy924 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy924, yymsp[0].minor.yy924, NULL); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 468: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
+{ yylhsminor.yy42 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy42, yymsp[0].minor.yy42, NULL); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 467: /* table_primary ::= table_name alias_opt */
-{ yylhsminor.yy924 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy233, &yymsp[0].minor.yy233); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 471: /* table_primary ::= table_name alias_opt */
+{ yylhsminor.yy42 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 468: /* table_primary ::= db_name NK_DOT table_name alias_opt */
-{ yylhsminor.yy924 = createRealTableNode(pCxt, &yymsp[-3].minor.yy233, &yymsp[-1].minor.yy233, &yymsp[0].minor.yy233); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 472: /* table_primary ::= db_name NK_DOT table_name alias_opt */
+{ yylhsminor.yy42 = createRealTableNode(pCxt, &yymsp[-3].minor.yy225, &yymsp[-1].minor.yy225, &yymsp[0].minor.yy225); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 469: /* table_primary ::= subquery alias_opt */
-{ yylhsminor.yy924 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy924), &yymsp[0].minor.yy233); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 473: /* table_primary ::= subquery alias_opt */
+{ yylhsminor.yy42 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy42), &yymsp[0].minor.yy225); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 471: /* alias_opt ::= */
-{ yymsp[1].minor.yy233 = nil_token; }
+ case 475: /* alias_opt ::= */
+{ yymsp[1].minor.yy225 = nil_token; }
break;
- case 473: /* alias_opt ::= AS table_alias */
-{ yymsp[-1].minor.yy233 = yymsp[0].minor.yy233; }
+ case 477: /* alias_opt ::= AS table_alias */
+{ yymsp[-1].minor.yy225 = yymsp[0].minor.yy225; }
break;
- case 474: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- case 475: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==475);
-{ yymsp[-2].minor.yy924 = yymsp[-1].minor.yy924; }
+ case 478: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ case 479: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==479);
+{ yymsp[-2].minor.yy42 = yymsp[-1].minor.yy42; }
break;
- case 476: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
-{ yylhsminor.yy924 = createJoinTableNode(pCxt, yymsp[-4].minor.yy428, yymsp[-5].minor.yy924, yymsp[-2].minor.yy924, yymsp[0].minor.yy924); }
- yymsp[-5].minor.yy924 = yylhsminor.yy924;
+ case 480: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+{ yylhsminor.yy42 = createJoinTableNode(pCxt, yymsp[-4].minor.yy638, yymsp[-5].minor.yy42, yymsp[-2].minor.yy42, yymsp[0].minor.yy42); }
+ yymsp[-5].minor.yy42 = yylhsminor.yy42;
break;
- case 477: /* join_type ::= */
-{ yymsp[1].minor.yy428 = JOIN_TYPE_INNER; }
+ case 481: /* join_type ::= */
+{ yymsp[1].minor.yy638 = JOIN_TYPE_INNER; }
break;
- case 478: /* join_type ::= INNER */
-{ yymsp[0].minor.yy428 = JOIN_TYPE_INNER; }
+ case 482: /* join_type ::= INNER */
+{ yymsp[0].minor.yy638 = JOIN_TYPE_INNER; }
break;
- case 479: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ case 483: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
- yymsp[-11].minor.yy924 = createSelectStmt(pCxt, yymsp[-10].minor.yy397, yymsp[-9].minor.yy776, yymsp[-8].minor.yy924);
- yymsp[-11].minor.yy924 = addWhereClause(pCxt, yymsp[-11].minor.yy924, yymsp[-7].minor.yy924);
- yymsp[-11].minor.yy924 = addPartitionByClause(pCxt, yymsp[-11].minor.yy924, yymsp[-6].minor.yy776);
- yymsp[-11].minor.yy924 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy924, yymsp[-2].minor.yy924);
- yymsp[-11].minor.yy924 = addGroupByClause(pCxt, yymsp[-11].minor.yy924, yymsp[-1].minor.yy776);
- yymsp[-11].minor.yy924 = addHavingClause(pCxt, yymsp[-11].minor.yy924, yymsp[0].minor.yy924);
- yymsp[-11].minor.yy924 = addRangeClause(pCxt, yymsp[-11].minor.yy924, yymsp[-5].minor.yy924);
- yymsp[-11].minor.yy924 = addEveryClause(pCxt, yymsp[-11].minor.yy924, yymsp[-4].minor.yy924);
- yymsp[-11].minor.yy924 = addFillClause(pCxt, yymsp[-11].minor.yy924, yymsp[-3].minor.yy924);
+ yymsp[-11].minor.yy42 = createSelectStmt(pCxt, yymsp[-10].minor.yy103, yymsp[-9].minor.yy110, yymsp[-8].minor.yy42);
+ yymsp[-11].minor.yy42 = addWhereClause(pCxt, yymsp[-11].minor.yy42, yymsp[-7].minor.yy42);
+ yymsp[-11].minor.yy42 = addPartitionByClause(pCxt, yymsp[-11].minor.yy42, yymsp[-6].minor.yy110);
+ yymsp[-11].minor.yy42 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy42, yymsp[-2].minor.yy42);
+ yymsp[-11].minor.yy42 = addGroupByClause(pCxt, yymsp[-11].minor.yy42, yymsp[-1].minor.yy110);
+ yymsp[-11].minor.yy42 = addHavingClause(pCxt, yymsp[-11].minor.yy42, yymsp[0].minor.yy42);
+ yymsp[-11].minor.yy42 = addRangeClause(pCxt, yymsp[-11].minor.yy42, yymsp[-5].minor.yy42);
+ yymsp[-11].minor.yy42 = addEveryClause(pCxt, yymsp[-11].minor.yy42, yymsp[-4].minor.yy42);
+ yymsp[-11].minor.yy42 = addFillClause(pCxt, yymsp[-11].minor.yy42, yymsp[-3].minor.yy42);
}
break;
- case 482: /* set_quantifier_opt ::= ALL */
-{ yymsp[0].minor.yy397 = false; }
+ case 486: /* set_quantifier_opt ::= ALL */
+{ yymsp[0].minor.yy103 = false; }
+ break;
+ case 489: /* select_item ::= NK_STAR */
+{ yylhsminor.yy42 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy42 = yylhsminor.yy42;
+ break;
+ case 491: /* select_item ::= common_expression column_alias */
+ case 501: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==501);
+{ yylhsminor.yy42 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy42), &yymsp[0].minor.yy225); }
+ yymsp[-1].minor.yy42 = yylhsminor.yy42;
break;
- case 485: /* select_item ::= NK_STAR */
-{ yylhsminor.yy924 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy924 = yylhsminor.yy924;
+ case 492: /* select_item ::= common_expression AS column_alias */
+ case 502: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==502);
+{ yylhsminor.yy42 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), &yymsp[0].minor.yy225); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 487: /* select_item ::= common_expression column_alias */
- case 497: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==497);
-{ yylhsminor.yy924 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy924), &yymsp[0].minor.yy233); }
- yymsp[-1].minor.yy924 = yylhsminor.yy924;
+ case 497: /* partition_by_clause_opt ::= PARTITION BY partition_list */
+ case 522: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==522);
+ case 541: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==541);
+{ yymsp[-2].minor.yy110 = yymsp[0].minor.yy110; }
break;
- case 488: /* select_item ::= common_expression AS column_alias */
- case 498: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==498);
-{ yylhsminor.yy924 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), &yymsp[0].minor.yy233); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 504: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
+{ yymsp[-5].minor.yy42 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), releaseRawExprNode(pCxt, yymsp[-1].minor.yy42)); }
break;
- case 493: /* partition_by_clause_opt ::= PARTITION BY partition_list */
- case 516: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==516);
- case 535: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==535);
-{ yymsp[-2].minor.yy776 = yymsp[0].minor.yy776; }
+ case 505: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */
+{ yymsp[-3].minor.yy42 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy42)); }
break;
- case 500: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
-{ yymsp[-5].minor.yy924 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), releaseRawExprNode(pCxt, yymsp[-1].minor.yy924)); }
+ case 506: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+{ yymsp[-5].minor.yy42 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), NULL, yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
break;
- case 501: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */
-{ yymsp[-3].minor.yy924 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy924)); }
+ case 507: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+{ yymsp[-7].minor.yy42 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy42), releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), yymsp[-1].minor.yy42, yymsp[0].minor.yy42); }
break;
- case 502: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
-{ yymsp[-5].minor.yy924 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), NULL, yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
+ case 508: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */
+{ yymsp[-6].minor.yy42 = createEventWindowNode(pCxt, yymsp[-3].minor.yy42, yymsp[0].minor.yy42); }
break;
- case 503: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
-{ yymsp[-7].minor.yy924 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy924), releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), yymsp[-1].minor.yy924, yymsp[0].minor.yy924); }
+ case 512: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
+{ yymsp[-3].minor.yy42 = createFillNode(pCxt, yymsp[-1].minor.yy410, NULL); }
break;
- case 504: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */
-{ yymsp[-6].minor.yy924 = createEventWindowNode(pCxt, yymsp[-3].minor.yy924, yymsp[0].minor.yy924); }
+ case 513: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+{ yymsp[-5].minor.yy42 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy110)); }
break;
- case 508: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
-{ yymsp[-3].minor.yy924 = createFillNode(pCxt, yymsp[-1].minor.yy646, NULL); }
+ case 514: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */
+{ yymsp[-5].minor.yy42 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy110)); }
break;
- case 509: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
-{ yymsp[-5].minor.yy924 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy776)); }
+ case 515: /* fill_mode ::= NONE */
+{ yymsp[0].minor.yy410 = FILL_MODE_NONE; }
break;
- case 510: /* fill_mode ::= NONE */
-{ yymsp[0].minor.yy646 = FILL_MODE_NONE; }
+ case 516: /* fill_mode ::= PREV */
+{ yymsp[0].minor.yy410 = FILL_MODE_PREV; }
break;
- case 511: /* fill_mode ::= PREV */
-{ yymsp[0].minor.yy646 = FILL_MODE_PREV; }
+ case 517: /* fill_mode ::= NULL */
+{ yymsp[0].minor.yy410 = FILL_MODE_NULL; }
break;
- case 512: /* fill_mode ::= NULL */
-{ yymsp[0].minor.yy646 = FILL_MODE_NULL; }
+ case 518: /* fill_mode ::= NULL_F */
+{ yymsp[0].minor.yy410 = FILL_MODE_NULL_F; }
break;
- case 513: /* fill_mode ::= LINEAR */
-{ yymsp[0].minor.yy646 = FILL_MODE_LINEAR; }
+ case 519: /* fill_mode ::= LINEAR */
+{ yymsp[0].minor.yy410 = FILL_MODE_LINEAR; }
break;
- case 514: /* fill_mode ::= NEXT */
-{ yymsp[0].minor.yy646 = FILL_MODE_NEXT; }
+ case 520: /* fill_mode ::= NEXT */
+{ yymsp[0].minor.yy410 = FILL_MODE_NEXT; }
break;
- case 517: /* group_by_list ::= expr_or_subquery */
-{ yylhsminor.yy776 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy924))); }
- yymsp[0].minor.yy776 = yylhsminor.yy776;
+ case 523: /* group_by_list ::= expr_or_subquery */
+{ yylhsminor.yy110 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy42))); }
+ yymsp[0].minor.yy110 = yylhsminor.yy110;
break;
- case 518: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */
-{ yylhsminor.yy776 = addNodeToList(pCxt, yymsp[-2].minor.yy776, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy924))); }
- yymsp[-2].minor.yy776 = yylhsminor.yy776;
+ case 524: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */
+{ yylhsminor.yy110 = addNodeToList(pCxt, yymsp[-2].minor.yy110, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy42))); }
+ yymsp[-2].minor.yy110 = yylhsminor.yy110;
break;
- case 522: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */
-{ yymsp[-5].minor.yy924 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy924), releaseRawExprNode(pCxt, yymsp[-1].minor.yy924)); }
+ case 528: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */
+{ yymsp[-5].minor.yy42 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy42), releaseRawExprNode(pCxt, yymsp[-1].minor.yy42)); }
break;
- case 525: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ case 531: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
- yylhsminor.yy924 = addOrderByClause(pCxt, yymsp[-3].minor.yy924, yymsp[-2].minor.yy776);
- yylhsminor.yy924 = addSlimitClause(pCxt, yylhsminor.yy924, yymsp[-1].minor.yy924);
- yylhsminor.yy924 = addLimitClause(pCxt, yylhsminor.yy924, yymsp[0].minor.yy924);
+ yylhsminor.yy42 = addOrderByClause(pCxt, yymsp[-3].minor.yy42, yymsp[-2].minor.yy110);
+ yylhsminor.yy42 = addSlimitClause(pCxt, yylhsminor.yy42, yymsp[-1].minor.yy42);
+ yylhsminor.yy42 = addLimitClause(pCxt, yylhsminor.yy42, yymsp[0].minor.yy42);
}
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 528: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */
-{ yylhsminor.yy924 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy924, yymsp[0].minor.yy924); }
- yymsp[-3].minor.yy924 = yylhsminor.yy924;
+ case 534: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */
+{ yylhsminor.yy42 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy42, yymsp[0].minor.yy42); }
+ yymsp[-3].minor.yy42 = yylhsminor.yy42;
break;
- case 529: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */
-{ yylhsminor.yy924 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy924, yymsp[0].minor.yy924); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 535: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */
+{ yylhsminor.yy42 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy42, yymsp[0].minor.yy42); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 537: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
- case 541: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==541);
-{ yymsp[-1].minor.yy924 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
+ case 543: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ case 547: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==547);
+{ yymsp[-1].minor.yy42 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
break;
- case 538: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- case 542: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==542);
-{ yymsp[-3].minor.yy924 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
+ case 544: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ case 548: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==548);
+{ yymsp[-3].minor.yy42 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
- case 539: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- case 543: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==543);
-{ yymsp[-3].minor.yy924 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
+ case 545: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ case 549: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==549);
+{ yymsp[-3].minor.yy42 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
break;
- case 544: /* subquery ::= NK_LP query_expression NK_RP */
-{ yylhsminor.yy924 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy924); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 550: /* subquery ::= NK_LP query_expression NK_RP */
+{ yylhsminor.yy42 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy42); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 549: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */
-{ yylhsminor.yy924 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy924), yymsp[-1].minor.yy870, yymsp[0].minor.yy89); }
- yymsp[-2].minor.yy924 = yylhsminor.yy924;
+ case 555: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */
+{ yylhsminor.yy42 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy42), yymsp[-1].minor.yy106, yymsp[0].minor.yy599); }
+ yymsp[-2].minor.yy42 = yylhsminor.yy42;
break;
- case 550: /* ordering_specification_opt ::= */
-{ yymsp[1].minor.yy870 = ORDER_ASC; }
+ case 556: /* ordering_specification_opt ::= */
+{ yymsp[1].minor.yy106 = ORDER_ASC; }
break;
- case 551: /* ordering_specification_opt ::= ASC */
-{ yymsp[0].minor.yy870 = ORDER_ASC; }
+ case 557: /* ordering_specification_opt ::= ASC */
+{ yymsp[0].minor.yy106 = ORDER_ASC; }
break;
- case 552: /* ordering_specification_opt ::= DESC */
-{ yymsp[0].minor.yy870 = ORDER_DESC; }
+ case 558: /* ordering_specification_opt ::= DESC */
+{ yymsp[0].minor.yy106 = ORDER_DESC; }
break;
- case 553: /* null_ordering_opt ::= */
-{ yymsp[1].minor.yy89 = NULL_ORDER_DEFAULT; }
+ case 559: /* null_ordering_opt ::= */
+{ yymsp[1].minor.yy599 = NULL_ORDER_DEFAULT; }
break;
- case 554: /* null_ordering_opt ::= NULLS FIRST */
-{ yymsp[-1].minor.yy89 = NULL_ORDER_FIRST; }
+ case 560: /* null_ordering_opt ::= NULLS FIRST */
+{ yymsp[-1].minor.yy599 = NULL_ORDER_FIRST; }
break;
- case 555: /* null_ordering_opt ::= NULLS LAST */
-{ yymsp[-1].minor.yy89 = NULL_ORDER_LAST; }
+ case 561: /* null_ordering_opt ::= NULLS LAST */
+{ yymsp[-1].minor.yy599 = NULL_ORDER_LAST; }
break;
default:
break;
diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp
index a7a11d8edf382da794b1ec62d8f67492e0688e0a..fab1fc49196a34ed38e09c87a14fd92bd2a80ea7 100644
--- a/source/libs/parser/test/parInitialCTest.cpp
+++ b/source/libs/parser/test/parInitialCTest.cpp
@@ -21,6 +21,26 @@ namespace ParserTest {
class ParserInitialCTest : public ParserDdlTest {};
+/*
+ * COMPACT DATABASE db_name
+ */
+TEST_F(ParserInitialCTest, compact) {
+ SCompactDbReq expect = {0};
+
+ auto setCompactDbReq = [&](const char* pDb) { snprintf(expect.db, sizeof(expect.db), "0.%s", pDb); };
+
+ setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
+ ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_COMPACT_DATABASE_STMT);
+ ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_COMPACT_DB);
+ SCompactDbReq req = {0};
+ ASSERT_EQ(tDeserializeSCompactDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
+ ASSERT_EQ(std::string(req.db), std::string(expect.db));
+ });
+
+ setCompactDbReq("wxy_db");
+ run("COMPACT DATABASE wxy_db");
+}
+
/*
* CREATE ACCOUNT account_name PASS value [create_account_options]
*
@@ -755,13 +775,13 @@ TEST_F(ParserInitialCTest, createStream) {
};
auto setCreateStreamReq = [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb,
- int8_t createStb = STREAM_CREATE_STABLE_TRUE, int8_t igExists = 0) {
+ int8_t igExists = 0) {
snprintf(expect.name, sizeof(expect.name), "0.%s", pStream);
snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb);
snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb);
expect.igExists = igExists;
expect.sql = strdup(pSql);
- expect.createStb = createStb;
+ expect.createStb = STREAM_CREATE_STABLE_TRUE;
expect.triggerType = STREAM_TRIGGER_AT_ONCE;
expect.maxDelay = 0;
expect.watermark = 0;
@@ -769,15 +789,18 @@ TEST_F(ParserInitialCTest, createStream) {
expect.igExpired = STREAM_DEFAULT_IGNORE_EXPIRED;
};
- auto setStreamOptions = [&](int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0,
- int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED,
- int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY) {
- expect.triggerType = triggerType;
- expect.maxDelay = maxDelay;
- expect.watermark = watermark;
- expect.fillHistory = fillHistory;
- expect.igExpired = igExpired;
- };
+ auto setStreamOptions =
+ [&](int8_t createStb = STREAM_CREATE_STABLE_TRUE, int8_t triggerType = STREAM_TRIGGER_AT_ONCE,
+ int64_t maxDelay = 0, int64_t watermark = 0, int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED,
+ int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY, int8_t igUpdate = STREAM_DEFAULT_IGNORE_UPDATE) {
+ expect.createStb = createStb;
+ expect.triggerType = triggerType;
+ expect.maxDelay = maxDelay;
+ expect.watermark = watermark;
+ expect.fillHistory = fillHistory;
+ expect.igExpired = igExpired;
+ expect.igUpdate = igUpdate;
+ };
auto addTag = [&](const char* pFieldName, uint8_t type, int32_t bytes = 0) {
SField field = {0};
@@ -824,6 +847,7 @@ TEST_F(ParserInitialCTest, createStream) {
}
ASSERT_EQ(req.checkpointFreq, expect.checkpointFreq);
ASSERT_EQ(req.createStb, expect.createStb);
+ ASSERT_EQ(req.igUpdate, expect.igUpdate);
tFreeSCMCreateStreamReq(&req);
});
@@ -833,13 +857,13 @@ TEST_F(ParserInitialCTest, createStream) {
setCreateStreamReq(
"s1", "test",
- "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 into st3 "
- "as select count(*) from t1 interval(10s)",
- "st3", 1, 1);
- setStreamOptions(STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 0, 1);
- run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 INTO st3 AS "
- "SELECT COUNT(*) "
- "FROM t1 INTERVAL(10S)");
+ "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 ignore "
+ "update 1 into st3 as select count(*) from t1 interval(10s)",
+ "st3", 1);
+ setStreamOptions(STREAM_CREATE_STABLE_TRUE, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND,
+ 10 * MILLISECOND_PER_SECOND, 0, 1, 1);
+ run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 IGNORE "
+ "UPDATE 1 INTO st3 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)");
clearCreateStreamReq();
setCreateStreamReq("s1", "test",
@@ -856,7 +880,8 @@ TEST_F(ParserInitialCTest, createStream) {
setCreateStreamReq(
"s1", "test",
"create stream s1 into st1 tags(tag2) as select max(c1), c2 from t1 partition by tbname tag2 interval(10s)",
- "st1", STREAM_CREATE_STABLE_FALSE);
+ "st1");
+ setStreamOptions(STREAM_CREATE_STABLE_FALSE);
run("CREATE STREAM s1 INTO st1 TAGS(tag2) AS SELECT MAX(c1), c2 FROM t1 PARTITION BY TBNAME tag2 INTERVAL(10S)");
clearCreateStreamReq();
}
diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c
index fef5bd654e04bee0618aa8d25fd2e2c6d46e1b39..c9ee83a64757b6fe951d93fd9c9d917ba357f58b 100644
--- a/source/libs/planner/src/planLogicCreater.c
+++ b/source/libs/planner/src/planLogicCreater.c
@@ -343,6 +343,13 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
pScan->node.groupAction = GROUP_ACTION_NONE;
pScan->node.resultDataOrder = DATA_ORDER_LEVEL_IN_BLOCK;
+ if (pCxt->pPlanCxt->streamQuery) {
+ pScan->triggerType = pCxt->pPlanCxt->triggerType;
+ pScan->watermark = pCxt->pPlanCxt->watermark;
+ pScan->deleteMark = pCxt->pPlanCxt->deleteMark;
+ pScan->igExpired = pCxt->pPlanCxt->igExpired;
+ pScan->igCheckUpdate = pCxt->pPlanCxt->igCheckUpdate;
+ }
// set columns to scan
if (TSDB_CODE_SUCCESS == code) {
@@ -374,6 +381,20 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
code = addDefaultScanCol(pRealTable->pMeta, &pScan->pScanCols);
}
+ if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pTags && NULL == pSelect->pPartitionByList) {
+ pScan->pTags = nodesCloneList(pSelect->pTags);
+ if (NULL == pScan->pTags) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ }
+ }
+
+ if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pSubtable && NULL == pSelect->pPartitionByList) {
+ pScan->pSubtable = nodesCloneNode(pSelect->pSubtable);
+ if (NULL == pScan->pSubtable) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ }
+ }
+
// set output
if (TSDB_CODE_SUCCESS == code) {
code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets);
@@ -705,6 +726,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
pWindow->watermark = pCxt->pPlanCxt->watermark;
pWindow->deleteMark = pCxt->pPlanCxt->deleteMark;
pWindow->igExpired = pCxt->pPlanCxt->igExpired;
+ pWindow->igCheckUpdate = pCxt->pPlanCxt->igCheckUpdate;
}
pWindow->inputTsOrder = ORDER_ASC;
pWindow->outputTsOrder = ORDER_ASC;
@@ -1041,7 +1063,7 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
TSWAP(pProject->node.pLimit, pSelect->pLimit);
TSWAP(pProject->node.pSlimit, pSelect->pSlimit);
- pProject->ignoreGroupId = (NULL == pSelect->pPartitionByList);
+ pProject->ignoreGroupId = pSelect->isSubquery ? true : (NULL == pSelect->pPartitionByList);
pProject->node.groupAction =
(!pSelect->isSubquery && pCxt->pPlanCxt->streamQuery) ? GROUP_ACTION_KEEP : GROUP_ACTION_CLEAR;
pProject->node.requireDataOrder = DATA_ORDER_LEVEL_NONE;
diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c
index 18aaabf448ae439af7560be5feb7bb54e0981603..16a5ef7bae1e7aeaa4c0521022bd96913b9c222a 100644
--- a/source/libs/planner/src/planOptimizer.c
+++ b/source/libs/planner/src/planOptimizer.c
@@ -328,10 +328,6 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) {
pScan->sliding = ((SWindowLogicNode*)pParent)->sliding;
pScan->intervalUnit = ((SWindowLogicNode*)pParent)->intervalUnit;
pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit;
- pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType;
- pScan->watermark = ((SWindowLogicNode*)pParent)->watermark;
- pScan->deleteMark = ((SWindowLogicNode*)pParent)->deleteMark;
- pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired;
}
}
diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c
index f83704be8783ac0f65c02823a3ace1b1031685b7..e9a2efaac79fe237c8e4e93a91cf79f397d27f33 100644
--- a/source/libs/planner/src/planPhysiCreater.c
+++ b/source/libs/planner/src/planPhysiCreater.c
@@ -582,6 +582,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
pTableScan->triggerType = pScanLogicNode->triggerType;
pTableScan->watermark = pScanLogicNode->watermark;
pTableScan->igExpired = pScanLogicNode->igExpired;
+ pTableScan->igCheckUpdate = pScanLogicNode->igCheckUpdate;
pTableScan->assignBlockUid = pCxt->pPlanCxt->rSmaQuery ? true : false;
int32_t code = createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
@@ -1718,6 +1719,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod
strcpy(pInserter->tableName, pModify->tableName);
pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId;
pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet;
+ pInserter->explain = (QUERY_NODE_EXPLAIN_STMT == nodeType(pCxt->pPlanCxt->pAstRoot) ? true : false);
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
int32_t code = setListSlotId(pCxt, pSubplan->pNode->pOutputDataBlockDesc->dataBlockId, -1, pModify->pInsertCols,
diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c
index 6208fc172aa4fd9a55b259f794e0d9e266bfabea..361cf33d58bffb63523156d6fab555b8ccb5d5d4 100644
--- a/source/libs/planner/src/planSpliter.c
+++ b/source/libs/planner/src/planSpliter.c
@@ -348,7 +348,8 @@ static bool stbSplIsPartTableAgg(SAggLogicNode* pAgg) {
return false;
}
if (NULL != pAgg->pGroupKeys) {
- return stbSplHasPartTbname(pAgg->pGroupKeys) && stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0));
+ return stbSplHasPartTbname(pAgg->pGroupKeys) &&
+ stbSplNotSystemScan((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0));
}
return stbSplHasPartTbname(stbSplGetPartKeys((SLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0)));
}
@@ -559,6 +560,8 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
if (NULL == pMerge->node.pLimit) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
+ ((SLimitNode*)pSplitNode->pLimit)->limit += ((SLimitNode*)pSplitNode->pLimit)->offset;
+ ((SLimitNode*)pSplitNode->pLimit)->offset = 0;
}
if (TSDB_CODE_SUCCESS == code) {
if (NULL == pSubplan) {
@@ -1039,21 +1042,29 @@ static int32_t stbSplSplitSortNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
return code;
}
-static int32_t stbSplSplitScanNodeWithoutPartTags(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
- SLogicNode* pSplitNode = pInfo->pSplitNode;
+static int32_t stbSplGetSplitNodeForScan(SStableSplitInfo* pInfo, SLogicNode** pSplitNode) {
+ *pSplitNode = pInfo->pSplitNode;
if (NULL != pInfo->pSplitNode->pParent && QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pInfo->pSplitNode->pParent) &&
NULL == pInfo->pSplitNode->pParent->pLimit && NULL == pInfo->pSplitNode->pParent->pSlimit) {
- pSplitNode = pInfo->pSplitNode->pParent;
+ *pSplitNode = pInfo->pSplitNode->pParent;
if (NULL != pInfo->pSplitNode->pLimit) {
- pSplitNode->pLimit = nodesCloneNode(pInfo->pSplitNode->pLimit);
- if (NULL == pSplitNode->pLimit) {
+ (*pSplitNode)->pLimit = nodesCloneNode(pInfo->pSplitNode->pLimit);
+ if (NULL == (*pSplitNode)->pLimit) {
return TSDB_CODE_OUT_OF_MEMORY;
}
((SLimitNode*)pInfo->pSplitNode->pLimit)->limit += ((SLimitNode*)pInfo->pSplitNode->pLimit)->offset;
((SLimitNode*)pInfo->pSplitNode->pLimit)->offset = 0;
}
}
- int32_t code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pSplitNode, SUBPLAN_TYPE_MERGE);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t stbSplSplitScanNodeWithoutPartTags(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
+ SLogicNode* pSplitNode = NULL;
+ int32_t code = stbSplGetSplitNodeForScan(pInfo, &pSplitNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = splCreateExchangeNodeForSubplan(pCxt, pInfo->pSubplan, pSplitNode, SUBPLAN_TYPE_MERGE);
+ }
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
(SNode*)splCreateScanSubplan(pCxt, pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
@@ -1063,12 +1074,11 @@ static int32_t stbSplSplitScanNodeWithoutPartTags(SSplitContext* pCxt, SStableSp
}
static int32_t stbSplSplitScanNodeWithPartTags(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
- SLogicNode* pSplitNode = pInfo->pSplitNode;
- if (NULL != pInfo->pSplitNode->pParent && QUERY_NODE_LOGIC_PLAN_PROJECT == nodeType(pInfo->pSplitNode->pParent) &&
- NULL == pInfo->pSplitNode->pParent->pLimit && NULL == pInfo->pSplitNode->pParent->pSlimit) {
- pSplitNode = pInfo->pSplitNode->pParent;
+ SLogicNode* pSplitNode = NULL;
+ int32_t code = stbSplGetSplitNodeForScan(pInfo, &pSplitNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pSplitNode, NULL, pSplitNode, true);
}
- int32_t code = stbSplCreateMergeNode(pCxt, pInfo->pSubplan, pSplitNode, NULL, pSplitNode, true);
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
(SNode*)splCreateScanSubplan(pCxt, pSplitNode, SPLIT_FLAG_STABLE_SPLIT));
diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h
index 787ef7501da7e467e67975d20563ad7f875ecced..9553cb97b549249ad203957367aab4cc27082134 100644
--- a/source/libs/qworker/inc/qwInt.h
+++ b/source/libs/qworker/inc/qwInt.h
@@ -194,6 +194,8 @@ typedef struct SQWorker {
SMsgCb msgCb;
SQWStat stat;
int32_t *destroyed;
+
+ int8_t nodeStopped;
} SQWorker;
typedef struct SQWorkerMgmt {
diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c
index fdd2775daacbbadecd600f117ea3928c162e8f08..7ee7c50c9687d26f94825a5b0888caba9371f66d 100644
--- a/source/libs/qworker/src/qwUtil.c
+++ b/source/libs/qworker/src/qwUtil.c
@@ -213,9 +213,15 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
QW_SET_QTID(id, qId, tId, eId);
*ctx = taosHashAcquire(mgmt->ctxHash, id, sizeof(id));
+ int8_t nodeStopped = atomic_load_8(&mgmt->nodeStopped);
if (NULL == (*ctx)) {
- QW_TASK_DLOG_E("task ctx not exist, may be dropped");
- QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
+ if (!nodeStopped) {
+ QW_TASK_DLOG_E("task ctx not exist, may be dropped");
+ QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
+ } else {
+ QW_TASK_DLOG_E("node stopped");
+ QW_ERR_RET(TSDB_CODE_VND_STOPPED);
+ }
}
return TSDB_CODE_SUCCESS;
@@ -226,9 +232,16 @@ int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) {
QW_SET_QTID(id, qId, tId, eId);
*ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id));
+ int8_t nodeStopped = atomic_load_8(&mgmt->nodeStopped);
+
if (NULL == (*ctx)) {
- QW_TASK_DLOG_E("task ctx not exist, may be dropped");
- QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
+ if (!nodeStopped) {
+ QW_TASK_DLOG_E("task ctx not exist, may be dropped");
+ QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST);
+ } else {
+ QW_TASK_DLOG_E("node stopped");
+ QW_ERR_RET(TSDB_CODE_VND_STOPPED);
+ }
}
return TSDB_CODE_SUCCESS;
diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c
index 2f712e6eba50a6dd3e8c4768397eaf57ec505bff..5645e969a2e44e1f0bc47ee162163e59288c886e 100644
--- a/source/libs/qworker/src/qworker.c
+++ b/source/libs/qworker/src/qworker.c
@@ -516,7 +516,7 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
}
if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) {
- if (QW_PHASE_POST_FETCH != phase || qwTaskNotInExec(ctx)) {
+ if (QW_PHASE_POST_FETCH != phase || ((!QW_QUERY_RUNNING(ctx)) && qwTaskNotInExec(ctx))) {
QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
QW_ERR_JRET(ctx->rspCode);
}
@@ -1187,6 +1187,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) {
uint64_t qId, tId, sId;
int32_t eId;
int64_t rId = 0;
+
+ atomic_store_8(&mgmt->nodeStopped, 1);
+
void *pIter = taosHashIterate(mgmt->ctxHash, NULL);
while (pIter) {
SQWTaskCtx *ctx = (SQWTaskCtx *)pIter;
diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c
index 6a8f81f8c78a0146396371d79f4c8ed95e73b1fb..fb8a7a42ba5409494b2efe51aadf6ca21c9fa700 100644
--- a/source/libs/scheduler/src/schJob.c
+++ b/source/libs/scheduler/src/schJob.c
@@ -234,7 +234,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) {
}
SSchTask *pTask = taosArrayGet(pLevel->subTasks, 0);
- if (SUBPLAN_TYPE_MODIFY != pTask->plan->subplanType) {
+ if (SUBPLAN_TYPE_MODIFY != pTask->plan->subplanType || EXPLAIN_MODE_DISABLE != pJob->attr.explainMode) {
pJob->attr.needFetch = true;
}
}
@@ -484,7 +484,7 @@ int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode) {
if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) {
return TSDB_CODE_SCH_IGNORE_ERROR;
}
-
+
schUpdateJobErrCode(pJob, errCode);
int32_t code = atomic_load_32(&pJob->errCode);
@@ -537,7 +537,9 @@ int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRs
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCC);
- schProcessOnDataFetched(pJob);
+ if (!SCH_IS_INSERT_JOB(pJob)) {
+ schProcessOnDataFetched(pJob);
+ }
return TSDB_CODE_SUCCESS;
}
@@ -682,7 +684,7 @@ void schFreeJobImpl(void *job) {
int32_t schJobFetchRows(SSchJob *pJob) {
int32_t code = 0;
- if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) {
+ if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC) && !(SCH_IS_EXPLAIN_JOB(pJob) && SCH_IS_INSERT_JOB(pJob))) {
SCH_ERR_RET(schLaunchFetchTask(pJob));
if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) {
diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c
index 5ceb8228b03bdd0b4811b7834b24fafe8b5e6a30..ad675cf383471826a9e8a94d9709bee75ee5a663 100644
--- a/source/libs/scheduler/src/schRemote.c
+++ b/source/libs/scheduler/src/schRemote.c
@@ -341,6 +341,14 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
}
+ if (taosArrayGetSize(pTask->parents) == 0 && SCH_IS_EXPLAIN_JOB(pJob) && SCH_IS_INSERT_JOB(pJob)) {
+ SRetrieveTableRsp *pRsp = NULL;
+ SCH_ERR_JRET(qExecExplainEnd(pJob->explainCtx, &pRsp));
+ if (pRsp) {
+ SCH_ERR_JRET(schProcessOnExplainDone(pJob, pTask, pRsp));
+ }
+ }
+
SQueryTableRsp rsp = {0};
if (tDeserializeSQueryTableRsp(msg, msgSize, &rsp) < 0) {
SCH_TASK_ELOG("tDeserializeSQueryTableRsp failed, msgSize:%d", msgSize);
diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c
index e26c8a5c5b128d6087c7c687a17cd3c5a2fa0b3e..2ef351cbb0abe06ebe44806eb32de9aa0f1c1947 100644
--- a/source/libs/stream/src/streamState.c
+++ b/source/libs/stream/src/streamState.c
@@ -128,7 +128,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
memset(statePath, 0, 1024);
tstrncpy(statePath, path, 1024);
}
- if (tdbOpen(statePath, szPage, pages, &pState->pTdbState->db, 0) < 0) {
+ if (tdbOpen(statePath, szPage, pages, &pState->pTdbState->db, 1) < 0) {
goto _err;
}
@@ -199,7 +199,7 @@ void streamStateClose(SStreamState* pState) {
}
int32_t streamStateBegin(SStreamState* pState) {
- if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL,
+ if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL,
TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
tdbAbort(pState->pTdbState->db, pState->pTdbState->txn);
return -1;
@@ -215,7 +215,7 @@ int32_t streamStateCommit(SStreamState* pState) {
return -1;
}
- if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL,
+ if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL,
TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
return -1;
}
@@ -227,7 +227,7 @@ int32_t streamStateAbort(SStreamState* pState) {
return -1;
}
- if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL,
+ if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL,
TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
return -1;
}
diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h
index 5277e7818fd8a152551eef51c2fdb5e858d724a5..063b4f51f56e244b3c1c2d34d4712e31cd01e068 100644
--- a/source/libs/sync/inc/syncSnapshot.h
+++ b/source/libs/sync/inc/syncSnapshot.h
@@ -24,7 +24,7 @@ extern "C" {
#define SYNC_SNAPSHOT_SEQ_INVALID -2
#define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -3
-#define SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT -1
+#define SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT -1
#define SYNC_SNAPSHOT_SEQ_BEGIN 0
#define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF
diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c
index 948d2f53e7510d52a574c7c977615178fd080c3d..835e5d248e345cbbb3206e35d67ddd20717009db 100644
--- a/source/libs/sync/src/syncAppendEntries.c
+++ b/source/libs/sync/src/syncAppendEntries.c
@@ -89,45 +89,6 @@
// /\ UNCHANGED <>
//
-int32_t syncNodeFollowerCommit(SSyncNode* ths, SyncIndex newCommitIndex) {
- ASSERT(false && "deprecated");
- if (ths->state != TAOS_SYNC_STATE_FOLLOWER) {
- sNTrace(ths, "can not do follower commit");
- return -1;
- }
-
- // maybe update commit index, leader notice me
- if (newCommitIndex > ths->commitIndex) {
- // has commit entry in local
- if (newCommitIndex <= ths->pLogStore->syncLogLastIndex(ths->pLogStore)) {
- // advance commit index to sanpshot first
- SSnapshot snapshot;
- ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot);
- if (snapshot.lastApplyIndex >= 0 && snapshot.lastApplyIndex > ths->commitIndex) {
- SyncIndex commitBegin = ths->commitIndex;
- SyncIndex commitEnd = snapshot.lastApplyIndex;
- ths->commitIndex = snapshot.lastApplyIndex;
- sNTrace(ths, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd);
- }
-
- SyncIndex beginIndex = ths->commitIndex + 1;
- SyncIndex endIndex = newCommitIndex;
-
- // update commit index
- ths->commitIndex = newCommitIndex;
-
- // call back Wal
- int32_t code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex);
- ASSERT(code == 0);
-
- code = syncNodeDoCommit(ths, beginIndex, endIndex, ths->state);
- ASSERT(code == 0);
- }
- }
-
- return 0;
-}
-
SSyncRaftEntry* syncBuildRaftEntryFromAppendEntries(const SyncAppendEntries* pMsg) {
SSyncRaftEntry* pEntry = taosMemoryMalloc(pMsg->dataLen);
if (pEntry == NULL) {
@@ -232,256 +193,3 @@ _IGNORE:
rpcFreeCont(rpcRsp.pCont);
return 0;
}
-
-int32_t syncNodeOnAppendEntriesOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
- SyncAppendEntries* pMsg = pRpcMsg->pCont;
- SRpcMsg rpcRsp = {0};
-
- // if already drop replica, do not process
- if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) {
- syncLogRecvAppendEntries(ths, pMsg, "not in my config");
- goto _IGNORE;
- }
-
- // prepare response msg
- int32_t code = syncBuildAppendEntriesReply(&rpcRsp, ths->vgId);
- if (code != 0) {
- syncLogRecvAppendEntries(ths, pMsg, "build rsp error");
- goto _IGNORE;
- }
-
- SyncAppendEntriesReply* pReply = rpcRsp.pCont;
- pReply->srcId = ths->myRaftId;
- pReply->destId = pMsg->srcId;
- pReply->term = ths->raftStore.currentTerm;
- pReply->success = false;
- // pReply->matchIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
- pReply->matchIndex = SYNC_INDEX_INVALID;
- pReply->lastSendIndex = pMsg->prevLogIndex + 1;
- pReply->startTime = ths->startTime;
-
- if (pMsg->term < ths->raftStore.currentTerm) {
- syncLogRecvAppendEntries(ths, pMsg, "reject, small term");
- goto _SEND_RESPONSE;
- }
-
- if (pMsg->term > ths->raftStore.currentTerm) {
- pReply->term = pMsg->term;
- }
-
- syncNodeStepDown(ths, pMsg->term);
- syncNodeResetElectTimer(ths);
-
- SyncIndex startIndex = ths->pLogStore->syncLogBeginIndex(ths->pLogStore);
- SyncIndex lastIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
-
- if (pMsg->prevLogIndex > lastIndex) {
- syncLogRecvAppendEntries(ths, pMsg, "reject, index not match");
- goto _SEND_RESPONSE;
- }
-
- if (pMsg->prevLogIndex >= startIndex) {
- SyncTerm myPreLogTerm = syncNodeGetPreTerm(ths, pMsg->prevLogIndex + 1);
- // ASSERT(myPreLogTerm != SYNC_TERM_INVALID);
- if (myPreLogTerm == SYNC_TERM_INVALID) {
- syncLogRecvAppendEntries(ths, pMsg, "reject, pre-term invalid");
- goto _SEND_RESPONSE;
- }
-
- if (myPreLogTerm != pMsg->prevLogTerm) {
- syncLogRecvAppendEntries(ths, pMsg, "reject, pre-term not match");
- goto _SEND_RESPONSE;
- }
- }
-
- // accept
- pReply->success = true;
- bool hasAppendEntries = pMsg->dataLen > 0;
- if (hasAppendEntries) {
- SSyncRaftEntry* pAppendEntry = syncEntryBuildFromAppendEntries(pMsg);
- ASSERT(pAppendEntry != NULL);
-
- SyncIndex appendIndex = pMsg->prevLogIndex + 1;
-
- LRUHandle* hLocal = NULL;
- LRUHandle* hAppend = NULL;
-
- int32_t code = 0;
- SSyncRaftEntry* pLocalEntry = NULL;
- SLRUCache* pCache = ths->pLogStore->pCache;
- hLocal = taosLRUCacheLookup(pCache, &appendIndex, sizeof(appendIndex));
- if (hLocal) {
- pLocalEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, hLocal);
- code = 0;
-
- ths->pLogStore->cacheHit++;
- sNTrace(ths, "hit cache index:%" PRId64 ", bytes:%u, %p", appendIndex, pLocalEntry->bytes, pLocalEntry);
-
- } else {
- ths->pLogStore->cacheMiss++;
- sNTrace(ths, "miss cache index:%" PRId64, appendIndex);
-
- code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, appendIndex, &pLocalEntry);
- }
-
- if (code == 0) {
- // get local entry success
-
- if (pLocalEntry->term == pAppendEntry->term) {
- // do nothing
- sNTrace(ths, "log match, do nothing, index:%" PRId64, appendIndex);
-
- } else {
- // truncate
- code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex);
- if (code != 0) {
- char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "ignore, truncate error, append-index:%" PRId64, appendIndex);
- syncLogRecvAppendEntries(ths, pMsg, logBuf);
-
- if (hLocal) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false);
- } else {
- syncEntryDestroy(pLocalEntry);
- }
-
- if (hAppend) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false);
- } else {
- syncEntryDestroy(pAppendEntry);
- }
-
- goto _IGNORE;
- }
-
- ASSERT(pAppendEntry->index == appendIndex);
-
- // append
- code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry, false);
- if (code != 0) {
- char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "ignore, append error, append-index:%" PRId64, appendIndex);
- syncLogRecvAppendEntries(ths, pMsg, logBuf);
-
- if (hLocal) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false);
- } else {
- syncEntryDestroy(pLocalEntry);
- }
-
- if (hAppend) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false);
- } else {
- syncEntryDestroy(pAppendEntry);
- }
-
- goto _IGNORE;
- }
-
- syncCacheEntry(ths->pLogStore, pAppendEntry, &hAppend);
- }
-
- } else {
- if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
- // log not exist
-
- // truncate
- code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex);
- if (code != 0) {
- char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, truncate error, append-index:%" PRId64, appendIndex);
- syncLogRecvAppendEntries(ths, pMsg, logBuf);
-
- syncEntryDestroy(pLocalEntry);
- syncEntryDestroy(pAppendEntry);
- goto _IGNORE;
- }
-
- // append
- code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry, false);
- if (code != 0) {
- char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, append error, append-index:%" PRId64, appendIndex);
- syncLogRecvAppendEntries(ths, pMsg, logBuf);
-
- if (hLocal) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false);
- } else {
- syncEntryDestroy(pLocalEntry);
- }
-
- if (hAppend) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false);
- } else {
- syncEntryDestroy(pAppendEntry);
- }
-
- goto _IGNORE;
- }
-
- syncCacheEntry(ths->pLogStore, pAppendEntry, &hAppend);
-
- } else {
- // get local entry success
- char logBuf[128];
- snprintf(logBuf, sizeof(logBuf), "ignore, get local entry error, append-index:%" PRId64 " err:%d", appendIndex,
- terrno);
- syncLogRecvAppendEntries(ths, pMsg, logBuf);
-
- if (hLocal) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false);
- } else {
- syncEntryDestroy(pLocalEntry);
- }
-
- if (hAppend) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false);
- } else {
- syncEntryDestroy(pAppendEntry);
- }
-
- goto _IGNORE;
- }
- }
-
- // update match index
- pReply->matchIndex = pAppendEntry->index;
-
- if (hLocal) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false);
- } else {
- syncEntryDestroy(pLocalEntry);
- }
-
- if (hAppend) {
- taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false);
- } else {
- syncEntryDestroy(pAppendEntry);
- }
-
- } else {
- // no append entries, do nothing
- // maybe has extra entries, no harm
-
- // update match index
- pReply->matchIndex = pMsg->prevLogIndex;
- }
-
- // maybe update commit index, leader notice me
- syncNodeFollowerCommit(ths, pMsg->commitIndex);
-
- syncLogRecvAppendEntries(ths, pMsg, "accept");
- goto _SEND_RESPONSE;
-
-_IGNORE:
- rpcFreeCont(rpcRsp.pCont);
- return 0;
-
-_SEND_RESPONSE:
- // msg event log
- syncLogSendAppendEntriesReply(ths, pReply, "");
-
- // send response
- syncNodeSendMsgById(&pReply->destId, ths, &rpcRsp);
- return 0;
-}
diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c
index 8157a5a14f9c5275036d14f8917aebf3dfe05a26..44a29da3ea0e54d4e9932183a67d298a9c6239ed 100644
--- a/source/libs/sync/src/syncAppendEntriesReply.c
+++ b/source/libs/sync/src/syncAppendEntriesReply.c
@@ -89,63 +89,3 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
}
return 0;
}
-
-int32_t syncNodeOnAppendEntriesReplyOld(SSyncNode* ths, SyncAppendEntriesReply* pMsg) {
- int32_t ret = 0;
-
- // if already drop replica, do not process
- if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) {
- syncLogRecvAppendEntriesReply(ths, pMsg, "not in my config");
- return 0;
- }
-
- // drop stale response
- if (pMsg->term < ths->raftStore.currentTerm) {
- syncLogRecvAppendEntriesReply(ths, pMsg, "drop stale response");
- return 0;
- }
-
- if (ths->state == TAOS_SYNC_STATE_LEADER) {
- if (pMsg->term > ths->raftStore.currentTerm) {
- syncLogRecvAppendEntriesReply(ths, pMsg, "error term");
- syncNodeStepDown(ths, pMsg->term);
- return -1;
- }
-
- ASSERT(pMsg->term == ths->raftStore.currentTerm);
-
- if (pMsg->success) {
- SyncIndex oldMatchIndex = syncIndexMgrGetIndex(ths->pMatchIndex, &(pMsg->srcId));
- if (pMsg->matchIndex > oldMatchIndex) {
- syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex);
- syncMaybeAdvanceCommitIndex(ths);
-
- // maybe update minMatchIndex
- ths->minMatchIndex = syncMinMatchIndex(ths);
- }
- syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1);
-
- } else {
- SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId));
- if (nextIndex > SYNC_INDEX_BEGIN) {
- --nextIndex;
- }
- syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex);
- }
-
- // send next append entries
- SPeerState* pState = syncNodeGetPeerState(ths, &(pMsg->srcId));
- ASSERT(pState != NULL);
-
- if (pMsg->lastSendIndex == pState->lastSendIndex) {
- int64_t timeNow = taosGetTimestampMs();
- int64_t elapsed = timeNow - pState->lastSendTime;
- sNTrace(ths, "sync-append-entries rtt elapsed:%" PRId64 ", index:%" PRId64, elapsed, pState->lastSendIndex);
-
- syncNodeReplicateOne(ths, &(pMsg->srcId), true);
- }
- }
-
- syncLogRecvAppendEntriesReply(ths, pMsg, "process");
- return 0;
-}
diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c
index 286cf4daf52a0ef206ff4d2bf285b673dd1a7b1a..6d256a735de387ac10523580b7d25508d8c10a80 100644
--- a/source/libs/sync/src/syncCommit.c
+++ b/source/libs/sync/src/syncCommit.c
@@ -43,148 +43,6 @@
// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex]
// /\ UNCHANGED <>
//
-void syncOneReplicaAdvance(SSyncNode* pSyncNode) {
- ASSERT(false && "deprecated");
- if (pSyncNode == NULL) {
- sError("pSyncNode is NULL");
- return;
- }
-
- if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
- sNError(pSyncNode, "not leader, can not advance commit index");
- return;
- }
-
- if (pSyncNode->replicaNum != 1) {
- sNError(pSyncNode, "not one replica, can not advance commit index");
- return;
- }
-
- // advance commit index to snapshot first
- SSnapshot snapshot;
- pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
- if (snapshot.lastApplyIndex > 0 && snapshot.lastApplyIndex > pSyncNode->commitIndex) {
- SyncIndex commitBegin = pSyncNode->commitIndex;
- SyncIndex commitEnd = snapshot.lastApplyIndex;
- pSyncNode->commitIndex = snapshot.lastApplyIndex;
- sNTrace(pSyncNode, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd);
- }
-
- // advance commit index as large as possible
- SyncIndex lastIndex = syncNodeGetLastIndex(pSyncNode);
- if (lastIndex > pSyncNode->commitIndex) {
- sNTrace(pSyncNode, "commit by wal from index:%" PRId64 " to index:%" PRId64, pSyncNode->commitIndex + 1, lastIndex);
- pSyncNode->commitIndex = lastIndex;
- }
-
- // call back Wal
- SyncIndex walCommitVer = logStoreWalCommitVer(pSyncNode->pLogStore);
- if (pSyncNode->commitIndex > walCommitVer) {
- pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex);
- }
-}
-
-void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
- ASSERTS(false, "deprecated");
- if (pSyncNode == NULL) {
- sError("pSyncNode is NULL");
- return;
- }
-
- if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
- sNError(pSyncNode, "not leader, can not advance commit index");
- return;
- }
-
- // advance commit index to sanpshot first
- SSnapshot snapshot;
- pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
- if (snapshot.lastApplyIndex > 0 && snapshot.lastApplyIndex > pSyncNode->commitIndex) {
- SyncIndex commitBegin = pSyncNode->commitIndex;
- SyncIndex commitEnd = snapshot.lastApplyIndex;
- pSyncNode->commitIndex = snapshot.lastApplyIndex;
- sNTrace(pSyncNode, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd);
- }
-
- // update commit index
- SyncIndex newCommitIndex = pSyncNode->commitIndex;
- for (SyncIndex index = syncNodeGetLastIndex(pSyncNode); index > pSyncNode->commitIndex; --index) {
- bool agree = syncAgree(pSyncNode, index);
-
- if (agree) {
- // term
- SSyncRaftEntry* pEntry = NULL;
- SLRUCache* pCache = pSyncNode->pLogStore->pCache;
- LRUHandle* h = taosLRUCacheLookup(pCache, &index, sizeof(index));
- if (h) {
- pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h);
-
- pSyncNode->pLogStore->cacheHit++;
- sNTrace(pSyncNode, "hit cache index:%" PRId64 ", bytes:%u, %p", index, pEntry->bytes, pEntry);
-
- } else {
- pSyncNode->pLogStore->cacheMiss++;
- sNTrace(pSyncNode, "miss cache index:%" PRId64, index);
-
- int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index, &pEntry);
- if (code != 0) {
- sNError(pSyncNode, "advance commit index error, read wal index:%" PRId64, index);
- return;
- }
- }
- // cannot commit, even if quorum agree. need check term!
- if (pEntry->term <= pSyncNode->raftStore.currentTerm) {
- // update commit index
- newCommitIndex = index;
-
- if (h) {
- taosLRUCacheRelease(pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
-
- break;
- } else {
- sNTrace(pSyncNode, "can not commit due to term not equal, index:%" PRId64 ", term:%" PRIu64, pEntry->index,
- pEntry->term);
- }
-
- if (h) {
- taosLRUCacheRelease(pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
- }
- }
-
- // advance commit index as large as possible
- SyncIndex walCommitVer = logStoreWalCommitVer(pSyncNode->pLogStore);
- if (walCommitVer > newCommitIndex) {
- newCommitIndex = walCommitVer;
- }
-
- // maybe execute fsm
- if (newCommitIndex > pSyncNode->commitIndex) {
- SyncIndex beginIndex = pSyncNode->commitIndex + 1;
- SyncIndex endIndex = newCommitIndex;
-
- // update commit index
- pSyncNode->commitIndex = newCommitIndex;
-
- // call back Wal
- pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex);
-
- // execute fsm
- if (pSyncNode != NULL && pSyncNode->pFsm != NULL) {
- int32_t code = syncNodeDoCommit(pSyncNode, beginIndex, endIndex, pSyncNode->state);
- if (code != 0) {
- sNError(pSyncNode, "advance commit index error, do commit begin:%" PRId64 ", end:%" PRId64, beginIndex,
- endIndex);
- return;
- }
- }
- }
-}
bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index) {
// I am leader, I agree
@@ -210,83 +68,7 @@ static inline int64_t syncNodeAbs64(int64_t a, int64_t b) {
return c;
}
-int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) {
- return pSyncNode->quorum;
-
-#if 0
- int32_t quorum = 1; // self
-
- int64_t timeNow = taosGetTimestampMs();
- for (int i = 0; i < pSyncNode->peersNum; ++i) {
- int64_t peerStartTime = syncIndexMgrGetStartTime(pSyncNode->pNextIndex, &(pSyncNode->peersId)[i]);
- int64_t peerRecvTime = syncIndexMgrGetRecvTime(pSyncNode->pNextIndex, &(pSyncNode->peersId)[i]);
- SyncIndex peerMatchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, &(pSyncNode->peersId)[i]);
-
- int64_t recvTimeDiff = TABS(peerRecvTime - timeNow);
- int64_t startTimeDiff = TABS(peerStartTime - pSyncNode->startTime);
- int64_t logDiff = TABS(peerMatchIndex - syncNodeGetLastIndex(pSyncNode));
-
- /*
- int64_t recvTimeDiff = syncNodeAbs64(peerRecvTime, timeNow);
- int64_t startTimeDiff = syncNodeAbs64(peerStartTime, pSyncNode->startTime);
- int64_t logDiff = syncNodeAbs64(peerMatchIndex, syncNodeGetLastIndex(pSyncNode));
- */
-
- int32_t addQuorum = 0;
-
- if (recvTimeDiff < SYNC_MAX_RECV_TIME_RANGE_MS) {
- if (startTimeDiff < SYNC_MAX_START_TIME_RANGE_MS) {
- addQuorum = 1;
- } else {
- if (logDiff < SYNC_ADD_QUORUM_COUNT) {
- addQuorum = 1;
- } else {
- addQuorum = 0;
- }
- }
- } else {
- addQuorum = 0;
- }
-
- /*
- if (recvTimeDiff < SYNC_MAX_RECV_TIME_RANGE_MS) {
- addQuorum = 1;
- } else {
- addQuorum = 0;
- }
-
- if (startTimeDiff > SYNC_MAX_START_TIME_RANGE_MS) {
- addQuorum = 0;
- }
- */
-
- quorum += addQuorum;
- }
-
- ASSERT(quorum <= pSyncNode->replicaNum);
-
- if (quorum < pSyncNode->quorum) {
- quorum = pSyncNode->quorum;
- }
-
- return quorum;
-#endif
-}
-
-/*
-bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) {
- int agreeCount = 0;
- for (int i = 0; i < pSyncNode->replicaNum; ++i) {
- if (syncAgreeIndex(pSyncNode, &(pSyncNode->replicasId[i]), index)) {
- ++agreeCount;
- }
- if (agreeCount >= syncNodeDynamicQuorum(pSyncNode)) {
- return true;
- }
- }
- return false;
-}
-*/
+int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) { return pSyncNode->quorum; }
bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) {
int count = 0;
@@ -328,7 +110,7 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) {
if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) {
SyncIndex commitIndex = indexLikely;
syncNodeUpdateCommitIndex(ths, commitIndex);
- sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index: %" PRId64 "", ths->vgId, ths->state,
+ sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state,
ths->raftStore.currentTerm, commitIndex);
}
return ths->commitIndex;
diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c
index cd3ffc33e34fef0047f9e92f319a5fadaf271419..682ace83ecfa99e4781f70915048cf62a5e2d76f 100644
--- a/source/libs/sync/src/syncElection.c
+++ b/source/libs/sync/src/syncElection.c
@@ -43,7 +43,10 @@ static int32_t syncNodeRequestVotePeers(SSyncNode* pNode) {
for (int i = 0; i < pNode->peersNum; ++i) {
SRpcMsg rpcMsg = {0};
ret = syncBuildRequestVote(&rpcMsg, pNode->vgId);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ sError("vgId:%d, failed to build request-vote msg since %s", pNode->vgId, terrstr());
+ continue;
+ }
SyncRequestVote* pMsg = rpcMsg.pCont;
pMsg->srcId = pNode->myRaftId;
@@ -51,13 +54,18 @@ static int32_t syncNodeRequestVotePeers(SSyncNode* pNode) {
pMsg->term = pNode->raftStore.currentTerm;
ret = syncNodeGetLastIndexTerm(pNode, &pMsg->lastLogIndex, &pMsg->lastLogTerm);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ sError("vgId:%d, failed to get index and term of last log since %s", pNode->vgId, terrstr());
+ continue;
+ }
ret = syncNodeSendMsgById(&pNode->peersId[i], pNode, &rpcMsg);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ sError("vgId:%d, failed to send msg to peerId:%" PRId64, pNode->vgId, pNode->peersId[i].addr);
+ continue;
+ }
}
-
- return ret;
+ return 0;
}
int32_t syncNodeElect(SSyncNode* pSyncNode) {
diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c
index 11067d43aa13f928006e5f3ebd67c9dda3cb452e..1d96412ba37db1ade312e19016fead9bfabf26fc 100644
--- a/source/libs/sync/src/syncMain.c
+++ b/source/libs/sync/src/syncMain.c
@@ -85,7 +85,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) {
int32_t syncStart(int64_t rid) {
SSyncNode* pSyncNode = syncNodeAcquire(rid);
if (pSyncNode == NULL) {
- sError("failed to acquire rid: %" PRId64 " of tsNodeReftId for pSyncNode", rid);
+ sError("failed to acquire rid:%" PRId64 " of tsNodeReftId for pSyncNode", rid);
return -1;
}
@@ -292,8 +292,6 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) {
goto _DEL_WAL;
} else {
- lastApplyIndex -= SYNC_VNODE_LOG_RETENTION;
-
SyncIndex beginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore);
SyncIndex endIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore);
bool isEmpty = pSyncNode->pLogStore->syncLogIsEmpty(pSyncNode->pLogStore);
@@ -308,6 +306,8 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) {
if (pSyncNode->replicaNum > 1) {
// multi replicas
+ lastApplyIndex = TMAX(lastApplyIndex - SYNC_VNODE_LOG_RETENTION, beginIndex - 1);
+
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
pSyncNode->minMatchIndex = syncMinMatchIndex(pSyncNode);
@@ -586,78 +586,6 @@ SSyncState syncGetState(int64_t rid) {
return state;
}
-#if 0
-int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) {
- if (index < SYNC_INDEX_BEGIN) {
- return -1;
- }
-
- SSyncNode* pSyncNode = syncNodeAcquire(rid);
- if (pSyncNode == NULL) {
- return -1;
- }
- ASSERT(rid == pSyncNode->rid);
-
- SSyncRaftEntry* pEntry = NULL;
- int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index, &pEntry);
- if (code != 0) {
- if (pEntry != NULL) {
- syncEntryDestroy(pEntry);
- }
- syncNodeRelease(pSyncNode);
- return -1;
- }
- ASSERT(pEntry != NULL);
-
- pSnapshot->data = NULL;
- pSnapshot->lastApplyIndex = index;
- pSnapshot->lastApplyTerm = pEntry->term;
- pSnapshot->lastConfigIndex = syncNodeGetSnapshotConfigIndex(pSyncNode, index);
-
- syncEntryDestroy(pEntry);
- syncNodeRelease(pSyncNode);
- return 0;
-}
-
-int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta) {
- SSyncNode* pSyncNode = syncNodeAcquire(rid);
- if (pSyncNode == NULL) {
- return -1;
- }
- ASSERT(rid == pSyncNode->rid);
- sMeta->lastConfigIndex = pSyncNode->raftCfg.lastConfigIndex;
-
- sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->raftCfg.lastConfigIndex);
-
- syncNodeRelease(pSyncNode);
- return 0;
-}
-
-int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct SSnapshotMeta* sMeta) {
- SSyncNode* pSyncNode = syncNodeAcquire(rid);
- if (pSyncNode == NULL) {
- return -1;
- }
- ASSERT(rid == pSyncNode->rid);
-
- ASSERT(pSyncNode->raftCfg.configIndexCount >= 1);
- SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0];
-
- for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) {
- if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex &&
- (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotIndex) {
- lastIndex = (pSyncNode->raftCfg.configIndexArr)[i];
- }
- }
- sMeta->lastConfigIndex = lastIndex;
- sTrace("vgId:%d, get snapshot meta by index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, snapshotIndex,
- sMeta->lastConfigIndex);
-
- syncNodeRelease(pSyncNode);
- return 0;
-}
-#endif
-
SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) {
ASSERT(pSyncNode->raftCfg.configIndexCount >= 1);
SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0];
@@ -828,7 +756,7 @@ int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) {
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
if (lastVer < commitIndex || firstVer > commitIndex + 1) {
if (pNode->pLogStore->syncLogRestoreFromSnapshot(pNode->pLogStore, commitIndex)) {
- sError("vgId:%d, failed to restore log store from snapshot since %s. lastVer: %" PRId64 ", snapshotVer: %" PRId64,
+ sError("vgId:%d, failed to restore log store from snapshot since %s. lastVer:%" PRId64 ", snapshotVer:%" PRId64,
pNode->vgId, terrstr(), lastVer, commitIndex);
return -1;
}
@@ -1042,9 +970,12 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pSyncNode->commitIndex = commitIndex;
sInfo("vgId:%d, sync node commitIndex initialized as %" PRId64, pSyncNode->vgId, pSyncNode->commitIndex);
+ // restore log store on need
if (syncNodeLogStoreRestoreOnNeed(pSyncNode) < 0) {
+ sError("vgId:%d, failed to restore log store since %s.", pSyncNode->vgId, terrstr());
goto _error;
}
+
// timer ms init
pSyncNode->pingBaseLine = PING_TIMER_MS;
pSyncNode->electBaseLine = tsElectInterval;
@@ -1107,10 +1038,16 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pSyncNode->changing = false;
// replication mgr
- syncNodeLogReplMgrInit(pSyncNode);
+ if (syncNodeLogReplMgrInit(pSyncNode) < 0) {
+ sError("vgId:%d, failed to init repl mgr since %s.", pSyncNode->vgId, terrstr());
+ goto _error;
+ }
// peer state
- syncNodePeerStateInit(pSyncNode);
+ if (syncNodePeerStateInit(pSyncNode) < 0) {
+ sError("vgId:%d, failed to init peer stat since %s.", pSyncNode->vgId, terrstr());
+ goto _error;
+ }
//
// min match index
@@ -1175,7 +1112,7 @@ int32_t syncNodeRestore(SSyncNode* pSyncNode) {
SyncIndex endIndex = pSyncNode->pLogBuf->endIndex;
if (lastVer != -1 && endIndex != lastVer + 1) {
terrno = TSDB_CODE_WAL_LOG_INCOMPLETE;
- sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex: %" PRId64 ", lastVer: %" PRId64 "",
+ sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex:%" PRId64 ", lastVer:%" PRId64 "",
pSyncNode->vgId, terrstr(), endIndex - 1, lastVer);
return -1;
}
@@ -1205,27 +1142,10 @@ int32_t syncNodeStart(SSyncNode* pSyncNode) {
int32_t ret = 0;
ret = syncNodeStartPingTimer(pSyncNode);
- ASSERT(ret == 0);
- return ret;
-}
-
-void syncNodeStartOld(SSyncNode* pSyncNode) {
- // start raft
- if (pSyncNode->replicaNum == 1) {
- raftStoreNextTerm(pSyncNode);
- syncNodeBecomeLeader(pSyncNode, "one replica start");
-
- // Raft 3.6.2 Committing entries from previous terms
- syncNodeAppendNoop(pSyncNode);
- syncMaybeAdvanceCommitIndex(pSyncNode);
-
- } else {
- syncNodeBecomeFollower(pSyncNode, "first start");
+ if (ret != 0) {
+ sError("vgId:%d, failed to start ping timer since %s", pSyncNode->vgId, terrstr());
}
-
- int32_t ret = 0;
- ret = syncNodeStartPingTimer(pSyncNode);
- ASSERT(ret == 0);
+ return ret;
}
int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) {
@@ -1236,11 +1156,16 @@ int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) {
// reset elect timer, long enough
int32_t electMS = TIMER_MAX_MS;
int32_t ret = syncNodeRestartElectTimer(pSyncNode, electMS);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ sError("vgId:%d, failed to restart elect timer since %s", pSyncNode->vgId, terrstr());
+ return -1;
+ }
- ret = 0;
ret = syncNodeStartPingTimer(pSyncNode);
- ASSERT(ret == 0);
+ if (ret < 0) {
+ sError("vgId:%d, failed to start ping timer since %s", pSyncNode->vgId, terrstr());
+ return -1;
+ }
return ret;
}
@@ -1829,12 +1754,6 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
pSyncNode->leaderCache = pSyncNode->myRaftId;
for (int32_t i = 0; i < pSyncNode->pNextIndex->replicaNum; ++i) {
- // maybe overwrite myself, no harm
- // just do it!
-
- // pSyncNode->pNextIndex->index[i] = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1;
-
- // maybe wal is deleted
SyncIndex lastIndex;
SyncTerm lastTerm;
int32_t code = syncNodeGetLastIndexTerm(pSyncNode, &lastIndex, &lastTerm);
@@ -1896,7 +1815,11 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
- ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted));
+ bool granted = voteGrantedMajority(pSyncNode->pVotesGranted);
+ if (!granted) {
+ sError("vgId:%d, not granted by majority.", pSyncNode->vgId);
+ return;
+ }
syncNodeBecomeLeader(pSyncNode, "candidate to leader");
sNTrace(pSyncNode, "state change syncNodeCandidate2Leader");
@@ -1908,24 +1831,10 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
ASSERT(lastIndex >= 0);
- sInfo("vgId:%d, become leader. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64 "",
+ sInfo("vgId:%d, become leader. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64 "",
pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex);
}
-void syncNodeCandidate2LeaderOld(SSyncNode* pSyncNode) {
- ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
- ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted));
- syncNodeBecomeLeader(pSyncNode, "candidate to leader");
-
- // Raft 3.6.2 Committing entries from previous terms
- syncNodeAppendNoop(pSyncNode);
- syncMaybeAdvanceCommitIndex(pSyncNode);
-
- if (pSyncNode->replicaNum > 1) {
- syncNodeReplicate(pSyncNode);
- }
-}
-
bool syncNodeIsMnode(SSyncNode* pSyncNode) { return (pSyncNode->vgId == 1); }
int32_t syncNodePeerStateInit(SSyncNode* pSyncNode) {
@@ -1941,7 +1850,7 @@ void syncNodeFollower2Candidate(SSyncNode* pSyncNode) {
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER);
pSyncNode->state = TAOS_SYNC_STATE_CANDIDATE;
SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
- sInfo("vgId:%d, become candidate from follower. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64,
+ sInfo("vgId:%d, become candidate from follower. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64,
pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex);
sNTrace(pSyncNode, "follower to candidate");
@@ -1951,7 +1860,7 @@ void syncNodeLeader2Follower(SSyncNode* pSyncNode) {
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_LEADER);
syncNodeBecomeFollower(pSyncNode, "leader to follower");
SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
- sInfo("vgId:%d, become follower from leader. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64,
+ sInfo("vgId:%d, become follower from leader. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64,
pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex);
sNTrace(pSyncNode, "leader to follower");
@@ -1961,7 +1870,7 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) {
ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
syncNodeBecomeFollower(pSyncNode, "candidate to follower");
SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
- sInfo("vgId:%d, become follower from candidate. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64,
+ sInfo("vgId:%d, become follower from candidate. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64,
pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex);
sNTrace(pSyncNode, "candidate to follower");
@@ -1971,7 +1880,8 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) {
// need assert
void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) {
ASSERT(term == pSyncNode->raftStore.currentTerm);
- ASSERT(!raftStoreHasVoted(pSyncNode));
+ bool voted = raftStoreHasVoted(pSyncNode);
+ ASSERT(!voted);
raftStoreVote(pSyncNode, pRaftId);
}
@@ -2400,7 +2310,7 @@ int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) {
// proceed match index, with replicating on needed
SyncIndex matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, NULL);
- sTrace("vgId:%d, append raft entry. index: %" PRId64 ", term: %" PRId64 " pBuf: [%" PRId64 " %" PRId64 " %" PRId64
+ sTrace("vgId:%d, append raft entry. index:%" PRId64 ", term:%" PRId64 " pBuf: [%" PRId64 " %" PRId64 " %" PRId64
", %" PRId64 ")",
ths->vgId, pEntry->index, pEntry->term, ths->pLogBuf->startIndex, ths->pLogBuf->commitIndex,
ths->pLogBuf->matchIndex, ths->pLogBuf->endIndex);
@@ -2573,7 +2483,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
sError("vgId:%d, sync enqueue step-down msg error, code:%d", ths->vgId, code);
rpcFreeCont(rpcMsgLocalCmd.pCont);
} else {
- sTrace("vgId:%d, sync enqueue step-down msg, new-term: %" PRId64, ths->vgId, pSyncMsg->currentTerm);
+ sTrace("vgId:%d, sync enqueue step-down msg, new-term:%" PRId64, ths->vgId, pSyncMsg->currentTerm);
}
}
}
@@ -2639,7 +2549,7 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
(void)syncNodeUpdateCommitIndex(ths, pMsg->commitIndex);
}
if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) {
- sError("vgId:%d, failed to commit raft log since %s. commit index: %" PRId64 "", ths->vgId, terrstr(),
+ sError("vgId:%d, failed to commit raft log since %s. commit index:%" PRId64 "", ths->vgId, terrstr(),
ths->commitIndex);
}
} else {
@@ -2649,24 +2559,6 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
return 0;
}
-int32_t syncNodeOnLocalCmdOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
- ASSERT(false && "deprecated");
- SyncLocalCmd* pMsg = pRpcMsg->pCont;
- syncLogRecvLocalCmd(ths, pMsg, "");
-
- if (pMsg->cmd == SYNC_LOCAL_CMD_STEP_DOWN) {
- syncNodeStepDown(ths, pMsg->currentTerm);
-
- } else if (pMsg->cmd == SYNC_LOCAL_CMD_FOLLOWER_CMT) {
- syncNodeFollowerCommit(ths, pMsg->commitIndex);
-
- } else {
- sError("error local cmd");
- }
-
- return 0;
-}
-
// TLA+ Spec
// ClientRequest(i, v) ==
// /\ state[i] = Leader
@@ -2711,96 +2603,6 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn
}
}
-int32_t syncNodeOnClientRequestOld(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIndex) {
- sNTrace(ths, "on client request");
-
- int32_t ret = 0;
- int32_t code = 0;
-
- SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore);
- SyncTerm term = ths->raftStore.currentTerm;
- SSyncRaftEntry* pEntry;
-
- if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
- pEntry = syncEntryBuildFromClientRequest(pMsg->pCont, term, index);
- } else {
- pEntry = syncEntryBuildFromRpcMsg(pMsg, term, index);
- }
-
- LRUHandle* h = NULL;
-
- if (ths->state == TAOS_SYNC_STATE_LEADER) {
- // append entry
- code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry, false);
- if (code != 0) {
- if (ths->replicaNum == 1) {
- if (h) {
- taosLRUCacheRelease(ths->pLogStore->pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
-
- return -1;
-
- } else {
- // del resp mgr, call FpCommitCb
- SFsmCbMeta cbMeta = {
- .index = pEntry->index,
- .lastConfigIndex = SYNC_INDEX_INVALID,
- .isWeak = pEntry->isWeak,
- .code = -1,
- .state = ths->state,
- .seqNum = pEntry->seqNum,
- .term = pEntry->term,
- .currentTerm = ths->raftStore.currentTerm,
- .flag = 0,
- };
- ths->pFsm->FpCommitCb(ths->pFsm, pMsg, &cbMeta);
-
- if (h) {
- taosLRUCacheRelease(ths->pLogStore->pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
-
- return -1;
- }
- }
-
- syncCacheEntry(ths->pLogStore, pEntry, &h);
-
- // if mulit replica, start replicate right now
- if (ths->replicaNum > 1) {
- syncNodeReplicate(ths);
- }
-
- // if only myself, maybe commit right now
- if (ths->replicaNum == 1) {
- if (syncNodeIsMnode(ths)) {
- syncMaybeAdvanceCommitIndex(ths);
- } else {
- syncOneReplicaAdvance(ths);
- }
- }
- }
-
- if (pRetIndex != NULL) {
- if (ret == 0 && pEntry != NULL) {
- *pRetIndex = pEntry->index;
- } else {
- *pRetIndex = SYNC_INDEX_INVALID;
- }
- }
-
- if (h) {
- taosLRUCacheRelease(ths->pLogStore->pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
-
- return ret;
-}
-
const char* syncStr(ESyncState state) {
switch (state) {
case TAOS_SYNC_STATE_FOLLOWER:
@@ -2905,129 +2707,6 @@ bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) {
return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType) && ths->vgId != 1);
}
-int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) {
- ASSERT(false);
- if (beginIndex > endIndex) {
- return 0;
- }
-
- if (ths == NULL) {
- return -1;
- }
-
- if (ths->pFsm != NULL && ths->pFsm->FpGetSnapshotInfo != NULL) {
- // advance commit index to sanpshot first
- SSnapshot snapshot = {0};
- ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot);
- if (snapshot.lastApplyIndex >= 0 && snapshot.lastApplyIndex >= beginIndex) {
- sNTrace(ths, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, beginIndex, snapshot.lastApplyIndex);
-
- // update begin index
- beginIndex = snapshot.lastApplyIndex + 1;
- }
- }
-
- int32_t code = 0;
- ESyncState state = flag;
-
- sNTrace(ths, "commit by wal from index:%" PRId64 " to index:%" PRId64, beginIndex, endIndex);
-
- // execute fsm
- if (ths->pFsm != NULL) {
- for (SyncIndex i = beginIndex; i <= endIndex; ++i) {
- if (i != SYNC_INDEX_INVALID) {
- SSyncRaftEntry* pEntry;
- SLRUCache* pCache = ths->pLogStore->pCache;
- LRUHandle* h = taosLRUCacheLookup(pCache, &i, sizeof(i));
- if (h) {
- pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h);
-
- ths->pLogStore->cacheHit++;
- sNTrace(ths, "hit cache index:%" PRId64 ", bytes:%u, %p", i, pEntry->bytes, pEntry);
-
- } else {
- ths->pLogStore->cacheMiss++;
- sNTrace(ths, "miss cache index:%" PRId64, i);
-
- code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry);
- // ASSERT(code == 0);
- // ASSERT(pEntry != NULL);
- if (code != 0 || pEntry == NULL) {
- sNError(ths, "get log entry error");
- sFatal("vgId:%d, get log entry %" PRId64 " error when commit since %s", ths->vgId, i, terrstr());
- continue;
- }
- }
-
- SRpcMsg rpcMsg = {0};
- syncEntry2OriginalRpc(pEntry, &rpcMsg);
-
- sTrace("do commit index:%" PRId64 ", type:%s", i, TMSG_INFO(pEntry->msgType));
-
- // user commit
- if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) {
- bool internalExecute = true;
- if ((ths->replicaNum == 1) && ths->restoreFinish && ths->vgId != 1) {
- internalExecute = false;
- }
-
- sNTrace(ths, "user commit index:%" PRId64 ", internal:%d, type:%s", i, internalExecute,
- TMSG_INFO(pEntry->msgType));
-
- // execute fsm in apply thread, or execute outside syncPropose
- if (internalExecute) {
- SFsmCbMeta cbMeta = {
- .index = pEntry->index,
- .lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, pEntry->index),
- .isWeak = pEntry->isWeak,
- .code = 0,
- .state = ths->state,
- .seqNum = pEntry->seqNum,
- .term = pEntry->term,
- .currentTerm = ths->raftStore.currentTerm,
- .flag = flag,
- };
-
- syncRespMgrGetAndDel(ths->pSyncRespMgr, cbMeta.seqNum, &rpcMsg.info);
- ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, &cbMeta);
- }
- }
-
-#if 0
- // execute in pre-commit
- // leader transfer
- if (pEntry->originalRpcType == TDMT_SYNC_LEADER_TRANSFER) {
- code = syncDoLeaderTransfer(ths, &rpcMsg, pEntry);
- ASSERT(code == 0);
- }
-#endif
-
- // restore finish
- // if only snapshot, a noop entry will be append, so syncLogLastIndex is always ok
- if (pEntry->index == ths->pLogStore->syncLogLastIndex(ths->pLogStore)) {
- if (ths->restoreFinish == false) {
- if (ths->pFsm->FpRestoreFinishCb != NULL) {
- ths->pFsm->FpRestoreFinishCb(ths->pFsm);
- }
- ths->restoreFinish = true;
-
- int64_t restoreDelay = taosGetTimestampMs() - ths->leaderTime;
- sNTrace(ths, "restore finish, index:%" PRId64 ", elapsed:%" PRId64 " ms", pEntry->index, restoreDelay);
- }
- }
-
- rpcFreeCont(rpcMsg.pCont);
- if (h) {
- taosLRUCacheRelease(pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
- }
- }
- }
- return 0;
-}
-
bool syncNodeInRaftGroup(SSyncNode* ths, SRaftId* pRaftId) {
for (int32_t i = 0; i < ths->replicaNum; ++i) {
if (syncUtilSameId(&((ths->replicasId)[i]), pRaftId)) {
diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c
index 1d2b0b57fed915ff5a2731f936b91a72140c6142..b3eb5684cfc1435384ba656322e5f656cdbfc2de 100644
--- a/source/libs/sync/src/syncPipeline.c
+++ b/source/libs/sync/src/syncPipeline.c
@@ -132,16 +132,16 @@ SSyncRaftEntry* syncEntryBuildDummy(SyncTerm term, SyncIndex index, int32_t vgId
int32_t syncLogValidateAlignmentOfCommit(SSyncNode* pNode, SyncIndex commitIndex) {
SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore);
if (firstVer > commitIndex + 1) {
- sError("vgId:%d, firstVer of WAL log greater than tsdb commit version + 1. firstVer: %" PRId64
- ", tsdb commit version: %" PRId64 "",
+ sError("vgId:%d, firstVer of WAL log greater than tsdb commit version + 1. firstVer:%" PRId64
+ ", tsdb commit version:%" PRId64 "",
pNode->vgId, firstVer, commitIndex);
return -1;
}
SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore);
if (lastVer < commitIndex) {
- sError("vgId:%d, lastVer of WAL log less than tsdb commit version. lastVer: %" PRId64
- ", tsdb commit version: %" PRId64 "",
+ sError("vgId:%d, lastVer of WAL log less than tsdb commit version. lastVer:%" PRId64
+ ", tsdb commit version:%" PRId64 "",
pNode->vgId, lastVer, commitIndex);
return -1;
}
@@ -293,7 +293,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
bool inBuf = true;
if (index <= pBuf->commitIndex) {
- sTrace("vgId:%d, already committed. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64
+ sTrace("vgId:%d, already committed. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64
" %" PRId64 ", %" PRId64 ")",
pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex,
pBuf->endIndex);
@@ -306,7 +306,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
}
if (index - pBuf->startIndex >= pBuf->size) {
- sWarn("vgId:%d, out of buffer range. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64
+ sWarn("vgId:%d, out of buffer range. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64
" %" PRId64 ", %" PRId64 ")",
pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex,
pBuf->endIndex);
@@ -314,8 +314,8 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
}
if (index > pBuf->matchIndex && lastMatchTerm != prevTerm) {
- sWarn("vgId:%d, not ready to accept. index: %" PRId64 ", term: %" PRId64 ": prevterm: %" PRId64
- " != lastmatch: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")",
+ sWarn("vgId:%d, not ready to accept. index:%" PRId64 ", term:%" PRId64 ": prevterm:%" PRId64
+ " != lastmatch:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")",
pNode->vgId, pEntry->index, pEntry->term, prevTerm, lastMatchTerm, pBuf->startIndex, pBuf->commitIndex,
pBuf->matchIndex, pBuf->endIndex);
goto _out;
@@ -328,7 +328,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
if (pEntry->term != pExist->term) {
(void)syncLogBufferRollback(pBuf, pNode, index);
} else {
- sTrace("vgId:%d, duplicate log entry received. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64
+ sTrace("vgId:%d, duplicate log entry received. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64
" %" PRId64 " %" PRId64 ", %" PRId64 ")",
pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex,
pBuf->endIndex);
@@ -434,7 +434,7 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p
// increase match index
pBuf->matchIndex = index;
- sTrace("vgId:%d, log buffer proceed. start index: %" PRId64 ", match index: %" PRId64 ", end index: %" PRId64,
+ sTrace("vgId:%d, log buffer proceed. start index:%" PRId64 ", match index:%" PRId64 ", end index:%" PRId64,
pNode->vgId, pBuf->startIndex, pBuf->matchIndex, pBuf->endIndex);
// replicate on demand
@@ -475,7 +475,7 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn
}
if (pEntry->originalRpcType == TDMT_VND_COMMIT) {
- sInfo("vgId:%d, fsm execute vnode commit. index: %" PRId64 ", term: %" PRId64 "", pNode->vgId, pEntry->index,
+ sInfo("vgId:%d, fsm execute vnode commit. index:%" PRId64 ", term:%" PRId64 "", pNode->vgId, pEntry->index,
pEntry->term);
}
@@ -528,7 +528,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
goto _out;
}
- sTrace("vgId:%d, commit. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 "), role: %d, term: %" PRId64,
+ sTrace("vgId:%d, commit. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 "), role:%d, term:%" PRId64,
pNode->vgId, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex, role, term);
// execute in fsm
@@ -541,19 +541,19 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
// execute it
if (!syncUtilUserCommit(pEntry->originalRpcType)) {
- sInfo("vgId:%d, commit sync barrier. index: %" PRId64 ", term:%" PRId64 ", type: %s", vgId, pEntry->index,
+ sInfo("vgId:%d, commit sync barrier. index:%" PRId64 ", term:%" PRId64 ", type:%s", vgId, pEntry->index,
pEntry->term, TMSG_INFO(pEntry->originalRpcType));
}
if (syncLogFsmExecute(pNode, pFsm, role, term, pEntry, 0) != 0) {
sError("vgId:%d, failed to execute sync log entry. index:%" PRId64 ", term:%" PRId64
- ", role: %d, current term: %" PRId64,
+ ", role:%d, current term:%" PRId64,
vgId, pEntry->index, pEntry->term, role, term);
goto _out;
}
pBuf->commitIndex = index;
- sTrace("vgId:%d, committed index: %" PRId64 ", term: %" PRId64 ", role: %d, current term: %" PRId64 "", pNode->vgId,
+ sTrace("vgId:%d, committed index:%" PRId64 ", term:%" PRId64 ", role:%d, current term:%" PRId64 "", pNode->vgId,
pEntry->index, pEntry->term, role, term);
if (!inBuf) {
@@ -614,7 +614,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
SRaftId* pDestId = &pNode->replicasId[pMgr->peerId];
if (pMgr->retryBackoff == SYNC_MAX_RETRY_BACKOFF) {
syncLogReplMgrReset(pMgr);
- sWarn("vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer: %" PRIx64, pNode->vgId,
+ sWarn("vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer:%" PRIx64, pNode->vgId,
pDestId->addr);
return -1;
}
@@ -639,7 +639,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
if (pMgr->states[pos].acked) {
if (pMgr->matchIndex < index && pMgr->states[pos].timeMs + (syncGetRetryMaxWaitMs() << 3) < nowMs) {
syncLogReplMgrReset(pMgr);
- sWarn("vgId:%d, reset sync log repl mgr since stagnation. index: %" PRId64 ", peer: %" PRIx64, pNode->vgId,
+ sWarn("vgId:%d, reset sync log repl mgr since stagnation. index:%" PRId64 ", peer:%" PRIx64, pNode->vgId,
index, pDestId->addr);
goto _out;
}
@@ -648,7 +648,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
bool barrier = false;
if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) {
- sError("vgId:%d, failed to replicate sync log entry since %s. index: %" PRId64 ", dest: %" PRIx64 "", pNode->vgId,
+ sError("vgId:%d, failed to replicate sync log entry since %s. index:%" PRId64 ", dest:%" PRIx64 "", pNode->vgId,
terrstr(), index, pDestId->addr);
goto _out;
}
@@ -670,8 +670,8 @@ _out:
if (retried) {
pMgr->retryBackoff = syncLogGetNextRetryBackoff(pMgr);
SSyncLogBuffer* pBuf = pNode->pLogBuf;
- sInfo("vgId:%d, resend %d sync log entries. dest: %" PRIx64 ", indexes: %" PRId64 " ..., terms: ... %" PRId64
- ", retryWaitMs: %" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64
+ sInfo("vgId:%d, resend %d sync log entries. dest:%" PRIx64 ", indexes:%" PRId64 " ..., terms: ... %" PRId64
+ ", retryWaitMs:%" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64
" %" PRId64 ", %" PRId64 ")",
pNode->vgId, count, pDestId->addr, firstIndex, term, retryWaitMs, pMgr->startIndex, pMgr->matchIndex,
pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex);
@@ -714,7 +714,7 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p
}
if (pMsg->success == false && pMsg->matchIndex >= pMsg->lastSendIndex) {
- sWarn("vgId:%d, failed to rollback match index. peer: dnode:%d, match index: %" PRId64 ", last sent: %" PRId64,
+ sWarn("vgId:%d, failed to rollback match index. peer: dnode:%d, match index:%" PRId64 ", last sent:%" PRId64,
pNode->vgId, DID(&destId), pMsg->matchIndex, pMsg->lastSendIndex);
if (syncNodeStartSnapshot(pNode, &destId) < 0) {
sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId));
@@ -761,7 +761,7 @@ int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pN
SSyncLogBuffer* pBuf = pNode->pLogBuf;
taosThreadMutexLock(&pBuf->mutex);
if (pMsg->startTime != 0 && pMsg->startTime != pMgr->peerStartTime) {
- sInfo("vgId:%d, reset sync log repl mgr in heartbeat. peer: %" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "",
+ sInfo("vgId:%d, reset sync log repl mgr in heartbeat. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "",
pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime);
syncLogReplMgrReset(pMgr);
pMgr->peerStartTime = pMsg->startTime;
@@ -774,7 +774,7 @@ int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sync
SSyncLogBuffer* pBuf = pNode->pLogBuf;
taosThreadMutexLock(&pBuf->mutex);
if (pMsg->startTime != pMgr->peerStartTime) {
- sInfo("vgId:%d, reset sync log repl mgr in appendlog reply. peer: %" PRIx64 ", start time:%" PRId64
+ sInfo("vgId:%d, reset sync log repl mgr in appendlog reply. peer:%" PRIx64 ", start time:%" PRId64
", old:%" PRId64,
pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime);
syncLogReplMgrReset(pMgr);
@@ -815,7 +815,7 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy
bool barrier = false;
SyncTerm term = -1;
if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) {
- sError("vgId:%d, failed to replicate log entry since %s. index: %" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId,
+ sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId,
terrstr(), index, pDestId->addr);
return -1;
}
@@ -830,7 +830,7 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy
pMgr->endIndex = index + 1;
SSyncLogBuffer* pBuf = pNode->pLogBuf;
- sInfo("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term: %" PRId64 ". mgr (rs:%d): [%" PRId64
+ sTrace("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term:%" PRId64 ". mgr (rs:%d): [%" PRId64
" %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")",
pNode->vgId, pDestId->addr, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex,
pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex);
@@ -860,7 +860,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode)
bool barrier = false;
SyncTerm term = -1;
if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) {
- sError("vgId:%d, failed to replicate log entry since %s. index: %" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId,
+ sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId,
terrstr(), index, pDestId->addr);
return -1;
}
@@ -874,7 +874,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode)
pMgr->endIndex = index + 1;
if (barrier) {
- sInfo("vgId:%d, replicated sync barrier to dest: %" PRIx64 ". index: %" PRId64 ", term: %" PRId64
+ sInfo("vgId:%d, replicated sync barrier to dest:%" PRIx64 ". index:%" PRId64 ", term:%" PRId64
", repl mgr: rs(%d) [%" PRId64 " %" PRId64 ", %" PRId64 ")",
pNode->vgId, pDestId->addr, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex,
pMgr->endIndex);
@@ -885,7 +885,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode)
syncLogReplMgrRetryOnNeed(pMgr, pNode);
SSyncLogBuffer* pBuf = pNode->pLogBuf;
- sTrace("vgId:%d, replicated %d msgs to peer: %" PRIx64 ". indexes: %" PRId64 "..., terms: ...%" PRId64
+ sTrace("vgId:%d, replicated %d msgs to peer:%" PRIx64 ". indexes:%" PRId64 "..., terms: ...%" PRId64
", mgr: (rs:%d) [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64
")",
pNode->vgId, count, pDestId->addr, firstIndex, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex,
@@ -945,8 +945,11 @@ int32_t syncNodeLogReplMgrInit(SSyncNode* pNode) {
for (int i = 0; i < TSDB_MAX_REPLICA; i++) {
ASSERT(pNode->logReplMgrs[i] == NULL);
pNode->logReplMgrs[i] = syncLogReplMgrCreate();
+ if (pNode->logReplMgrs[i] == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return -1;
+ }
pNode->logReplMgrs[i]->peerId = i;
- ASSERTS(pNode->logReplMgrs[i] != NULL, "Out of memory.");
}
return 0;
}
@@ -1025,7 +1028,7 @@ int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex
return 0;
}
- sInfo("vgId:%d, rollback sync log buffer. toindex: %" PRId64 ", buffer: [%" PRId64 " %" PRId64 " %" PRId64
+ sInfo("vgId:%d, rollback sync log buffer. toindex:%" PRId64 ", buffer: [%" PRId64 " %" PRId64 " %" PRId64
", %" PRId64 ")",
pNode->vgId, toIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex);
@@ -1116,11 +1119,11 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy
pEntry = syncLogBufferGetOneEntry(pBuf, pNode, index, &inBuf);
if (pEntry == NULL) {
- sError("vgId:%d, failed to get raft entry for index: %" PRId64 "", pNode->vgId, index);
+ sError("vgId:%d, failed to get raft entry for index:%" PRId64 "", pNode->vgId, index);
if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(pNode, pDestId);
if (pMgr) {
- sInfo("vgId:%d, reset sync log repl mgr of peer: %" PRIx64 " since %s. index: %" PRId64, pNode->vgId,
+ sInfo("vgId:%d, reset sync log repl mgr of peer:%" PRIx64 " since %s. index:%" PRId64, pNode->vgId,
pDestId->addr, terrstr(), index);
(void)syncLogReplMgrReset(pMgr);
}
@@ -1131,7 +1134,7 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy
prevLogTerm = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index);
if (prevLogTerm < 0) {
- sError("vgId:%d, failed to get prev log term since %s. index: %" PRId64 "", pNode->vgId, terrstr(), index);
+ sError("vgId:%d, failed to get prev log term since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index);
goto _err;
}
if (pTerm) *pTerm = pEntry->term;
@@ -1144,7 +1147,7 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy
(void)syncNodeSendAppendEntries(pNode, pDestId, &msgOut);
- sTrace("vgId:%d, replicate one msg index: %" PRId64 " term: %" PRId64 " prevterm: %" PRId64 " to dest: 0x%016" PRIx64,
+ sTrace("vgId:%d, replicate one msg index:%" PRId64 " term:%" PRId64 " prevterm:%" PRId64 " to dest: 0x%016" PRIx64,
pNode->vgId, pEntry->index, pEntry->term, prevLogTerm, pDestId->addr);
if (!inBuf) {
diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c
index 988a86cc67eaad387a1657396e8eaa3859e8e20d..623f1b77a428806a859c4ba5ffc42404ad9d0c84 100644
--- a/source/libs/sync/src/syncRaftEntry.c
+++ b/source/libs/sync/src/syncRaftEntry.c
@@ -91,7 +91,7 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId)
void syncEntryDestroy(SSyncRaftEntry* pEntry) {
if (pEntry != NULL) {
- sTrace("free entry: %p", pEntry);
+ sTrace("free entry:%p", pEntry);
taosMemoryFree(pEntry);
}
}
diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c
index e6569d99741f762c593c557751e800f11b6c150e..92996519991619ccebad62865a36a62dd5bd7d34 100644
--- a/source/libs/sync/src/syncRaftLog.c
+++ b/source/libs/sync/src/syncRaftLog.c
@@ -249,6 +249,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
int64_t ts2 = taosGetTimestampNs();
code = walReadVer(pWalHandle, index);
+ walReadReset(pWalHandle);
int64_t ts3 = taosGetTimestampNs();
// code = walReadVerCached(pWalHandle, index);
diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c
index 1aa476e84e03ab46a925085ff7792ca88b0af5b4..3df203221b88bbd0b9d804613e2ea50e881be149 100644
--- a/source/libs/sync/src/syncReplication.c
+++ b/source/libs/sync/src/syncReplication.c
@@ -48,92 +48,6 @@
int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg);
-int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapshot) {
- ASSERT(false && "deprecated");
- // next index
- SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId);
-
- if (snapshot) {
- // maybe start snapshot
- SyncIndex logStartIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore);
- SyncIndex logEndIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore);
- if (nextIndex < logStartIndex || nextIndex - 1 > logEndIndex) {
- sNTrace(pSyncNode, "maybe start snapshot for next-index:%" PRId64 ", start:%" PRId64 ", end:%" PRId64, nextIndex,
- logStartIndex, logEndIndex);
- // start snapshot
- int32_t code = syncNodeStartSnapshot(pSyncNode, pDestId);
- }
- }
-
- // pre index, pre term
- SyncIndex preLogIndex = syncNodeGetPreIndex(pSyncNode, nextIndex);
- SyncTerm preLogTerm = syncNodeGetPreTerm(pSyncNode, nextIndex);
-
- // prepare entry
- SRpcMsg rpcMsg = {0};
- SyncAppendEntries* pMsg = NULL;
-
- SSyncRaftEntry* pEntry = NULL;
- SLRUCache* pCache = pSyncNode->pLogStore->pCache;
- LRUHandle* h = taosLRUCacheLookup(pCache, &nextIndex, sizeof(nextIndex));
- int32_t code = 0;
- if (h) {
- pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h);
- code = 0;
-
- pSyncNode->pLogStore->cacheHit++;
- sNTrace(pSyncNode, "hit cache index:%" PRId64 ", bytes:%u, %p", nextIndex, pEntry->bytes, pEntry);
-
- } else {
- pSyncNode->pLogStore->cacheMiss++;
- sNTrace(pSyncNode, "miss cache index:%" PRId64, nextIndex);
-
- code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, nextIndex, &pEntry);
- }
-
- if (code == 0) {
- ASSERT(pEntry != NULL);
-
- code = syncBuildAppendEntries(&rpcMsg, (int32_t)(pEntry->bytes), pSyncNode->vgId);
- ASSERT(code == 0);
-
- pMsg = rpcMsg.pCont;
- memcpy(pMsg->data, pEntry, pEntry->bytes);
- } else {
- if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) {
- // no entry in log
- code = syncBuildAppendEntries(&rpcMsg, 0, pSyncNode->vgId);
- ASSERT(code == 0);
-
- pMsg = rpcMsg.pCont;
- } else {
- sNError(pSyncNode, "replicate to dnode:%d error, next-index:%" PRId64, DID(pDestId), nextIndex);
- return -1;
- }
- }
-
- if (h) {
- taosLRUCacheRelease(pCache, h, false);
- } else {
- syncEntryDestroy(pEntry);
- }
-
- // prepare msg
- ASSERT(pMsg != NULL);
- pMsg->srcId = pSyncNode->myRaftId;
- pMsg->destId = *pDestId;
- pMsg->term = pSyncNode->raftStore.currentTerm;
- pMsg->prevLogIndex = preLogIndex;
- pMsg->prevLogTerm = preLogTerm;
- pMsg->commitIndex = pSyncNode->commitIndex;
- pMsg->privateTerm = 0;
- // pMsg->privateTerm = syncIndexMgrGetTerm(pSyncNode->pNextIndex, pDestId);
-
- // send msg
- syncNodeMaybeSendAppendEntries(pSyncNode, pDestId, &rpcMsg);
- return 0;
-}
-
int32_t syncNodeReplicate(SSyncNode* pNode) {
SSyncLogBuffer* pBuf = pNode->pLogBuf;
taosThreadMutexLock(&pBuf->mutex);
@@ -156,25 +70,6 @@ int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) {
return 0;
}
-int32_t syncNodeReplicateOld(SSyncNode* pSyncNode) {
- if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) {
- return -1;
- }
-
- sNTrace(pSyncNode, "do replicate");
-
- int32_t ret = 0;
- for (int i = 0; i < pSyncNode->peersNum; ++i) {
- SRaftId* pDestId = &(pSyncNode->peersId[i]);
- ret = syncNodeReplicateOne(pSyncNode, pDestId, true);
- if (ret != 0) {
- sError("vgId:%d, do append entries error for dnode:%d", pSyncNode->vgId, DID(pDestId));
- }
- }
-
- return 0;
-}
-
int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) {
SyncAppendEntries* pMsg = pRpcMsg->pCont;
pMsg->destId = *destRaftId;
@@ -182,39 +77,6 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI
return 0;
}
-int32_t syncNodeSendAppendEntriesOld(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) {
- int32_t ret = 0;
- SyncAppendEntries* pMsg = pRpcMsg->pCont;
- if (pMsg == NULL) {
- sError("vgId:%d, sync-append-entries msg is NULL", pSyncNode->vgId);
- return 0;
- }
-
- SPeerState* pState = syncNodeGetPeerState(pSyncNode, destRaftId);
- if (pState == NULL) {
- sError("vgId:%d, replica maybe dropped", pSyncNode->vgId);
- return 0;
- }
-
- // save index, otherwise pMsg will be free by rpc
- SyncIndex saveLastSendIndex = pState->lastSendIndex;
- bool update = false;
- if (pMsg->dataLen > 0) {
- saveLastSendIndex = pMsg->prevLogIndex + 1;
- update = true;
- }
-
- syncLogSendAppendEntries(pSyncNode, pMsg, "");
- syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg);
-
- if (update) {
- pState->lastSendIndex = saveLastSendIndex;
- pState->lastSendTime = taosGetTimestampMs();
- }
-
- return ret;
-}
-
int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) {
int32_t ret = 0;
SyncAppendEntries* pMsg = pRpcMsg->pCont;
diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c
index 880c76e4ddebe6ff443b59769fdcdb28a477a65f..18f263cc95f7bb9f611cb0a81343b60e7e36d95b 100644
--- a/source/libs/sync/src/syncSnapshot.c
+++ b/source/libs/sync/src/syncSnapshot.c
@@ -112,7 +112,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) {
pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex;
pMsg->lastConfig = pSender->lastConfig;
pMsg->startTime = pSender->startTime;
- pMsg->seq = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT;
+ pMsg->seq = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT;
// event log
syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender start");
@@ -379,7 +379,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p
}
pReceiver->start = true;
- pReceiver->ack = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT;
+ pReceiver->ack = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT;
pReceiver->term = pReceiver->pSyncNode->raftStore.currentTerm;
pReceiver->fromId = pPreMsg->srcId;
pReceiver->startTime = pPreMsg->startTime;
@@ -510,16 +510,8 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) {
SSyncLogStoreData *pData = ths->pLogStore->data;
SWal *pWal = pData->pWal;
- bool isEmpty = ths->pLogStore->syncLogIsEmpty(ths->pLogStore);
int64_t walCommitVer = walGetCommittedVer(pWal);
-
- if (!isEmpty && ths->commitIndex != walCommitVer) {
- sNError(ths, "commit not same, wal-commit:%" PRId64 ", commit:%" PRId64 ", ignore", walCommitVer,
- ths->commitIndex);
- snapStart = walCommitVer + 1;
- } else {
- snapStart = ths->commitIndex + 1;
- }
+ snapStart = TMAX(ths->commitIndex, walCommitVer) + 1;
sNInfo(ths, "snapshot begin index is %" PRId64, snapStart);
}
@@ -527,7 +519,7 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) {
return snapStart;
}
-static int32_t syncNodeOnSnapshotPre(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
+static int32_t syncNodeOnSnapshotPrep(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver;
int64_t timeNow = taosGetTimestampMs();
int32_t code = 0;
@@ -565,7 +557,7 @@ _START_RECEIVER:
} else {
// waiting for clock match
while (timeNow < pMsg->startTime) {
- sRInfo(pReceiver, "snapshot receiver pre waitting for true time, now:%" PRId64 ", stime:%" PRId64, timeNow,
+ sRInfo(pReceiver, "snapshot receiver pre waitting for true time, now:%" PRId64 ", startTime:%" PRId64, timeNow,
pMsg->startTime);
taosMsleep(10);
timeNow = taosGetTimestampMs();
@@ -765,7 +757,7 @@ static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMs
// receiver on message
//
-// condition 1, recv SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT
+// condition 1, recv SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT
// if receiver already start
// if sender.start-time > receiver.start-time, restart receiver(reply snapshot start)
// if sender.start-time = receiver.start-time, maybe duplicate msg
@@ -809,9 +801,9 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
int32_t code = 0;
if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) {
if (pMsg->term == pSyncNode->raftStore.currentTerm) {
- if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) {
+ if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) {
syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq pre-snapshot");
- code = syncNodeOnSnapshotPre(pSyncNode, pMsg);
+ code = syncNodeOnSnapshotPrep(pSyncNode, pMsg);
} else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) {
syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq begin");
code = syncNodeOnSnapshotBegin(pSyncNode, pMsg);
@@ -848,7 +840,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
return code;
}
-static int32_t syncNodeOnSnapshotPreRsp(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) {
+static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) {
SSnapshot snapshot = {0};
pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot);
@@ -945,8 +937,8 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
if (pMsg->startTime != pSender->startTime) {
syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender and receiver time not match");
- sSError(pSender, "sender:%" PRId64 " receiver:%" PRId64 " time not match, code:0x%x", pMsg->startTime,
- pSender->startTime, pMsg->code);
+ sSError(pSender, "sender:%" PRId64 " receiver:%" PRId64 " time not match, error:%s 0x%x", pMsg->startTime,
+ pSender->startTime, tstrerror(pMsg->code), pMsg->code);
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
goto _ERROR;
}
@@ -961,15 +953,15 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
if (pMsg->code != 0) {
syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error code");
- sSError(pSender, "snapshot sender receive error code:0x%x and stop sender", pMsg->code);
+ sSError(pSender, "snapshot sender receive error:%s 0x%x and stop sender", tstrerror(pMsg->code), pMsg->code);
terrno = pMsg->code;
goto _ERROR;
}
// prepare , send begin msg
- if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) {
+ if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) {
syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq pre-snapshot");
- return syncNodeOnSnapshotPreRsp(pSyncNode, pSender, pMsg);
+ return syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg);
}
if (pSender->pReader == NULL || pSender->finish) {
diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c
index b246d9a79d58c153d9e5b12775965929f9ec7adf..97641b8f414dd6afe1aa8243a9bd482f68a6b57c 100644
--- a/source/libs/sync/src/syncUtil.c
+++ b/source/libs/sync/src/syncUtil.c
@@ -43,7 +43,7 @@ void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet) {
bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) {
uint32_t ipv4 = taosGetIpv4FromFqdn(pInfo->nodeFqdn);
if (ipv4 == 0xFFFFFFFF || ipv4 == 1) {
- sError("failed to resolve ipv4 addr, fqdn: %s", pInfo->nodeFqdn);
+ sError("failed to resolve ipv4 addr, fqdn:%s", pInfo->nodeFqdn);
terrno = TSDB_CODE_TSC_INVALID_FQDN;
return false;
}
@@ -141,20 +141,15 @@ static void syncLogReplMgrStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bu
}
static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) {
- int32_t len = 1;
-
+ int32_t len = 0;
+ len += snprintf(buf + len, bufLen - len, "%s", "{");
for (int32_t i = 0; i < pSyncNode->replicaNum; ++i) {
SPeerState* pState = syncNodeGetPeerState(pSyncNode, &(pSyncNode->replicasId[i]));
if (pState == NULL) break;
-
- if (i < pSyncNode->replicaNum - 1) {
- len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 ", ", i, pState->lastSendIndex,
- pState->lastSendTime);
- } else {
- len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 "}", i, pState->lastSendIndex,
- pState->lastSendTime);
- }
+ len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 "%s", i, pState->lastSendIndex,
+ pState->lastSendTime, (i < pSyncNode->replicaNum - 1) ? ", " : "");
}
+ len += snprintf(buf + len, bufLen - len, "%s", "}");
}
void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...) {
@@ -245,7 +240,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
char cfgStr[1024] = "";
syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr));
- char peerStr[1024] = "{";
+ char peerStr[1024] = "";
syncPeerState2Str(pNode, peerStr, sizeof(peerStr));
char eventLog[512]; // {0};
@@ -255,20 +250,21 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
va_end(argpointer);
taosPrintLog(flags, level, dflag,
- "vgId:%d, %s, sync:%s, {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64
- " lcindex:%" PRId64
- " seq:%d ack:%d finish:%d replica-index:%d dnode:%d}"
- ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64
- ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64
- ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
+ "vgId:%d, %s, sync:%s, snap-sender:{%p start:%" PRId64 " end:%" PRId64 " last-index:%" PRId64
+ " last-term:%" PRIu64 " last-cfg:%" PRId64
+ ", seq:%d ack:%d finish:%d, as:%d dnode:%d}"
+ ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64
+ ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64
+ "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64
+ ", chging:%d, restore:%d, quorum:%d, lc-timer:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s",
pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->snapshotParam.start,
pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm,
pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex,
DID(&pNode->replicasId[pSender->replicaIndex]), pNode->raftStore.currentTerm, pNode->commitIndex,
logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm,
- pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum,
- pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode),
- pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr);
+ pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, pNode->raftCfg.lastConfigIndex,
+ pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock,
+ pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr);
}
void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver,
@@ -291,7 +287,7 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df
char cfgStr[1024] = "";
syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr));
- char peerStr[1024] = "{";
+ char peerStr[1024] = "";
syncPeerState2Str(pNode, peerStr, sizeof(peerStr));
char eventLog[512]; // {0};
@@ -300,22 +296,22 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df
int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer);
va_end(argpointer);
- taosPrintLog(flags, level, dflag,
- "vgId:%d, %s, sync:%s,"
- " {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from dnode:%d s-param:%" PRId64
- " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64
- "}"
- ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64
- ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64
- ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s",
- pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack,
- pReceiver->term, pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start,
- pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm,
- pReceiver->snapshot.lastConfigIndex, pNode->raftStore.currentTerm, pNode->commitIndex, logBeginIndex,
- logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm,
- pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum,
- pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode),
- pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr);
+ taosPrintLog(
+ flags, level, dflag,
+ "vgId:%d, %s, sync:%s,"
+ " snap-receiver:{%p started:%d acked:%d term:%" PRIu64 " start-time:%" PRId64 " from-dnode:%d, start:%" PRId64
+ " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64
+ "}"
+ ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64
+ ", snap:{last-index:%" PRId64 ", last-term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64
+ ", chging:%d, restore:%d, quorum:%d, lc-timers:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s",
+ pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term,
+ pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, pReceiver->snapshotParam.end,
+ pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex,
+ pNode->raftStore.currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex,
+ snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize,
+ pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish,
+ syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr);
}
void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s) {
@@ -351,13 +347,13 @@ void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool
int64_t execTime) {
if (printX) {
sNTrace(pSyncNode,
- "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64
- "}, x",
+ "send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
+ ", ts:%" PRId64 "}, x",
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp);
} else {
sNTrace(pSyncNode,
- "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64
- "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64,
+ "send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
+ ", ts:%" PRId64 "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64,
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed,
execTime);
}
@@ -368,14 +364,14 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64
pSyncNode->hbSlowNum++;
sNInfo(pSyncNode,
- "recv sync-heartbeat from dnode:%d slow {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64
+ "recv sync-heartbeat from dnode:%d slow {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
", ts:%" PRId64 "}, %s, net elapsed:%" PRId64,
DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff);
}
sNTrace(pSyncNode,
- "recv sync-heartbeat from dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64
- "}, %s, net elapsed:%" PRId64,
+ "recv sync-heartbeat from dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
+ ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64,
DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff);
}
@@ -400,67 +396,64 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p
void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
sNDebug(pSyncNode,
- "send sync-snapshot-send to dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64
- ", lterm:%" PRId64 ", stime:%" PRId64,
+ "send sync-snapshot-send to dnode:%d, %s, seq:%d, term:%" PRId64 ", begin-index:%" PRId64
+ ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64,
DID(&pMsg->destId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm,
pMsg->startTime);
}
void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) {
sNDebug(pSyncNode,
- "recv sync-snapshot-send from dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
- ", lterm:%" PRId64 ", stime:%" PRId64 ", len:%u",
+ "recv sync-snapshot-send from dnode:%d, %s, seq:%d, term:%" PRId64 ", begin-index:%" PRId64
+ ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64 ", data-len:%u",
DID(&pMsg->srcId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm,
pMsg->startTime, pMsg->dataLen);
}
void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
sNDebug(pSyncNode,
- "send sync-snapshot-rsp to dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
- ", lterm:%" PRId64 ", stime:%" PRId64,
+ "send sync-snapshot-rsp to dnode:%d, %s, acked:%d, term:%" PRId64 ", begin-index:%" PRId64
+ ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64,
DID(&pMsg->destId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm,
pMsg->startTime);
}
void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) {
sNDebug(pSyncNode,
- "recv sync-snapshot-rsp from dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64
- ", lterm:%" PRId64 ", stime:%" PRId64,
+ "recv sync-snapshot-rsp from dnode:%d, %s, ack:%d, term:%" PRId64 ", begin-index:%" PRId64
+ ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64,
DID(&pMsg->srcId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm,
pMsg->startTime);
}
void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
sNTrace(pSyncNode,
- "recv sync-append-entries from dnode:%d {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64
- ", cmt:%" PRId64 ", pterm:%" PRId64 ", datalen:%d}, %s",
- DID(&pMsg->srcId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->privateTerm,
- pMsg->dataLen, s);
+ "recv sync-append-entries from dnode:%d {term:%" PRId64 ", prev-log:{index:%" PRId64 ", term:%" PRId64
+ "}, commit-index:%" PRId64 ", datalen:%d}, %s",
+ DID(&pMsg->srcId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->dataLen, s);
}
void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) {
sNTrace(pSyncNode,
- "send sync-append-entries to dnode:%d, {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64
- ", lsend-index:%" PRId64 ", cmt:%" PRId64 ", datalen:%d}, %s",
+ "send sync-append-entries to dnode:%d, {term:%" PRId64 ", prev-log:{index:%" PRId64 ", term:%" PRId64
+ "}, index:%" PRId64 ", commit-index:%" PRId64 ", datalen:%d}, %s",
DID(&pMsg->destId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, (pMsg->prevLogIndex + 1),
pMsg->commitIndex, pMsg->dataLen, s);
}
-void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, const char* s) {
- if (voteGranted == -1) {
- sNInfo(pSyncNode,
- "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s",
- DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s);
- } else {
- sNInfo(pSyncNode,
- "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64
- "}, granted:%d",
- DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, voteGranted);
- }
+void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted,
+ const char* errmsg) {
+ char statusMsg[64];
+ snprintf(statusMsg, sizeof(statusMsg), "granted:%d", voteGranted);
+ sNInfo(pSyncNode,
+ "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", last-index:%" PRId64 ", last-term:%" PRId64 "}, %s",
+ DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm,
+ (voteGranted != -1) ? statusMsg : errmsg);
}
void syncLogSendRequestVote(SSyncNode* pNode, const SyncRequestVote* pMsg, const char* s) {
- sNInfo(pNode, "send sync-request-vote to dnode:%d {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s",
+ sNInfo(pNode,
+ "send sync-request-vote to dnode:%d {term:%" PRId64 ", last-index:%" PRId64 ", last-term:%" PRId64 "}, %s",
DID(&pMsg->destId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s);
}
diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c
index f19c3f28c05e4ec586328320228c59966ad1e3ba..c6310f4985da8fc18a4502d5a4dda5ecfa0d8a64 100644
--- a/source/libs/tdb/src/db/tdbPage.c
+++ b/source/libs/tdb/src/db/tdbPage.c
@@ -484,77 +484,50 @@ static int tdbPageFree(SPage *pPage, int idx, SCell *pCell, int szCell) {
return 0;
}
-static int tdbPageDefragment(SPage *pPage) {
- int nFree;
- int nCells;
- SCell *pCell;
- SCell *pNextCell;
- SCell *pTCell;
- int szCell;
- int idx;
- int iCell;
-
- nFree = TDB_PAGE_NFREE(pPage);
- nCells = TDB_PAGE_NCELLS(pPage);
-
- if (pPage->pFreeEnd - pPage->pFreeStart >= nFree) {
- tdbError("tdb/page-defragment: invalid free range, nFree: %d.", nFree);
+typedef struct {
+ int32_t iCell;
+ int32_t offset;
+} SCellIdx;
+static int32_t tCellIdxCmprFn(const void *p1, const void *p2) {
+ if (((SCellIdx *)p1)->offset < ((SCellIdx *)p2)->offset) {
return -1;
+ } else if (((SCellIdx *)p1)->offset > ((SCellIdx *)p2)->offset) {
+ return 1;
+ } else {
+ return 0;
}
+}
+static int tdbPageDefragment(SPage *pPage) {
+ int32_t nFree = TDB_PAGE_NFREE(pPage);
+ int32_t nCell = TDB_PAGE_NCELLS(pPage);
- // Loop to compact the page content
- // Here we use an O(n^2) algorithm to do the job since
- // this is a low frequency job.
- pNextCell = (u8 *)pPage->pPageFtr;
- pCell = NULL;
- for (iCell = 0;; iCell++) {
- // compact over
- if (iCell == nCells) {
- pPage->pFreeEnd = pNextCell;
- break;
- }
-
- for (int i = 0; i < nCells; i++) {
- if (TDB_PAGE_CELL_OFFSET_AT(pPage, i) < pNextCell - pPage->pData) {
- pTCell = TDB_PAGE_CELL_AT(pPage, i);
- if (pCell == NULL || pCell < pTCell) {
- pCell = pTCell;
- idx = i;
- }
- } else {
- continue;
- }
- }
-
- if (NULL == pCell) {
- tdbError("tdb/page-defragment: null ptr pCell.");
- return -1;
- }
+ SCellIdx *aCellIdx = (SCellIdx *)tdbOsMalloc(sizeof(SCellIdx) * nCell);
+ if (aCellIdx == NULL) return -1;
+ for (int32_t iCell = 0; iCell < nCell; iCell++) {
+ aCellIdx[iCell].iCell = iCell;
+ aCellIdx[iCell].offset = TDB_PAGE_CELL_OFFSET_AT(pPage, iCell);
+ }
+ taosSort(aCellIdx, nCell, sizeof(SCellIdx), tCellIdxCmprFn);
- szCell = (*pPage->xCellSize)(pPage, pCell, 0, NULL, NULL);
+ SCell *pNextCell = (u8 *)pPage->pPageFtr;
+ for (int32_t iCell = nCell - 1; iCell >= 0; iCell--) {
+ SCell *pCell = TDB_PAGE_CELL_AT(pPage, aCellIdx[iCell].iCell);
+ int32_t szCell = pPage->xCellSize(pPage, pCell, 0, NULL, NULL);
- if (pCell + szCell > pNextCell) {
- tdbError("tdb/page-defragment: invalid cell range, pCell: %p, szCell: %d, pNextCell: %p.", pCell, szCell,
- pNextCell);
- return -1;
- }
+ ASSERT(pNextCell - szCell >= pCell);
- if (pCell + szCell < pNextCell) {
- memmove(pNextCell - szCell, pCell, szCell);
+ pNextCell -= szCell;
+ if (pNextCell > pCell) {
+ memmove(pNextCell, pCell, szCell);
+ TDB_PAGE_CELL_OFFSET_AT_SET(pPage, aCellIdx[iCell].iCell, pNextCell - pPage->pData);
}
-
- pCell = NULL;
- pNextCell = pNextCell - szCell;
- TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, pNextCell - pPage->pData);
- }
-
- if (pPage->pFreeEnd - pPage->pFreeStart != nFree) {
- tdbError("tdb/page-defragment: invalid free range, nFree: %d.", nFree);
- return -1;
}
-
+ pPage->pFreeEnd = pNextCell;
TDB_PAGE_CCELLS_SET(pPage, pPage->pFreeEnd - pPage->pData);
TDB_PAGE_FCELL_SET(pPage, 0);
+ tdbOsFree(aCellIdx);
+
+ ASSERT(pPage->pFreeEnd - pPage->pFreeStart == nFree);
return 0;
}
diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c
index ced867e938fc66574e70774e0e99000be2bf2fa5..29b7fa740c85e9ea74def8e53d47edd69c76b743 100644
--- a/source/libs/tdb/src/db/tdbPager.c
+++ b/source/libs/tdb/src/db/tdbPager.c
@@ -445,6 +445,11 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
SPgno journalSize = 0;
int ret;
+ if (pTxn->jfd == 0) {
+ // txn is commited
+ return 0;
+ }
+
// sync the journal file
ret = tdbOsFSync(pTxn->jfd);
if (ret < 0) {
diff --git a/source/libs/tdb/test/CMakeLists.txt b/source/libs/tdb/test/CMakeLists.txt
index 2621e02b02b9a9a28ec29c58b657202f8522a894..fd4d7c101d06ce73de37678e858716326e83feee 100644
--- a/source/libs/tdb/test/CMakeLists.txt
+++ b/source/libs/tdb/test/CMakeLists.txt
@@ -6,7 +6,11 @@ target_link_libraries(tdbTest tdb gtest gtest_main)
add_executable(tdbUtilTest "tdbUtilTest.cpp")
target_link_libraries(tdbUtilTest tdb gtest gtest_main)
-# tdbUtilTest
+# overflow pages testing
add_executable(tdbExOVFLTest "tdbExOVFLTest.cpp")
target_link_libraries(tdbExOVFLTest tdb gtest gtest_main)
+# page defragment testing
+add_executable(tdbPageDefragmentTest "tdbPageDefragmentTest.cpp")
+target_link_libraries(tdbPageDefragmentTest tdb gtest gtest_main)
+
diff --git a/source/libs/tdb/test/tdbPageDefragmentTest.cpp b/source/libs/tdb/test/tdbPageDefragmentTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7aeef94d14bb0a4b8441de3421185beaf45caf1a
--- /dev/null
+++ b/source/libs/tdb/test/tdbPageDefragmentTest.cpp
@@ -0,0 +1,722 @@
+#include
+
+#define ALLOW_FORBID_FUNC
+#include "os.h"
+#include "tdb.h"
+
+#include
+#include
+#include
+#include
+#include "tlog.h"
+
+typedef struct SPoolMem {
+ int64_t size;
+ struct SPoolMem *prev;
+ struct SPoolMem *next;
+} SPoolMem;
+
+static SPoolMem *openPool() {
+ SPoolMem *pPool = (SPoolMem *)taosMemoryMalloc(sizeof(*pPool));
+
+ pPool->prev = pPool->next = pPool;
+ pPool->size = 0;
+
+ return pPool;
+}
+
+static void clearPool(SPoolMem *pPool) {
+ SPoolMem *pMem;
+
+ do {
+ pMem = pPool->next;
+
+ if (pMem == pPool) break;
+
+ pMem->next->prev = pMem->prev;
+ pMem->prev->next = pMem->next;
+ pPool->size -= pMem->size;
+
+ taosMemoryFree(pMem);
+ } while (1);
+
+ assert(pPool->size == 0);
+}
+
+static void closePool(SPoolMem *pPool) {
+ clearPool(pPool);
+ taosMemoryFree(pPool);
+}
+
+static void *poolMalloc(void *arg, size_t size) {
+ void *ptr = NULL;
+ SPoolMem *pPool = (SPoolMem *)arg;
+ SPoolMem *pMem;
+
+ pMem = (SPoolMem *)taosMemoryMalloc(sizeof(*pMem) + size);
+ if (pMem == NULL) {
+ assert(0);
+ }
+
+ pMem->size = sizeof(*pMem) + size;
+ pMem->next = pPool->next;
+ pMem->prev = pPool;
+
+ pPool->next->prev = pMem;
+ pPool->next = pMem;
+ pPool->size += pMem->size;
+
+ ptr = (void *)(&pMem[1]);
+ return ptr;
+}
+
+static void poolFree(void *arg, void *ptr) {
+ SPoolMem *pPool = (SPoolMem *)arg;
+ SPoolMem *pMem;
+
+ pMem = &(((SPoolMem *)ptr)[-1]);
+
+ pMem->next->prev = pMem->prev;
+ pMem->prev->next = pMem->next;
+ pPool->size -= pMem->size;
+
+ taosMemoryFree(pMem);
+}
+
+static int tKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
+ int k1, k2;
+
+ std::string s1((char *)pKey1 + 3, kLen1 - 3);
+ std::string s2((char *)pKey2 + 3, kLen2 - 3);
+ k1 = stoi(s1);
+ k2 = stoi(s2);
+
+ if (k1 < k2) {
+ return -1;
+ } else if (k1 > k2) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2) {
+ int mlen;
+ int cret;
+
+ ASSERT(keyLen1 > 0 && keyLen2 > 0 && pKey1 != NULL && pKey2 != NULL);
+
+ mlen = keyLen1 < keyLen2 ? keyLen1 : keyLen2;
+ cret = memcmp(pKey1, pKey2, mlen);
+ if (cret == 0) {
+ if (keyLen1 < keyLen2) {
+ cret = -1;
+ } else if (keyLen1 > keyLen2) {
+ cret = 1;
+ } else {
+ cret = 0;
+ }
+ }
+ return cret;
+}
+
+// TEST(TdbPageDefragmentTest, DISABLED_TbUpsertTest) {
+// TEST(TdbPageDefragmentTest, TbUpsertTest) {
+//}
+
+// TEST(TdbPageDefragmentTest, DISABLED_TbPGetTest) {
+// TEST(TdbPageDefragmentTest, TbPGetTest) {
+//}
+
+static void generateBigVal(char *val, int valLen) {
+ for (int i = 0; i < valLen; ++i) {
+ char c = char(i & 0xff);
+ if (c == 0) {
+ c = 1;
+ }
+ val[i] = c;
+ }
+}
+
+static TDB *openEnv(char const *envName, int const pageSize, int const pageNum) {
+ TDB *pEnv = NULL;
+
+ int ret = tdbOpen(envName, pageSize, pageNum, &pEnv, 0);
+ if (ret) {
+ pEnv = NULL;
+ }
+
+ return pEnv;
+}
+
+static void insertOfp(void) {
+ int ret = 0;
+
+ taosRemoveDir("tdb");
+
+ // open Env
+ int const pageSize = 4096;
+ int const pageNum = 64;
+ TDB *pEnv = openEnv("tdb", pageSize, pageNum);
+ GTEST_ASSERT_NE(pEnv, nullptr);
+
+ // open db
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc = tKeyCmpr;
+ // ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ ret = tdbTbOpen("ofp_insert.db", 12, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // open the pool
+ SPoolMem *pPool = openPool();
+
+ // start a transaction
+ TXN *txn = NULL;
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ // generate value payload
+ // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[32605];
+ int valLen = sizeof(val) / sizeof(val[0]);
+ generateBigVal(val, valLen);
+
+ // insert the generated big data
+ // char const *key = "key1";
+ char const *key = "key123456789";
+ ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+}
+
+TEST(TdbPageDefragmentTest, DISABLED_TbInsertTest) {
+ // TEST(TdbPageDefragmentTest, TbInsertTest) {
+ // ofp inserting
+ insertOfp();
+}
+
+TEST(TdbPageDefragmentTest, DISABLED_TbGetTest) {
+ // TEST(TdbPageDefragmentTest, TbGetTest) {
+ insertOfp();
+
+ // open Env
+ int const pageSize = 4096;
+ int const pageNum = 64;
+ TDB *pEnv = openEnv("tdb", pageSize, pageNum);
+ GTEST_ASSERT_NE(pEnv, nullptr);
+
+ // open db
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc = tKeyCmpr;
+ // int ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ int ret = tdbTbOpen("ofp_insert.db", 12, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // generate value payload
+ // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[32605];
+ int valLen = sizeof(val) / sizeof(val[0]);
+ generateBigVal(val, valLen);
+
+ { // Query the data
+ void *pVal = NULL;
+ int vLen;
+
+ // char const *key = "key1";
+ char const *key = "key123456789";
+ ret = tdbTbGet(pDb, key, strlen(key), &pVal, &vLen);
+ ASSERT(ret == 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ GTEST_ASSERT_EQ(vLen, valLen);
+ GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0);
+
+ tdbFree(pVal);
+ }
+}
+
+TEST(TdbPageDefragmentTest, DISABLED_TbDeleteTest) {
+ // TEST(TdbPageDefragmentTest, TbDeleteTest) {
+ int ret = 0;
+
+ taosRemoveDir("tdb");
+
+ // open Env
+ int const pageSize = 4096;
+ int const pageNum = 64;
+ TDB *pEnv = openEnv("tdb", pageSize, pageNum);
+ GTEST_ASSERT_NE(pEnv, nullptr);
+
+ // open db
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc = tKeyCmpr;
+ ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // open the pool
+ SPoolMem *pPool = openPool();
+
+ // start a transaction
+ TXN *txn;
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ // generate value payload
+ // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[((4083 - 4 - 3 - 2) + 1) * 2]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ int valLen = sizeof(val) / sizeof(val[0]);
+ generateBigVal(val, valLen);
+
+ { // insert the generated big data
+ ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ }
+
+ { // query the data
+ void *pVal = NULL;
+ int vLen;
+
+ ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen);
+ ASSERT(ret == 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ GTEST_ASSERT_EQ(vLen, valLen);
+ GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0);
+
+ tdbFree(pVal);
+ }
+ /* open to debug committed file
+tdbCommit(pEnv, &txn);
+tdbTxnClose(&txn);
+
+++txnid;
+tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+tdbBegin(pEnv, &txn);
+ */
+ { // upsert the data
+ ret = tdbTbUpsert(pDb, "key1", strlen("key1"), "value1", strlen("value1"), txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ }
+
+ { // query the upserted data
+ void *pVal = NULL;
+ int vLen;
+
+ ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen);
+ ASSERT(ret == 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ GTEST_ASSERT_EQ(vLen, strlen("value1"));
+ GTEST_ASSERT_EQ(memcmp("value1", pVal, vLen), 0);
+
+ tdbFree(pVal);
+ }
+
+ { // delete the data
+ ret = tdbTbDelete(pDb, "key1", strlen("key1"), txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ }
+
+ { // query the deleted data
+ void *pVal = NULL;
+ int vLen = -1;
+
+ ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen);
+ ASSERT(ret == -1);
+ GTEST_ASSERT_EQ(ret, -1);
+
+ GTEST_ASSERT_EQ(vLen, -1);
+ GTEST_ASSERT_EQ(pVal, nullptr);
+
+ tdbFree(pVal);
+ }
+
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+}
+
+TEST(TdbPageDefragmentTest, DISABLED_simple_insert1) {
+ // TEST(TdbPageDefragmentTest, simple_insert1) {
+ int ret;
+ TDB *pEnv;
+ TTB *pDb;
+ tdb_cmpr_fn_t compFunc;
+ int nData = 1;
+ TXN *txn;
+ int const pageSize = 4096;
+
+ taosRemoveDir("tdb");
+
+ // Open Env
+ ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // Create a database
+ compFunc = tKeyCmpr;
+ ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ {
+ char key[64];
+ // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ int64_t poolLimit = 4096; // 1M pool limit
+ SPoolMem *pPool;
+
+ // open the pool
+ pPool = openPool();
+
+ // start a transaction
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ for (int iData = 1; iData <= nData; iData++) {
+ sprintf(key, "key0");
+ sprintf(val, "value%d", iData);
+
+ // ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn);
+ // GTEST_ASSERT_EQ(ret, 0);
+
+ // generate value payload
+ int valLen = sizeof(val) / sizeof(val[0]);
+ for (int i = 6; i < valLen; ++i) {
+ char c = char(i & 0xff);
+ if (c == 0) {
+ c = 1;
+ }
+ val[i] = c;
+ }
+
+ ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // if pool is full, commit the transaction and start a new one
+ if (pPool->size >= poolLimit) {
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // start a new transaction
+ clearPool(pPool);
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+ }
+ }
+
+ // commit the transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ { // Query the data
+ void *pVal = NULL;
+ int vLen;
+
+ for (int i = 1; i <= nData; i++) {
+ sprintf(key, "key%d", i);
+ // sprintf(val, "value%d", i);
+
+ ret = tdbTbGet(pDb, key, strlen(key), &pVal, &vLen);
+ ASSERT(ret == 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ GTEST_ASSERT_EQ(vLen, sizeof(val) / sizeof(val[0]));
+ GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0);
+ }
+
+ tdbFree(pVal);
+ }
+
+ { // Iterate to query the DB data
+ TBC *pDBC;
+ void *pKey = NULL;
+ void *pVal = NULL;
+ int vLen, kLen;
+ int count = 0;
+
+ ret = tdbTbcOpen(pDb, &pDBC, NULL);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ tdbTbcMoveToFirst(pDBC);
+
+ for (;;) {
+ ret = tdbTbcNext(pDBC, &pKey, &kLen, &pVal, &vLen);
+ if (ret < 0) break;
+
+ // std::cout.write((char *)pKey, kLen) /* << " " << kLen */ << " ";
+ // std::cout.write((char *)pVal, vLen) /* << " " << vLen */;
+ // std::cout << std::endl;
+
+ count++;
+ }
+
+ GTEST_ASSERT_EQ(count, nData);
+
+ tdbTbcClose(pDBC);
+
+ tdbFree(pKey);
+ tdbFree(pVal);
+ }
+ }
+
+ ret = tdbTbDrop(pDb);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // Close a database
+ tdbTbClose(pDb);
+
+ // Close Env
+ ret = tdbClose(pEnv);
+ GTEST_ASSERT_EQ(ret, 0);
+}
+
+// TEST(TdbPageDefragmentTest, DISABLED_seq_insert) {
+TEST(TdbPageDefragmentTest, seq_insert) {
+ int ret = 0;
+ TDB *pEnv = NULL;
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc;
+ int nData = 64 * 1024;
+ TXN *txn = NULL;
+ int const pageSize = 1 * 1024 * 1024;
+
+ taosRemoveDir("tdb");
+
+ // Open Env
+ ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // Create a database
+ compFunc = tKeyCmpr;
+ ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // 1, insert nData kv
+ {
+ char key[64];
+ // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ int64_t poolLimit = 4096; // 1M pool limit
+ SPoolMem *pPool;
+
+ // open the pool
+ pPool = openPool();
+
+ // start a transaction
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ for (int iData = 0; iData < nData; ++iData) {
+ sprintf(key, "key%d", iData);
+ sprintf(val, "value%d", iData);
+
+ ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ /*
+ // generate value payload
+ int valLen = sizeof(val) / sizeof(val[0]);
+ for (int i = 6; i < valLen; ++i) {
+ char c = char(i & 0xff);
+ if (c == 0) {
+ c = 1;
+ }
+ val[i] = c;
+ }
+
+ ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ */
+ // if pool is full, commit the transaction and start a new one
+ if (pPool->size >= poolLimit) {
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // start a new transaction
+ clearPool(pPool);
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+ }
+ }
+
+ // commit the transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // 2, delete nData/2 records
+ }
+
+ // Close a database
+ tdbTbClose(pDb);
+
+ // Close Env
+ ret = tdbClose(pEnv);
+ GTEST_ASSERT_EQ(ret, 0);
+}
+
+// TEST(TdbPageDefragmentTest, DISABLED_seq_delete) {
+TEST(TdbPageDefragmentTest, seq_delete) {
+ int ret = 0;
+ TDB *pEnv = NULL;
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc;
+ int nData = 64 * 1024;
+ TXN *txn = NULL;
+ int const pageSize = 1 * 1024 * 1024;
+
+ // Open Env
+ ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // Create a database
+ compFunc = tKeyCmpr;
+ ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // 2, delete nData/2 records
+ {
+ char key[64];
+ // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ int64_t poolLimit = 4096; // 1M pool limit
+ SPoolMem *pPool;
+
+ // open the pool
+ pPool = openPool();
+
+ // start a transaction
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ for (int iData = 1; iData <= nData; iData++) {
+ if (iData % 2 == 0) continue;
+
+ sprintf(key, "key%d", iData);
+ sprintf(val, "value%d", iData);
+
+ { // delete the data
+ ret = tdbTbDelete(pDb, key, strlen(key), txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ }
+
+ /*
+ // generate value payload
+ int valLen = sizeof(val) / sizeof(val[0]);
+ for (int i = 6; i < valLen; ++i) {
+ char c = char(i & 0xff);
+ if (c == 0) {
+ c = 1;
+ }
+ val[i] = c;
+ }
+
+ ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ */
+ // if pool is full, commit the transaction and start a new one
+ if (pPool->size >= poolLimit) {
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // start a new transaction
+ clearPool(pPool);
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+ }
+ }
+
+ // commit the transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+ }
+
+ // Close a database
+ tdbTbClose(pDb);
+
+ // Close Env
+ ret = tdbClose(pEnv);
+ GTEST_ASSERT_EQ(ret, 0);
+}
+
+// TEST(TdbPageDefragmentTest, DISABLED_defragment_insert) {
+TEST(TdbPageDefragmentTest, defragment_insert) {
+ int ret = 0;
+ TDB *pEnv = NULL;
+ TTB *pDb = NULL;
+ tdb_cmpr_fn_t compFunc;
+ int nData = 64 * 1024;
+ TXN *txn = NULL;
+ int const pageSize = 1 * 1024 * 1024;
+
+ // Open Env
+ ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // Create a database
+ compFunc = tKeyCmpr;
+ ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0);
+ GTEST_ASSERT_EQ(ret, 0);
+
+ // 3, insert 32k records
+ {
+ char key[64];
+ // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
+ int64_t poolLimit = 4096; // 1M pool limit
+ SPoolMem *pPool;
+
+ // open the pool
+ pPool = openPool();
+
+ // start a transaction
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+
+ for (int iData = nData + 1; iData <= nData * 2; iData++) {
+ // if (iData % 2 == 0) continue;
+ sprintf(key, "key%d", iData);
+ sprintf(val, "value%d", iData);
+
+ ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ /*
+ // generate value payload
+ int valLen = sizeof(val) / sizeof(val[0]);
+ for (int i = 6; i < valLen; ++i) {
+ char c = char(i & 0xff);
+ if (c == 0) {
+ c = 1;
+ }
+ val[i] = c;
+ }
+
+ ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn);
+ GTEST_ASSERT_EQ(ret, 0);
+ */
+ // if pool is full, commit the transaction and start a new one
+ if (pPool->size >= poolLimit) {
+ // commit current transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // start a new transaction
+ clearPool(pPool);
+
+ tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
+ }
+ }
+
+ // commit the transaction
+ tdbCommit(pEnv, txn);
+ tdbPostCommit(pEnv, txn);
+
+ // 2, delete nData/2 records
+ }
+
+ // Close a database
+ tdbTbClose(pDb);
+
+ // Close Env
+ ret = tdbClose(pEnv);
+ GTEST_ASSERT_EQ(ret, 0);
+}
diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c
index 9a71fc7f30ffebb5cf864d30faea3b8690438112..1d20b4d43daa8fff936ac12e9f7902bc38007c0b 100644
--- a/source/libs/tfs/src/tfs.c
+++ b/source/libs/tfs/src/tfs.c
@@ -295,7 +295,7 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname) {
for (int32_t id = 0; id < pTier->ndisk; id++) {
STfsDisk *pDisk = pTier->disks[id];
snprintf(aname, TMPNAME_LEN, "%s%s%s", pDisk->path, TD_DIRSEP, rname);
- uInfo("tfs remove dir : path:%s aname:%s rname:[%s]", pDisk->path, aname, rname);
+ uInfo("tfs remove dir:%s aname:%s rname:[%s]", pDisk->path, aname, rname);
taosRemoveDir(aname);
}
}
@@ -303,7 +303,7 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname) {
return 0;
}
-int32_t tfsRename(STfs *pTfs, char *orname, char *nrname) {
+int32_t tfsRename(STfs *pTfs, const char *orname, const char *nrname) {
char oaname[TMPNAME_LEN] = "\0";
char naname[TMPNAME_LEN] = "\0";
diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c
index 9b8f1dfd07eff893225d2611f158f822fb67e735..fc95cab76e867817e53c4bde6b6507e9472a40f5 100644
--- a/source/libs/transport/src/tmsgcb.c
+++ b/source/libs/transport/src/tmsgcb.c
@@ -60,11 +60,15 @@ void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) { (*defaultMsgCb.re
void tmsgReportStartup(const char* name, const char* desc) { (*defaultMsgCb.reportStartupFp)(name, desc); }
bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port) {
- return (*defaultMsgCb.updateDnodeInfoFp)(defaultMsgCb.data, dnodeId, clusterId, fqdn, port);
+ if (defaultMsgCb.updateDnodeInfoFp) {
+ return (*defaultMsgCb.updateDnodeInfoFp)(defaultMsgCb.data, dnodeId, clusterId, fqdn, port);
+ } else {
+ return false;
+ }
}
void tmsgUpdateDnodeEpSet(SEpSet* epset) {
for (int32_t i = 0; i < epset->numOfEps; ++i) {
tmsgUpdateDnodeInfo(NULL, NULL, epset->eps[i].fqdn, &epset->eps[i].port);
}
-}
\ No newline at end of file
+}
diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c
index 1a99db5f992d51f5e01ba5120e2099f1d53a307f..111742a6f448b735fb16d7df48bf1fc3cc479393 100644
--- a/source/libs/transport/src/transCli.c
+++ b/source/libs/transport/src/transCli.c
@@ -671,7 +671,7 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
conn->stream = (uv_stream_t*)taosMemoryMalloc(sizeof(uv_tcp_t));
uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream));
conn->stream->data = conn;
- transSetConnOption((uv_tcp_t*)conn->stream);
+ // transSetConnOption((uv_tcp_t*)conn->stream);
uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL;
if (timer == NULL) {
@@ -778,7 +778,7 @@ static void cliSendCb(uv_write_t* req, int status) {
SCliMsg* pMsg = !transQueueEmpty(&pConn->cliMsgs) ? transQueueGet(&pConn->cliMsgs, 0) : NULL;
if (pMsg != NULL) {
int64_t cost = taosGetTimestampUs() - pMsg->st;
- if (cost > 1000) {
+ if (cost > 1000 * 20) {
tWarn("%s conn %p send cost:%dus, send exception", CONN_GET_INST_LABEL(pConn), pConn, (int)cost);
}
}
@@ -800,9 +800,12 @@ static void cliSendCb(uv_write_t* req, int status) {
}
void cliSend(SCliConn* pConn) {
- bool empty = transQueueEmpty(&pConn->cliMsgs);
- ASSERTS(empty == false, "trans-cli get invalid msg");
- if (empty == true) {
+ SCliThrd* pThrd = pConn->hostThrd;
+ STrans* pTransInst = pThrd->pTransInst;
+
+ if (transQueueEmpty(&pConn->cliMsgs)) {
+ tError("%s conn %p not msg to send", pTransInst->label, pConn);
+ cliHandleExcept(pConn);
return;
}
@@ -812,9 +815,6 @@ void cliSend(SCliConn* pConn) {
STransConnCtx* pCtx = pCliMsg->ctx;
- SCliThrd* pThrd = pConn->hostThrd;
- STrans* pTransInst = pThrd->pTransInst;
-
STransMsg* pMsg = (STransMsg*)(&pCliMsg->msg);
if (pMsg->pCont == 0) {
pMsg->pCont = (void*)rpcMallocCont(0);
@@ -1045,6 +1045,12 @@ static FORCE_INLINE uint32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn)
uint32_t* v = taosHashGet(cache, fqdn, strlen(fqdn));
if (v == NULL) {
addr = taosGetIpv4FromFqdn(fqdn);
+ if (addr == 0xffffffff) {
+ terrno = TAOS_SYSTEM_ERROR(errno);
+ tError("failed to get ip from fqdn:%s since %s", fqdn, terrstr());
+ return addr;
+ }
+
taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr));
} else {
addr = *v;
@@ -1061,9 +1067,10 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
STransConnCtx* pCtx = pMsg->ctx;
cliMayCvtFqdnToIp(&pCtx->epSet, &pThrd->cvtAddr);
+ STraceId* trace = &pMsg->msg.info.traceId;
if (!EPSET_IS_VALID(&pCtx->epSet)) {
- tError("invalid epset");
+ tGError("%s, msg %s sent with invalid epset", pTransInst->label, TMSG_INFO(pMsg->msg.msgType));
destroyCmsg(pMsg);
return;
}
@@ -1116,15 +1123,45 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
conn->ip = strdup(EPSET_GET_INUSE_IP(&pCtx->epSet));
conn->port = EPSET_GET_INUSE_PORT(&pCtx->epSet);
+ uint32_t ipaddr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, conn->ip);
+ if (ipaddr == 0xffffffff) {
+ uv_timer_stop(conn->timer);
+ conn->timer->data = NULL;
+ taosArrayPush(pThrd->timerList, &conn->timer);
+ conn->timer = NULL;
+
+ cliHandleExcept(conn);
+ return;
+ }
+
struct sockaddr_in addr;
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, conn->ip);
+ addr.sin_addr.s_addr = ipaddr;
addr.sin_port = (uint16_t)htons((uint16_t)conn->port);
- STraceId* trace = &(pMsg->msg.info.traceId);
tGTrace("%s conn %p try to connect to %s:%d", pTransInst->label, conn, conn->ip, conn->port);
+ int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 4);
+ if (fd == -1) {
+ tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
+ tstrerror(TAOS_SYSTEM_ERROR(errno)));
+ cliHandleExcept(conn);
+ errno = 0;
+ return;
+ }
+ int ret = uv_tcp_open((uv_tcp_t*)conn->stream, fd);
+ if (ret != 0) {
+ tGError("%s conn %p failed to set stream, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
+ cliHandleExcept(conn);
+ return;
+ }
+ ret = transSetConnOption((uv_tcp_t*)conn->stream);
+ if (ret != 0) {
+ tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret));
+ cliHandleExcept(conn);
+ return;
+ }
- int ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
+ ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb);
if (ret != 0) {
tGError("%s conn %p failed to connect to %s:%d, reason:%s", pTransInst->label, conn, conn->ip, conn->port,
uv_err_name(ret));
@@ -1139,7 +1176,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
}
uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0);
}
- STraceId* trace = &pMsg->msg.info.traceId;
tGTrace("%s conn %p ready", pTransInst->label, conn);
}
static void cliAsyncCb(uv_async_t* handle) {
@@ -1275,7 +1311,11 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads,
for (int i = 0; i < cli->numOfThreads; i++) {
SCliThrd* pThrd = createThrdObj(shandle);
- int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd));
+ if (pThrd == NULL) {
+ return NULL;
+ }
+
+ int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd));
if (err == 0) {
tDebug("success to create tranport-cli thread:%d", i);
}
@@ -1332,9 +1372,23 @@ static SCliThrd* createThrdObj(void* trans) {
taosThreadMutexInit(&pThrd->msgMtx, NULL);
pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
- uv_loop_init(pThrd->loop);
-
+ int err = uv_loop_init(pThrd->loop);
+ if (err != 0) {
+ tError("failed to init uv_loop, reason:%s", uv_err_name(err));
+ taosMemoryFree(pThrd->loop);
+ taosThreadMutexDestroy(&pThrd->msgMtx);
+ taosMemoryFree(pThrd);
+ return NULL;
+ }
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, cliAsyncCb);
+ if (pThrd->asyncPool == NULL) {
+ tError("failed to init async pool");
+ uv_loop_close(pThrd->loop);
+ taosMemoryFree(pThrd->loop);
+ taosThreadMutexDestroy(&pThrd->msgMtx);
+ taosMemoryFree(pThrd);
+ return NULL;
+ }
pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t));
uv_prepare_init(pThrd->loop, pThrd->prepare);
diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c
index 1161ed7c00408a9559146ba532c74055813f5c5d..4c107a88f18d39fb4bebb2f45237a9de669e5db4 100644
--- a/source/libs/transport/src/transComm.c
+++ b/source/libs/transport/src/transComm.c
@@ -205,6 +205,10 @@ bool transReadComplete(SConnBuffer* connBuf) {
}
int transSetConnOption(uv_tcp_t* stream) {
+#if defined(WINDOWS) || defined(DARWIN)
+#else
+ uv_tcp_keepalive(stream, 1, 20);
+#endif
return uv_tcp_nodelay(stream, 1);
// int ret = uv_tcp_keepalive(stream, 5, 60);
}
@@ -214,24 +218,37 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb)
pool->nAsync = sz;
pool->asyncs = taosMemoryCalloc(1, sizeof(uv_async_t) * pool->nAsync);
- for (int i = 0; i < pool->nAsync; i++) {
+ int i = 0, err = 0;
+ for (i = 0; i < pool->nAsync; i++) {
+ uv_async_t* async = &(pool->asyncs[i]);
+
SAsyncItem* item = taosMemoryCalloc(1, sizeof(SAsyncItem));
item->pThrd = arg;
QUEUE_INIT(&item->qmsg);
taosThreadMutexInit(&item->mtx, NULL);
- uv_async_t* async = &(pool->asyncs[i]);
- uv_async_init(loop, async, cb);
async->data = item;
+ err = uv_async_init(loop, async, cb);
+ if (err != 0) {
+ tError("failed to init async, reason:%s", uv_err_name(err));
+ break;
+ }
+ }
+
+ if (i != pool->nAsync) {
+ transAsyncPoolDestroy(pool);
+ pool = NULL;
}
+
return pool;
}
void transAsyncPoolDestroy(SAsyncPool* pool) {
for (int i = 0; i < pool->nAsync; i++) {
uv_async_t* async = &(pool->asyncs[i]);
-
SAsyncItem* item = async->data;
+ if (item == NULL) continue;
+
taosThreadMutexDestroy(&item->mtx);
taosMemoryFree(item);
}
diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c
index 4a0570bee34cafb95f2ce389fa48dbde831383c0..07109883dbc580b29ad84923b2e861ac8724ff0a 100644
--- a/source/libs/wal/src/walMeta.c
+++ b/source/libs/wal/src/walMeta.c
@@ -322,6 +322,35 @@ bool walLogEntriesComplete(const SWal* pWal) {
return complete;
}
+int walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
+ SWalFileInfo* pFileInfo = taosArrayGet(pWal->fileInfoSet, fileIdx);
+ ASSERT(pFileInfo != NULL);
+ char fnameStr[WAL_FILE_LEN];
+ walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
+
+ int64_t fileSize = 0;
+ taosStatFile(fnameStr, &fileSize, NULL);
+ int64_t records = TMAX(0, pFileInfo->lastVer - pFileInfo->firstVer + 1);
+ int64_t lastEndOffset = records * sizeof(SWalIdxEntry);
+
+ if (fileSize <= lastEndOffset) {
+ return 0;
+ }
+
+ TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE);
+ if (pFile == NULL) {
+ terrno = TAOS_SYSTEM_ERROR(errno);
+ return -1;
+ }
+
+ wInfo("vgId:%d, trim idx file. file: %s, size: %" PRId64 ", offset: %" PRId64, pWal->cfg.vgId, fnameStr, fileSize,
+ lastEndOffset);
+
+ taosFtruncateFile(pFile, lastEndOffset);
+ taosCloseFile(&pFile);
+ return 0;
+}
+
int walCheckAndRepairMeta(SWal* pWal) {
// load log files, get first/snapshot/last version info
const char* logPattern = "^[0-9]+.log$";
@@ -396,6 +425,8 @@ int walCheckAndRepairMeta(SWal* pWal) {
}
updateMeta = true;
+ (void)walTrimIdxFile(pWal, fileIdx);
+
int64_t lastVer = walScanLogGetLastVer(pWal, fileIdx);
if (lastVer < 0) {
if (terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) {
@@ -558,6 +589,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
goto _err;
}
+ int64_t count = 0;
while (idxEntry.ver < pFileInfo->lastVer) {
/*A(idxEntry.ver == ckHead.head.version);*/
@@ -569,11 +601,11 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
idxEntry.offset, fLogNameStr);
goto _err;
}
- wWarn("vgId:%d, wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset);
if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
goto _err;
}
+ count++;
}
if (taosFsyncFile(pIdxFile) < 0) {
@@ -581,6 +613,11 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
goto _err;
}
+ if (count > 0) {
+ wInfo("vgId:%d, rebuilt %" PRId64 " wal idx entries until lastVer: %" PRId64, pWal->cfg.vgId, count,
+ pFileInfo->lastVer);
+ }
+
(void)taosCloseFile(&pLogFile);
(void)taosCloseFile(&pIdxFile);
return 0;
diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c
index d068ede52d217a389cce32bc8ff01b5a813bd47c..e31616f53e3cb5670f8a7760f483656dd338aa31 100644
--- a/source/libs/wal/src/walRead.c
+++ b/source/libs/wal/src/walRead.c
@@ -576,3 +576,12 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
return 0;
}
+
+void walReadReset(SWalReader *pReader) {
+ taosThreadMutexLock(&pReader->mutex);
+ taosCloseFile(&pReader->pIdxFile);
+ taosCloseFile(&pReader->pLogFile);
+ pReader->curInvalid = 1;
+ pReader->curFileFirstVer = -1;
+ taosThreadMutexUnlock(&pReader->mutex);
+}
diff --git a/source/libs/wal/src/walRef.c b/source/libs/wal/src/walRef.c
index fa04ba3e58a05c3ee902bde8ace004e821683f37..d3c03c335b2e570b18d78321bd3c2690e1756251 100644
--- a/source/libs/wal/src/walRef.c
+++ b/source/libs/wal/src/walRef.c
@@ -77,6 +77,31 @@ void walUnrefVer(SWalRef *pRef) {
}
#endif
+SWalRef *walRefFirstVer(SWal *pWal, SWalRef *pRef) {
+ if (pRef == NULL) {
+ pRef = walOpenRef(pWal);
+ if (pRef == NULL) {
+ return NULL;
+ }
+ }
+ taosThreadMutexLock(&pWal->mutex);
+
+ int64_t ver = walGetFirstVer(pWal);
+
+ wDebug("vgId:%d, wal ref version %" PRId64 " for first", pWal->cfg.vgId, ver);
+
+ pRef->refVer = ver;
+ // bsearch in fileSet
+ SWalFileInfo tmpInfo;
+ tmpInfo.firstVer = ver;
+ SWalFileInfo *pRet = taosArraySearch(pWal->fileInfoSet, &tmpInfo, compareWalFileInfo, TD_LE);
+ ASSERT(pRet != NULL);
+ pRef->refFile = pRet->firstVer;
+
+ taosThreadMutexUnlock(&pWal->mutex);
+ return pRef;
+}
+
SWalRef *walRefCommittedVer(SWal *pWal) {
SWalRef *pRef = walOpenRef(pWal);
if (pRef == NULL) {
@@ -87,6 +112,8 @@ SWalRef *walRefCommittedVer(SWal *pWal) {
int64_t ver = walGetCommittedVer(pWal);
+ wDebug("vgId:%d, wal ref version %" PRId64 " for committed", pWal->cfg.vgId, ver);
+
pRef->refVer = ver;
// bsearch in fileSet
SWalFileInfo tmpInfo;
diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt
index 3aac5e97751295be13956283c2e8dae46f4c453e..db066a82b6647462eb3b17e7723411477f7fa1e1 100644
--- a/source/os/CMakeLists.txt
+++ b/source/os/CMakeLists.txt
@@ -37,11 +37,13 @@ if(CHECK_STR2INT_ERROR)
add_definitions(-DTD_CHECK_STR_TO_INT_ERROR)
endif()
target_link_libraries(
- os PUBLIC pthread
+ os
+ PUBLIC pthread
+ PUBLIC zlibstatic
)
if(TD_WINDOWS)
target_link_libraries(
- os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp
+ os PUBLIC ws2_32 iconv msvcregex wcwidth winmm crashdump dbghelp version
)
elseif(TD_DARWIN_64)
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
@@ -51,6 +53,10 @@ elseif(TD_DARWIN_64)
target_link_libraries(
os PUBLIC dl m iconv
)
+elseif(TD_ALPINE)
+ target_link_libraries(
+ os PUBLIC dl m rt unwind
+ )
else()
target_link_libraries(
os PUBLIC dl m rt
@@ -63,4 +69,4 @@ ENDIF ()
if(${BUILD_TEST})
add_subdirectory(test)
-endif(${BUILD_TEST})
\ No newline at end of file
+endif(${BUILD_TEST})
diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c
index 71b3125de8ff42f4a3ea1ef19690c6053a00e707..8cc9885adbc507368b4fc012c276ccc12a6a3c51 100644
--- a/source/os/src/osFile.c
+++ b/source/os/src/osFile.c
@@ -15,6 +15,7 @@
#define ALLOW_FORBID_FUNC
#include "os.h"
#include "osSemaphore.h"
+#include "zlib.h"
#ifdef WINDOWS
#include
@@ -870,3 +871,48 @@ bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) {
}
bool taosCheckExistFile(const char *pathname) { return taosCheckAccessFile(pathname, TD_FILE_ACCESS_EXIST_OK); };
+
+int32_t taosCompressFile(char *srcFileName, char *destFileName) {
+ int32_t compressSize = 163840;
+ int32_t ret = 0;
+ int32_t len = 0;
+ char *data = taosMemoryMalloc(compressSize);
+ gzFile dstFp = NULL;
+
+ TdFilePtr pSrcFile = taosOpenFile(srcFileName, TD_FILE_READ | TD_FILE_STREAM);
+ if (pSrcFile == NULL) {
+ ret = -1;
+ goto cmp_end;
+ }
+
+ TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
+ if (pFile == NULL) {
+ ret = -2;
+ goto cmp_end;
+ }
+
+ dstFp = gzdopen(pFile->fd, "wb6f");
+ if (dstFp == NULL) {
+ ret = -3;
+ taosCloseFile(&pFile);
+ goto cmp_end;
+ }
+
+ while (!feof(pSrcFile->fp)) {
+ len = (int32_t)fread(data, 1, compressSize, pSrcFile->fp);
+ (void)gzwrite(dstFp, data, len);
+ }
+
+cmp_end:
+ if (pSrcFile) {
+ taosCloseFile(&pSrcFile);
+ }
+
+ if (dstFp) {
+ gzclose(dstFp);
+ }
+
+ taosMemoryFree(data);
+
+ return ret;
+}
diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c
index 8f49a3d917b0ecb363bd9bb7642a4a65b8b3da0b..b466f89a1d127db23a1618f3455d876f25643f97 100644
--- a/source/os/src/osMath.c
+++ b/source/os/src/osMath.c
@@ -15,8 +15,8 @@
#define ALLOW_FORBID_FUNC
#define _DEFAULT_SOURCE
-#include "os.h"
#include
+#include "talgo.h"
#ifdef WINDOWS
void swapStr(char* j, char* J, int width) {
@@ -41,7 +41,7 @@ int32_t qsortHelper(const void* p1, const void* p2, const void* param) {
void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) {
#ifdef _ALPINE
void* param = compar;
- taosqsort(base, width, sz, param, qsortHelper);
+ taosqsort(base, sz, width, param, qsortHelper);
#else
qsort(base, sz, width, compar);
#endif
diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c
index 3825b8e074b73cff3b2caec533671405916009e1..e685cc8351585eb02d33b4dacc0a979340e22e89 100644
--- a/source/os/src/osMemory.c
+++ b/source/os/src/osMemory.c
@@ -346,7 +346,7 @@ int64_t taosMemorySize(void *ptr) {
}
void taosMemoryTrim(int32_t size) {
-#if defined(WINDOWS) || defined(DARWIN)
+#if defined(WINDOWS) || defined(DARWIN) || defined(_ALPINE)
// do nothing
return;
#else
diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c
index 715c2632e0ba0cf299d1180038e319571604d81f..ddb8eca0ebafdd08bdd7149793c75ad31438220d 100644
--- a/source/os/src/osSocket.c
+++ b/source/os/src/osSocket.c
@@ -55,7 +55,7 @@ typedef struct TdSocket {
#endif
int refId;
SocketFd fd;
-} * TdSocketPtr, TdSocket;
+} *TdSocketPtr, TdSocket;
typedef struct TdSocketServer {
#if SOCKET_WITH_LOCK
@@ -63,7 +63,7 @@ typedef struct TdSocketServer {
#endif
int refId;
SocketFd fd;
-} * TdSocketServerPtr, TdSocketServer;
+} *TdSocketServerPtr, TdSocketServer;
typedef struct TdEpoll {
#if SOCKET_WITH_LOCK
@@ -71,7 +71,7 @@ typedef struct TdEpoll {
#endif
int refId;
EpollFd fd;
-} * TdEpollPtr, TdEpoll;
+} *TdEpollPtr, TdEpoll;
#if 0
int32_t taosSendto(TdSocketPtr pSocket, void *buf, int len, unsigned int flags, const struct sockaddr *dest_addr,
@@ -944,7 +944,7 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
// printf("WSAStartup failed: %d\n", iResult);
- return 1;
+ return 0xFFFFFFFF;
}
#endif
struct addrinfo hints = {0};
@@ -1005,7 +1005,7 @@ int32_t taosGetFqdn(char *fqdn) {
// immediately
// hints.ai_family = AF_INET;
strcpy(fqdn, hostname);
- strcpy(fqdn+strlen(hostname), ".local");
+ strcpy(fqdn + strlen(hostname), ".local");
#else // __APPLE__
struct addrinfo hints = {0};
struct addrinfo *result = NULL;
@@ -1060,7 +1060,7 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) {
#if defined(WINDOWS)
SOCKET fd;
#else
- int fd;
+ int fd;
#endif
if ((fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
return -1;
@@ -1071,11 +1071,12 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) {
return -1;
}
#elif defined(_TD_DARWIN_64)
- uint32_t conn_timeout_ms = timeout * 1000;
- if (0 != setsockopt(fd, IPPROTO_TCP, TCP_CONNECTIONTIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
- taosCloseSocketNoCheck1(fd);
- return -1;
- }
+ // invalid config
+ // uint32_t conn_timeout_ms = timeout * 1000;
+ // if (0 != setsockopt(fd, IPPROTO_TCP, TCP_CONNECTIONTIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
+ // taosCloseSocketNoCheck1(fd);
+ // return -1;
+ //}
#else // Linux like systems
uint32_t conn_timeout_ms = timeout * 1000;
if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
diff --git a/source/os/src/osString.c b/source/os/src/osString.c
index b9f537ad34a15c89a003390c2173f70b227beb2b..ae4a8a5cada3789c05e09a7b59455b9a38f54df7 100644
--- a/source/os/src/osString.c
+++ b/source/os/src/osString.c
@@ -351,7 +351,7 @@ char *taosStrCaseStr(const char *str, const char *pattern) {
int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
int64_t tmp = strtoll(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -363,7 +363,7 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
uint64_t tmp = strtoull(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -375,7 +375,7 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
int32_t tmp = strtol(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -387,7 +387,7 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtol(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -399,7 +399,7 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
int32_t tmp = strtol(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -413,7 +413,7 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtoul(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
@@ -437,7 +437,7 @@ int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtoul(str, pEnd, radix);
-#ifdef DARWIN
+#if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0;
#endif
#ifdef TD_CHECK_STR_TO_INT_ERROR
diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c
index 9ba8468438246bfc1d88191cfb0b0f2d45c6a002..6471dad033c349b8d2da3972837b6411d80f5573 100644
--- a/source/os/src/osSysinfo.c
+++ b/source/os/src/osSysinfo.c
@@ -124,7 +124,7 @@ static char tsProcIOFile[25] = {0};
static void taosGetProcIOnfos() {
tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024;
tsOpenMax = sysconf(_SC_OPEN_MAX);
- tsStreamMax = sysconf(_SC_STREAM_MAX);
+ tsStreamMax = TMAX(sysconf(_SC_STREAM_MAX), 0);
tsProcId = (pid_t)syscall(SYS_gettid);
snprintf(tsProcMemFile, sizeof(tsProcMemFile), "/proc/%d/status", tsProcId);
@@ -280,11 +280,46 @@ int32_t taosGetEmail(char *email, int32_t maxLen) {
#endif
}
+#ifdef WINDOWS
+bool getWinVersionReleaseName(char *releaseName, int32_t maxLen) {
+ TCHAR szFileName[MAX_PATH];
+ DWORD dwHandle;
+ DWORD dwLen;
+ LPVOID lpData;
+ UINT uLen;
+ VS_FIXEDFILEINFO *pFileInfo;
+
+ GetWindowsDirectory(szFileName, MAX_PATH);
+ wsprintf(szFileName, L"%s%s", szFileName, L"\\explorer.exe");
+ dwLen = GetFileVersionInfoSize(szFileName, &dwHandle);
+ if (dwLen == 0) {
+ return false;
+ }
+ lpData = malloc(dwLen);
+ if (lpData == NULL) return false;
+ if (!GetFileVersionInfo(szFileName, dwHandle, dwLen, lpData)) {
+ free(lpData);
+ return false;
+ }
+
+ if (!VerQueryValue(lpData, L"\\", (LPVOID *)&pFileInfo, &uLen)) {
+ free(lpData);
+ return false;
+ }
+
+ snprintf(releaseName, maxLen, "Windows %d.%d", HIWORD(pFileInfo->dwProductVersionMS),
+ LOWORD(pFileInfo->dwProductVersionMS));
+ free(lpData);
+ return true;
+}
+#endif
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
#ifdef WINDOWS
- snprintf(releaseName, maxLen, "Windows");
+ if (!getWinVersionReleaseName(releaseName, maxLen)) {
+ snprintf(releaseName, maxLen, "Windows");
+ }
return 0;
#elif defined(_TD_DARWIN_64)
char osversion[32];
diff --git a/source/os/src/osTimer.c b/source/os/src/osTimer.c
index d1c233ea9c2a06de6f4f973395276fcae6246188..5a57007d1765302994c091bc3f970ef98388e000 100644
--- a/source/os/src/osTimer.c
+++ b/source/os/src/osTimer.c
@@ -99,8 +99,8 @@ static void *taosProcessAlarmSignal(void *tharg) {
setThreadName("tmr");
#ifdef _ALPINE
- sevent.sigev_notify = SIGEV_THREAD;
- sevent.sigev_value.sival_int = syscall(__NR_gettid);
+ sevent.sigev_notify = SIGEV_THREAD_ID;
+ sevent.sigev_notify_thread_id = syscall(__NR_gettid);
#else
sevent.sigev_notify = SIGEV_THREAD_ID;
sevent._sigev_un._tid = syscall(__NR_gettid);
diff --git a/source/os/test/osTests.cpp b/source/os/test/osTests.cpp
index 2e24bb05269ba9a4529b16726ca8c59d6de7ac68..1d6542e78cd987e5228c94609cf0dd865a6d6396 100644
--- a/source/os/test/osTests.cpp
+++ b/source/os/test/osTests.cpp
@@ -34,6 +34,12 @@ TEST(osTest, osSystem) {
ELogLevel level = DEBUG_FATAL;
int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag
taosPrintTrace(flags, level, dflag, 0);
+
+ const int sysLen = 64;
+ char osSysName[sysLen];
+ int ret = taosGetOsReleaseName(osSysName, sysLen);
+ printf("os systeme name:%s\n", osSysName);
+ ASSERT_EQ(ret, 0);
}
void fileOperateOnFree(void *param) {
diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c
index d9319485b7c3bbed717c054f6d63f91ca2220063..e373850b3cc5257ab78a8e9fde8249e14412dd21 100644
--- a/source/util/src/talgo.c
+++ b/source/util/src/talgo.c
@@ -28,32 +28,26 @@ static void median(void *src, int64_t size, int64_t s, int64_t e, const void *pa
void *buf) {
int32_t mid = ((int32_t)(e - s) >> 1u) + (int32_t)s;
- if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) {
+ if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) > 0) {
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf);
}
- if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, e), param) == 1) {
+ if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, e), param) > 0) {
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf);
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, e), size, buf);
- } else if (comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) == 1) {
+ } else if (comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) > 0) {
doswap(elePtrAt(src, size, s), elePtrAt(src, size, e), size, buf);
}
ASSERT(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 &&
comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) <= 0);
-
-#ifdef _DEBUG_VIEW
-// tTagsPrints(src[s], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
-// tTagsPrints(src[mid], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
-// tTagsPrints(src[e], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx);
-#endif
}
static void tInsertSort(void *src, int64_t size, int32_t s, int32_t e, const void *param, __ext_compar_fn_t comparFn,
void *buf) {
for (int32_t i = s + 1; i <= e; ++i) {
for (int32_t j = i; j > s; --j) {
- if (comparFn(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), param) == -1) {
+ if (comparFn(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), param) < 0) {
doswap(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), size, buf);
} else {
break;
@@ -278,14 +272,4 @@ void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar,
}
taosMemoryFree(buf);
- /*
- char *buf = taosMemoryCalloc(1, size);
-
- for (i = len - 1; i > 0; i--) {
- doswap(elePtrAt(base, size, 0), elePtrAt(base, size, i));
- taosheapadjust(base, size, 0, i - 1, parcompar, compar, parswap, swap, maxroot);
- }
-
- taosMemoryFreeClear(buf);
- */
}
diff --git a/source/util/src/terror.c b/source/util/src/terror.c
index 66211922916e1a276c89488d54802d5f611517c1..40eb8901ca7283bf1570682a5df8dce56374dc74 100644
--- a/source/util/src/terror.c
+++ b/source/util/src/terror.c
@@ -88,6 +88,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NEED_RETRY, "Retry needed")
TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE, "Out of memory in rpc queue")
TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TIMESTAMP, "Invalid timestamp format")
TAOS_DEFINE_ERROR(TSDB_CODE_MSG_DECODE_ERROR, "Msg decode error")
+TAOS_DEFINE_ERROR(TSDB_CODE_MSG_ENCODE_ERROR, "Msg encode error")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_AVAIL_DISK, "No available disk")
TAOS_DEFINE_ERROR(TSDB_CODE_NOT_FOUND, "Not found")
TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISKSPACE, "Out of disk space")
@@ -289,6 +290,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_NOT_EXIST, "Stream not exist")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_OPTION, "Invalid stream option")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_MUST_BE_DELETED, "Stream must be dropped first")
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB, "Stream temporarily does not support source db having replica > 1")
+TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_STREAMS, "Too many streams")
// mnode-sma
TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "SMA already exists")
diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c
index 62f074db5b9e28ffe71ca7ec3f4506b619ad20b1..89dd51a8924b3a24e70a665a3ae76e14541f6081 100644
--- a/source/util/src/tlog.c
+++ b/source/util/src/tlog.c
@@ -115,7 +115,6 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t m
static SLogBuff *taosLogBuffNew(int32_t bufSize);
static void taosCloseLogByFd(TdFilePtr pFile);
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
-static int32_t taosCompressFile(char *srcFileName, char *destFileName);
static FORCE_INLINE void taosUpdateDaylight() {
struct tm Tm, *ptm;
@@ -748,50 +747,6 @@ static void *taosAsyncOutputLog(void *param) {
return NULL;
}
-int32_t taosCompressFile(char *srcFileName, char *destFileName) {
- int32_t compressSize = 163840;
- int32_t ret = 0;
- int32_t len = 0;
- char *data = taosMemoryMalloc(compressSize);
- // gzFile dstFp = NULL;
-
- // srcFp = fopen(srcFileName, "r");
- TdFilePtr pSrcFile = taosOpenFile(srcFileName, TD_FILE_READ);
- if (pSrcFile == NULL) {
- ret = -1;
- goto cmp_end;
- }
-
- TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
- if (pFile == NULL) {
- ret = -2;
- goto cmp_end;
- }
-
- // dstFp = gzdopen(fd, "wb6f");
- // if (dstFp == NULL) {
- // ret = -3;
- // close(fd);
- // goto cmp_end;
- // }
- //
- // while (!feof(srcFp)) {
- // len = (int32_t)fread(data, 1, compressSize, srcFp);
- // (void)gzwrite(dstFp, data, len);
- // }
-
-cmp_end:
- if (pSrcFile) {
- taosCloseFile(&pSrcFile);
- }
- // if (dstFp) {
- // gzclose(dstFp);
- // }
- taosMemoryFree(data);
-
- return ret;
-}
-
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) {
if (condition) return false;
diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c
index 7c60862c56b8544dc815723aa5427dc604a0fff5..3cecfdff9cffbfa0120656e380d9bddc0ea14073 100644
--- a/source/util/src/tpagedbuf.c
+++ b/source/util/src/tpagedbuf.c
@@ -5,11 +5,11 @@
#include "thash.h"
#include "tlog.h"
-#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES)
-#define BUF_PAGE_IN_MEM(_p) ((_p)->pData != NULL)
+#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES)
+#define BUF_PAGE_IN_MEM(_p) ((_p)->pData != NULL)
#define CLEAR_BUF_PAGE_IN_MEM_FLAG(_p) ((_p)->pData = NULL)
-#define HAS_DATA_IN_DISK(_p) ((_p)->offset >= 0)
-#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages)
+#define HAS_DATA_IN_DISK(_p) ((_p)->offset >= 0)
+#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages)
typedef struct SPageDiskInfo {
int64_t offset;
@@ -17,7 +17,7 @@ typedef struct SPageDiskInfo {
} SPageDiskInfo, SFreeListItem;
struct SPageInfo {
- SListNode* pn; // point to list node struct. it is NULL when the page is evicted from the in-memory buffer
+ SListNode* pn; // point to list node struct. it is NULL when the page is evicted from the in-memory buffer
void* pData;
int64_t offset;
int32_t pageId;
@@ -52,10 +52,13 @@ struct SDiskbasedBuf {
};
static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
- if (pBuf->path == NULL) { // prepare the file name when needed it
+ if (pBuf->path == NULL) { // prepare the file name when needed it
char path[PATH_MAX] = {0};
taosGetTmpfilePath(pBuf->prefix, "paged-buf", path);
pBuf->path = taosMemoryStrDup(path);
+ if (pBuf->path == NULL) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
}
pBuf->pFile =
@@ -126,6 +129,30 @@ static uint64_t allocateNewPositionInFile(SDiskbasedBuf* pBuf, size_t size) {
static FORCE_INLINE size_t getAllocPageSize(int32_t pageSize) { return pageSize + POINTER_BYTES + sizeof(SFilePage); }
+static int32_t doFlushBufPageImpl(SDiskbasedBuf* pBuf, int64_t offset, const char* pData, int32_t size) {
+ int32_t ret = taosLSeekFile(pBuf->pFile, offset, SEEK_SET);
+ if (ret == -1) {
+ terrno = TAOS_SYSTEM_ERROR(errno);
+ return terrno;
+ }
+
+ ret = (int32_t)taosWriteFile(pBuf->pFile, pData, size);
+ if (ret != size) {
+ terrno = TAOS_SYSTEM_ERROR(errno);
+ return terrno;
+ }
+
+ // extend the file
+ if (pBuf->fileSize < offset + size) {
+ pBuf->fileSize = offset + size;
+ }
+
+ pBuf->statis.flushBytes += size;
+ pBuf->statis.flushPages += 1;
+
+ return TSDB_CODE_SUCCESS;
+}
+
static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
if (pg->pData == NULL || pg->used) {
uError("invalid params in paged buffer process when flushing buf to disk, %s", pBuf->id);
@@ -134,12 +161,15 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
}
int32_t size = pBuf->pageSize;
- char* t = NULL;
+ int64_t offset = pg->offset;
+
+ char* t = NULL;
if ((!HAS_DATA_IN_DISK(pg)) || pg->dirty) {
void* payload = GET_PAYLOAD_DATA(pg);
t = doCompressData(payload, pBuf->pageSize, &size, pBuf);
if (size < 0) {
uError("failed to compress data when flushing data to disk, %s", pBuf->id);
+ terrno = TSDB_CODE_INVALID_PARA;
return NULL;
}
}
@@ -147,59 +177,29 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
// this page is flushed to disk for the first time
if (pg->dirty) {
if (!HAS_DATA_IN_DISK(pg)) {
- pg->offset = allocateNewPositionInFile(pBuf, size);
+ offset = allocateNewPositionInFile(pBuf, size);
pBuf->nextPos += size;
- int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET);
- if (ret == -1) {
- terrno = TAOS_SYSTEM_ERROR(errno);
+ int32_t code = doFlushBufPageImpl(pBuf, offset, t, size);
+ if (code != TSDB_CODE_SUCCESS) {
return NULL;
}
-
- ret = (int32_t)taosWriteFile(pBuf->pFile, t, size);
- if (ret != size) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- return NULL;
- }
-
- // extend the file size
- if (pBuf->fileSize < pg->offset + size) {
- pBuf->fileSize = pg->offset + size;
- }
-
- pBuf->statis.flushBytes += size;
- pBuf->statis.flushPages += 1;
} else {
// length becomes greater, current space is not enough, allocate new place, otherwise, do nothing
if (pg->length < size) {
// 1. add current space to free list
- SPageDiskInfo dinfo = {.length = pg->length, .offset = pg->offset};
+ SPageDiskInfo dinfo = {.length = pg->length, .offset = offset};
taosArrayPush(pBuf->pFree, &dinfo);
// 2. allocate new position, and update the info
- pg->offset = allocateNewPositionInFile(pBuf, size);
+ offset = allocateNewPositionInFile(pBuf, size);
pBuf->nextPos += size;
}
- // 3. write to disk.
- int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET);
- if (ret == -1) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- return NULL;
- }
-
- ret = (int32_t)taosWriteFile(pBuf->pFile, t, size);
- if (ret != size) {
- terrno = TAOS_SYSTEM_ERROR(errno);
+ int32_t code = doFlushBufPageImpl(pBuf, offset, t, size);
+ if (code != TSDB_CODE_SUCCESS) {
return NULL;
}
-
- if (pBuf->fileSize < pg->offset + size) {
- pBuf->fileSize = pg->offset + size;
- }
-
- pBuf->statis.flushBytes += size;
- pBuf->statis.flushPages += 1;
}
} else { // NOTE: the size may be -1, the this recycle page has not been flushed to disk yet.
size = pg->length;
@@ -209,9 +209,10 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
memset(pDataBuf, 0, getAllocPageSize(pBuf->pageSize));
#ifdef BUF_PAGE_DEBUG
- uDebug("page_flush %p, pageId:%d, offset:%d", pDataBuf, pg->pageId, pg->offset);
+ uDebug("page_flush %p, pageId:%d, offset:%d", pDataBuf, pg->pageId, offset);
#endif
+ pg->offset = offset;
pg->length = size; // on disk size
return pDataBuf;
}
@@ -236,7 +237,7 @@ static char* flushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
// load file block data in disk
static int32_t loadPageFromDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) {
if (pg->offset < 0 || pg->length <= 0) {
- uError("failed to load buf page from disk, offset:%"PRId64", length:%d, %s", pg->offset, pg->length, pBuf->id);
+ uError("failed to load buf page from disk, offset:%" PRId64 ", length:%d, %s", pg->offset, pg->length, pBuf->id);
return TSDB_CODE_INVALID_PARA;
}
@@ -303,6 +304,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
static char* evictBufPage(SDiskbasedBuf* pBuf) {
SListNode* pn = getEldestUnrefedPage(pBuf);
if (pn == NULL) { // no available buffer pages now, return.
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
@@ -382,14 +384,14 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
goto _error;
}
- pPBuf->prefix = (char*) dir;
+ pPBuf->prefix = (char*)dir;
pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
// qDebug("QInfo:0x%"PRIx64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId,
// pPBuf->pageSize, pPBuf->inMemPages, pPBuf->path);
return TSDB_CODE_SUCCESS;
- _error:
+_error:
destroyDiskbasedBuf(pPBuf);
return TSDB_CODE_OUT_OF_MEMORY;
}
@@ -399,11 +401,12 @@ static char* doExtractPage(SDiskbasedBuf* pBuf) {
if (NO_IN_MEM_AVAILABLE_PAGES(pBuf)) {
availablePage = evictBufPage(pBuf);
if (availablePage == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- uWarn("no available buf pages, current:%d, max:%d", listNEles(pBuf->lruList), pBuf->inMemPages)
+ uWarn("no available buf pages, current:%d, max:%d, reason: %s, %s", listNEles(pBuf->lruList), pBuf->inMemPages,
+ terrstr(), pBuf->id)
}
} else {
- availablePage = taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased.
+ availablePage =
+ taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased.
if (availablePage == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
}
@@ -551,9 +554,7 @@ void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) {
size_t getTotalBufSize(const SDiskbasedBuf* pBuf) { return (size_t)pBuf->totalBufSize; }
-SArray* getDataBufPagesIdList(SDiskbasedBuf* pBuf) {
- return pBuf->pIdList;
-}
+SArray* getDataBufPagesIdList(SDiskbasedBuf* pBuf) { return pBuf->pIdList; }
void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
if (pBuf == NULL) {
@@ -567,7 +568,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
needRemoveFile = true;
uDebug(
"Paged buffer closed, total:%.2f Kb (%d Pages), inmem size:%.2f Kb (%d Pages), file size:%.2f Kb, page "
- "size:%.2f Kb, %s\n",
+ "size:%.2f Kb, %s",
pBuf->totalBufSize / 1024.0, pBuf->numOfPages, listNEles(pBuf->lruList) * pBuf->pageSize / 1024.0,
listNEles(pBuf->lruList), pBuf->fileSize / 1024.0, pBuf->pageSize / 1024.0f, pBuf->id);
@@ -584,8 +585,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages);
} else {
uDebug(
- "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f "
- "Kb",
+ "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPgSize:%.2f Kb",
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
}
@@ -628,9 +628,7 @@ SPageInfo* getLastPageInfo(SArray* pList) {
return pPgInfo;
}
-int32_t getPageId(const SPageInfo* pPgInfo) {
- return pPgInfo->pageId;
-}
+int32_t getPageId(const SPageInfo* pPgInfo) { return pPgInfo->pageId; }
int32_t getBufPageSize(const SDiskbasedBuf* pBuf) { return pBuf->pageSize; }
@@ -686,7 +684,7 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) {
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
} else {
- //printf("no page loaded\n");
+ // printf("no page loaded\n");
}
}
diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c
index ffae5441aa088f2cc71710b301d5243cb3975235..e7386d5912dd83c5a76af3c902bcd910b5ffef87 100644
--- a/source/util/src/trbtree.c
+++ b/source/util/src/trbtree.c
@@ -147,6 +147,10 @@ static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn) {
pTree->cmprFn = cmprFn;
+ tRBTreeClear(pTree);
+}
+
+void tRBTreeClear(SRBTree *pTree) {
pTree->n = 0;
pTree->NIL = &pTree->NILNODE;
pTree->NIL->color = BLACK;
@@ -423,6 +427,22 @@ SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
return pNode;
}
+SRBTreeNode *tRBTreeDropMin(SRBTree *pTree) {
+ SRBTreeNode *pNode = tRBTreeMin(pTree);
+ if (pNode) {
+ tRBTreeDrop(pTree, pNode);
+ }
+ return pNode;
+}
+
+SRBTreeNode *tRBTreeDropMax(SRBTree *pTree) {
+ SRBTreeNode *pNode = tRBTreeMax(pTree);
+ if (pNode) {
+ tRBTreeDrop(pTree, pNode);
+ }
+ return pNode;
+}
+
SRBTreeNode *tRBTreeGet(SRBTree *pTree, const SRBTreeNode *pKeyNode) {
SRBTreeNode *pNode = pTree->root;
diff --git a/tests/ci/Dockerfile b/tests/ci/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..594bcc902d09028a7ef98f3023dece1a44636b94
--- /dev/null
+++ b/tests/ci/Dockerfile
@@ -0,0 +1,48 @@
+FROM python:3.8
+RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
+RUN pip3 install pandas psutil fabric2 requests faker simplejson toml pexpect tzlocal distro
+RUN apt-get update
+RUN apt-get install -y psmisc sudo tree libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config build-essential valgrind \
+ vim libjemalloc-dev openssh-server screen sshpass net-tools dirmngr gnupg apt-transport-https ca-certificates software-properties-common r-base iputils-ping
+RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
+RUN add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
+RUN apt install -y r-base
+ADD go1.17.6.linux-amd64.tar.gz /usr/local/
+ADD jdk-8u144-linux-x64.tar.gz /usr/local/
+ADD apache-maven-3.8.4-bin.tar.gz /usr/local/
+RUN apt-get install wget -y \
+ && wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
+ && dpkg -i packages-microsoft-prod.deb \
+ && rm packages-microsoft-prod.deb \
+ && apt-get update && apt-get install -y dotnet-sdk-5.0 && apt-get install -y dotnet-sdk-6.0
+ADD node-v12.20.0-linux-x64.tar.gz /usr/local/
+RUN sh -c "rm -f /etc/localtime;ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;echo \"Asia/Shanghai\" >/etc/timezone"
+COPY id_rsa /root/.ssh/id_rsa
+COPY .m2 /root/.m2
+COPY .nuget /root/.nuget
+COPY .dotnet /root/.dotnet
+COPY .cargo /root/.cargo
+COPY go /root/go
+ADD cmake-3.21.5-linux-x86_64.tar.gz /usr/local/
+RUN echo " export RUSTUP_DIST_SERVER=\"https://rsproxy.cn\" " >> /root/.bashrc
+RUN echo " export RUSTUP_UPDATE_ROOT=\"https://rsproxy.cn/rustup\" " >> /root/.bashrc
+RUN curl https://sh.rustup.rs -o /tmp/rustup-init.sh
+RUN sh /tmp/rustup-init.sh -y
+ENV PATH /usr/local/go/bin:/usr/local/node-v12.20.0-linux-x64/bin:/usr/local/apache-maven-3.8.4/bin:/usr/local/jdk1.8.0_144/bin:/usr/local/cmake-3.21.5-linux-x86_64/bin:/root/.cargo/bin:$PATH
+ENV JAVA_HOME /usr/local/jdk1.8.0_144
+RUN go env -w GOPROXY=https://goproxy.cn
+RUN echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config
+RUN npm config -g set unsafe-perm
+RUN npm config -g set registry https://registry.npm.taobao.org
+COPY .npm /root/.npm
+RUN R CMD javareconf JAVA_HOME=${JAVA_HOME} JAVA=${JAVA_HOME}/bin/java JAVAC=${JAVA_HOME}/bin/javac JAVAH=${JAVA_HOME}/bin/javah JAR=${JAVA_HOME}/bin/jar
+RUN echo "install.packages(\"RJDBC\", repos=\"http://cran.us.r-project.org\")"|R --no-save
+COPY .gitconfig /root/.gitconfig
+RUN mkdir -p /run/sshd
+COPY id_rsa.pub /root/.ssh/id_rsa.pub
+COPY id_rsa.pub /root/.ssh/authorized_keys
+RUN pip3 uninstall -y taostest
+COPY repository/TDinternal /home/TDinternal
+COPY repository/taos-connector-python /home/taos-connector-python
+RUN sh -c "cd /home/taos-connector-python; pip3 install ."
+COPY setup.sh /home/setup.sh
\ No newline at end of file
diff --git a/tests/ci/build_image.sh b/tests/ci/build_image.sh
new file mode 100755
index 0000000000000000000000000000000000000000..1864df35db7cc0af02b02277af71b9ad0c115b9a
--- /dev/null
+++ b/tests/ci/build_image.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+docker build --no-cache -t taos_test:v1.0 .
+
diff --git a/tests/ci/daily_build_image.sh b/tests/ci/daily_build_image.sh
new file mode 100755
index 0000000000000000000000000000000000000000..01148a3aae769297e829ffb4b6cd483d73673c31
--- /dev/null
+++ b/tests/ci/daily_build_image.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+set -x
+
+script_dir=`dirname $0`
+cd $script_dir
+script_dir=`pwd`
+cd $script_dir/repository/taos-connector-python
+git pull
+
+cd $script_dir/repository/TDinternal
+git clean -fxd
+git pull
+
+cd $script_dir/repository/TDinternal/community
+git clean -fxd
+git checkout main
+git pull origin main
+git submodule update --init --recursive
+
+cd $script_dir
+cp $script_dir/repository/TDinternal/community/tests/ci/build_image.sh .
+cp $script_dir/repository/TDinternal/community/tests/ci/daily_build_image.sh .
+
+./build_image.sh || exit 1
+docker image prune -f
+ips="\
+192.168.1.47 \
+192.168.1.48 \
+192.168.1.49 \
+192.168.1.52 \
+192.168.0.215 \
+192.168.0.217 \
+192.168.0.219 \
+"
+
+image=taos_image.tar
+
+docker save taos_test:v1.0 -o $image
+
+for ip in $ips; do
+ echo "scp $image root@$ip:/home/ &"
+ scp $image root@$ip:/home/ &
+done
+wait
+
+for ip in $ips; do
+ echo "ssh root@$ip docker load -i /home/$image &"
+ ssh root@$ip docker load -i /home/$image &
+done
+wait
+
+for ip in $ips; do
+ echo "ssh root@$ip rm -f /home/$image &"
+ ssh root@$ip rm -f /home/$image &
+done
+wait
+
+rm -rf taos_image.tar
+
diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json
index 62ec0ff9bfff3d847e785b285b102ae5fecf8c2f..26a08b3fee7af72361229b944de7fefe7f8a1317 100644
--- a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json
+++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_json_alltypes.json
@@ -16,13 +16,7 @@
"databases": [{
"dbinfo": {
"name": "db",
- "drop": "yes",
- "replica": 1,
- "precision": "ms",
- "keep": 36500,
- "minRows": 100,
- "maxRows": 4096,
- "comp":2
+ "drop": "yes"
},
"super_tables": [{
"name": "stb1",
@@ -37,7 +31,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -62,7 +56,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -87,7 +81,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -112,7 +106,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -137,7 +131,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -162,7 +156,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -187,7 +181,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -212,7 +206,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
@@ -237,7 +231,7 @@
"line_protocol": "json",
"childtable_limit": 0,
"childtable_offset": 0,
- "insert_rows": 10,
+ "insert_rows": 20,
"insert_interval": 0,
"interlace_rows": 0,
"disorder_ratio": 0,
diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py
index 789a0ce0a2aaf195665f3ab483428cbca346b1b0..0d10741331578f678198ad8dac597fe56a6c0709 100644
--- a/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py
+++ b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py
@@ -19,32 +19,38 @@ from util.dnodes import *
class TDTestCase:
def caseDescription(self):
- '''
+ """
[TD-11510] taosBenchmark test cases
- '''
- return
+ """
def init(self, conn, logSql, replicaVar=1):
- self.replicaVar = int(replicaVar)
tdLog.debug("start to execute %s" % __file__)
+ self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor(), logSql)
def getPath(self, tool="taosBenchmark"):
selfPath = os.path.dirname(os.path.realpath(__file__))
- if ("community" in selfPath):
- projPath = selfPath[:selfPath.find("community")]
+ if "community" in selfPath:
+ projPath = selfPath[: selfPath.find("community")]
+ elif "src" in selfPath:
+ projPath = selfPath[: selfPath.find("src")]
+ elif "/tools/" in selfPath:
+ projPath = selfPath[: selfPath.find("/tools/")]
+ elif "/tests/" in selfPath:
+ projPath = selfPath[: selfPath.find("/tests/")]
else:
- projPath = selfPath[:selfPath.find("tests")]
+ tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath))
+ projPath = "/usr/local/taos/bin/"
paths = []
- for root, dirs, files in os.walk(projPath):
- if ((tool) in files):
+ for root, dummy, files in os.walk(projPath):
+ if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root))
- if ("packaging" not in rootRealPath):
+ if "packaging" not in rootRealPath:
paths.append(os.path.join(root, tool))
break
- if (len(paths) == 0):
+ if len(paths) == 0:
tdLog.exit("taosBenchmark not found!")
return
else:
@@ -52,49 +58,63 @@ class TDTestCase:
return paths[0]
def run(self):
+ tdSql.query("select client_version()")
+ client_ver = "".join(tdSql.queryResult[0])
+ major_ver = client_ver.split(".")[0]
+
binPath = self.getPath()
- cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_json_alltypes.json" %binPath
+ cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_json_alltypes.json" % binPath
tdLog.info("%s" % cmd)
os.system("%s" % cmd)
tdSql.execute("reset query cache")
tdSql.query("describe db.stb1")
tdSql.checkData(1, 1, "BOOL")
tdSql.query("describe db.stb2")
- tdSql.checkData(1, 1, "TINYINT")
+ tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb3")
- tdSql.checkData(1, 1, "SMALLINT")
+ tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb4")
- tdSql.checkData(1, 1, "INT")
+ tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb5")
- tdSql.checkData(1, 1, "BIGINT")
+ tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb6")
- tdSql.checkData(1, 1, "FLOAT")
+ tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb7")
tdSql.checkData(1, 1, "DOUBLE")
tdSql.query("describe db.stb8")
- tdSql.checkData(1, 1, "VARCHAR")
- tdSql.checkData(1, 2, 16)
+ if major_ver == "3":
+ tdSql.checkData(1, 1, "VARCHAR")
+ tdSql.checkData(1, 2, 16)
+ else:
+ tdSql.checkData(1, 1, "NCHAR")
+ tdSql.checkData(1, 2, 8)
+
tdSql.query("describe db.stb9")
- tdSql.checkData(1, 1, "NCHAR")
- tdSql.checkData(1, 2, 16)
+ if major_ver == "3":
+ tdSql.checkData(1, 1, "VARCHAR")
+ tdSql.checkData(1, 2, 16)
+ else:
+ tdSql.checkData(1, 1, "NCHAR")
+ tdSql.checkData(1, 2, 8)
+
tdSql.query("select count(*) from db.stb1")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb2")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb3")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb4")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb5")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb6")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb7")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb8")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
tdSql.query("select count(*) from db.stb9")
- tdSql.checkData(0, 0, 80)
+ tdSql.checkData(0, 0, 160)
def stop(self):
tdSql.close()
diff --git a/tests/docs-examples-test/python.sh b/tests/docs-examples-test/python.sh
index ccb391b7527fbf2490911d868d08c87436221162..31342b33d7a6a0038bb02c32e2ce99c788957792 100644
--- a/tests/docs-examples-test/python.sh
+++ b/tests/docs-examples-test/python.sh
@@ -83,4 +83,5 @@ python3 fast_write_example.py
# 20
pip3 install kafka-python
-python3 kafka_example.py
+python3 kafka_example_consumer.py
+
diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task
index 94d87c705cfaa07028ed64caf30ae668ad245cf3..e1baac4a0fe597dee33212289c501a0468b7a531 100644
--- a/tests/parallel_test/cases.task
+++ b/tests/parallel_test/cases.task
@@ -179,6 +179,8 @@
,,y,script,./test.sh -f tsim/query/udf_with_const.sim
,,y,script,./test.sh -f tsim/query/sys_tbname.sim
,,y,script,./test.sh -f tsim/query/groupby.sim
+,,y,script,./test.sh -f tsim/query/event.sim
+,,y,script,./test.sh -f tsim/query/forceFill.sim
,,y,script,./test.sh -f tsim/qnode/basic1.sim
,,y,script,./test.sh -f tsim/snode/basic1.sim
,,y,script,./test.sh -f tsim/mnode/basic1.sim
@@ -408,7 +410,7 @@
,,y,script,./test.sh -f tmp/monitor.sim
#system test
-
+,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellNetChk.py
@@ -1053,6 +1055,11 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 4
+,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py
+,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -R
+,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 2
+,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 3
+,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4
diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh
index 221e5490560252989b81264247ca2b8bf6eda7b1..ff854449bb913bea8bf5dd1b6477d7d9c7a7b70e 100755
--- a/tests/parallel_test/container_build.sh
+++ b/tests/parallel_test/container_build.sh
@@ -55,7 +55,7 @@ fi
date
docker run \
-v $REP_MOUNT_PARAM \
- --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true;make -j || exit 1"
+ --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true;make -j || exit 1"
if [[ -d ${WORKDIR}/debugNoSan ]] ;then
echo "delete ${WORKDIR}/debugNoSan"
@@ -70,7 +70,7 @@ mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugNoSan
date
docker run \
-v $REP_MOUNT_PARAM \
- --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug;make -j || exit 1 "
+ --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true;make -j || exit 1 "
mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan
diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py
index a1682f47b3e229e24a9b7bdd750b8cbe4890dea5..ddb3bfaa269e90a3272233181e0b7e3feab5bbab 100644
--- a/tests/pytest/util/dnodes.py
+++ b/tests/pytest/util/dnodes.py
@@ -15,6 +15,7 @@ import sys
import os
import os.path
import platform
+import distro
import subprocess
from time import sleep
import base64
@@ -22,6 +23,7 @@ import json
import copy
from fabric2 import Connection
from util.log import *
+from shutil import which
class TDSimClient:
@@ -166,9 +168,9 @@ class TDDnode:
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")
+ 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")
+ self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh")
def getDataSize(self):
totalSize = 0
@@ -686,7 +688,7 @@ class TDDnodes:
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:
+ 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")
@@ -765,7 +767,8 @@ class TDDnodes:
def stopAll(self):
tdLog.info("stop all dnodes, asan:%d" % self.asan)
- if self.asan:
+ distro_id = distro.id()
+ if self.asan and distro_id != "alpine":
tdLog.info("execute script: %s" % self.stopDnodesPath)
os.system(self.stopDnodesPath)
tdLog.info("execute finished")
@@ -777,24 +780,41 @@ class TDDnodes:
for i in range(len(self.dnodes)):
self.dnodes[i].stop()
- 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):
- if platform.system().lower() == 'windows':
- killCmd = "kill -9 %s > nul 2>&1" % processID
- else:
- 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 (distro_id == "alpine"):
+ print(distro_id)
+ 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)
+ if platform.system().lower() == 'windows':
+ killCmd = "kill -9 %s > nul 2>&1" % processID
+ else:
+ 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()
+
+ 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):
+ if platform.system().lower() == 'windows':
+ killCmd = "kill -9 %s > nul 2>&1" % processID
+ else:
+ 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"
diff --git a/tests/requirements.txt b/tests/requirements.txt
index ce459414c44c6adcb8c8a77b03ea790480a41cd2..d2edbfb32d705202a94022aed4304b9210dfe75a 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -3,3 +3,8 @@ numpy
fabric2
psutil
pandas
+toml
+distro
+requests
+pexpect
+faker
\ No newline at end of file
diff --git a/tests/script/sh/cfg.sh b/tests/script/sh/cfg.sh
index 7d4d747e54bab9ed98b42ab1902f8580e17fca6c..bf58185f6201b5046608881d9c9f1a5b5e8de3ac 100755
--- a/tests/script/sh/cfg.sh
+++ b/tests/script/sh/cfg.sh
@@ -45,11 +45,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/checkAsan.sh b/tests/script/sh/checkAsan.sh
index 72257227916785de3d174349d4c83d3302064295..31fe80829fa693d8fd3bb5a5da8efbd7ed2e4035 100755
--- a/tests/script/sh/checkAsan.sh
+++ b/tests/script/sh/checkAsan.sh
@@ -2,7 +2,19 @@
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
+if [[ "$TD_OS" == "Alpine" ]]; then
+ echo -e "os is Alpine,skip check Asan"
+ exit 0
+fi
unset LD_PRELOAD
SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
diff --git a/tests/script/sh/clear.sh b/tests/script/sh/clear.sh
index 4ee296cf058370552b14c31b67006830e84847dd..587a33f633fbfac4319cf5f6724a29fa60680a91 100755
--- a/tests/script/sh/clear.sh
+++ b/tests/script/sh/clear.sh
@@ -48,11 +48,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh
index 217bd66ef61d937a575145e36c645db37b20f046..7da8da09bfcf3810b692ff25f37333c93ae87497 100755
--- a/tests/script/sh/deploy.sh
+++ b/tests/script/sh/deploy.sh
@@ -39,11 +39,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/exec-default.sh b/tests/script/sh/exec-default.sh
index f648315c6745f63cfba9eb06ecfd53a9ccef1fed..0a83fa1dc81e5b510e85c2a5e2bf7f646f69e684 100755
--- a/tests/script/sh/exec-default.sh
+++ b/tests/script/sh/exec-default.sh
@@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/exec-no-random-fail.sh b/tests/script/sh/exec-no-random-fail.sh
index e01b18a8e6bb0d4631a28c64c6accd57bceb9076..b15783afb569a760405091dea54dcbb6832fa920 100755
--- a/tests/script/sh/exec-no-random-fail.sh
+++ b/tests/script/sh/exec-no-random-fail.sh
@@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/exec-random-fail.sh b/tests/script/sh/exec-random-fail.sh
index 1f31899e3ac26861fc1860d10cb0a4899ff7bf36..15f2864ca6d9b371412e173ea81034a52a437994 100755
--- a/tests/script/sh/exec-random-fail.sh
+++ b/tests/script/sh/exec-random-fail.sh
@@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh
index c8cb121b8a88b618cbd7410e95741091655cef38..f548a4cc418d34ac5d4fe27fb944181c54b3a5c2 100755
--- a/tests/script/sh/exec.sh
+++ b/tests/script/sh/exec.sh
@@ -10,6 +10,14 @@
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
unset LD_PRELOAD
UNAME_BIN=`which uname`
@@ -44,7 +52,10 @@ do
;;
esac
done
-
+if [[ "$VALGRIND_OPTION" = "true" ]] && [[ "$TD_OS" == "Alpine" ]]; then
+ echo alpine skip valgrind
+ VALGRIND_OPTION="false"
+fi
SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`
@@ -59,11 +70,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/exec_tarbitrator.sh b/tests/script/sh/exec_tarbitrator.sh
index e985bd65856025b2db8dfef724fdc652b2a03392..eacf5fd2262e54e5ef8d2f475e9cc4faf0515430 100755
--- a/tests/script/sh/exec_tarbitrator.sh
+++ b/tests/script/sh/exec_tarbitrator.sh
@@ -51,11 +51,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/sh/mv_old_data.sh b/tests/script/sh/mv_old_data.sh
index 3f4be6714fd757ee60d21ee97be5d411e3f95bdd..1a6bd22c621873253bf98690900759c1ef2304d7 100755
--- a/tests/script/sh/mv_old_data.sh
+++ b/tests/script/sh/mv_old_data.sh
@@ -20,11 +20,7 @@ fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/test.sh b/tests/script/test.sh
index 19180382fd30de26667fef44a5ebc54d19d5b6a7..b10865dd65a8ac2a0771ca49b58ef72ed473bec3 100755
--- a/tests/script/test.sh
+++ b/tests/script/test.sh
@@ -51,11 +51,7 @@ fi
TOP_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
diff --git a/tests/script/tsim/compute/block_dist.sim b/tests/script/tsim/compute/block_dist.sim
index 2d0a4e890267af3520e8c99f21a4d87c5bc1ceef..4fdcf63e34f5c5949d87f9b02cc3b620c87bd429 100644
--- a/tests/script/tsim/compute/block_dist.sim
+++ b/tests/script/tsim/compute/block_dist.sim
@@ -91,6 +91,10 @@ print ============== TD-5998
sql_error select _block_dist() from (select * from $nt)
sql_error select _block_dist() from (select * from $mt)
+print ============== TD-22140 & TD-22165
+sql_error show table distributed information_schema.ins_databases
+sql_error show table distributed performance_schema.perf_apps
+
print =============== clear
sql drop database $db
sql select * from information_schema.ins_databases
diff --git a/tests/script/tsim/dnode/balance3.sim b/tests/script/tsim/dnode/balance3.sim
index 2fb284b46614e37ee6ac27bd13a16eb7429e9d86..d0235e096e483e93c1785b555be93150c2a3c35e 100644
--- a/tests/script/tsim/dnode/balance3.sim
+++ b/tests/script/tsim/dnode/balance3.sim
@@ -130,13 +130,13 @@ print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 1 then
return -1
endi
-if $data(2)[2] != 1 then
+if $data(2)[2] != 2 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
-if $data(4)[2] != 2 then
+if $data(4)[2] != 1 then
return -1
endi
@@ -216,7 +216,7 @@ endi
print ========== step4
sql create database d3 replica 3 vgroups 1
-sql create table d3.t3 (t timestamp, i int)
+sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
sql insert into d3.t3 values(now+3s, 33)
@@ -231,10 +231,10 @@ print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 2 then
return -1
endi
-if $data(3)[2] != 2 then
+if $data(3)[2] != 3 then
return -1
endi
-if $data(4)[2] != 3 then
+if $data(4)[2] != 2 then
return -1
endi
if $data(5)[2] != 2 then
@@ -315,10 +315,10 @@ endi
if $data(3)[2] != null then
return -1
endi
-if $data(4)[2] != 2 then
+if $data(4)[2] != 3 then
return -1
endi
-if $data(5)[2] != 3 then
+if $data(5)[2] != 2 then
return -1
endi
if $data(6)[2] != 2 then
diff --git a/tests/script/tsim/dnode/balancex.sim b/tests/script/tsim/dnode/balancex.sim
index 0cfc64a954f10457ab720990c758cfe4032e900a..6f077be521e4a4835b3c778a1dee25ea61a8c4eb 100644
--- a/tests/script/tsim/dnode/balancex.sim
+++ b/tests/script/tsim/dnode/balancex.sim
@@ -145,10 +145,10 @@ print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 1 then
return -1
endi
-if $data(2)[2] != 1 then
+if $data(2)[2] != 2 then
return -1
endi
-if $data(3)[2] != 2 then
+if $data(3)[2] != 1 then
return -1
endi
if $data(4)[2] != 1 then
diff --git a/tests/script/tsim/dnode/drop_dnode_force.sim b/tests/script/tsim/dnode/drop_dnode_force.sim
index 26e48933be4929e158a407fd512734720be32d95..425e5f48b2f278f3ef2f2bad51b25f81b8133fc2 100644
--- a/tests/script/tsim/dnode/drop_dnode_force.sim
+++ b/tests/script/tsim/dnode/drop_dnode_force.sim
@@ -120,9 +120,9 @@ if $rows != 12 then
return -1
endi
-print =============== step3: create qnode snode on dnode 2
-sql create qnode on dnode 2
-sql create snode on dnode 2
+print =============== step3: create qnode snode on dnode 3
+sql create qnode on dnode 3
+sql create snode on dnode 3
sql select * from information_schema.ins_qnodes
if $rows != 1 then
return -1
@@ -136,16 +136,16 @@ print =============== step4: create mnode on dnode 2
sql create mnode on dnode 3
sql create mnode on dnode 2
$x = 0
-step4:
+step4:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql select * from information_schema.ins_mnodes -x step4
-print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
-print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
-print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[1][4]
+print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
+print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
+print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[1][4]
#if $data(1)[2] != leader then
# goto step4
#endi
@@ -157,7 +157,7 @@ endi
#endi
print =============== step5: create dnode 5
-system sh/exec.sh -n dnode2 -s stop -x SIGINT
+system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s start
$x = 0
step5:
@@ -179,10 +179,10 @@ endi
if $data(1)[4] != ready then
goto step5
endi
-if $data(2)[4] != offline then
+if $data(2)[4] != ready then
goto step5
endi
-if $data(3)[4] != ready then
+if $data(3)[4] != offline then
goto step5
endi
if $data(4)[4] != ready then
@@ -192,9 +192,9 @@ if $data(5)[4] != ready then
goto step5
endi
-print =============== step5a: drop dnode 2
-sql_error drop dnode 2
-sql drop dnode 2 force
+print =============== step5a: drop dnode 3
+sql_error drop dnode 3
+sql drop dnode 3 force
print select * from information_schema.ins_dnodes;
sql select * from information_schema.ins_dnodes;
diff --git a/tests/script/tsim/dnode/split_vgroup_replica1.sim b/tests/script/tsim/dnode/split_vgroup_replica1.sim
index 1bdd322714a1e8e7443d337daacc69d3ce2a4792..51d63d25f482985b67ae37f2d4f005b8010f759e 100644
--- a/tests/script/tsim/dnode/split_vgroup_replica1.sim
+++ b/tests/script/tsim/dnode/split_vgroup_replica1.sim
@@ -11,7 +11,6 @@ system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
sql connect
-sql create user u1 pass 'taosdata'
print =============== step1 create dnode2
sql create dnode $hostname port 7200
@@ -73,8 +72,21 @@ print =============== step3: create database
sql use d1
sql create table d1.st (ts timestamp, i int) tags (j int)
sql create table d1.c1 using st tags(1)
+sql create table d1.c2 using st tags(2)
+sql create table d1.c3 using st tags(3)
+sql create table d1.c4 using st tags(4)
+sql create table d1.c5 using st tags(5)
+sql insert into d1.c1 values (now, 1);
+sql insert into d1.c2 values (now, 2);
+sql insert into d1.c3 values (now, 3);
+sql insert into d1.c4 values (now, 4);
+sql insert into d1.c5 values (now, 5);
sql show d1.tables
-if $rows != 1 then
+if $rows != 5 then
+ return -1
+endi
+sql select * from d1.st
+if $rows != 5 then
return -1
endi
@@ -82,6 +94,34 @@ print =============== step4: split
print split vgroup 2
sql split vgroup 2
+print =============== step5: check split result
+sql show d1.tables
+#if $rows != 5 then
+# return -1
+#endi
+#sql select * from d1.st
+#if $rows != 5 then
+# return -1
+#endi
+
+print =============== step6: create tables
+sql create table d1.c6 using st tags(6)
+sql create table d1.c7 using st tags(7)
+sql create table d1.c8 using st tags(8)
+sql create table d1.c9 using st tags(9)
+sql insert into d1.c6 values (now, 6);
+sql insert into d1.c7 values (now, 7);
+sql insert into d1.c8 values (now, 8);
+sql insert into d1.c9 values (now, 9);
+sql show d1.tables
+#if $rows != 9 then
+# return -1
+#endi
+#sql select * from d1.st
+#if $rows != 9 then
+# return -1
+#endi
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
diff --git a/tests/script/tsim/dnode/vnode_clean.sim b/tests/script/tsim/dnode/vnode_clean.sim
index ba1d083c68e069fdbfecbd13144f31750a81eb81..aead25938ec0b7c1e52ed69ddbfcd58f79d060b7 100644
--- a/tests/script/tsim/dnode/vnode_clean.sim
+++ b/tests/script/tsim/dnode/vnode_clean.sim
@@ -207,10 +207,10 @@ print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 1 then
return -1
endi
-if $data(3)[2] != 1 then
+if $data(3)[2] != 2 then
return -1
endi
-if $data(4)[2] != 2 then
+if $data(4)[2] != 1 then
return -1
endi
diff --git a/tests/script/tsim/parser/interp.sim b/tests/script/tsim/parser/interp.sim
index 1b7878178c9b72701626460b995dc2312a1ab2f4..e6512a22d79da5ca5970665f08e369e582eed361 100644
--- a/tests/script/tsim/parser/interp.sim
+++ b/tests/script/tsim/parser/interp.sim
@@ -72,4 +72,33 @@ sql_error select interp(*) from nt5931 where ts=now
sql_error select interp(*) from st5931 where ts=now
sql_error select interp(*) from ct5931 where ts=now
+sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int);
+sql create table tba1 using sta tags(1);
+sql insert into tba1 values ('2022-04-26 15:15:01', -3.0, "a");
+sql insert into tba1 values ('2022-04-26 15:15:05', 3.0, "b");
+sql select a from (select interp(f1) as a from tba1 where ts >= '2022-04-26 15:15:01' and ts <= '2022-04-26 15:15:05' range('2022-04-26 15:15:01','2022-04-26 15:15:05') every(1s) fill(linear)) where a > 0;
+if $rows != 2 then
+ return -1
+endi
+if $data00 != 1.500000000 then
+ return -1
+endi
+if $data10 != 3.000000000 then
+ return -1
+endi
+
+sql select a from (select interp(f1+1) as a from tba1 where ts >= '2022-04-26 15:15:01' and ts <= '2022-04-26 15:15:05' range('2022-04-26 15:15:01','2022-04-26 15:15:05') every(1s) fill(linear)) where a > 0;
+if $rows != 3 then
+ return -1
+endi
+if $data00 != 1.000000000 then
+ return -1
+endi
+if $data10 != 2.500000000 then
+ return -1
+endi
+if $data20 != 4.000000000 then
+ return -1
+endi
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/parser/regressiontest.sim b/tests/script/tsim/parser/regressiontest.sim
index 1b127155cbed8f9eaf26898c27bd87e46ed1d7e4..c08b1bbf27e81a3fdc719271e6e0f539176dcd35 100644
--- a/tests/script/tsim/parser/regressiontest.sim
+++ b/tests/script/tsim/parser/regressiontest.sim
@@ -15,7 +15,7 @@ $db = $dbPrefix . $i
sql drop database if exists $db -x step1
step1:
-sql create database $db vgroups 1;
+sql create database $db vgroups 1 cachemodel 'last_row'
sql use $db
sql create table $tb (ts timestamp, c1 int)
@@ -31,13 +31,8 @@ sql insert into $tb values ( $ts , $x )
$x = $x + 1
endw
-print ================== restart server to commit data into disk
-system sh/exec.sh -n dnode1 -s stop -x SIGINT
-system sh/exec.sh -n dnode1 -s start
-print ================== server restart completed
-sql connect
+sql flush database $db
-sql use $db
sql delete from $tb where ts=1537146000000
sql delete from $tb where ts=1537146409500
@@ -63,4 +58,138 @@ if $rows != 8198 then
return -1
endi
+sql drop database if exists $db -x step1
+sql create database $db vgroups 1;
+
+sql use $db
+sql create stable st1 (ts timestamp, c int) tags(a int);
+sql create table t1 using st1 tags(1);
+sql create table t2 using st1 tags(2);
+
+$i = 0
+$ts = 1674977959000
+$rowNum = 200
+
+$x = 0
+while $x < $rowNum
+$xs = $x * $delta
+$ts = $ts0 + $xs
+sql insert into t1 values ( $ts , $x )
+sql insert into t2 values ( $ts + 1000a, $x )
+$x = $x + 1
+$ts = $ts + 1000
+endw
+
+sql flush database $db
+
+print ===========================> TD-22077 && TD-21877
+
+sql insert into t1 values('2018-09-17 09:00:26', 26);
+sql insert into t2 values('2018-09-17 09:00:25', 25);
+
+sql insert into t2 values('2018-09-17 09:00:30', 30);
+sql flush database reg_db0;
+
+sql delete from st1 where ts<='2018-9-17 09:00:26';
+sql select * from st1;
+
+sql drop table t1
+sql drop table t2
+
+print =========================================>TD-22196
+sql create table t1 using st1 tags(1);
+
+$i = 0
+$ts = 1674977959000
+$rowNum = 200
+
+$x = 0
+while $x < $rowNum
+$xs = $x * $delta
+$ts = $ts0 + $xs
+sql insert into t1 values ( $ts , $x )
+$x = $x + 1
+$ts = $ts + 1000
+endw
+
+sql flush database $db
+sql select min(c),max(c) from t1
+if $data00 != 0 then
+ return -1
+endi
+
+if $data01 != 199 then
+ return -1
+endi
+
+sql drop table t1
+
+$rowNum = 8200
+$ts0 = 1537146000000
+sql create table t1 (ts timestamp, c1 int)
+
+$i = 0
+$ts = $ts0
+
+$x = 0
+while $x < $rowNum
+$xs = $x * $delta
+$ts = $ts0 + $xs
+sql insert into t1 values ( $ts , $x )
+$x = $x + 1
+endw
+
+sql delete from t1 where ts<=1537146409500
+
+sql flush database $db
+
+print =====================================>TD-22007
+sql select count(*) from t1 interval(10a)
+
+sql drop table t1
+
+sql create table st1 (ts timestamp, k int) tags(a int);
+sql insert into t1 using st1 tags(1) values('2020-1-1 10:10:10', 0);
+sql insert into t2 using st1 tags(1) values('2020-1-1 10:10:11', 1);
+sql insert into t3 using st1 tags(1) values('2020-1-1 10:10:12', 2);
+sql insert into t4 using st1 tags(1) values('2020-1-1 10:10:13', 3);
+sql insert into t5 using st1 tags(1) values('2020-1-1 10:10:14', 4);
+sql insert into t6 using st1 tags(2) values('2020-1-1 10:10:15', 5);
+sql insert into t7 using st1 tags(2) values('2020-1-1 10:10:16', 6);
+sql insert into t8 using st1 tags(2) values('2020-1-1 10:10:17', 7);
+sql insert into t9 using st1 tags(2) values('2020-1-1 10:10:18', 8);
+sql insert into t10 using st1 tags(2) values('2020-1-1 10:10:19', 9);
+
+sql select count(*) from st1
+if $data00 != 10 then
+ return -1
+endi
+
+sql select last_row(*) from st1 group by a
+if $rows != 2 then
+ return -1
+endi
+
+if $data00 != @20-01-01 10:10:19.000@ then
+ return -1
+endi
+
+if $data01 != 9 then
+ return -1
+endi
+
+if $data10 != @20-01-01 10:10:14.000@ then
+ return -1
+endi
+
+if $data11 != 4 then
+ return -1
+endi
+
+print ===============================================> TS-2613
+sql select * from information_schema.ins_databases limit 1 offset 1;
+if $rows != 1 then
+ return -1
+endi
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/query/event.sim b/tests/script/tsim/query/event.sim
index adc94a34decca06f43f4dbc3c2417415ea583214..16fe0f4a137426a9ef6b9bf0fd0434290584e581 100644
--- a/tests/script/tsim/query/event.sim
+++ b/tests/script/tsim/query/event.sim
@@ -11,20 +11,18 @@ sql use db1;
sql create stable sta (ts timestamp, f1 int, f2 binary(10), f3 bool) tags(t1 int, t2 bool, t3 binary(10));
sql create table tba1 using sta tags(0, false, '0');
sql create table tba2 using sta tags(1, true, '1');
-sql create table tba3 using sta tags(null, null, '');
-sql create table tba4 using sta tags(1, false, null);
-sql create table tba5 using sta tags(3, true, 'aa');
sql insert into tba1 values ('2022-09-26 15:15:01', 0, "a", false);
sql insert into tba1 values ('2022-09-26 15:15:02', 1, "0", true);
sql insert into tba1 values ('2022-09-26 15:15:03', 5, "5", false);
sql insert into tba1 values ('2022-09-26 15:15:04', 3, 'b', false);
sql insert into tba1 values ('2022-09-26 15:15:05', 0, '1', false);
sql insert into tba1 values ('2022-09-26 15:15:06', 2, 'd', true);
-
-sql insert into tba2 values ('2022-09-27 15:15:01', 0, "a", false);
-sql insert into tba2 values ('2022-09-27 15:15:02', 1, "0", true);
-sql insert into tba2 values ('2022-09-27 15:15:03', 5, "5", false);
-sql insert into tba2 values ('2022-09-27 15:15:04', null, null, null);
+sql insert into tba2 values ('2022-09-26 15:15:01', 0, "a", false);
+sql insert into tba2 values ('2022-09-26 15:15:02', 1, "0", true);
+sql insert into tba2 values ('2022-09-26 15:15:03', 5, "5", false);
+sql insert into tba2 values ('2022-09-26 15:15:04', 3, 'b', false);
+sql insert into tba2 values ('2022-09-26 15:15:05', 0, '1', false);
+sql insert into tba2 values ('2022-09-26 15:15:06', 2, 'd', true);
# child table: no window
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f2 = 'c';
@@ -35,7 +33,7 @@ endi
# child table: single row window
print ====> select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
-sql select count(*) from tba1 event_window start with f1 = 0 end with f3 = false
+sql select count(*) from tba1 event_window start with f1 = 0 end with f3 = false;
if $rows != 2 then
return -1
endi
@@ -66,4 +64,176 @@ if $data10 != 4 then
return -1
endi
+# super table: no window
+print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
+sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'c';
+if $rows != 0 then
+ return -1
+endi
+
+# super table: single row window
+print ====> select count(*) from sta event_window start with f1 = 0 end with f3 = false;
+sql select count(*) from sta event_window start with f1 = 0 end with f3 = false;
+if $rows != 4 then
+ return -1
+endi
+if $data00 != 1 then
+ return -1
+endi
+
+# super table: multi rows window
+print ====> select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
+sql select count(*) from sta event_window start with f1 = 0 end with f2 = 'b';
+if $rows != 1 then
+ return -1
+endi
+if $data00 != 7 then
+ return -1
+endi
+
+# super table: multi windows
+print ====> select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
+sql select count(*) from sta event_window start with f1 >= 0 end with f3 = true;
+if $rows != 4 then
+ return -1
+endi
+if $data00 != 3 then
+ return -1
+endi
+if $data10 != 1 then
+ return -1
+endi
+if $data20 != 7 then
+ return -1
+endi
+if $data30 != 1 then
+ return -1
+endi
+
+# multi-child table: no window
+print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
+sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'c';
+if $rows != 0 then
+ return -1
+endi
+
+# multi-child table: single row window
+print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
+sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f3 = false;
+if $rows != 4 then
+ return -1
+endi
+if $data01 != 1 then
+ return -1
+endi
+
+# multi-child table: multi rows window
+print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
+sql select tbname, count(*) from sta partition by tbname event_window start with f1 = 0 end with f2 = 'b';
+if $rows != 2 then
+ return -1
+endi
+if $data01 != 4 then
+ return -1
+endi
+if $data11 != 4 then
+ return -1
+endi
+
+# multi-child table: multi windows
+print ====> select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
+sql select tbname, count(*) from sta partition by tbname event_window start with f1 >= 0 end with f3 = true;
+if $rows != 4 then
+ return -1
+endi
+if $data01 != 2 then
+ return -1
+endi
+if $data11 != 4 then
+ return -1
+endi
+
+# where + partition by
+print ====> select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
+sql select tbname, count(*) from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0;
+if $rows != 4 then
+ return -1
+endi
+if $data01 != 1 then
+ return -1
+endi
+if $data11 != 2 then
+ return -1
+endi
+
+# where + order by
+print ====> select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
+sql select count(*) cnt from tba1 where f3 = false event_window start with f1 >0 end with f2 > 0 order by cnt desc;
+if $rows != 2 then
+ return -1
+endi
+if $data00 != 2 then
+ return -1
+endi
+if $data10 != 1 then
+ return -1
+endi
+
+# where + partition by + order by
+print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
+sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt;
+if $rows != 4 then
+ return -1
+endi
+if $data01 != 1 then
+ return -1
+endi
+if $data11 != 1 then
+ return -1
+endi
+
+# where + partition by + order by + limit
+print ====> select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
+sql select tbname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
+if $rows != 2 then
+ return -1
+endi
+if $data01 != 2 then
+ return -1
+endi
+if $data11 != 2 then
+ return -1
+endi
+
+# subquery(where + partition by + order by + limit)
+print ====> select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
+sql select * from (select tbname tname, count(*) cnt from sta where f3 = false partition by tbname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2);
+if $rows != 2 then
+ return -1
+endi
+if $data01 != 2 then
+ return -1
+endi
+if $data11 != 2 then
+ return -1
+endi
+
+# subquery + where + partition by + order by + limit
+print ====> select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
+sql select tname, count(*) cnt from (select tbname tname, * from sta) where f3 = false partition by tname event_window start with f1 >0 end with f2 > 0 order by cnt limit 2 offset 2;
+if $rows != 2 then
+ return -1
+endi
+if $data01 != 2 then
+ return -1
+endi
+if $data11 != 2 then
+ return -1
+endi
+
+sql_error select f1, f2 from sta event_window start with f1 >0 end with f2 > 0;
+sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 partition by tbname;
+sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 group by tbname;
+sql_error select count(*) from sta event_window start with f1 >0 end with f2 > 0 fill(NULL);
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim
index 78d905233b7d59d64f2c17cc5a97b7b84888bfab..eb6b102bd9a8d85352dc1312d906fcbabb22b960 100644
--- a/tests/script/tsim/query/explain.sim
+++ b/tests/script/tsim/query/explain.sim
@@ -29,43 +29,62 @@ sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..2
#sql create table tb4 using st2 tags(4);
#sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
+# for explain insert into select
+sql create table t1 (ts timestamp, f1 int, f2 binary(200), t1 int);
print ======== step2
sql explain select * from st1 where -2;
+sql explain insert into t1 select * from st1 where -2;
sql explain select ts from tb1;
+sql explain insert into t1(ts) select ts from tb1;
sql explain select * from st1;
+sql explain insert into t1 select * from st1;
sql explain select * from st1 order by ts;
+sql explain insert into t1 select * from st1 order by ts;
sql explain select * from information_schema.ins_stables;
sql explain select count(*),sum(f1) from tb1;
sql explain select count(*),sum(f1) from st1;
sql explain select count(*),sum(f1) from st1 group by f1;
#sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
+sql explain insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
print ======== step3
sql explain verbose true select * from st1 where -2;
+sql explain verbose true insert into t1 select * from st1 where -2;
sql explain verbose true select ts from tb1 where f1 > 0;
+sql explain verbose true insert into t1(ts) select ts from tb1 where f1 > 0;
sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
+sql explain verbose true insert into t1 select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
sql explain verbose true select count(*) from st1 partition by tbname slimit 1 soffset 2 limit 2 offset 1;
sql explain verbose true select * from information_schema.ins_stables where db_name='db2';
sql explain verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0;
+sql explain verbose true insert into t1(ts) select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0;
+sql explain verbose true insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
print ======== step4
sql explain analyze select ts from st1 where -2;
+sql explain analyze insert into t1(ts) select ts from st1 where -2;
sql explain analyze select ts from tb1;
+sql explain analyze insert into t1(ts) select ts from tb1;
sql explain analyze select ts from st1;
-sql explain analyze select ts from st1;
+sql explain analyze insert into t1(ts) select ts from st1;
sql explain analyze select ts from st1 order by ts;
+sql explain analyze insert into t1(ts) select ts from st1 order by ts;
sql explain analyze select * from information_schema.ins_stables;
sql explain analyze select count(*),sum(f1) from tb1;
sql explain analyze select count(*),sum(f1) from st1;
sql explain analyze select count(*),sum(f1) from st1 group by f1;
+sql explain analyze insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s);
print ======== step5
sql explain analyze verbose true select ts from st1 where -2;
+sql explain analyze verbose true insert into t1(ts) select ts from st1 where -2;
sql explain analyze verbose true select ts from tb1;
+sql explain analyze verbose true insert into t1(ts) select ts from tb1;
sql explain analyze verbose true select ts from st1;
-sql explain analyze verbose true select ts from st1;
+sql explain analyze verbose true insert into t1(ts) select ts from st1;
sql explain analyze verbose true select ts from st1 order by ts;
+sql explain analyze verbose true insert into t1(ts) select ts from st1 order by ts;
sql explain analyze verbose true select * from information_schema.ins_stables;
sql explain analyze verbose true select count(*),sum(f1) from tb1;
sql explain analyze verbose true select count(*),sum(f1) from st1;
diff --git a/tests/script/tsim/query/forceFill.sim b/tests/script/tsim/query/forceFill.sim
new file mode 100644
index 0000000000000000000000000000000000000000..37eb85baaa550a05180174cf73c2fa86d6e1c1f2
--- /dev/null
+++ b/tests/script/tsim/query/forceFill.sim
@@ -0,0 +1,367 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sql connect
+
+sql drop database if exists db1;
+sql create database db1 vgroups 10;
+sql use db1;
+sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int);
+sql create table tba1 using sta tags(1);
+sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a");
+sql insert into tba1 values ('2022-04-26 15:15:02', 2.0, "b");
+sql insert into tba1 values ('2022-04-26 15:15:04', 4.0, "b");
+sql insert into tba1 values ('2022-04-26 15:15:05', 5.0, "b");
+
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(value_f, 8.8);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != 8.800000000 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(value, 8.8);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != 8.800000000 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(null);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != NULL then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(null_f);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != NULL then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(value, 8.8);
+if $rows != 0 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(value_f, 8.8);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 8.800000000 then
+ return -1
+endi
+if $data20 != 8.800000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 8.800000000 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(null);
+if $rows != 0 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(null_f);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != NULL then
+ return -1
+endi
+if $data20 != NULL then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != NULL then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:16:00' and ts <= '2022-04-26 19:15:59' interval(1s) fill(value_f, 8.8);
+if $rows != 14400 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+sql select avg(f1) from tba1 where ts >= '2022-04-26 15:16:00' and ts <= '2022-04-26 19:15:59' interval(1s) fill(null_f);
+if $rows != 14400 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(value_f, 8.8);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != 8.800000000 then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(value, 8.8);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != 8.800000000 then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(null);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != NULL then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(null_f);
+if $rows != 7 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != 1.000000000 then
+ return -1
+endi
+if $data20 != 2.000000000 then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != 4.000000000 then
+ return -1
+endi
+if $data50 != 5.000000000 then
+ return -1
+endi
+if $data60 != NULL then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(value, 8.8);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 8.800000000 then
+ return -1
+endi
+if $data20 != 8.800000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 8.800000000 then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(value_f, 8.8);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+if $data10 != 8.800000000 then
+ return -1
+endi
+if $data20 != 8.800000000 then
+ return -1
+endi
+if $data30 != 8.800000000 then
+ return -1
+endi
+if $data40 != 8.800000000 then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(null);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != NULL then
+ return -1
+endi
+if $data20 != NULL then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != NULL then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(null_f);
+if $rows != 5 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+if $data10 != NULL then
+ return -1
+endi
+if $data20 != NULL then
+ return -1
+endi
+if $data30 != NULL then
+ return -1
+endi
+if $data40 != NULL then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:16:00','2022-04-26 19:15:59') every(1s) fill(value_f, 8.8);
+if $rows != 14400 then
+ return -1
+endi
+if $data00 != 8.800000000 then
+ return -1
+endi
+sql select interp(f1) from tba1 range('2022-04-26 15:16:00','2022-04-26 19:15:59') every(1s) fill(null_f);
+if $rows != 14400 then
+ return -1
+endi
+if $data00 != NULL then
+ return -1
+endi
+
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/scalar/tsConvert.sim b/tests/script/tsim/scalar/tsConvert.sim
index 75efdb442f5055b559950173c68941a2260aa5bd..ad8d3b3b93382ac706edaeac85ab58fabf14e04d 100644
--- a/tests/script/tsim/scalar/tsConvert.sim
+++ b/tests/script/tsim/scalar/tsConvert.sim
@@ -13,7 +13,7 @@ sql insert into tb1 values ('2022-07-10 16:31:00', 1, '1');
sql insert into tb1 values ('2022-07-10 16:32:00', 2, '2');
sql insert into tb1 values ('2022-07-10 16:33:00', 3, '3');
sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4');
-sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <=' 2022-11-3 23:59:59' ) t where td >12;
+sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <='2022-11-3 23:59:59' ) t where td >12;
if $rows != 4 then
return -1
endi
diff --git a/tests/script/tsim/stream/basic1.sim b/tests/script/tsim/stream/basic1.sim
index 7bf10df6372fac03bdfc2cae6a9eef2d0c01b6a9..c61c7667f8fef94ea84b7379a4a6fc12cc5b2141 100644
--- a/tests/script/tsim/stream/basic1.sim
+++ b/tests/script/tsim/stream/basic1.sim
@@ -834,4 +834,57 @@ endi
print ====== test _wstart end
+print insert into ts1 values(-1648791211000,1,2,3)
+
+sql create database test7 vgroups 1;
+sql use test7;
+sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
+sql create table ts1 using st tags(1,1,1);
+sql create stream streams7 trigger at_once into streamt7 as select _wstart, count(*) from ts1 interval(10s) ;
+
+sql insert into ts1 values(1648791211000,1,2,3);
+sql_error insert into ts1 values(-1648791211000,1,2,3);
+
+loop18:
+
+sleep 200
+sql select * from streamt7;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop18
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop18
+endi
+
+sql_error insert into ts1 values(-1648791211001,1,2,3) (1648791211001,1,2,3);
+
+sql select _wstart, count(*) from ts1 interval(10s) ;
+
+print $data00 $data01
+print $data10 $data11
+
+loop19:
+
+sleep 200
+sql select * from streamt7;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop19
+endi
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/stream/basic3.sim b/tests/script/tsim/stream/basic3.sim
index e598919e34b60d22478de67cce5df9c0c976216d..2df33541b461b1f2fe1c772cb80550e421fe56aa 100644
--- a/tests/script/tsim/stream/basic3.sim
+++ b/tests/script/tsim/stream/basic3.sim
@@ -81,6 +81,15 @@ if $rows == 0 then
return -1
endi
+sleep 3000
+
+sql drop stream if exists streamd1;
+sql drop stream if exists streamd2;
+sql drop stream if exists streamd3;
+sql drop stream if exists streamd4;
+sql drop stream if exists streamd5;
+sql drop stream if exists streamd6;
+
sql create stream streamd10 into streamd10 as select _wstart, _wend, count(*), first(ca), last(cb) as c2 from t1 interval(10s);
sql desc streamd10;
@@ -100,15 +109,6 @@ if $rows == 0 then
return -1
endi
-sleep 3000
-
-sql drop stream if exists streamd1;
-sql drop stream if exists streamd2;
-sql drop stream if exists streamd3;
-sql drop stream if exists streamd4;
-sql drop stream if exists streamd5;
-sql drop stream if exists streamd6;
-
_OVER:
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/stream/checkStreamSTable.sim b/tests/script/tsim/stream/checkStreamSTable.sim
index 2ed6958196e7defc114378f06f889d5b00b032a1..b60ab0ac05b5e9b88819c50d07ef1661e02cb481 100644
--- a/tests/script/tsim/stream/checkStreamSTable.sim
+++ b/tests/script/tsim/stream/checkStreamSTable.sim
@@ -19,9 +19,9 @@ sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);
-sql create stable result.streamt0(ts timestamp,a int,b int) tags(ta int,tb int,tc int);
+sql create stable result.streamt0(ts timestamp,a int,b int) tags(ta int,tb varchar(100),tc int);
-sql create stream streams0 trigger at_once into result.streamt0 as select _wstart, count(*) c1, max(a) c2 from st partition by tbname interval(10s);
+sql create stream streams0 trigger at_once into result.streamt0 tags(tb) as select _wstart, count(*) c1, max(a) c2 from st partition by tbname tb interval(10s);
sql insert into t1 values(1648791213000,1,2,3);
sql insert into t2 values(1648791213000,2,2,3);
@@ -61,6 +61,16 @@ if $data02 != 1 then
goto loop0
endi
+if $data03 != NULL then
+ print =====data03=$data03
+ goto loop0
+endi
+
+if $data04 != t1 then
+ print =====data04=$data04
+ goto loop0
+endi
+
if $data11 != 1 then
print =====data11=$data11
goto loop0
@@ -71,6 +81,16 @@ if $data12 != 2 then
goto loop0
endi
+if $data13 != NULL then
+ print =====data13=$data13
+ goto loop0
+endi
+
+if $data14 != t2 then
+ print =====data14=$data14
+ goto loop0
+endi
+
print ===== step3
sql create database result1 vgroups 1;
@@ -83,9 +103,9 @@ sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);
-sql create stable result1.streamt1(ts timestamp,a int,b int,c int) tags(ta bigint unsigned,tb int,tc int);
+sql create stable result1.streamt1(ts timestamp,a int,b int,c int) tags(ta varchar(100),tb int,tc int);
-sql create stream streams1 trigger at_once into result1.streamt1(ts,c,a,b) as select _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname interval(10s);
+sql create stream streams1 trigger at_once into result1.streamt1(ts,c,a,b) tags(ta) as select _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname as ta interval(10s);
sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);
@@ -161,7 +181,7 @@ sql create table t2 using st tags(2,2,2);
sql create stable result2.streamt2(ts timestamp, a int , b int) tags(ta varchar(20));
# tag dest 1, source 2
-##sql_error create stream streams2 trigger at_once into result2.streamt2 TAGS(aa varchar(100), ta int) as select _wstart, count(*) c1, max(a) from st partition by tbname as aa, ta interval(10s);
+sql_error create stream streams2 trigger at_once into result2.streamt2 TAGS(aa varchar(100), ta int) as select _wstart, count(*) c1, max(a) from st partition by tbname as aa, ta interval(10s);
# column dest 3, source 4
sql_error create stream streams2 trigger at_once into result2.streamt2 as select _wstart, count(*) c1, max(a), max(b) from st partition by tbname interval(10s);
@@ -173,7 +193,7 @@ sql_error create stream streams2 trigger at_once into result2.streamt2(ts, a, b
sql_error create stream streams2 trigger at_once into result2.streamt2 as select _wstart, count(*) c1 from st partition by tbname interval(10s);
# column dest 3, source 2
-sql create stream streams2 trigger at_once into result2.streamt2(ts, a) as select _wstart, count(*) c1 from st partition by tbname interval(10s);
+sql create stream streams2 trigger at_once into result2.streamt2(ts, a) tags(ta) as select _wstart, count(*) c1 from st partition by tbname as ta interval(10s);
print ===== step5
@@ -252,16 +272,16 @@ sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);
-sql create stable result4.streamt4(ts timestamp,a int,b int,c int, d int) tags(ta int,tb int,tc int);
+sql create stable result4.streamt4(ts timestamp,a int,b int,c int, d int) tags(tg1 int,tg2 int,tg3 int);
-sql create stream streams4 trigger at_once into result4.streamt4(ts,c,a,b) tags(tg2 int, tg3 varchar(100), tg1 bigint) subtable(concat("tbl-", tg1)) as select _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
+sql create stream streams4 trigger at_once into result4.streamt4(ts,c,a,b) tags(tg2, tg3, tg1) subtable( concat("tbl-", cast(tg1 as varchar(10)) ) ) as select _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);
$loop_count = 0
-sql select _wstart, count(*) c1, max(a),min(b) c2 from st interval(10s);
+sql select _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23
@@ -275,7 +295,7 @@ if $loop_count == 10 then
return -1
endi
-sql select * from result4.streamt4;
+sql select * from result4.streamt4 order by tg1;
if $rows != 2 then
print =====rows=$rows
@@ -285,7 +305,7 @@ if $rows != 2 then
goto loop2
endi
-if $data01 != 40 then
+if $data01 != 10 then
print =====data01=$data01
goto loop2
endi
@@ -295,7 +315,7 @@ if $data02 != 20 then
goto loop2
endi
-if $data03 != 2 then
+if $data03 != 1 then
print =====data03=$data03
goto loop2
endi
@@ -305,6 +325,26 @@ if $data04 != NULL then
goto loop2
endi
+if $data11 != 40 then
+ print =====data11=$data11
+ goto loop2
+endi
+
+if $data12 != 50 then
+ print =====data12=$data12
+ goto loop2
+endi
+
+if $data13 != 1 then
+ print =====data13=$data13
+ goto loop2
+endi
+
+if $data14 != NULL then
+ print =====data14=$data14
+ goto loop2
+endi
+
print ======over
system sh/stop_dnodes.sh
diff --git a/tests/script/tsim/stream/drop_stream.sim b/tests/script/tsim/stream/drop_stream.sim
index 1a474bd9aeca6f7f241f108ff14a0872a2eddf86..7ff9632a3e2b95f37e4b88bda2373dcfbad9aaa4 100644
--- a/tests/script/tsim/stream/drop_stream.sim
+++ b/tests/script/tsim/stream/drop_stream.sim
@@ -55,62 +55,62 @@ sql create stream stb_asin_stream trigger at_once into output_asin_stb as select
sql create stream ctb_asin_stream trigger at_once into output_asin_ctb as select ts, asin(c1), asin(c2), c3 from scalar_ct1;
sql create stream tb_asin_stream trigger at_once into output_asin_tb as select ts, asin(c1), asin(c2), c3 from scalar_tb;
sql create stream stb_atan_stream trigger at_once into output_atan_stb as select ts, atan(c1), atan(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1;
-sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb;
-sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1;
-sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb;
-sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1;
-sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb;
-sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1;
-sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb;
-sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1;
-sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb;
-sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1;
-sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb;
-sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1;
-sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb;
-sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1;
-sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb;
-sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1;
-sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb;
-sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1;
-sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb;
-sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname;
-sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1;
-sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb;
-sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname;
-sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1;
-sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb;
-sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname;
-sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1;
-sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb;
-sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname;
-sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1;
-sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb;
-sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname;
-sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1;
-sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb;
-sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname;
-sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1;
-sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb;
-sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname;
-sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1;
-sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb;
-sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname;
-sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1;
-sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb;
-sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname;
-sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1;
-sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb;
+# sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1;
+# sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb;
+# sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1;
+# sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb;
+# sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1;
+# sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb;
+# sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1;
+# sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb;
+# sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1;
+# sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb;
+# sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1;
+# sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb;
+# sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1;
+# sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb;
+# sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1;
+# sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb;
+# sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1;
+# sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb;
+# sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1;
+# sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb;
+# sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1;
+# sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb;
+# sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname;
+# sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1;
+# sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb;
+# sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname;
+# sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1;
+# sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb;
+# sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1;
+# sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb;
+# sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1;
+# sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb;
+# sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1;
+# sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb;
+# sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1;
+# sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb;
+# sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname;
+# sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1;
+# sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb;
+# sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1;
+# sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb;
sql insert into scalar_ct1 values (1656668180503, 100, 100.1, "beijing", "taos", "Taos");
sql insert into scalar_ct1 values (1656668180503+1s, -50, -50.1, "tianjin", "taosdata", "Taosdata");
sql insert into scalar_ct1 values (1656668180503+2s, 0, Null, "hebei", "TDengine", Null);
@@ -146,62 +146,62 @@ sql create stream stb_asin_stream trigger at_once into output_asin_stb as select
sql create stream ctb_asin_stream trigger at_once into output_asin_ctb as select ts, asin(c1), asin(c2), c3 from scalar_ct1;
sql create stream tb_asin_stream trigger at_once into output_asin_tb as select ts, asin(c1), asin(c2), c3 from scalar_tb;
sql create stream stb_atan_stream trigger at_once into output_atan_stb as select ts, atan(c1), atan(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1;
-sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb;
-sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1;
-sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb;
-sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1;
-sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb;
-sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1;
-sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb;
-sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1;
-sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb;
-sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1;
-sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb;
-sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1;
-sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb;
-sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1;
-sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb;
-sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1;
-sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb;
-sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname;
-sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1;
-sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb;
-sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname;
-sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1;
-sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb;
-sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname;
-sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1;
-sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb;
-sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname;
-sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1;
-sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb;
-sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname;
-sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1;
-sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb;
-sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname;
-sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1;
-sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb;
-sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname;
-sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1;
-sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb;
-sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname;
-sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1;
-sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb;
-sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname;
-sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1;
-sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb;
-sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname;
-sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1;
-sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb;
+# sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1;
+# sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb;
+# sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1;
+# sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb;
+# sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1;
+# sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb;
+# sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1;
+# sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb;
+# sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1;
+# sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb;
+# sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1;
+# sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb;
+# sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1;
+# sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb;
+# sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1;
+# sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb;
+# sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1;
+# sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb;
+# sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname;
+# sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1;
+# sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb;
+# sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1;
+# sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb;
+# sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname;
+# sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1;
+# sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb;
+# sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname;
+# sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1;
+# sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb;
+# sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1;
+# sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb;
+# sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1;
+# sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb;
+# sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1;
+# sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb;
+# sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1;
+# sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb;
+# sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname;
+# sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1;
+# sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb;
+# sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname;
+# sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1;
+# sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb;
sql insert into scalar_ct1 values (1656668180503, 100, 100.1, "beijing", "taos", "Taos");
sql insert into scalar_ct1 values (1656668180503+1s, -50, -50.1, "tianjin", "taosdata", "Taosdata");
sql insert into scalar_ct1 values (1656668180503+2s, 0, Null, "hebei", "TDengine", Null);
@@ -273,4 +273,4 @@ print ========== step7
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
-system sh/exec.sh -n dnode4 -s stop -x SIGINT
\ No newline at end of file
+system sh/exec.sh -n dnode4 -s stop -x SIGINT
diff --git a/tests/script/tsim/stream/fillIntervalValue.sim b/tests/script/tsim/stream/fillIntervalValue.sim
index fe4ec759eb2fa9ea0520c3c03766a83eacd5fe6f..2cd419397fdb0230aacd8983c2c5b238e82ab673 100644
--- a/tests/script/tsim/stream/fillIntervalValue.sim
+++ b/tests/script/tsim/stream/fillIntervalValue.sim
@@ -14,6 +14,7 @@ sql use test;
sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20));;
sql create stream streams1 trigger at_once into streamt as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(value, 100);
+sql create stream streams1a trigger at_once into streamta as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(value_f, 100);
sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa');
sleep 100
sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa');
@@ -77,6 +78,69 @@ if $data71 != 1 then
goto loop0
endi
+
+print "force fill vaule"
+
+$loop_count = 0
+
+loop0a:
+sleep 200
+sql select * from streamta order by ts;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 8 then
+ print =====rows=$rows
+ goto loop0a
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop0a
+endi
+
+if $data11 != 1 then
+ print =====data11=$data11
+ goto loop0a
+endi
+
+if $data21 != 1 then
+ print =====data21=$data21
+ goto loop0a
+endi
+
+if $data31 != 100 then
+ print =====data31=$data31
+ goto loop0a
+endi
+
+if $data41 != 1 then
+ print =====data41=$data41
+ goto loop0a
+endi
+
+if $data51 != 100 then
+ print =====data01=$data01
+ goto loop0a
+endi
+
+if $data61 != 100 then
+ print =====data61=$data61
+ goto loop0a
+endi
+
+if $data71 != 1 then
+ print =====data71=$data71
+ goto loop0a
+endi
+
+
+
+
+
sql drop stream if exists streams2;
sql drop database if exists test2;
sql create database test2 vgroups 1;
@@ -408,6 +472,7 @@ sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);
sql create stream streams4 trigger at_once into streamt4 as select _wstart ts, count(*) c1, concat(tbname, 'aaa') as pname, timezone() from st where ts > 1648791000000 and ts < 1648793000000 partition by tbname interval(10s) fill(NULL);
+sql create stream streams4a trigger at_once into streamt4a as select _wstart ts, count(*) c1, concat(tbname, 'aaa') as pname, timezone() from st where ts > 1648791000000 and ts < 1648793000000 partition by tbname interval(10s) fill(NULL_F);
sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa');
sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa');
sql insert into t1 values(1648791273000,1,2,3,1.0,'aaa');
@@ -512,32 +577,104 @@ if $data[12][3] == NULL then
goto loop4
endi
+print "force fill null"
+$loop_count = 0
+loop4a:
+sleep 200
+sql select * from streamt4a order by pname, ts;
+print ===> $data[0][0] , $data[0][1] , $data[0][2] , $data[0][3]
+print ===> $data[1][0] , $data[1][1] , $data[1][2] , $data[1][3]
+print ===> $data[2][0] , $data[2][1] , $data[2][2] , $data[2][3]
+print ===> $data[3][0] , $data[3][1] , $data[3][2] , $data[3][3]
+print ===> $data[4][0] , $data[4][1] , $data[4][2] , $data[4][3]
+print ===> $data[5][0] , $data[5][1] , $data[5][2] , $data[5][3]
+print ===> $data[6][0] , $data[6][1] , $data[6][2] , $data[6][3]
+print ===> $data[7][0] , $data[7][1] , $data[7][2] , $data[7][3]
+print ===> $data[8][0] , $data[8][1] , $data[8][2] , $data[8][3]
+print ===> $data[9][0] , $data[9][1] , $data[9][2] , $data[9][3]
+print ===> $data[10][0] , $data[10][1] , $data[10][2] , $data[10][3]
+print ===> $data[11][0] , $data[11][1] , $data[11][2] , $data[11][3]
+print ===> $data[12][0] , $data[12][1] , $data[12][2] , $data[12][3]
+print ===> $data[13][0] , $data[13][1] , $data[13][2] , $data[13][3]
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+if $rows != 14 then
+ print =====rows=$rows
+ goto loop4a
+endi
+if $data11 != NULL then
+ print =====data11=$data11
+ goto loop4a
+endi
+if $data12 != t1aaa then
+ print =====data12=$data12
+ goto loop4a
+endi
+if $data13 == NULL then
+ print =====data13=$data13
+ goto loop4a
+endi
+if $data32 != t1aaa then
+ print =====data32=$data32
+ goto loop4a
+endi
+if $data42 != t1aaa then
+ print =====data42=$data42
+ goto loop4a
+endi
+if $data52 != t1aaa then
+ print =====data52=$data52
+ goto loop4a
+endi
+if $data81 != NULL then
+ print =====data81=$data81
+ goto loop4a
+endi
+if $data82 != t2aaa then
+ print =====data82=$data82
+ goto loop4a
+endi
+if $data83 == NULL then
+ print =====data83=$data83
+ goto loop4a
+endi
+if $data[10][2] != t2aaa then
+ print =====data[10][2]=$data[10][2]
+ goto loop4a
+endi
+if $data[11][2] != t2aaa then
+ print =====data[11][2]=$data[11][2]
+ goto loop4a
+endi
+if $data[12][2] != t2aaa then
+ print =====data[12][2]=$data[12][2]
+ goto loop4a
+endi
-
-
-
-
-
-
-
+if $data[12][3] == NULL then
+ print =====data[12][3]=$data[12][3]
+ goto loop4a
+endi
@@ -584,4 +721,4 @@ print ============loop_all=$loop_all
system sh/stop_dnodes.sh
-#goto looptest
\ No newline at end of file
+#goto looptest
diff --git a/tests/script/tsim/stream/ignoreCheckUpdate.sim b/tests/script/tsim/stream/ignoreCheckUpdate.sim
new file mode 100644
index 0000000000000000000000000000000000000000..7f99c534c8d5ffca96f9a394e330c33bf7500afb
--- /dev/null
+++ b/tests/script/tsim/stream/ignoreCheckUpdate.sim
@@ -0,0 +1,285 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sleep 50
+sql connect
+
+print step 1 start
+
+sql drop stream if exists streams0;
+sql drop database if exists test;
+sql create database test vgroups 1;
+sql use test;
+sql create table t1(ts timestamp, a int, b int , c int);
+
+print create stream streams0 trigger at_once ignore update 1 into streamt as select _wstart c1, count(*) c2, max(b) c3 from t1 interval(10s);
+
+sql create stream streams0 trigger at_once ignore update 1 into streamt as select _wstart c1, count(*) c2, max(b) c3 from t1 interval(10s);
+
+sql insert into t1 values(1648791213000,1,1,1);
+sql insert into t1 values(1648791213000,2,2,2);
+
+$loop_count = 0
+
+loop0:
+sleep 300
+sql select * from streamt order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop0
+endi
+
+if $data02 != 2 then
+ print =====data02=$data02
+ goto loop0
+endi
+
+
+sql insert into t1 values(1648791213000,3,3,3);
+
+$loop_count = 0
+
+loop1:
+sleep 300
+sql select * from streamt order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 3 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop1
+endi
+
+print step 1 end
+
+print step 2 start
+
+sql drop stream if exists streams1;
+sql drop database if exists test1;
+sql create database test1 vgroups 1;
+sql use test1;
+sql create table t1(ts timestamp, a int, b int , c int);
+
+print create stream streams1 trigger at_once ignore update 1 into streamt1 as select _wstart c1, count(*) c2, max(b) c3 from t1 session(ts, 10s);
+
+sql create stream streams1 trigger at_once ignore update 1 into streamt1 as select _wstart c1, count(*) c2, max(b) c3 from t1 session(ts, 10s);
+
+sql insert into t1 values(1648791213000,1,1,1);
+sql insert into t1 values(1648791213000,2,2,2);
+
+$loop_count = 0
+
+loop2:
+sleep 300
+sql select * from streamt1 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop2
+endi
+
+if $data02 != 2 then
+ print =====data02=$data02
+ goto loop2
+endi
+
+
+sql insert into t1 values(1648791213000,3,3,3);
+
+$loop_count = 0
+
+loop3:
+
+sleep 300
+sql select * from streamt1 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 3 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+print step 2 end
+
+print step 3 start
+
+sql drop stream if exists streams2;
+sql drop database if exists test2;
+sql create database test2 vgroups 1;
+sql use test2;
+sql create table t1(ts timestamp, a int, b int , c int);
+
+print create stream streams2 trigger at_once ignore update 1 into streamt2 as select _wstart c1, count(*) c2, max(b) c3 from t1 state_window(c);
+
+sql create stream streams2 trigger at_once ignore update 1 into streamt2 as select _wstart c1, count(*) c2, max(b) c3 from t1 state_window(c);
+
+sql insert into t1 values(1648791213000,1,1,1);
+sql insert into t1 values(1648791213000,2,2,1);
+
+$loop_count = 0
+
+loop2:
+sleep 300
+sql select * from streamt2 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop2
+endi
+
+if $data02 != 2 then
+ print =====data02=$data02
+ goto loop2
+endi
+
+
+sql insert into t1 values(1648791213000,3,3,1);
+
+$loop_count = 0
+
+loop3:
+
+sleep 300
+sql select * from streamt2 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 3 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+print step 3 end
+
+print step 4 start
+
+sql drop stream if exists streams3;
+sql drop database if exists test3;
+sql create database test3 vgroups 4;
+sql use test3;
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+
+print create stream streams3 trigger at_once ignore update 1 into streamt3 as select _wstart c1, count(*) c2, max(b) c3 from st interval(10s);
+
+sql create stream streams3 trigger at_once ignore update 1 into streamt3 as select _wstart c1, count(*) c2, max(b) c3 from st interval(10s);
+
+sql insert into t1 values(1648791213000,1,1,1);
+sql insert into t1 values(1648791213000,2,2,2);
+
+sql insert into t2 values(1648791213000,1,1,1);
+sql insert into t2 values(1648791213000,2,2,2);
+
+$loop_count = 0
+
+loop0:
+sleep 300
+sql select * from streamt3 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 4 then
+ print =====data01=$data01
+ goto loop0
+endi
+
+if $data02 != 2 then
+ print =====data02=$data02
+ goto loop0
+endi
+
+
+sql insert into t1 values(1648791213000,3,3,3);
+
+$loop_count = 0
+
+loop1:
+sleep 300
+sql select * from streamt3 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 5 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop1
+endi
+
+sql insert into t2 values(1648791213000,4,4,4);
+
+$loop_count = 0
+
+loop1:
+sleep 300
+sql select * from streamt3 order by 1,2,3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 6 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop1
+endi
+
+print step 4 end
+
+system sh/stop_dnodes.sh
diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim
index ea7528b1cb3d2ca33e805bb0e516168a26d8ef59..07abdc0040d962bc6c6b6b0f15996cdf973ab450 100644
--- a/tests/script/tsim/stream/state0.sim
+++ b/tests/script/tsim/stream/state0.sim
@@ -16,6 +16,9 @@ print $data00 $data01 $data02
sql use test;
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
+
+print create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
+
sql create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0,1);
@@ -79,86 +82,88 @@ endi
if $data03 != 1 then
print ======$data03
- return -1
+ goto loop1
endi
if $data04 != 1 then
print ======$data04
- return -1
+ goto loop1
endi
if $data05 != 3 then
print ======$data05
- return -1
+ goto loop1
endi
if $data06 != 5 then
print ======$data06
- return -1
+ goto loop1
endi
# row 1
if $data11 != 1 then
print ======$data11
- return -1
+ goto loop1
endi
if $data12 != 1 then
print ======$data12
- return -1
+ goto loop1
endi
if $data13 != 2 then
print ======$data13
- return -1
+ goto loop1
endi
if $data14 != 2 then
print ======$data14
- return -1
+ goto loop1
endi
if $data15 != 3 then
print ======$data15
- return -1
+ goto loop1
endi
if $data16 != 4 then
print ======$data16
- return -1
+ goto loop1
endi
# row 2
if $data21 != 1 then
print ======$data21
- return -1
+ goto loop1
endi
if $data22 != 1 then
print ======$data22
- return -1
+ goto loop1
endi
if $data23 != 1 then
print ======$data23
- return -1
+ goto loop1
endi
if $data24 != 1 then
print ======$data24
- return -1
+ goto loop1
endi
if $data25 != 3 then
print ======$data25
- return -1
+ goto loop1
endi
if $data26 != 6 then
print ======$data26
- return -1
+ goto loop1
endi
+print loop1 end
+
sql insert into t1 values(1648791213011,1,2,3,1.0,7);
$loop_count = 0
@@ -174,33 +179,31 @@ endi
if $data21 != 2 then
print =====data21=$data21
goto loop2
- return -1
endi
if $data22 != 2 then
print =====data22=$data22
goto loop2
- return -1
endi
if $data23 != 2 then
print ======$data23
- return -1
+ goto loop2
endi
if $data24 != 1 then
print ======$data24
- return -1
+ goto loop2
endi
if $data25 != 3 then
print ======$data25
- return -1
+ goto loop2
endi
if $data26 != 7 then
print ======$data26
- return -1
+ goto loop2
endi
sql insert into t1 values(1648791213011,1,2,3,1.0,8);
@@ -238,99 +241,93 @@ endi
if $data21 != 1 then
print =====data21=$data21
goto loop3
- return -1
endi
if $data22 != 1 then
print =====data22=$data22
goto loop3
- return -1
endi
if $data23 != 10 then
print ======$data23
- return -1
+ goto loop3
endi
if $data24 != 10 then
print ======$data24
- return -1
+ goto loop3
endi
if $data25 != 10 then
print ======$data25
- return -1
+ goto loop3
endi
if $data26 != 12 then
print ======$data26
- return -1
+ goto loop3
endi
# row 3
if $data31 != 1 then
print =====data31=$data31
goto loop3
- return -1
endi
if $data32 != 1 then
print =====data32=$data32
goto loop3
- return -1
endi
if $data33 != 3 then
print ======$data33
- return -1
+ goto loop3
endi
if $data34 != 3 then
print ======$data34
- return -1
+ goto loop3
endi
if $data35 != 3 then
print ======$data35
- return -1
+ goto loop3
endi
if $data36 != 10 then
print ======$data36
- return -1
+ goto loop3
endi
# row 4
if $data41 != 1 then
print =====data41=$data41
goto loop3
- return -1
endi
if $data42 != 1 then
print =====data42=$data42
goto loop3
- return -1
endi
if $data43 != 1 then
print ======$data43
- return -1
+ goto loop3
endi
if $data44 != 1 then
print ======$data44
- return -1
+ goto loop3
endi
if $data45 != 3 then
print ======$data45
- return -1
+ goto loop3
endi
if $data46 != 11 then
print ======$data46
- return -1
+ goto loop3
endi
sql insert into t1 values(1648791213030,3,12,12,12.0,13);
@@ -360,95 +357,93 @@ endi
if $data02 != 2 then
print ======$data02
- return -1
+ goto loop4
endi
if $data03 != 6 then
print ======$data03
- return -1
+ goto loop4
endi
if $data04 != 3 then
print ======$data04
- return -1
+ goto loop4
endi
if $data05 != 3 then
print ======$data05
- return -1
+ goto loop4
endi
if $data06 != 15 then
print ======$data06
- return -1
+ goto loop4
endi
# row 1
if $data11 != 1 then
print =====data11=$data11
goto loop4
- return -1
endi
if $data12 != 1 then
print =====data12=$data12
goto loop4
- return -1
endi
if $data13 != 15 then
print ======$data13
- return -1
+ goto loop4
endi
if $data14 != 15 then
print ======$data14
- return -1
+ goto loop4
endi
if $data15 != 15 then
print ======$data15
- return -1
+ goto loop4
endi
if $data16 != 16 then
print ======$data16
- return -1
+ goto loop4
endi
# row 2
if $data21 != 1 then
print =====data21=$data21
goto loop4
- return -1
endi
if $data22 != 1 then
print =====data22=$data22
goto loop4
- return -1
endi
if $data23 != 1 then
print ======$data23
- return -1
+ goto loop4
endi
if $data24 != 1 then
print ======$data24
- return -1
+ goto loop4
endi
if $data25 != 13 then
print ======$data25
- return -1
+ goto loop4
endi
if $data26 != 14 then
print ======$data26
- return -1
+ goto loop4
endi
+print loop4 end
+
sql create database test1 vgroups 1;
sql select * from information_schema.ins_databases;
@@ -457,6 +452,9 @@ print $data00 $data01 $data02
sql use test1;
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
+
+print create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
+
sql create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a);
sql insert into t1 values(1648791212000,2,2,3,1.0,1);
@@ -502,6 +500,9 @@ sql create database test3 vgroups 1;
sql use test3;
sql create table t1(ts timestamp, a int, b int , c int, d double, id int);
+
+print create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a);
+
sql create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a);
sql insert into t1 values(1648791212000,1,2,3,1.0,1);
sql insert into t1 values(1648791213000,2,2,3,1.0,1);
@@ -543,7 +544,6 @@ if $rows != 10 then
goto loop6
endi
-
sql drop stream if exists streams4;
sql drop database if exists test4;
sql drop stable if exists streamt4;
@@ -552,6 +552,9 @@ sql use test4;
sql create table st (ts timestamp, c1 tinyint, c2 smallint) tags (t1 tinyint) ;
sql create table t1 using st tags (-81) ;
sql create table t2 using st tags (-81) ;
+
+print create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1);
+
sql create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1);
sql insert into t1 (ts, c1) values (1668073288209, 11);
@@ -636,7 +639,7 @@ sql insert into t1 (ts, c1) values (1668073288225, 65);
sql insert into t1 (ts, c1) values (1668073288226, 65);
$loop_count = 0
-loop8:
+loop81:
sleep 200
@@ -649,27 +652,27 @@ endi
if $rows != 2 then
print =====rows=$rows
- goto loop8
+ goto loop81
endi
if $data01 != 11 then
print =====data01=$data01
- goto loop8
+ goto loop81
endi
if $data02 != 5 then
print =====data02=$data02
- goto loop8
+ goto loop81
endi
if $data11 != 29 then
print =====data11=$data11
- goto loop8
+ goto loop81
endi
if $data12 != 1 then
print =====data12=$data12
- goto loop8
+ goto loop81
endi
sql insert into t1 (ts, c1) values (1668073288224, 64);
@@ -738,6 +741,9 @@ sql use test5;
sql create table tb (ts timestamp, a int);
sql insert into tb values (now + 1m , 1 );
sql create table b (c timestamp, d int, e int , f int, g double);
+
+print create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a);
+
sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a);
sql insert into b values(1648791213000,NULL,NULL,NULL,NULL);
sql select * from streamt order by c1, c2, c3;
@@ -792,4 +798,6 @@ if $data00 != 2 then
goto loop10
endi
+print state0 end
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/stream/triggerInterval0.sim b/tests/script/tsim/stream/triggerInterval0.sim
index 7353f026bb01a824fe6935d4e44c870029555e97..b522dcf035f66c439e8c59a8190d9228ea8dca5c 100644
--- a/tests/script/tsim/stream/triggerInterval0.sim
+++ b/tests/script/tsim/stream/triggerInterval0.sim
@@ -29,69 +29,119 @@ sql insert into t1 values(1648791223001,2,2,3,1.1);
sql insert into t1 values(1648791223002,2,2,3,1.1);
sql insert into t1 values(1648791223003,2,2,3,1.1);
sql insert into t1 values(1648791223001,2,2,3,1.1);
+
+print step 0
+
+$loop_count = 0
+
+loop0:
sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
sql select * from streamt;
+
if $rows != 1 then
print ======$rows
- return -1
+ goto loop0
endi
if $data01 != 1 then
print ======$data01
- return -1
+ goto loop0
endi
sql insert into t1 values(1648791233001,2,2,3,1.1);
+
+print step 1
+
+$loop_count = 0
+
+loop1:
sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
sql select * from streamt;
if $rows != 2 then
print ======$rows
- return -1
+ goto loop1
endi
if $data01 != 1 then
print ======$data01
- return -1
+ goto loop1
endi
if $data11 != 3 then
print ======$data11
- return -1
+ goto loop1
endi
sql insert into t1 values(1648791223004,2,2,3,1.1);
sql insert into t1 values(1648791223004,2,2,3,1.1);
sql insert into t1 values(1648791223005,2,2,3,1.1);
+
+print step 2
+
+$loop_count = 0
+
+loop2:
sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
sql select * from streamt;
if $rows != 2 then
print ======$rows
- return -1
+ goto loop2
endi
+
if $data01 != 1 then
print ======$data01
- return -1
+ goto loop2
endi
if $data11 != 5 then
print ======$data11
- return -1
+ goto loop2
endi
sql insert into t1 values(1648791233002,3,2,3,2.1);
sql insert into t1 values(1648791213002,4,2,3,3.1)
sql insert into t1 values(1648791213002,4,2,3,4.1);
+
+print step 3
+
+$loop_count = 0
+
+loop3:
sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
sql select * from streamt;
if $rows != 2 then
print ======$rows
- return -1
+ goto loop3
endi
if $data01 != 2 then
print ======$data01
- return -1
+ goto loop3
endi
if $data11 != 5 then
print ======$data11
- return -1
+ goto loop3
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
diff --git a/tests/script/tsim/stream/udTableAndTag0.sim b/tests/script/tsim/stream/udTableAndTag0.sim
index 5cb5c2dd8b4f14cd6910535b96c305296618b50a..bfc299df0f0541dac5c152304275fd67ff905570 100644
--- a/tests/script/tsim/stream/udTableAndTag0.sim
+++ b/tests/script/tsim/stream/udTableAndTag0.sim
@@ -367,6 +367,77 @@ if $data22 != tag-t3 then
goto loop8
endi
+print ===== step6
+print ===== transform tag value
+
+sql drop stream if exists streams1;
+sql drop stream if exists streams2;
+sql drop stream if exists streams3;
+sql drop stream if exists streams4;
+sql drop stream if exists streams5;
+
+sql drop database if exists test1;
+sql drop database if exists test2;
+sql drop database if exists test3;
+sql drop database if exists test4;
+sql drop database if exists test5;
+
+sql drop database if exists result1;
+sql drop database if exists result2;
+sql drop database if exists result3;
+sql drop database if exists result4;
+sql drop database if exists result5;
+
+
+
+sql create database result6 vgroups 1;
+
+sql create database test6 vgroups 4;
+sql use test6;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta varchar(20), tb int, tc int);
+sql create table t1 using st tags("1",1,1);
+sql create table t2 using st tags("2",2,2);
+sql create table t3 using st tags("3",3,3);
+
+sql create stream streams6 trigger at_once into result6.streamt6 TAGS(dd int) as select _wstart, count(*) c1 from st partition by concat(ta, "0") as dd, tbname interval(10s);
+sql insert into t1 values(1648791213000,1,1,1) t2 values(1648791213000,2,2,2) t3 values(1648791213000,3,3,3);
+
+
+$loop_count = 0
+loop9:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result6.streamt6 order by 3;
+
+if $rows != 3 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop9
+endi
+
+if $data02 != 10 then
+ print =====data02=$data02
+ goto loop9
+endi
+
+if $data12 != 20 then
+ print =====data12=$data12
+ goto loop9
+endi
+
+if $data22 != 30 then
+ print =====data22=$data22
+ goto loop8
+endi
+
print ======over
system sh/stop_dnodes.sh
diff --git a/tests/script/tsim/stream/udTableAndTag2.sim b/tests/script/tsim/stream/udTableAndTag2.sim
new file mode 100644
index 0000000000000000000000000000000000000000..bacc301ad005d54dadd098a1b88db9ab17427c16
--- /dev/null
+++ b/tests/script/tsim/stream/udTableAndTag2.sim
@@ -0,0 +1,515 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+
+print ===== step1
+
+system sh/exec.sh -n dnode1 -s start
+sleep 50
+sql connect
+
+print ===== step2
+print ===== table name
+
+sql create database result vgroups 1;
+
+sql create database test vgroups 4;
+sql use test;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+
+sql create stream streams1 trigger at_once into result.streamt SUBTABLE("aaa") as select _wstart, count(*) c1 from st interval(10s);
+print ===== insert into 1
+sql insert into t1 values(1648791213000,1,2,3);
+sql insert into t2 values(1648791213000,2,2,3);
+
+$loop_count = 0
+loop0:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select table_name from information_schema.ins_tables where db_name="result" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop0
+endi
+
+if $data00 != aaa then
+ print =====data00=$data00
+ goto loop0
+endi
+
+
+$loop_count = 0
+loop1:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result.streamt;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+# group id
+if $data02 == NULL then
+ print =====data02=$data02
+ goto loop1
+endi
+
+
+print ===== step3
+print ===== column name
+
+sql create database result2 vgroups 1;
+
+sql create database test2 vgroups 4;
+sql use test2;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+
+sql create stream streams2 trigger at_once into result2.streamt2 TAGS(cc varchar(100)) as select _wstart, count(*) c1 from st interval(10s);
+print ===== insert into 2
+sql insert into t1 values(1648791213000,1,2,3);
+sql insert into t2 values(1648791213000,2,2,3);
+
+
+$loop_count = 0
+loop2:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+print select tag_name from information_schema.ins_tags where db_name="result2" and stable_name = "streamt2" order by 1;
+
+sql select tag_name from information_schema.ins_tags where db_name="result2" and stable_name = "streamt2" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop2
+endi
+
+if $data00 != cc then
+ print =====data00=$data00
+ goto loop2
+endi
+
+print sql select cc from result2.streamt2 order by 1;
+
+$loop_count = 0
+loop21:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select cc from result2.streamt2 order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop21
+endi
+
+if $data00 != NULL then
+ print =====data00=$data00
+ goto loop21
+endi
+
+
+$loop_count = 0
+loop3:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result2.streamt2;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop3
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop3
+endi
+
+
+print ===== step4
+print ===== column name + table name
+
+sql create database result3 vgroups 1;
+
+sql create database test3 vgroups 4;
+sql use test3;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+
+sql create stream streams3 trigger at_once into result3.streamt3 TAGS(dd varchar(100)) SUBTABLE(concat("tbn-", "1") ) as select _wstart, count(*) c1 from st interval(10s);
+print ===== insert into 3
+sql insert into t1 values(1648791213000,1,2,3);
+sql insert into t2 values(1648791213000,2,2,3);
+
+
+$loop_count = 0
+loop4:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select tag_name from information_schema.ins_tags where db_name="result3" and stable_name = "streamt3" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop4
+endi
+
+if $data00 != dd then
+ print =====data00=$data00
+ goto loop4
+endi
+
+sql select dd from result3.streamt3 order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop4
+endi
+
+if $data00 != NULL then
+ print =====data00=$data00
+ goto loop4
+endi
+
+$loop_count = 0
+loop5:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result3.streamt3;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop5
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop5
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop5
+endi
+
+$loop_count = 0
+loop6:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select table_name from information_schema.ins_tables where db_name="result3" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop6
+endi
+
+if $data00 != tbn-1 then
+ print =====data00=$data00
+ goto loop6
+endi
+
+print ===== step5
+print ===== tag name + table name
+
+sql create database result4 vgroups 1;
+
+sql create database test4 vgroups 1;
+sql use test4;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+sql create table t3 using st tags(3,3,3);
+
+sql create stream streams4 trigger at_once into result4.streamt4 TAGS(dd varchar(100)) SUBTABLE(concat("tbn-", "1")) as select _wstart, count(*) c1 from st interval(10s);
+sql insert into t1 values(1648791213000,1,1,1) t2 values(1648791213000,2,2,2) t3 values(1648791213000,3,3,3);
+
+
+$loop_count = 0
+loop7:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select table_name from information_schema.ins_tables where db_name="result4" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop7
+endi
+
+if $data00 != tbn-1 then
+ print =====data00=$data00
+ goto loop7
+endi
+
+$loop_count = 0
+loop8:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result4.streamt4 order by 3;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop8
+endi
+
+if $data01 != 3 then
+ print =====data01=$data01
+ goto loop8
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop8
+endi
+
+
+print ===== step6
+print ===== table name
+
+sql create database result5 vgroups 1;
+
+sql create database test5 vgroups 1;
+sql use test5;
+
+
+sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+
+sql create stream streams51 trigger at_once into result5.streamt51 SUBTABLE("aaa") as select _wstart, count(*) c1 from st interval(10s);
+sql create stream streams52 trigger at_once into result5.streamt52 TAGS(cc varchar(100)) as select _wstart, count(*) c1 from st interval(10s);
+sql create stream streams53 trigger at_once into result5.streamt53 TAGS(dd varchar(100)) SUBTABLE(concat("aaa-", "1") ) as select _wstart, count(*) c1 from st interval(10s);
+
+sql insert into t1 values(1648791213000,1,2,3);
+sql insert into t2 values(1648791213000,2,2,3);
+
+$loop_count = 0
+loop9:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+print select table_name from information_schema.ins_tables where db_name="result5" order by 1;
+
+sql select table_name from information_schema.ins_tables where db_name="result5" order by 1;
+
+if $rows != 3 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ print $data20
+ print $data40
+ goto loop9
+endi
+
+if $data00 != aaa then
+ print =====data00=$data00
+ goto loop9
+endi
+
+if $data10 != aaa-1 then
+ print =====data00=$data00
+ goto loop9
+endi
+
+$loop_count = 0
+loop10:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+print sql select tag_name from information_schema.ins_tags where db_name="result5" and stable_name = "streamt52" order by 1;
+
+sql select tag_name from information_schema.ins_tags where db_name="result5" and stable_name = "streamt52" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop10
+endi
+
+if $data00 != cc then
+ print =====data00=$data00
+ goto loop10
+endi
+
+print sql select tag_name from information_schema.ins_tags where db_name="result5" and stable_name = "streamt53" order by 1;
+
+sql select tag_name from information_schema.ins_tags where db_name="result5" and stable_name = "streamt53" order by 1;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00
+ print $data10
+ goto loop10
+endi
+
+if $data00 != dd then
+ print =====data00=$data00
+ goto loop10
+endi
+
+
+
+
+
+$loop_count = 0
+loop11:
+
+sleep 300
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+sql select * from result5.streamt51;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop11
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop11
+endi
+
+sql select * from result5.streamt52;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop11
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop11
+endi
+
+sql select * from result5.streamt53;
+
+if $rows != 1 then
+ print =====rows=$rows
+ print $data00 $data10
+ goto loop11
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop11
+endi
+
+print ======over
+
+system sh/stop_dnodes.sh
diff --git a/tests/system-test/0-others/balance_vgroups_r1.py b/tests/system-test/0-others/balance_vgroups_r1.py
new file mode 100644
index 0000000000000000000000000000000000000000..ae504cbab11e1bddf7b4d4a6f14ab41342d9d2be
--- /dev/null
+++ b/tests/system-test/0-others/balance_vgroups_r1.py
@@ -0,0 +1,99 @@
+###################################################################
+# 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 util import constant
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.common import *
+from util.sqlset import *
+from util.cluster import *
+class TDTestCase:
+ def init(self, conn, logSql, replicaVar=1):
+ self.replicaVar = int(replicaVar)
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor())
+ self.dnode_num=len(cluster.dnodes)
+ self.dbname = 'db_test'
+ self.setsql = TDSetSql()
+ self.stbname = f'{self.dbname}.stb'
+ self.rowNum = 5
+ self.tbnum = 10
+ self.ts = 1537146000000
+ self.binary_str = 'taosdata'
+ self.nchar_str = '涛思数据'
+ self.column_dict = {
+ 'ts' : 'timestamp',
+ 'col1': 'tinyint',
+ 'col2': 'smallint',
+ 'col3': 'int',
+ 'col4': 'bigint',
+ 'col5': 'tinyint unsigned',
+ 'col6': 'smallint unsigned',
+ 'col7': 'int unsigned',
+ 'col8': 'bigint unsigned',
+ 'col9': 'float',
+ 'col10': 'double',
+ 'col11': 'bool',
+ 'col12': 'binary(20)',
+ 'col13': 'nchar(20)'
+ }
+ self.replica = [1,3]
+
+ def insert_data(self,column_dict,tbname,row_num):
+ insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str)
+ for i in range(row_num):
+ insert_list = []
+ self.setsql.insert_values(column_dict,i,insert_sql,insert_list,self.ts)
+ def prepare_data(self,dbname,stbname,column_dict,tbnum,rowNum,replica):
+ tag_dict = {
+ 't0':'int'
+ }
+ tag_values = [
+ f'1'
+ ]
+ tdSql.execute(f"create database if not exists {dbname} vgroups 1 replica {replica} ")
+ tdSql.execute(f'use {dbname}')
+ tdSql.execute(self.setsql.set_create_stable_sql(stbname,column_dict,tag_dict))
+ for i in range(tbnum):
+ tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})")
+ self.insert_data(self.column_dict,f'{stbname}_{i}',rowNum)
+ def redistribute_vgroups(self,replica,stbname,tbnum,rownum):
+ tdSql.query('show vgroups')
+ vnode_id = tdSql.queryResult[0][0]
+ if replica == 1:
+ for dnode_id in range(1,self.dnode_num+1) :
+ tdSql.execute(f'redistribute vgroup {vnode_id} dnode {dnode_id}')
+ tdSql.query(f'select count(*) from {stbname}')
+ tdSql.checkEqual(tdSql.queryResult[0][0],tbnum*rownum)
+ elif replica == 3:
+ for dnode_id in range(1,self.dnode_num-1):
+ tdSql.execute(f'redistribute vgroup {vnode_id} dnode {dnode_id} dnode {dnode_id+1} dnode {dnode_id+2}')
+ tdSql.query(f'select count(*) from {stbname}')
+ tdSql.checkEqual(tdSql.queryResult[0][0],tbnum*rownum)
+
+ def run(self):
+ for replica in self.replica:
+ self.prepare_data(self.dbname,self.stbname,self.column_dict,self.tbnum,self.rowNum,replica)
+ self.redistribute_vgroups(replica,self.stbname,self.tbnum,self.rowNum)
+ tdSql.execute(f'drop database {self.dbname}')
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py
index 1834432bc9a9364e039df2c95ce47fb01e945eab..a5cded7a6b65cf9fb72374389175274bb7ae7687 100644
--- a/tests/system-test/0-others/compatibility.py
+++ b/tests/system-test/0-others/compatibility.py
@@ -99,6 +99,10 @@ class TDTestCase:
def run(self):
+ distro_id = distro.id()
+ if distro_id == "alpine":
+ tdLog.info(f"alpine skip compatibility test")
+ return True
bPath = self.getBuildPath()
cPath = self.getCfgPath()
dbname = "test"
diff --git a/tests/system-test/1-insert/insert_drop.py b/tests/system-test/1-insert/insert_drop.py
index 029d013d5bd82a00511df1fcef9755b9dee99259..930c65d90ef00cf318e03d49e4ff4afd4c1d41f3 100644
--- a/tests/system-test/1-insert/insert_drop.py
+++ b/tests/system-test/1-insert/insert_drop.py
@@ -31,6 +31,10 @@ class TDTestCase:
tdSql.execute('create database if not exists test;')
tdSql.execute('create table test.stb (ts timestamp, c11 int, c12 float ) TAGS(t11 int, t12 int );')
tdSql.execute('create table test.tb using test.stb TAGS (1, 1);')
+
+ # double comma insert check error
+ tdSql.error("insert into test.tb(ts, c11) values(now,,100)")
+
sql_list = list()
for i in range(5):
sql = f'insert into test.tb values (now-{i}m, {i}, {i});'
diff --git a/tests/system-test/2-query/case_when.py b/tests/system-test/2-query/case_when.py
index cfe03995538abcbd436e7ee3b4ed3fb714555a49..eebbcc3fa36fe2181f814f3a75a4f65e732a1e1f 100755
--- a/tests/system-test/2-query/case_when.py
+++ b/tests/system-test/2-query/case_when.py
@@ -111,6 +111,17 @@ class TDTestCase:
sql2 = "select (case when sum(q_smallint)=0 then null else sum(q_smallint) end) from %s.stable_1_1 limit 100;" %database
self.constant_check(database,sql1,sql2,0)
+ #TD-20257
+ sql1 = "select tbname,first(ts),q_int,q_smallint,q_bigint,case when q_int <0 then 1 else 0 end from %s.stable_1 where tbname = 'stable_1_1' and ts < now partition by tbname state_window(case when q_int <0 then 1 else 0 end);" %database
+ sql2 = "select tbname,first(ts),q_int,q_smallint,q_bigint,case when q_int <0 then 1 else 0 end from %s.stable_1_1 where ts < now partition by tbname state_window(case when q_int <0 then 1 else 0 end);" %database
+ self.constant_check(database,sql1,sql2,0)
+ self.constant_check(database,sql1,sql2,1)
+ self.constant_check(database,sql1,sql2,2)
+ self.constant_check(database,sql1,sql2,3)
+ self.constant_check(database,sql1,sql2,4)
+ self.constant_check(database,sql1,sql2,5)
+
+ #TD-20260
sql1 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1 where tbname = 'stable_1_1' and ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
sql2 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1_1 where ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database
self.constant_check(database,sql1,sql2,0)
diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py
index 8aa2b3d42001bf8e354e850bc79d66d093c696f6..d976edb49ceb4cfd376e1c354398c08ba5dd3163 100644
--- a/tests/system-test/2-query/irate.py
+++ b/tests/system-test/2-query/irate.py
@@ -97,7 +97,7 @@ class TDTestCase:
tdSql.execute(
f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
- for i in range(9):
+ for i in range(1,10):
tdSql.execute(
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
)
diff --git a/tests/system-test/2-query/max_min_data.py b/tests/system-test/2-query/max_min_data.py
new file mode 100755
index 0000000000000000000000000000000000000000..e3dff5da7854c595343f08b0990b4e436ea97a1c
--- /dev/null
+++ b/tests/system-test/2-query/max_min_data.py
@@ -0,0 +1,159 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import random
+import os
+import time
+import taos
+import subprocess
+from faker import Faker
+from util.log import tdLog
+from util.cases import tdCases
+from util.sql import tdSql
+from util.dnodes import tdDnodes
+from util.dnodes import *
+
+class TDTestCase:
+ updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 131 ,"querySmaOptimize":1}
+
+ def init(self, conn, logSql, replicaVar):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ self.testcasePath = os.path.split(__file__)[0]
+ self.testcaseFilename = os.path.split(__file__)[-1]
+ os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
+
+ self.db = "max_min"
+
+ def dropandcreateDB_random(self,database,n):
+ ts = 1630000000000
+ num_random = 5
+ fake = Faker('zh_CN')
+ tdSql.execute('''drop database if exists %s ;''' %database)
+ tdSql.execute('''create database %s keep 36500 ;'''%(database))
+ tdSql.execute('''use %s;'''%database)
+
+ tdSql.execute('''create stable %s.stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \
+ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \
+ tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database)
+
+ for i in range(num_random):
+ tdSql.execute('''create table %s.stable_1_%d using %s.stable_1 tags('stable_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;'''
+ %(database,i,database,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
+ fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
+ fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
+
+ # insert data
+ for i in range(num_random):
+ for j in range(n):
+ tdSql.execute('''insert into %s.stable_1_%d (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts)\
+ values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;'''
+ % (database,i,ts + i*1000 + j, fake.random_int(min=-2147483647, max=2147483647, step=1),
+ fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
+ fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
+ fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i))
+
+ tdSql.query("select count(*) from %s.stable_1;" %database)
+ tdSql.checkData(0,0,num_random*n)
+ tdSql.query("select count(*) from %s.stable_1_1;"%database)
+ tdSql.checkData(0,0,n)
+
+
+ def TD_22219_max(self,database):
+
+ sql3 = "select count(*) from (select max(q_int) from %s.stable_1 group by tbname); ;" %database
+ tdSql.query(sql3)
+ sql_value = tdSql.getData(0,0)
+ self.value_check(sql_value,5)
+
+ sql1 = "select max(q_int) from %s.stable_1_1 ;" %database
+ sql2 = "select max(q_int) from %s.stable_1 where tbname = 'stable_1_1' ;" %database
+ self.constant_check(database,sql1,sql2,0)
+
+ sql3 = "select count(*) from (select max(q_int) from %s.stable_1 group by tbname); ;" %database
+ tdSql.query(sql3)
+ sql_value = tdSql.getData(0,0)
+ self.value_check(sql_value,5)
+
+ def TD_22219_min(self,database):
+
+ sql3 = "select count(*) from (select min(q_int) from %s.stable_1 group by tbname); ;" %database
+ tdSql.query(sql3)
+ sql_value = tdSql.getData(0,0)
+ self.value_check(sql_value,5)
+
+ sql1 = "select min(q_int) from %s.stable_1_1 ;" %database
+ sql2 = "select min(q_int) from %s.stable_1 where tbname = 'stable_1_1' ;" %database
+ self.constant_check(database,sql1,sql2,0)
+
+ sql3 = "select count(*) from (select min(q_int) from %s.stable_1 group by tbname); ;" %database
+ tdSql.query(sql3)
+ sql_value = tdSql.getData(0,0)
+ self.value_check(sql_value,5)
+
+ def constant_check(self,database,sql1,sql2,column):
+ #column =0 代表0列, column = n代表n-1列
+ tdLog.info("\n=============sql1:(%s)___sql2:(%s) ====================\n" %(sql1,sql2))
+
+ tdSql.query(sql1)
+ sql1_value = tdSql.getData(0,column)
+ tdSql.query(sql2)
+ sql2_value = tdSql.getData(0,column)
+ self.value_check(sql1_value,sql2_value)
+
+ tdSql.execute(" flush database %s;" %database)
+
+ time.sleep(3)
+
+ tdSql.query(sql1)
+ sql1_flush_value = tdSql.getData(0,column)
+ tdSql.query(sql2)
+ sql2_flush_value = tdSql.getData(0,column)
+ self.value_check(sql1_flush_value,sql2_flush_value)
+
+ self.value_check(sql1_value,sql1_flush_value)
+ self.value_check(sql2_value,sql2_flush_value)
+
+ def value_check(self,base_value,check_value):
+ if base_value==check_value:
+ tdLog.info(f"checkEqual success, base_value={base_value},check_value={check_value}")
+ else :
+ tdLog.exit(f"checkEqual error, base_value=={base_value},check_value={check_value}")
+
+ def run(self):
+
+ startTime = time.time()
+
+ os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
+
+ self.dropandcreateDB_random("%s" %self.db, 2000)
+
+ self.TD_22219_max("%s" %self.db)
+
+ self.dropandcreateDB_random("%s" %self.db, 2000)
+
+ self.TD_22219_min("%s" %self.db)
+
+ endTime = time.time()
+ print("total time %ds" % (endTime - startTime))
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/system-test/6-cluster/5dnode1mnode.py b/tests/system-test/6-cluster/5dnode1mnode.py
index ce87bced1b75d1994024586cf5084c5194befc22..f21fae0d7b9a4908a6112d2f5ea7cc214bd961bf 100644
--- a/tests/system-test/6-cluster/5dnode1mnode.py
+++ b/tests/system-test/6-cluster/5dnode1mnode.py
@@ -145,8 +145,8 @@ class TDTestCase:
tdSql.query("show db.alive;")
tdSql.checkData(0, 0, 1)
- # stop 5 dnode
- self.TDDnodes.stoptaosd(5)
+ # stop 3 dnode
+ self.TDDnodes.stoptaosd(3)
tdSql.checkDataLoop(0, 0, 2, "show cluster alive;", 20, 0.5)
tdSql.query("show db.alive;")
diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py
index abe8ed29450fc105efb983ce2083a63e717d3e39..cdcdadbcbb396d1e7228bba7779549e86646871c 100644
--- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py
+++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py
@@ -236,8 +236,8 @@ class TDTestCase:
tdDnodes[0].starttaosd()
self.check3mnode()
- tdLog.info("3. stop dnode 1")
- tdDnodes[1].stoptaosd()
+ tdLog.info("3. stop dnode 2")
+ tdDnodes[2].stoptaosd()
time.sleep(10)
self.check3mnode1off()
diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py
index 95ce03e6533223288b2424dcc22932b1e9b54a5a..37946d0c22dae353ac62cb8e564c1361115bf8f9 100644
--- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py
+++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py
@@ -192,7 +192,7 @@ class TDTestCase:
topicList = topicNameList[0]
ifcheckdata = 1
ifManualCommit = 1
- keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:300, auto.offset.reset:earliest'
+ keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:100, auto.offset.reset:earliest'
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
tdLog.info("start consume processor 0")
diff --git a/tests/system-test/7-tmq/tmqUpdate-1ctb.py b/tests/system-test/7-tmq/tmqUpdate-1ctb.py
index b974e4a41a2c60d4c882b2006400f500ec799efc..2fa6600fb99efa22035091da6d75ac00d6b55afa 100644
--- a/tests/system-test/7-tmq/tmqUpdate-1ctb.py
+++ b/tests/system-test/7-tmq/tmqUpdate-1ctb.py
@@ -183,6 +183,7 @@ class TDTestCase:
tdLog.info("restart taosd to ensure that the data falls into the disk")
tdSql.query("flush database %s"%(paraDict['dbName']))
+ time.sleep(10)
# update to half tables
paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl / 2)
@@ -206,7 +207,7 @@ class TDTestCase:
paraDict['rowsPerTbl'] = self.rowsPerTbl
consumerId = 1
if self.snapshot == 0:
- expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2))
+ expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2))
elif self.snapshot == 1:
expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1))
diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py
index d5df88cf43b1e207f3856807bb9b0bcf55b4b8c6..daffff44c1cf0dda7c4ecf5ac2dfd3dadfdf5504 100644
--- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py
+++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py
@@ -213,9 +213,9 @@ class TDTestCase:
paraDict['rowsPerTbl'] = self.rowsPerTbl
consumerId = 1
if self.snapshot == 0:
- expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2 + 1/2*1/2))
+ expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2) * (1/2*3))
elif self.snapshot == 1:
- expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2))
+ expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/2))
topicList = topicFromStb1
ifcheckdata = 1
diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py
index 7ca18f293cddf415a2b4ac3354f5848171e7b736..593c91a470fc3f77ae49af7be069b2b6ff4df9b0 100644
--- a/tests/system-test/7-tmq/tmq_taosx.py
+++ b/tests/system-test/7-tmq/tmq_taosx.py
@@ -43,9 +43,9 @@ class TDTestCase:
tdSql.execute('use db_taosx')
tdSql.query("show tables")
if drop:
- tdSql.checkRows(10)
+ tdSql.checkRows(11)
else:
- tdSql.checkRows(15)
+ tdSql.checkRows(16)
tdSql.query("select * from jt order by i")
tdSql.checkRows(2)
tdSql.checkData(0, 1, 1)
@@ -63,20 +63,20 @@ class TDTestCase:
tdSql.checkData(1, 5, "sttb4")
tdSql.query("select * from stt order by ts")
- tdSql.checkRows(2)
+ tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
- tdSql.checkData(1, 1, 21)
+ tdSql.checkData(2, 1, 21)
tdSql.checkData(0, 2, 2)
- tdSql.checkData(1, 2, 21)
+ tdSql.checkData(2, 2, 21)
tdSql.checkData(0, 5, "stt3")
- tdSql.checkData(1, 5, "stt4")
+ tdSql.checkData(2, 5, "stt4")
tdSql.execute('use abc1')
tdSql.query("show tables")
if drop:
- tdSql.checkRows(10)
+ tdSql.checkRows(11)
else:
- tdSql.checkRows(15)
+ tdSql.checkRows(16)
tdSql.query("select * from jt order by i")
tdSql.checkRows(2)
tdSql.checkData(0, 1, 1)
@@ -94,13 +94,13 @@ class TDTestCase:
tdSql.checkData(1, 5, "sttb4")
tdSql.query("select * from stt order by ts")
- tdSql.checkRows(2)
+ tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
- tdSql.checkData(1, 1, 21)
+ tdSql.checkData(2, 1, 21)
tdSql.checkData(0, 2, 2)
- tdSql.checkData(1, 2, 21)
+ tdSql.checkData(2, 2, 21)
tdSql.checkData(0, 5, "stt3")
- tdSql.checkData(1, 5, "stt4")
+ tdSql.checkData(2, 5, "stt4")
return
@@ -199,6 +199,11 @@ class TDTestCase:
tdSql.checkData(0, 2, None)
tdSql.checkData(1, 1, 1)
tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}')
+
+ tdSql.query("select * from information_schema.ins_tables where table_name = 'stt4'")
+ uid1 = tdSql.getData(0, 5)
+ uid2 = tdSql.getData(1, 5)
+ tdSql.checkNotEqual(uid1, uid2)
return
def checkWal1Vgroup(self):
diff --git a/tests/system-test/pytest.sh b/tests/system-test/pytest.sh
index 68d49f5d06c48d7ffcbfa564d802762b7f120b4f..792cab98f7895e00490644ccea9dbf5e8757956b 100755
--- a/tests/system-test/pytest.sh
+++ b/tests/system-test/pytest.sh
@@ -8,15 +8,23 @@
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`
+UNAME_BIN=$(which uname)
+OS_TYPE=$($UNAME_BIN)
cd .
# Get responsible directories
-CODE_DIR=`dirname $0`
-CODE_DIR=`pwd`
+CODE_DIR=$(dirname $0)
+CODE_DIR=$(pwd)
IN_TDINTERNAL="community"
if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then
@@ -25,19 +33,15 @@ else
cd ../../
fi
-TOP_DIR=`pwd`
-TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
+TOP_DIR=$(pwd)
+TAOSD_DIR=$(find . -name "taosd" | grep bin | head -n1)
-if [[ "$OS_TYPE" != "Darwin" ]]; then
- cut_opt="--field="
-else
- cut_opt="-f "
-fi
+cut_opt="-f "
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
- BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
+ 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`
+ BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2)
fi
declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR
@@ -66,35 +70,38 @@ ulimit -c unlimited
#sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e
echo "ExcuteCmd:" $*
-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`
-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
-
-AsanFileSuccessLen=`grep -w successfully $AsanFile | wc -l`
-echo "AsanFileSuccessLen:" $AsanFileSuccessLen
-if [ $AsanFileSuccessLen -gt 0 ]; then
- echo "Execute script successfully and check asan"
- $CODE_DIR/../script/sh/checkAsan.sh
+if [[ "$TD_OS" == "Alpine" ]]; then
+ $*
else
- echo "Execute script failure"
- exit 1
+ 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)
+ 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
+
+ AsanFileSuccessLen=$(grep -w successfully $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/tools/CMakeLists.txt b/tools/CMakeLists.txt
index d61d25602b081d9cc6e7609f7e807add5a71e597..1461a7b373e3395ed3f4afc111a2df8ca0e5ed60 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -7,25 +7,45 @@ IF (TD_WEBSOCKET)
SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}")
ENDIF ()
MESSAGE("${Green} use libtaos-ws${ColourReset}")
-
- include(ExternalProject)
- ExternalProject_Add(taosws-rs
- PREFIX "taosws-rs"
- SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
- BUILD_ALWAYS off
- DEPENDS taos
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
- PATCH_COMMAND
- COMMAND git clean -f -d
- BUILD_COMMAND
- COMMAND cargo update
- COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored
- INSTALL_COMMAND
- COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
- COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
- COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include
- )
+ IF (TD_ALPINE)
+ include(ExternalProject)
+ ExternalProject_Add(taosws-rs
+ PREFIX "taosws-rs"
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
+ BUILD_ALWAYS off
+ DEPENDS taos
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
+ PATCH_COMMAND
+ COMMAND git clean -f -d
+ BUILD_COMMAND
+ COMMAND cargo update
+ COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features native-tls
+ INSTALL_COMMAND
+ COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
+ COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
+ COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include
+ )
+ ELSE()
+ include(ExternalProject)
+ ExternalProject_Add(taosws-rs
+ PREFIX "taosws-rs"
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
+ BUILD_ALWAYS off
+ DEPENDS taos
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
+ PATCH_COMMAND
+ COMMAND git clean -f -d
+ BUILD_COMMAND
+ COMMAND cargo update
+ COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored
+ INSTALL_COMMAND
+ COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
+ COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
+ COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include
+ )
+ ENDIF ()
ENDIF ()
IF (TD_TAOS_TOOLS)
diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt
index 342d6410d29f1b94d80b508c05507a0f5b81cdec..600e33feab10fcd0b3c0ccee2de3cd61544e16d8 100644
--- a/tools/shell/CMakeLists.txt
+++ b/tools/shell/CMakeLists.txt
@@ -30,15 +30,23 @@ IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL)
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL)
+IF (TD_LINUX AND TD_ALPINE)
+ SET(LINK_ARGP "/usr/lib/libargp.a")
+ELSE ()
+ SET(LINK_ARGP "")
+ENDIF ()
+
if(TD_WINDOWS)
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
else()
- target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC})
+ target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC} ${LINK_ARGP})
endif ()
+
target_link_libraries(
shell
PRIVATE os common transport util
)
+
target_include_directories(
shell
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c
index d899249b97f0160d366db385653c1c65a9864d9a..0612c2f4558f3cad270b69d3187b39549efa9990 100644
--- a/tools/shell/src/shellArguments.c
+++ b/tools/shell/src/shellArguments.c
@@ -97,7 +97,11 @@ void shellPrintHelp() {
#ifdef LINUX
#include
+#ifdef _ALPINE
+#include
+#else
#include
+#endif
const char *argp_program_version = version;
const char *argp_program_bug_address = cusEmail;
diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c
index e3584b689009f9ca120af6e6a29e7ab8c643ec29..4ac4cfb119aa026eba7b427d5181559da6542c56 100644
--- a/tools/shell/src/shellWebsocket.c
+++ b/tools/shell/src/shellWebsocket.c
@@ -224,8 +224,13 @@ void shellRunSingleCommandWebsocketImp(char *command) {
res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout);
int code = ws_errno(res);
if (code != 0 && !shell.stop_query) {
- et = taosGetTimestampUs();
- fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6);
+ // websocket interface masked off first bit from standard error number.
+ if (TSDB_CODE_PAR_SYNTAX_ERROR == (code|0x80000000)) {
+ et = taosGetTimestampUs();
+ fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6);
+ ws_free_result(res);
+ return;
+ }
if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) {
fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n");
} else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) {
diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c
index 69bf52bb1ac1c80015e12a6ecf6701dc73f8d139..fb05ae262b0881ec00150aef7a5c51548c9c8b00 100644
--- a/utils/test/c/tmq_taosx_ci.c
+++ b/utils/test/c/tmq_taosx_ci.c
@@ -71,6 +71,8 @@ static void msg_process(TAOS_RES* msg) {
printf("write raw data type: %d\n", raw.raw_type);
int32_t ret = tmq_write_raw(pConn, raw);
printf("write raw data: %s\n", tmq_err2str(ret));
+ ASSERT(ret == 0);
+
tmq_free_raw(raw);
taos_close(pConn);
}
@@ -361,7 +363,7 @@ int buildDatabase(TAOS* pConn, TAOS_RES* pRes){
}
taos_free_result(pRes);
- pRes = taos_query(pConn, "insert into stt3 using stt tags(23, \"stt3\", true) values(now + 1s, 1, 2, 'stt3') sttb3 using sttb tags(4, \"sttb3\", true) values(now + 2s, 13, 22, 'sttb3') "
+ pRes = taos_query(pConn, "insert into stt1 values(now + 2s, 3, 2, 'stt1') stt3 using stt tags(23, \"stt3\", true) values(now + 1s, 1, 2, 'stt3') sttb3 using sttb tags(4, \"sttb3\", true) values(now + 2s, 13, 22, 'sttb3') "
"stt4 using stt tags(433, \"stt4\", false) values(now + 3s, 21, 21, 'stt4') sttb4 using sttb tags(543, \"sttb4\", true) values(now + 4s, 16, 25, 'sttb4')");
if (taos_errno(pRes) != 0) {
printf("failed to create child table stt1, reason:%s\n", taos_errstr(pRes));