diff --git a/.clang-format b/.clang-format index e58d518b3b8cacdd1e13dd965805fa364a996eb2..56ca83e724ad0b804a10b9be0dd42aa7a05eeaf7 100644 --- a/.clang-format +++ b/.clang-format @@ -88,4 +88,3 @@ Standard: Auto TabWidth: 8 UseTab: Never ... - diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..912b302ad23d47c46708d672175a908f2dbc74e8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.py linguist-detectable=false diff --git a/.gitignore b/.gitignore index 76b581b18224c4036c59573900943804aeabe905..5f1e24109df622591bdd31536d0316d2bb2c5450 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/ compile_commands.json +CMakeSettings.json .cache .ycm_extra_conf.py .tasks diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c7e31bfbb891cc23c2cd5e788772d6f33bc329e..90e841d5e04fd72338f38ca11f1dd5a522b61918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif(${BUILD_TEST}) add_subdirectory(source) add_subdirectory(tools) -add_subdirectory(tests) +add_subdirectory(utils) add_subdirectory(examples/c) # docs diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 887fbd86d55d782cdf3c1d7c95dfee2dc2ec446d..3aa1ffc07e73acdf480a21b478d55e05153694f8 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -46,7 +46,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - MESSAGE("Current system arch is arm64") + MESSAGE("Current system arch is 64") SET(TD_DARWIN_64 TRUE) ADD_DEFINITIONS("-D_TD_DARWIN_64") ENDIF () diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index c0de75c6dd067021f1088b3501910cef95ea3fe5..b905e30489a3455fd834ba76a711675e88f28cac 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 aa45ad4 + GIT_TAG a4d9b92 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 506559a245ee7a3e506e8481a12a3fe7f01dd5ac..54e898ecc093a5401b93080a13156f284a4cd0a4 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 7a54d21 + GIT_TAG 6fc47d7 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 22e62bc5e05fe83065b0e101644b01dbba2b5874..5265be42f81c4f43fa73e5b7d603d8989c2a5671 100644 --- a/docs/en/01-index.md +++ b/docs/en/01-index.md @@ -4,25 +4,24 @@ sidebar_label: Documentation Home slug: / --- - -TDengine is an [open source](https://tdengine.com/tdengine/open-source-time-series-database/), [cloud native](https://tdengine.com/tdengine/cloud-native-time-series-database/) time-series database optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. This document is the TDengine user manual. It introduces the basic, as well as novel concepts, in TDengine, and also talks in detail about installation, features, SQL, APIs, operation, maintenance, kernel design and other topics. It’s written mainly for architects, developers and system administrators. +TDengine is an [open-source](https://tdengine.com/tdengine/open-source-time-series-database/), [cloud-native](https://tdengine.com/tdengine/cloud-native-time-series-database/) time-series database optimized for the Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. This document is the TDengine user manual. It introduces the basic, as well as novel concepts, in TDengine, and also talks in detail about installation, features, SQL, APIs, operation, maintenance, kernel design, and other topics. It’s written mainly for architects, developers, and system administrators. To get an overview of TDengine, such as a feature list, benchmarks, and competitive advantages, please browse through the [Introduction](./intro) section. -TDengine greatly improves the efficiency of data ingestion, querying and storage by exploiting the characteristics of time series data, introducing the novel concepts of "one table for one data collection point" and "super table", and designing an innovative storage engine. To understand the new concepts in TDengine and make full use of the features and capabilities of TDengine, please read [“Concepts”](./concept) thoroughly. +TDengine greatly improves the efficiency of data ingestion, querying, and storage by exploiting the characteristics of time series data, introducing the novel concepts of "one table for one data collection point" and "super table", and designing an innovative storage engine. To understand the new concepts in TDengine and make full use of the features and capabilities of TDengine, please read [Concepts](./concept) thoroughly. -If you are a developer, please read the [“Developer Guide”](./develop) carefully. This section introduces the database connection, data modeling, data ingestion, query, continuous query, cache, data subscription, user-defined functions, and other functionality in detail. Sample code is provided for a variety of programming languages. In most cases, you can just copy and paste the sample code, make a few changes to accommodate your application, and it will work. +If you are a developer, please read the [Developer Guide](./develop) carefully. This section introduces the database connection, data modeling, data ingestion, query, continuous query, cache, data subscription, user-defined functions, and other functionality in detail. Sample code is provided for a variety of programming languages. In most cases, you can just copy and paste the sample code, and make a few changes to accommodate your application, and it will work. -We live in the era of big data, and scale-up is unable to meet the growing needs of business. Any modern data system must have the ability to scale out, and clustering has become an indispensable feature of big data systems. Not only did the TDengine team develop the cluster feature, but also decided to open source this important feature. To learn how to deploy, manage and maintain a TDengine cluster please refer to ["cluster deployment"](../deployment). +We live in the era of big data, and scale-up is unable to meet the growing needs of the business. Any modern data system must have the ability to scale out, and clustering has become an indispensable feature of big data systems. Not only did the TDengine team develop the cluster feature, but also decided to open source this important feature. To learn how to deploy, manage and maintain a TDengine cluster please refer to [Cluster Deployment](../deployment). -TDengine uses ubiquitious SQL as its query language, which greatly reduces learning costs and migration costs. In addition to the standard SQL, TDengine has extensions to better support time series data analysis. These extensions include functions such as roll up, interpolation and time weighted average, among many others. The ["SQL Reference"](./taos-sql) chapter describes the SQL syntax in detail, and lists the various supported commands and functions. +TDengine uses ubiquitous SQL as its query language, which greatly reduces learning costs and migration costs. In addition to the standard SQL, TDengine has extensions to better support time series data analysis. These extensions include functions such as roll-up, interpolation, and time-weighted average, among many others. The [SQL Reference](./taos-sql) chapter describes the SQL syntax in detail and lists the various supported commands and functions. -If you are a system administrator who cares about installation, upgrade, fault tolerance, disaster recovery, data import, data export, system configuration, how to monitor whether TDengine is running healthily, and how to improve system performance, please refer to, and thoroughly read the ["Administration"](./operation) section. +If you are a system administrator who cares about installation, upgrade, fault tolerance, disaster recovery, data import, data export, system configuration, how to monitor whether TDengine is running healthily, and how to improve system performance, please refer to, and thoroughly read the [Administration](./operation) section. -If you want to know more about TDengine tools, the REST API, and connectors for various programming languages, please see the ["Reference"](./reference) chapter. +If you want to know more about TDengine tools, the REST API, and connectors for various programming languages, please see the [Reference](./reference) chapter. -If you are very interested in the internal design of TDengine, please read the chapter ["Inside TDengine”](./tdinternal), which introduces the cluster design, data partitioning, sharding, writing, and reading processes in detail. If you want to study TDengine code or even contribute code, please read this chapter carefully. +If you are very interested in the internal design of TDengine, please read the chapter [Inside TDengine](./tdinternal), which introduces the cluster design, data partitioning, sharding, writing, and reading processes in detail. If you want to study TDengine code or even contribute code, please read this chapter carefully. -TDengine is an open source database, and we would love for you to be a part of TDengine. If you find any errors in the documentation, or see parts where more clarity or elaboration is needed, please click "Edit this page" at the bottom of each page to edit it directly. +TDengine is an open-source database, and we would love for you to be a part of TDengine. If you find any errors in the documentation or see parts where more clarity or elaboration is needed, please click "Edit this page" at the bottom of each page to edit it directly. -Together, we make a difference. +Together, we make a difference! diff --git a/docs/en/02-intro/index.md b/docs/en/02-intro/index.md index 51df83194884743026fc050111686e495105da2e..d385845d7c57203d6e1cc8ddb8d53307f2655914 100644 --- a/docs/en/02-intro/index.md +++ b/docs/en/02-intro/index.md @@ -12,34 +12,34 @@ This section introduces the major features, competitive advantages, typical use- The major features are listed below: 1. Insert data - * supports [using SQL to insert](../develop/insert-data/sql-writing). - * supports [schemaless writing](../reference/schemaless/) just like NoSQL databases. It also supports standard protocols like [InfluxDB LINE](../develop/insert-data/influxdb-line),[OpenTSDB Telnet](../develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](../develop/insert-data/opentsdb-json) among others. - * supports seamless integration with third-party tools like [Telegraf](../third-party/telegraf/), [Prometheus](../third-party/prometheus/), [collectd](../third-party/collectd/), [StatsD](../third-party/statsd/), [TCollector](../third-party/tcollector/) and [icinga2/](../third-party/icinga2/), they can write data into TDengine with simple configuration and without a single line of code. + - Supports [using SQL to insert](../develop/insert-data/sql-writing). + - Supports [schemaless writing](../reference/schemaless/) just like NoSQL databases. It also supports standard protocols like [InfluxDB Line](../develop/insert-data/influxdb-line), [OpenTSDB Telnet](../develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](../develop/insert-data/opentsdb-json) among others. + - Supports seamless integration with third-party tools like [Telegraf](../third-party/telegraf/), [Prometheus](../third-party/prometheus/), [collectd](../third-party/collectd/), [StatsD](../third-party/statsd/), [TCollector](../third-party/tcollector/), [EMQX](../third-party/emq-broker), [HiveMQ](../third-party/hive-mq-broker), and [Icinga2](../third-party/icinga2/), they can write data into TDengine with simple configuration and without a single line of code. 2. Query data - * supports standard [SQL](../taos-sql/), including nested query. - * supports [time series specific functions](../taos-sql/function/#time-series-extensions) and [time series specific queries](../taos-sql/distinguished), like downsampling, interpolation, cumulated sum, time weighted average, state window, session window and many others. - * supports [user defined functions](../taos-sql/udf). + - Supports standard [SQL](../taos-sql/), including nested query. + - Supports [time series specific functions](../taos-sql/function/#time-series-extensions) and [time series specific queries](../taos-sql/distinguished), like downsampling, interpolation, cumulated sum, time weighted average, state window, session window and many others. + - Supports [User Defined Functions (UDF)](../taos-sql/udf). 3. [Caching](../develop/cache/): TDengine always saves the last data point in cache, so Redis is not needed for time-series data processing. -4. [Stream Processing](../develop/stream/): not only is the continuous query is supported, but TDengine also supports even driven stream processing, so Flink or spark is not needed for time-series daata processing. -5. [Data Dubscription](../develop/tmq/): application can subscribe a table or a set of tables. API is the same as Kafka, but you can specify filter conditions. +4. [Stream Processing](../develop/stream/): Not only is the continuous query is supported, but TDengine also supports event driven stream processing, so Flink or Spark is not needed for time-series data processing. +5. [Data Subscription](../develop/tmq/): Application can subscribe a table or a set of tables. API is the same as Kafka, but you can specify filter conditions. 6. Visualization - * supports seamless integration with [Grafana](../third-party/grafana/) for visualization. - * supports seamless integration with Google Data Studio. + - Supports seamless integration with [Grafana](../third-party/grafana/) for visualization. + - Supports seamless integration with Google Data Studio. 7. Cluster - * supports [cluster](../deployment/) with the capability of increasing processing power by adding more nodes. - * supports [deployment on Kubernetes](../deployment/k8s/) - * supports high availability via data replication. + - Supports [cluster](../deployment/) with the capability of increasing processing power by adding more nodes. + - Supports [deployment on Kubernetes](../deployment/k8s/). + - Supports high availability via data replication. 8. Administration - * provides [monitoring](../operation/monitor) on running instances of TDengine. - * provides many ways to [import](../operation/import) and [export](../operation/export) data. + - Provides [monitoring](../operation/monitor) on running instances of TDengine. + - Provides many ways to [import](../operation/import) and [export](../operation/export) data. 9. Tools - * provides an interactive [command-line interface](../reference/taos-shell) for management, maintenance and ad-hoc queries. - * provides a tool [taosBenchmark](../reference/taosbenchmark/) for testing the performance of TDengine. + - Provides an interactive [Command-line Interface (CLI)](../reference/taos-shell) for management, maintenance and ad-hoc queries. + - Provides a tool [taosBenchmark](../reference/taosbenchmark/) for testing the performance of TDengine. 10. Programming - * provides [connectors](../reference/connector/) for [C/C++](../reference/connector/cpp), [Java](../reference/connector/java), [Python](../reference/connector/python), [Go](../reference/connector/go), [Rust](../reference/connector/rust), [Node.js](../reference/connector/node) and other programming languages. - * provides a [REST API](../reference/rest-api/). + - Provides [connectors](../reference/connector/) for [C/C++](../reference/connector/cpp), [Java](../reference/connector/java), [Python](../reference/connector/python), [Go](../reference/connector/go), [Rust](../reference/connector/rust), [Node.js](../reference/connector/node) and other programming languages. + - Provides a [REST API](../reference/rest-api/). -For more details on features, please read through the entire documentation. +For more details on features, please read through the entire documentation. ## Competitive Advantages @@ -49,23 +49,31 @@ By making full use of [characteristics of time series data](https://tdengine.com - **[Simplified Solution](https://tdengine.com/tdengine/simplified-time-series-data-solution/)**: Through built-in caching, stream processing and data subscription features, TDengine provides a simplified solution for time-series data processing. It reduces system design complexity and operation costs significantly. -- **[Cloud Native](https://tdengine.com/tdengine/cloud-native-time-series-database/)**: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for kubernetes deployment and full observability, TDengine is a cloud native Time-Series Database and can be deployed on public, private or hybrid clouds. +- **[Cloud Native](https://tdengine.com/tdengine/cloud-native-time-series-database/)**: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for Kubernetes deployment and full observability, TDengine is a cloud native Time-series Database and can be deployed on public, private or hybrid clouds. - **[Ease of Use](https://tdengine.com/tdengine/easy-time-series-data-platform/)**: For administrators, TDengine significantly reduces the effort to[ -](https://tdengine.com/tdengine/easy-time-series-data-platform/) deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access. + ](https://tdengine.com/tdengine/easy-time-series-data-platform/) deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access. -- **[Easy Data Analytics](https://tdengine.com/tdengine/time-series-data-analytics-made-easy/)**: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way. +- **[Easy Data Analytics](https://tdengine.com/tdengine/time-series-data-analytics-made-easy/)**: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way. - **[Open Source](https://tdengine.com/tdengine/open-source-time-series-database/)**: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered over 19k stars on GitHub. There is an active developer community, and over 140k running instances worldwide. -With TDengine, the total cost of ownership of your time-series data platform can be greatly reduced. 1: With its superior performance, the computing and storage resources are reduced significantly;2: With SQL support, it can be seamlessly integrated with many third party tools, and learning costs/migration costs are reduced significantly;3: With its simplified solution and nearly zero management, the operation and maintenance costs are reduced significantly. +With TDengine, the total cost of ownership of your time-series data platform can be greatly reduced. + +1. With its superior performance, the computing and storage resources are reduced significantly. +2. With SQL support, it can be seamlessly integrated with many third party tools, and learning costs/migration costs are reduced significantly. +3. With its simplified solution and nearly zero management, the operation and maintenance costs are reduced significantly. ## Technical Ecosystem + This is how TDengine would be situated, in a typical time-series data processing platform: +
+ ![TDengine Database Technical Ecosystem ](eco_system.webp) -
Figure 1. TDengine Technical Ecosystem
+
Figure 1. TDengine Technical Ecosystem
+
On the left-hand side, there are data collection agents like OPC-UA, MQTT, Telegraf and Kafka. On the right-hand side, visualization/BI tools, HMI, Python/R, and IoT Apps can be connected. TDengine itself provides an interactive command-line interface and a web interface for management and maintenance. @@ -75,42 +83,42 @@ As a high-performance, scalable and SQL supported time-series database, TDengine ### Characteristics and Requirements of Data Sources -| **Data Source Characteristics and Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | -| -------------------------------------------------------- | ------------------ | ----------------------- | ------------------- | :----------------------------------------------------------- | -| A massive amount of total data | | | √ | TDengine provides excellent scale-out functions in terms of capacity, and has a storage structure with matching high compression ratio to achieve the best storage efficiency in the industry.| -| Data input velocity is extremely high | | | √ | TDengine's performance is much higher than that of other similar products. It can continuously process larger amounts of input data in the same hardware environment, and provides a performance evaluation tool that can easily run in the user environment. | -| A huge number of data sources | | | √ | TDengine is optimized specifically for a huge number of data sources. It is especially suitable for efficiently ingesting, writing and querying data from billions of data sources. | +| **Data Source Characteristics and Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------ | ------------------ | ----------------------- | ------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| A massive amount of total data | | | √ | TDengine provides excellent scale-out functions in terms of capacity, and has a storage structure with matching high compression ratio to achieve the best storage efficiency in the industry. | +| Data input velocity is extremely high | | | √ | TDengine's performance is much higher than that of other similar products. It can continuously process larger amounts of input data in the same hardware environment, and provides a performance evaluation tool that can easily run in the user environment. | +| A huge number of data sources | | | √ | TDengine is optimized specifically for a huge number of data sources. It is especially suitable for efficiently ingesting, writing and querying data from billions of data sources. | ### System Architecture Requirements -| **System Architecture Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | -| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | +| **System Architecture Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ----------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | A simple and reliable system architecture | | | √ | TDengine's system architecture is very simple and reliable, with its own message queue, cache, stream computing, monitoring and other functions. There is no need to integrate any additional third-party products. | -| Fault-tolerance and high-reliability | | | √ | TDengine has cluster functions to automatically provide high-reliability and high-availability functions such as fault tolerance and disaster recovery. | -| Standardization support | | | √ | TDengine supports standard SQL and provides SQL extensions for time-series data analysis. | +| Fault-tolerance and high-reliability | | | √ | TDengine has cluster functions to automatically provide high-reliability and high-availability functions such as fault tolerance and disaster recovery. | +| Standardization support | | | √ | TDengine supports standard SQL and provides SQL extensions for time-series data analysis. | ### System Function Requirements -| **System Function Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | -| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | -| Complete data processing algorithms built-in | | √ | | While TDengine implements various general data processing algorithms, industry specific algorithms and special types of processing will need to be implemented at the application level.| -| A large number of crosstab queries | | √ | | This type of processing is better handled by general purpose relational database systems but TDengine can work in concert with relational database systems to provide more complete solutions. | +| **System Function Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| -------------------------------------------- | ------------------ | ----------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Complete data processing algorithms built-in | | √ | | While TDengine implements various general data processing algorithms, industry specific algorithms and special types of processing will need to be implemented at the application level. | +| A large number of crosstab queries | | √ | | This type of processing is better handled by general purpose relational database systems but TDengine can work in concert with relational database systems to provide more complete solutions. | ### System Performance Requirements -| **System Performance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | -| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | -| Very large total processing capacity | | | √ | TDengine’s cluster functions can easily improve processing capacity via multi-server coordination. | -| Extremely high-speed data processing | | | √ | TDengine’s storage and data processing are optimized for IoT, and can process data many times faster than similar products.| -| Extremely fast processing of high resolution data | | | √ | TDengine has achieved the same or better performance than other relational and NoSQL data processing systems. | +| **System Performance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| Very large total processing capacity | | | √ | TDengine’s cluster functions can easily improve processing capacity via multi-server coordination. | +| Extremely high-speed data processing | | | √ | TDengine’s storage and data processing are optimized for IoT, and can process data many times faster than similar products. | +| Extremely fast processing of high resolution data | | | √ | TDengine has achieved the same or better performance than other relational and NoSQL data processing systems. | ### System Maintenance Requirements -| **System Maintenance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | -| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ | -| Native high-reliability | | | √ | TDengine has a very robust, reliable and easily configurable system architecture to simplify routine operation. Human errors and accidents are eliminated to the greatest extent, with a streamlined experience for operators. | -| Minimize learning and maintenance costs | | | √ | In addition to being easily configurable, standard SQL support and the TDengine CLI for ad hoc queries makes maintenance simpler, allows reuse and reduces learning costs.| -| Abundant talent supply | √ | | | Given the above, and given the extensive training and professional services provided by TDengine, it is easy to migrate from existing solutions or create a new and lasting solution based on TDengine.| +| **System Maintenance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** | +| --------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Native high-reliability | | | √ | TDengine has a very robust, reliable and easily configurable system architecture to simplify routine operation. Human errors and accidents are eliminated to the greatest extent, with a streamlined experience for operators. | +| Minimize learning and maintenance costs | | | √ | In addition to being easily configurable, standard SQL support and the TDengine CLI for ad hoc queries makes maintenance simpler, allows reuse and reduces learning costs. | +| Abundant talent supply | √ | | | Given the above, and given the extensive training and professional services provided by TDengine, it is easy to migrate from existing solutions or create a new and lasting solution based on TDengine. | ## Comparison with other databases diff --git a/docs/en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md index 901fe69d24640e1cfab5ed4cbc3875ac240e493b..61eb8f04eb3fb8cea5096b321105fa9e88722bda 100644 --- a/docs/en/07-develop/01-connect/index.md +++ b/docs/en/07-develop/01-connect/index.md @@ -1,6 +1,7 @@ --- -title: Connect -description: "This document explains how to establish connections to TDengine and how to install and use TDengine connectors." +sidebar_label: Connect +title: Connect to TDengine +description: "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/03-insert-data/05-high-volume.md b/docs/en/07-develop/03-insert-data/05-high-volume.md index 8163ae03b2ab8ea515ae339e2881047a095aed23..9ea0c884473e670d0624cb3be737830f46bedc38 100644 --- a/docs/en/07-develop/03-insert-data/05-high-volume.md +++ b/docs/en/07-develop/03-insert-data/05-high-volume.md @@ -16,7 +16,7 @@ To achieve high performance writing, there are a few aspects to consider. In the From the perspective of application program, you need to consider: -1. The data size of each single write, also known as batch size. Generally speaking, higher batch size generates better writing performance. However, once the batch size is over a specific value, you will not get any additional benefit anymore. When using SQL to write into TDengine, it's better to put as much as possible data in single SQL. The maximum SQL length supported by TDengine is 1,048,576 bytes, i.e. 1 MB. It can be configured by parameter `maxSQLLength` on client side, and the default value is 65,480. +1. The data size of each single write, also known as batch size. Generally speaking, higher batch size generates better writing performance. However, once the batch size is over a specific value, you will not get any additional benefit anymore. When using SQL to write into TDengine, it's better to put as much as possible data in single SQL. The maximum SQL length supported by TDengine is 1,048,576 bytes, i.e. 1 MB. 2. The number of concurrent connections. Normally more connections can get better result. However, once the number of connections exceeds the processing ability of the server side, the performance may downgrade. @@ -46,12 +46,9 @@ If the data source is Kafka, then the appication program is a consumer of Kafka, ### Tune TDengine -TDengine is a distributed and high performance time series database, there are also some ways to tune TDengine to get better writing performance. +On the server side, database configuration parameter `vgroups` needs to be set carefully to maximize the system performance. If it's set too low, the system capability can't be utilized fully; if it's set too big, unnecessary resource competition may be produced. A normal recommendation for `vgroups` parameter is 2 times of the number of CPU cores. However, depending on the actual system resources, it may still need to tuned. -1. Set proper number of `vgroups` according to available CPU cores. Normally, we recommend 2 \* number_of_cores as a starting point. If the verification result shows this is not enough to utilize CPU resources, you can use a higher value. -2. Set proper `minTablesPerVnode`, `tableIncStepPerVnode`, and `maxVgroupsPerDb` according to the number of tables so that tables are distributed even across vgroups. The purpose is to balance the workload among all vnodes so that system resources can be utilized better to get higher performance. - -For more performance tuning parameters, please refer to [Configuration Parameters](../../../reference/config). +For more configuration parameters, please refer to [Database Configuration](../../../taos-sql/database) and [Server Configuration](../../../reference/config)。 ## Sample Programs @@ -359,7 +356,7 @@ Writing process tries to read as much as possible data from message queue and wr
-SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug. This class also checks the SQL length, if the SQL length is closed to `maxSQLLength` the SQL will be executed immediately. To improve writing efficiency, it's better to increase `maxSQLLength` properly. +SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug. This class also checks the SQL length, and passes the maximum SQL length by parameter maxSQLLength according to actual TDengine limit. SQLWriter diff --git a/docs/en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md index d9dadae976bf07bbf6cfb49401d55bb0bf18da49..5a84bbf3709ff2355157409ae11d5f85191a8271 100644 --- a/docs/en/12-taos-sql/02-database.md +++ b/docs/en/12-taos-sql/02-database.md @@ -71,9 +71,9 @@ database_option: { - SINGLE_STABLE: specifies whether the database can contain more than one supertable. - 0: The database can contain multiple supertables. - 1: The database can contain only one supertable. -- WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. Enter a time in seconds. The default value is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. -- WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. -- WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk. +- WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. Enter a time in seconds. The default value of single copy is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. The default value of multiple copy is 4 days. +- WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. Enter a size in KB. The default value of single copy is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted. The default value of multiple copy is -1. +- WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value of single copy is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk. The default values of multiple copy is 1 day. - WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. After the current WAL file reaches this size, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk. ### Example Statement diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index 1dd0caed38235d3d10813b2cd74fec6446c5ec24..1f861119250e9e32fcac3344a5bdfb760e6191a7 100644 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -52,11 +52,6 @@ window_clause: { | STATE_WINDOW(col) | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] -changes_option: { - DURATION duration_val - | ROWS rows_val -} - group_by_clause: GROUP BY expr [, expr] ... HAVING condition @@ -126,7 +121,6 @@ SELECT DISTINCT col_name [, col_name ...] FROM tb_name; 1. Configuration parameter `maxNumOfDistinctRes` in `taos.cfg` is used to control the number of rows to output. The minimum configurable value is 100,000, the maximum configurable value is 100,000,000, the default value is 1,000,000. If the actual number of rows exceeds the value of this parameter, only the number of rows specified by this parameter will be output. 2. It can't be guaranteed that the results selected by using `DISTINCT` on columns of `FLOAT` or `DOUBLE` are exactly unique because of the precision errors in floating point numbers. -3. `DISTINCT` can't be used in the sub-query of a nested query statement, and can't be used together with aggregate functions, `GROUP BY` or `JOIN` in the same SQL statement. ::: diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index d6905c84a11ecf1f827ad239076ad5d4c93f8e3e..f74d0dbe5c6ae2019b266df4c55a13a49630bf71 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -613,6 +613,7 @@ SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHER **Explanations**: - _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX. - `algo_type` can only be input as `default` or `t-digest` Enter `default` to use a histogram-based algorithm. Enter `t-digest` to use the t-digest algorithm to calculate the approximation of the quantile. `default` is used by default. +- The approximation result of `t-digest` algorithm is sensitive to input data order. For example, when querying STable with different input data order there might be minor differences in calculated results. ### AVG @@ -916,7 +917,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; **Return value type**:Same as the data type of the column being operated upon -**Applicable data types**: Numeric +**Applicable data types**: Numeric, Timestamp **Applicable table types**: standard tables and supertables @@ -931,7 +932,7 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **Return value type**:Same as the data type of the column being operated upon -**Applicable data types**: Numeric +**Applicable data types**: Numeric, Timestamp **Applicable table types**: standard tables and supertables diff --git a/docs/en/12-taos-sql/14-stream.md b/docs/en/12-taos-sql/14-stream.md index fcd78765104af17285b43749969821ceb98da33b..17e4e4d1b0da6d0461c9ab478a9430855379fb12 100644 --- a/docs/en/12-taos-sql/14-stream.md +++ b/docs/en/12-taos-sql/14-stream.md @@ -44,13 +44,13 @@ For example, the following SQL statement creates a stream and automatically crea ```sql CREATE STREAM avg_vol_s INTO avg_vol AS -SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s); +SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s); ``` ## Delete a Stream ```sql -DROP STREAM [IF NOT EXISTS] stream_name +DROP STREAM [IF EXISTS] stream_name ``` This statement deletes the stream processing service only. The data generated by the stream is retained. diff --git a/docs/en/12-taos-sql/22-meta.md b/docs/en/12-taos-sql/22-meta.md index 796b25dcb0a425aa0ffd76a6e9b8de45ba069357..9bda5a0a1027243ea5f50c55e303fdb7155c853b 100644 --- a/docs/en/12-taos-sql/22-meta.md +++ b/docs/en/12-taos-sql/22-meta.md @@ -245,3 +245,35 @@ Provides dnode configuration information. | 1 | dnode_id | INT | Dnode ID | | 2 | name | BINARY(32) | Parameter | | 3 | value | BINARY(64) | Value | + +## INS_TOPICS + +| # | **Column** | **Data Type** | **Description** | +| --- | :---------: | ------------ | ------------------------------ | +| 1 | topic_name | BINARY(192) | Topic name | +| 2 | db_name | BINARY(64) | Database for the topic | +| 3 | create_time | TIMESTAMP | Creation time | +| 4 | sql | BINARY(1024) | SQL statement used to create the topic | + +## INS_SUBSCRIPTIONS + +| # | **Column** | **Data Type** | **Description** | +| --- | :------------: | ------------ | ------------------------ | +| 1 | topic_name | BINARY(204) | Subscribed topic | +| 2 | consumer_group | BINARY(193) | Subscribed consumer group | +| 3 | vgroup_id | INT | Vgroup ID for the consumer | +| 4 | consumer_id | BIGINT | Consumer ID | + +## INS_STREAMS + +| # | **Column** | **Data Type** | **Description** | +| --- | :----------: | ------------ | --------------------------------------- | +| 1 | stream_name | BINARY(64) | Stream name | +| 2 | create_time | TIMESTAMP | Creation time | +| 3 | sql | BINARY(1024) | SQL statement used to create the stream | +| 4 | status | BIANRY(20) | Current status | +| 5 | source_db | BINARY(64) | Source database | +| 6 | target_db | BIANRY(64) | Target database | +| 7 | target_table | BINARY(192) | Target table | +| 8 | watermark | BIGINT | Watermark (see stream processing documentation) | +| 9 | trigger | INT | Method of triggering the result push (see stream processing documentation) | diff --git a/docs/en/12-taos-sql/23-perf.md b/docs/en/12-taos-sql/23-perf.md index 10a93380220d357261914066d2fe036b8470e224..29cf3af6abfbbc06e42ae99c78f35f33a3c7c30a 100644 --- a/docs/en/12-taos-sql/23-perf.md +++ b/docs/en/12-taos-sql/23-perf.md @@ -61,15 +61,6 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE | 12 | sub_status | BINARY(1000) | Subquery status | | 13 | sql | BINARY(1024) | SQL statement | -## PERF_TOPICS - -| # | **Column** | **Data Type** | **Description** | -| --- | :---------: | ------------ | ------------------------------ | -| 1 | topic_name | BINARY(192) | Topic name | -| 2 | db_name | BINARY(64) | Database for the topic | -| 3 | create_time | TIMESTAMP | Creation time | -| 4 | sql | BINARY(1024) | SQL statement used to create the topic | - ## PERF_CONSUMERS | # | **Column** | **Data Type** | **Description** | @@ -83,15 +74,6 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE | 7 | subscribe_time | TIMESTAMP | Time of first subscription | | 8 | rebalance_time | TIMESTAMP | Time of first rebalance triggering | -## PERF_SUBSCRIPTIONS - -| # | **Column** | **Data Type** | **Description** | -| --- | :------------: | ------------ | ------------------------ | -| 1 | topic_name | BINARY(204) | Subscribed topic | -| 2 | consumer_group | BINARY(193) | Subscribed consumer group | -| 3 | vgroup_id | INT | Vgroup ID for the consumer | -| 4 | consumer_id | BIGINT | Consumer ID | - ## PERF_TRANS | # | **Column** | **Data Type** | **Description** | @@ -113,17 +95,3 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE | 2 | create_time | TIMESTAMP | Creation time | | 3 | stable_name | BINARY(192) | Supertable name | | 4 | vgroup_id | INT | Dedicated vgroup name | - -## PERF_STREAMS - -| # | **Column** | **Data Type** | **Description** | -| --- | :----------: | ------------ | --------------------------------------- | -| 1 | stream_name | BINARY(64) | Stream name | -| 2 | create_time | TIMESTAMP | Creation time | -| 3 | sql | BINARY(1024) | SQL statement used to create the stream | -| 4 | status | BIANRY(20) | Current status | -| 5 | source_db | BINARY(64) | Source database | -| 6 | target_db | BIANRY(64) | Target database | -| 7 | target_table | BINARY(192) | Target table | -| 8 | watermark | BIGINT | Watermark (see stream processing documentation) | -| 9 | trigger | INT | Method of triggering the result push (see stream processing documentation) | diff --git a/docs/en/12-taos-sql/24-show.md b/docs/en/12-taos-sql/24-show.md index c9adb0cf782d1da63a8f9654f6c89b02a60a7cb7..5f3bef3546ea05745070268e1f6add25add4773b 100644 --- a/docs/en/12-taos-sql/24-show.md +++ b/docs/en/12-taos-sql/24-show.md @@ -5,16 +5,6 @@ title: SHOW Statement for Metadata `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`. -## SHOW ACCOUNTS - -```sql -SHOW ACCOUNTS; -``` - -Shows information about tenants on the system. - -Note: TDengine Enterprise Edition only. - ## SHOW APPS ```sql diff --git a/docs/en/14-reference/03-connector/05-go.mdx b/docs/en/14-reference/03-connector/05-go.mdx index 00e3bc1bc38bb7433e823642202957abbdf5566c..518d3625d54492c2b6ec209302ac91ca32d03ad2 100644 --- a/docs/en/14-reference/03-connector/05-go.mdx +++ b/docs/en/14-reference/03-connector/05-go.mdx @@ -7,7 +7,7 @@ title: TDengine Go Connector import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Preparition from "./_preparition.mdx" +import Preparition from "./_preparation.mdx" import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx" import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx" import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx" diff --git a/docs/en/14-reference/03-connector/06-rust.mdx b/docs/en/14-reference/03-connector/06-rust.mdx index 1184c98a287cac8a214aff67ace01f7a836940e5..0d391c6ac308c5e9e998e2e7e3423cc5a809905e 100644 --- a/docs/en/14-reference/03-connector/06-rust.mdx +++ b/docs/en/14-reference/03-connector/06-rust.mdx @@ -7,7 +7,7 @@ title: TDengine Rust Connector import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Preparition from "./_preparition.mdx" +import Preparition from "./_preparation.mdx" import RustInsert from "../../07-develop/03-insert-data/_rust_sql.mdx" import RustBind from "../../07-develop/03-insert-data/_rust_stmt.mdx" import RustQuery from "../../07-develop/04-query-data/_rust.mdx" diff --git a/docs/en/14-reference/03-connector/07-python.mdx b/docs/en/14-reference/03-connector/07-python.mdx index fc95033baada48e7f322a06d00cede16fb827c51..d92a93fd4fd79bfa449249a16e87268b924c8475 100644 --- a/docs/en/14-reference/03-connector/07-python.mdx +++ b/docs/en/14-reference/03-connector/07-python.mdx @@ -7,7 +7,7 @@ description: "taospy is the official Python connector for TDengine. taospy provi import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -`taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively. +`taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively. In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/). The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection". diff --git a/docs/en/14-reference/03-connector/08-node.mdx b/docs/en/14-reference/03-connector/08-node.mdx index f93632b4171a0b563a17f80533d3ede4c76e4425..bf7c6b95ea67dc8bf8fa1277591b549a2fd6322d 100644 --- a/docs/en/14-reference/03-connector/08-node.mdx +++ b/docs/en/14-reference/03-connector/08-node.mdx @@ -7,7 +7,7 @@ title: TDengine Node.js Connector import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -import Preparition from "./_preparition.mdx"; +import Preparition from "./_preparation.mdx"; import NodeInsert from "../../07-develop/03-insert-data/_js_sql.mdx"; import NodeInfluxLine from "../../07-develop/03-insert-data/_js_line.mdx"; import NodeOpenTSDBTelnet from "../../07-develop/03-insert-data/_js_opts_telnet.mdx"; diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx index 823e9075993e0a4fd32abafbbd4e95f1cc7bc2cf..bc16cd086bdbef4b594df6e866a019a02ae54fd8 100644 --- a/docs/en/14-reference/03-connector/09-csharp.mdx +++ b/docs/en/14-reference/03-connector/09-csharp.mdx @@ -7,7 +7,7 @@ title: C# Connector import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import Preparition from "./_preparition.mdx" +import Preparition from "./_preparation.mdx" import CSInsert from "../../07-develop/03-insert-data/_cs_sql.mdx" import CSInfluxLine from "../../07-develop/03-insert-data/_cs_line.mdx" import CSOpenTSDBTelnet from "../../07-develop/03-insert-data/_cs_opts_telnet.mdx" diff --git a/docs/en/14-reference/03-connector/_preparition.mdx b/docs/en/14-reference/03-connector/_preparition.mdx deleted file mode 100644 index 87538ebfd8c60507aec90ee86e427d85979dbc4a..0000000000000000000000000000000000000000 --- a/docs/en/14-reference/03-connector/_preparition.mdx +++ /dev/null @@ -1,10 +0,0 @@ -- 已安装客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装) - -:::info - -由于 TDengine 的客户端驱动使用 C 语言编写,使用原生连接时需要加载系统对应安装在本地的客户端驱动共享库文件,通常包含在 TDengine 安装包。TDengine Linux 服务端安装包附带了 TDengine 客户端,也可以单独安装 [Linux 客户端](/get-started/) 。在 Windows 环境开发时需要安装 TDengine 对应的 [Windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) 。 - -- libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 -- taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 - -::: diff --git a/docs/en/14-reference/14-taosKeeper.md b/docs/en/14-reference/14-taosKeeper.md index 476b5a1fd20b4dce4379026a6300ae8e26db6656..665bc75380d4f59666d792d074fb37c65c810264 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: Instructions and tips for using taosKeeper +description: exports TDengine monitoring metrics. --- ## Introduction @@ -22,26 +22,35 @@ You can compile taosKeeper separately and install it. Please refer to the [taosK ### Configuration and running methods - -taosKeeper needs to be executed on the terminal of the operating system. To run taosKeeper, see [configuration file](#configuration-file-parameters-in-detail). +taosKeeper needs to be executed on the terminal of the operating system, it supports three configuration methods: [Command-line arguments](#command-line-arguments-in-detail), [environment variable](#environment-variable-in-detail) and [configuration file](#configuration-file-parameters-in-detail). The precedence of those is Command-line, environment variable and configuration file. **Make sure that the TDengine cluster is running correctly before running taosKeeper. ** Ensure that the monitoring service in TDengine has been started. For more information, see [TDengine Monitoring Configuration](../config/#monitoring). - +### Environment variable + +You can use Environment variable to run taosKeeper and control its behavior: + +```shell +$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3 + +$ taoskeeper +``` + +you can run `taoskeeper -h` for more detail. + ### Configuration File You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used. ```shell -taoskeeper -c +$ taoskeeper -c ``` **Sample configuration files** @@ -110,7 +119,7 @@ Query OK, 1 rows in database (0.036162s) #### Export Monitoring Metrics ```shell -curl http://127.0.0.1:6043/metrics +$ curl http://127.0.0.1:6043/metrics ``` Sample result set (excerpt): diff --git a/docs/en/20-third-party/12-google-data-studio.md b/docs/en/20-third-party/12-google-data-studio.md new file mode 100644 index 0000000000000000000000000000000000000000..fc94f98056bbeeeec88ca7ea12a4a6a7e6f15dc5 --- /dev/null +++ b/docs/en/20-third-party/12-google-data-studio.md @@ -0,0 +1,36 @@ +--- +sidebar_label: Google Data Studio +title: Use Google Data Studio to access TDengine +--- + +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. + +TDengine is a high-performance, scalable time-series database that supports SQL. Many businesses and developers in fields spanning from IoT and Industry Internet to IT and finance are using TDengine as their time-series database management solution. + +The TDengine team immediately saw the benefits of using TDengine to process time-series data with Data Studio to analyze it, and they got to work to create a connector for Data Studio. + +With the release of the TDengine connector in Data Studio, you can now get even more out of your data. To obtain the connector, first go to the Data Studio Connector Gallery, click Connect to Data, and search for “TDengine”. + +![02](gds/gds-02.png.webp) + +Select the TDengine connector and click Authorize. + +![03](gds/gds-03.png.webp) + +Then sign in to your Google Account and click Allow to enable the connection to TDengine. + +![04](gds/gds-04.png.webp) + +In the Enter URL field, type the hostname and port of the server running the TDengine REST service. In the following fields, type your username, password, database name, table name, and the start and end times of your query range. Then, click Connect. + +![05](gds/gds-05.png.webp) + +After the connection is established, you can use Data Studio to process your data and create reports. + +![06](gds/gds-06.png.webp) + +In Data Studio, TDengine timestamps and tags are considered dimensions, and all other items are considered metrics. You can create all kinds of custom charts with your data – some examples are shown below. + +![07](gds/gds-07.png.webp) + +With the ability to process petabytes of data per day and provide monitoring and alerting in real time, TDengine is a great solution for time-series data management. Now, with the Data Studio connector, we’re sure you’ll be able to gain new insights and obtain even more value from your data. diff --git a/docs/en/20-third-party/gds/gds-01.webp b/docs/en/20-third-party/gds/gds-01.webp new file mode 100644 index 0000000000000000000000000000000000000000..2e5f9e4ff5db1e37718e2397c9a13a9f0e05602d Binary files /dev/null and b/docs/en/20-third-party/gds/gds-01.webp differ diff --git a/docs/en/20-third-party/gds/gds-02.png.webp b/docs/en/20-third-party/gds/gds-02.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..3b3537f5a488019482f94452e70bd1bd79867ab5 Binary files /dev/null and b/docs/en/20-third-party/gds/gds-02.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-03.png.webp b/docs/en/20-third-party/gds/gds-03.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..5719436d5b2f21aa861067b966511e4b34d17dce Binary files /dev/null and b/docs/en/20-third-party/gds/gds-03.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-04.png.webp b/docs/en/20-third-party/gds/gds-04.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..ddaae5c1a63b6b4db692e12491df55b88dcaadee Binary files /dev/null and b/docs/en/20-third-party/gds/gds-04.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-05.png.webp b/docs/en/20-third-party/gds/gds-05.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..9a917678fc7e60f0a739fa1e2b0f4fa010d12708 Binary files /dev/null and b/docs/en/20-third-party/gds/gds-05.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-06.png.webp b/docs/en/20-third-party/gds/gds-06.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..c76b68d32b5907bd5ba4e4010456f2ca5303448f Binary files /dev/null and b/docs/en/20-third-party/gds/gds-06.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-07.png.webp b/docs/en/20-third-party/gds/gds-07.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..1386ae9c4db4f2465dd071afc5a047658b47031c Binary files /dev/null and b/docs/en/20-third-party/gds/gds-07.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-08.png.webp b/docs/en/20-third-party/gds/gds-08.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..59dcf8b31df8bde8d4073ee0c7b1c7bdd7bd439d Binary files /dev/null and b/docs/en/20-third-party/gds/gds-08.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-09.png.webp b/docs/en/20-third-party/gds/gds-09.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..b94439f211a814f66d41231c9386c57f3ffe8322 Binary files /dev/null and b/docs/en/20-third-party/gds/gds-09.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-10.png.webp b/docs/en/20-third-party/gds/gds-10.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..a63cad9e9a3d412b1132359506530498fb1a0e57 Binary files /dev/null and b/docs/en/20-third-party/gds/gds-10.png.webp differ diff --git a/docs/en/20-third-party/gds/gds-11.png.webp b/docs/en/20-third-party/gds/gds-11.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..fc38cd9a29c00afa48238741c33b439f737a7b8f Binary files /dev/null and b/docs/en/20-third-party/gds/gds-11.png.webp differ diff --git a/docs/zh/01-index.md b/docs/zh/01-index.md index 79d5424ac2e67e05c346e546847c743595d7a82b..f9127121f35c8cdb9d28e121c20b9b7bb9101625 100644 --- a/docs/zh/01-index.md +++ b/docs/zh/01-index.md @@ -4,22 +4,22 @@ sidebar_label: 文档首页 slug: / --- -TDengine是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库Time Series Database, TSDB), 它专为物联网、工业互联网、金融等场景优化设计。同时它还带有内建的缓存、流式计算、数据订阅等系统功能,能大幅减少系统设计的复杂度,降低研发和运营成本,是一极简的时序数据处理平台。本文档是 TDengine 用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发者与系统管理员的。 +TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库Time Series Database, TSDB), 它专为物联网、车联网、工业互联网、金融、IT 运维等场景优化设计。同时它还带有内建的缓存、流式计算、数据订阅等系统功能,能大幅减少系统设计的复杂度,降低研发和运营成本,是一款极简的时序数据处理平台。本文档是 TDengine 的用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发工程师与系统管理员的。 -TDengine 充分利用了时序数据的特点,提出了“一个数据采集点一张表”与“超级表”的概念,设计了创新的存储引擎,让数据的写入、查询和存储效率都得到极大的提升。为正确理解并使用TDengine, 无论如何,请您仔细阅读[基本概念](./concept)一章。 +TDengine 充分利用了时序数据的特点,提出了“一个数据采集点一张表”与“超级表”的概念,设计了创新的存储引擎,让数据的写入、查询和存储效率都得到极大的提升。为正确理解并使用 TDengine,无论如何,请您仔细阅读[基本概念](./concept)一章。 -如果你是开发者,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要把示例代码拷贝粘贴,针对自己的应用稍作改动,就能跑起来。 +如果你是开发工程师,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要复制粘贴示例代码,针对自己的应用稍作改动,就能跑起来。 -我们已经生活在大数据的时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请参考[部署集群](./deployment)一章。 +我们已经生活在大数据时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 Database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请仔细参考[部署集群](./deployment)一章。 -TDengine 采用 SQL 作为其查询语言,大大降低学习成本、降低迁移成本,但同时针对时序数据场景,又做了一些扩展,以支持插值、降采样、时间加权平均等操作。[SQL 手册](./taos-sql)一章详细描述了 SQL 语法、详细列出了各种支持的命令和函数。 +TDengine 采用 SQL 作为查询语言,大大降低学习成本、降低迁移成本,但同时针对时序数据场景,又做了一些扩展,以支持插值、降采样、时间加权平均等操作。[SQL 手册](./taos-sql)一章详细描述了 SQL 语法、详细列出了各种支持的命令和函数。 -如果你是系统管理员,关心安装、升级、容错灾备、关心数据导入、导出,配置参数,怎么监测 TDengine 是否健康运行,怎么提升系统运行的性能,那么请仔细参考[运维指南](./operation)一章。 +如果你是系统管理员,关心安装、升级、容错灾备、关心数据导入、导出、配置参数,如何监测 TDengine 是否健康运行,如何提升系统运行的性能,请仔细参考[运维指南](./operation)一章。 -如果你对 TDengine 外围工具,REST API, 各种编程语言的连接器想做更多详细了解,请看[参考指南](./reference)一章。 +如果你对 TDengine 的外围工具、REST API、各种编程语言的连接器(Connector)想做更多详细了解,请看[参考指南](./reference)一章。 -如果你对 TDengine 内部的架构设计很有兴趣,欢迎仔细阅读[技术内幕](./tdinternal)一章,里面对集群的设计、数据分区、分片、写入、读出、查询、聚合查询的流程都做了详细的介绍。如果你想研读 TDengine 代码甚至贡献代码,请一定仔细读完这一章。 +如果你对 TDengine 的内部架构设计很有兴趣,欢迎仔细阅读[技术内幕](./tdinternal)一章,里面对集群的设计、数据分区、分片、写入、读出、查询、聚合查询的流程都做了详细的介绍。如果你想研读 TDengine 代码甚至贡献代码,请一定仔细读完这一章。 -最后,作为一个开源软件,欢迎大家的参与。如果发现文档的任何错误,描述不清晰的地方,都请在每个页面的最下方,点击“编辑本文档“直接进行修改。 +最后,作为一个开源软件,欢迎大家的参与。如果发现文档有任何错误、描述不清晰的地方,请在每个页面的最下方,点击“编辑本文档”直接进行修改。 Together, we make a difference! diff --git a/docs/zh/02-intro.md b/docs/zh/02-intro.md index 152d03d9e3edeafc830c81e73963eb0c5831810f..9a0a6fb547ceef373bf7f57e333fda93d40eb5b6 100644 --- a/docs/zh/02-intro.md +++ b/docs/zh/02-intro.md @@ -4,53 +4,53 @@ description: 简要介绍 TDengine 的主要功能 toc_max_heading_level: 2 --- -TDengine 是一款开源、高性能、云原生的[时序数据库](https://tdengine.com/tsdb/),且针对物联网、车联网以及工业互联网进行了优化。TDengine 的代码,包括其集群功能,都在 GNU AGPL v3.0 下开源。除核心的时序数据库功能外,TDengine 还提供[缓存](../develop/cache/)、[数据订阅](../develop/tmq)、[流式计算](../develop/stream)等其它功能以降低系统复杂度及研发和运维成本。 +TDengine 是一款开源、高性能、云原生的[时序数据库](https://tdengine.com/tsdb/),且针对物联网、车联网、工业互联网、金融、IT 运维等场景进行了优化。TDengine 的代码,包括集群功能,都在 GNU AGPL v3.0 下开源。除核心的时序数据库功能外,TDengine 还提供[缓存](../develop/cache/)、[数据订阅](../develop/tmq)、[流式计算](../develop/stream)等其它功能以降低系统复杂度及研发和运维成本。 -本章节介绍TDengine的主要功能、竞争优势、适用场景、与其他数据库的对比测试等等,让大家对TDengine有个整体的了解。 +本章节介绍 TDengine 的主要功能、竞争优势、适用场景、与其他数据库的对比测试等等,让大家对 TDengine 有个整体的了解。 ## 主要功能 -TDengine的主要功能如下: +TDengine 的主要功能如下: 1. 写入数据,支持 - - [SQL 写入](../develop/insert-data/sql-writing) - - [Schemaless 写入](../reference/schemaless/),支持多种标准写入协议 - - [InfluxDB LINE 协议](../develop/insert-data/influxdb-line) - - [OpenTSDB Telnet 协议](../develop/insert-data/opentsdb-telnet) - - [OpenTSDB JSON 协议](../develop/insert-data/opentsdb-json) - - 与多种第三方工具的无缝集成,它们都可以仅通过配置而无需任何代码即可将数据写入 TDengine - - [Telegraf](../third-party/telegraf) - - [Prometheus](../third-party/prometheus) - - [StatsD](../third-party/statsd) - - [collectd](../third-party/collectd) - - [icinga2](../third-party/icinga2) - - [TCollector](../third-party/tcollector) - - [EMQ](../third-party/emq-broker) - - [HiveMQ](../third-party/hive-mq-broker) ; + - [SQL 写入](../develop/insert-data/sql-writing) + - [无模式(Schemaless)写入](../reference/schemaless/),支持多种标准写入协议 + - [InfluxDB Line 协议](../develop/insert-data/influxdb-line) + - [OpenTSDB Telnet 协议](../develop/insert-data/opentsdb-telnet) + - [OpenTSDB JSON 协议](../develop/insert-data/opentsdb-json) + - 与多种第三方工具的无缝集成,它们都可以仅通过配置而无需任何代码即可将数据写入 TDengine + - [Telegraf](../third-party/telegraf) + - [Prometheus](../third-party/prometheus) + - [StatsD](../third-party/statsd) + - [collectd](../third-party/collectd) + - [Icinga2](../third-party/icinga2) + - [TCollector](../third-party/tcollector) + - [EMQX](../third-party/emq-broker) + - [HiveMQ](../third-party/hive-mq-broker) 2. 查询数据,支持 - - [标准SQL](../taos-sql),含嵌套查询 - - [时序数据特色函数](../taos-sql/function/#time-series-extensions) - - [时序顺序特色查询](../taos-sql/distinguished),例如降采样、插值、累加和、时间加权平均、状态窗口、会话窗口等 - - [用户自定义函数](../taos-sql/udf) + - [标准 SQL](../taos-sql),含嵌套查询 + - [时序数据特色函数](../taos-sql/function/#time-series-extensions) + - [时序数据特色查询](../taos-sql/distinguished),例如降采样、插值、累加和、时间加权平均、状态窗口、会话窗口等 + - [用户自定义函数(UDF)](../taos-sql/udf) 3. [缓存](../develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis 就能对时序数据进行高效处理 -4. [流式计算](../develop/stream)(Stream Processing),TDengine 不仅支持连续查询,还支持事件驱动的流式计算,这样在处理时序数据时就无需 Flink 或 Spark 这样流计算组件 -5. [数据订阅](../develop/tmq),应用程序可以订阅一张表或一组表的数据,API 与 Kafka 相同,而且可以指定过滤条件 +4. [流式计算(Stream Processing)](../develop/stream),TDengine 不仅支持连续查询,还支持事件驱动的流式计算,这样在处理时序数据时就无需 Flink 或 Spark 这样流式计算组件 +5. [数据订阅](../develop/tmq),应用程序可以订阅一张表或一组表的数据,提供与 Kafka 相同的 API,而且可以指定过滤条件 6. 可视化 - - 支持与 [Grafana](../third-party/grafana/) 的无缝集成 - - 支持与 Google Data Studio 的无缝集成 + - 支持与 [Grafana](../third-party/grafana/) 的无缝集成 + - 支持与 Google Data Studio 的无缝集成 7. 集群 - - 集群部署(../deployment/),可以通过增加节点进行水平扩展以提升处理能力 - - 可以通过 [Kubernets 部署 TDengine](../deployment/k8s/) - - 通过多副本提供高可用能力 + - [集群部署](../deployment/),可以通过增加节点进行水平扩展以提升处理能力 + - 可以通过 [Kubernetes 部署 TDengine](../deployment/k8s/) + - 通过多副本提供高可用能力 8. 管理 - - [监控](../operation/monitor)运行中的 TDengine 实例 - - 多种[数据导入](../operation/import)方式 - - 多种[数据导出](../operation/export)方式 + - [监控](../operation/monitor)运行中的 TDengine 实例 + - 多种[数据导入](../operation/import)方式 + - 多种[数据导出](../operation/export)方式 9. 工具 - - 提供交互式[命令行程序](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询 - - 提供压力测试工具[taosBenchmark](../reference/taosbenchmark),用于测试 TDengine 的性能 + - 提供[交互式命令行程序(CLI)](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询 + - 提供压力测试工具[taosBenchmark](../reference/taosbenchmark),用于测试 TDengine 的性能 10. 编程 - - 提供各种语言的[连接器](../connector): 如 [C/C++](../connector/cpp), [Java](../connector/java), [Go](../connector/go), [Node.JS](../connector/node), [Rust](../connector/rust), [Python](../connector/python), [C#](../connector/csharp) 等 + - 提供各种语言的[连接器(Connector)](../connector): 如 [C/C++](../connector/cpp)、[Java](../connector/java)、[Go](../connector/go)、[Node.js](../connector/node)、[Rust](../connector/rust)、[Python](../connector/python)、[C#](../connector/csharp) 等 - 支持 [REST 接口](../connector/rest-api/) 更多细节功能,请阅读整个文档。 @@ -63,36 +63,36 @@ TDengine的主要功能如下: - **[极简时序数据平台](https://www.taosdata.com/tdengine/simplified_solution_for_time-series_data_processing)**:TDengine 内建缓存、流式计算和数据订阅等功能,为时序数据的处理提供了极简的解决方案,从而大幅降低了业务系统的设计复杂度和运维成本。 -- **[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)**:通过原生的分布式设计、数据分片和分区、存算分离、RAFT 协议、Kubernets 部署和完整的可观测性,TDengine 是一款云原生时序数据库并且能够部署在公有云、私有云和混合云上。 +- **[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)**:通过原生的分布式设计、数据分片和分区、存算分离、RAFT 协议、Kubernetes 部署和完整的可观测性,TDengine 是一款云原生时序数据库并且能够部署在公有云、私有云和混合云上。 -- **[简单易用](https://www.taosdata.com/tdengine/ease_of_use)**:对系统管理员来说,TDengine 大幅降低了管理和维护的代价。对开发者来说, TDengine 提供了简单的接口、极简的解决方案和与第三方工具的无缝集成。对数据分析专家来说,TDengine 提供了便捷的数据访问。 +- **[简单易用](https://www.taosdata.com/tdengine/ease_of_use)**:对系统管理员来说,TDengine 大幅降低了管理和维护的代价。对开发者来说, TDengine 提供了简单的接口、极简的解决方案和与第三方工具的无缝集成。对数据分析专家来说,TDengine 提供了便捷的数据访问能力。 - **[分析能力](https://www.taosdata.com/tdengine/easy_data_analytics)**:通过超级表、存储计算分离、分区分片、预计算和其它技术,TDengine 能够高效地浏览、格式化和访问数据。 -- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部在开源协议下公开。全球超过 140k 个运行实例,GitHub Star 19k,且拥有一个活跃的开发者社区。 +- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部在开源协议下公开。全球超过 140k 个运行实例,GitHub Star 19k,且拥有一个活跃的开发者社区。 采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面: -1. 由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低 +1. 由于其超强性能,它能将系统所需的计算资源和存储资源大幅降低 2. 因为支持 SQL,能与众多第三方软件无缝集成,学习迁移成本大幅下降 -3. 因为是一极简的时序数据平台,系统复杂度、研发和运营成本大幅降低 +3. 因为是一款极简的时序数据平台,系统复杂度、研发和运营成本大幅降低 ## 技术生态 -在整个时序大数据平台中,TDengine 在其中扮演的角色如下: +在整个时序大数据平台中,TDengine 扮演的角色如下:
![TDengine Database 技术生态图](eco_system.webp) +
图 1. TDengine 技术生态图
-
图 1. TDengine技术生态图
-上图中,左侧是各种数据采集或消息队列,包括 OPC-UA、MQTT、Telegraf、也包括 Kafka, 他们的数据将被源源不断的写入到 TDengine。右侧则是可视化、BI 工具、组态软件、应用程序。下侧则是 TDengine 自身提供的命令行程序 (CLI) 以及可视化管理管理。 +上图中,左侧是各种数据采集或消息队列,包括 OPC-UA、MQTT、Telegraf、也包括 Kafka,他们的数据将被源源不断的写入到 TDengine。右侧则是可视化、BI 工具、组态软件、应用程序。下侧则是 TDengine 自身提供的命令行程序(CLI)以及可视化管理工具。 ## 典型适用场景 -作为一个高性能、分布式、支持 SQL 的时序数据库 (Database),TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT 运维、能源、金融证券等领域。需要指出的是,TDengine 是针对时序数据场景设计的专用数据库和专用大数据处理工具,因充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。本文对适用场景做更多详细的分析。 +作为一个高性能、分布式、支持 SQL 的时序数据库(Database),TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT 运维、能源、金融证券等领域。需要指出的是,TDengine 是针对时序数据场景设计的专用数据库和专用大数据处理工具,因其充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。下面本文将对适用场景做更多详细的分析。 ### 数据源特点和需求 @@ -114,18 +114,18 @@ TDengine的主要功能如下: ### 系统功能需求 -| 系统功能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| -------------------------- | ------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------- | -| 要求完整的内置数据处理算法 | | √ | | TDengine 的实现了通用的数据处理算法,但是还没有做到妥善处理各行各业的所有要求,因此特殊类型的处理还需要应用层面处理。 | -| 需要大量的交叉查询处理 | | √ | | 这种类型的处理更多应该用关系型数据系统处理,或者应该考虑 TDengine 和关系型数据系统配合实现系统功能。 | +| 系统功能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | +| -------------------------- | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------- | +| 要求完整的内置数据处理算法 | | √ | | TDengine 实现了通用的数据处理算法,但是还没有做到妥善处理各行各业的所有需求,因此特殊类型的处理需求还需要在应用层面解决。 | +| 需要大量的交叉查询处理 | | √ | | 这种类型的处理更多应该用关系型数据库处理,或者应该考虑 TDengine 和关系型数据库配合实现系统功能。 | ### 系统性能需求 -| 系统性能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | -| ---------------------- | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------ | -| 要求较大的总体处理能力 | | | √ | TDengine 的集群功能可以轻松地让多服务器配合达成处理能力的提升。 | -| 要求高速处理数据 | | | √ | TDengine 的专门为 IoT 优化的存储和数据处理的设计,一般可以让系统得到超出同类产品多倍数的处理速度提升。 | -| 要求快速处理小粒度数据 | | | √ | 这方面 TDengine 性能可以完全对标关系型和 NoSQL 型数据处理系统。 | +| 系统性能需求 | 不适用 | 可能适用 | 非常适用 | 简单说明 | +| ---------------------- | ------ | -------- | -------- | -------------------------------------------------------------------------------------------------- | +| 要求较大的总体处理能力 | | | √ | TDengine 的集群功能可以轻松地让多服务器配合达成处理能力的提升。 | +| 要求高速处理数据 | | | √ | TDengine 专门为 IoT 优化的存储和数据处理设计,一般可以让系统得到超出同类产品多倍数的处理速度提升。 | +| 要求快速处理小粒度数据 | | | √ | 这方面 TDengine 性能可以完全对标关系型和 NoSQL 型数据处理系统。 | ### 系统维护需求 diff --git a/docs/zh/07-develop/03-insert-data/05-high-volume.md b/docs/zh/07-develop/03-insert-data/05-high-volume.md index 32be8cb8903493f6b5290928a36507ae225a37df..d7581467ae0315442d89de395d35bbd677f75d3a 100644 --- a/docs/zh/07-develop/03-insert-data/05-high-volume.md +++ b/docs/zh/07-develop/03-insert-data/05-high-volume.md @@ -11,7 +11,7 @@ import TabItem from "@theme/TabItem"; 从客户端程序的角度来说,高效写入数据要考虑以下几个因素: -1. 单次写入的数据量。一般来讲,每批次写入的数据量越大越高效(但超过一定阈值其优势会消失)。使用 SQL 写入 TDengine 时,尽量在一条 SQL 中拼接更多数据。目前,TDengine 支持的一条 SQL 的最大长度为 1,048,576(1M)个字符。可通过配置客户端参数 maxSQLLength(默认值为 65480)进行修改。 +1. 单次写入的数据量。一般来讲,每批次写入的数据量越大越高效(但超过一定阈值其优势会消失)。使用 SQL 写入 TDengine 时,尽量在一条 SQL 中拼接更多数据。目前,TDengine 支持的一条 SQL 的最大长度为 1,048,576(1M)个字符。 2. 并发连接数。一般来讲,同时写入数据的并发连接数越多写入越高效(但超过一定阈值反而会下降,取决于服务端处理能力)。 3. 数据在不同表(或子表)之间的分布,即要写入数据的相邻性。一般来说,每批次只向同一张表(或子表)写入数据比向多张表(或子表)写入数据要更高效; 4. 写入方式。一般来讲: @@ -38,13 +38,9 @@ import TabItem from "@theme/TabItem"; ### 服务器配置的角度 {#setting-view} -从服务器配置的角度来说,也有很多优化写入性能的方法。 +从服务端配置的角度,要根据系统中磁盘的数量,磁盘的 I/O 能力,以及处理器能力在创建数据库时设置适当的 vgroups 数量以充分发挥系统性能。如果 vgroups 过少,则系统性能无法发挥;如果 vgroups 过多,会造成无谓的资源竞争。常规推荐 vgroups 数量为 CPU 核数的 2 倍,但仍然要结合具体的系统资源配置进行调优。 -如果总表数不多(远小于核数乘以1000), 且无论怎么调节客户端程序,taosd 进程的 CPU 使用率都很低,那么很可能是因为表在各个 vgroup 分布不均。比如:数据库总表数是 1000 且 minTablesPerVnode 设置的也是 1000,那么所有的表都会分布在 1 个 vgroup 上。此时如果将 minTablesPerVnode 和 tablelncStepPerVnode 都设置成 100, 则可将表分布至 10 个 vgroup。(假设 maxVgroupsPerDb 大于等于 10)。 - -如果总表数比较大(比如大于500万),适当增加 maxVgroupsPerDb 也能显著提高建表的速度。maxVgroupsPerDb 默认值为 0, 自动配置为 CPU 的核数。 如果表的数量巨大,也建议调节 maxTablesPerVnode 参数,以免超过单个 vnode 建表的上限。 - -更多调优参数,请参考 [配置参考](../../../reference/config)部分。 +更多调优参数,请参考 [数据库管理](../../../taos-sql/database) 和 [服务端配置](../../../reference/config)。 ## 高效写入示例 {#sample-code} @@ -352,7 +348,7 @@ main 函数可以接收 5 个启动参数,依次是:
-SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提前创建,而是在发生表不存在错误的时候,再以超级表为模板批量建表,然后重新执行 INSERT 语句。对于其它错误会记录当时执行的 SQL, 以便排查错误和故障恢复。这个类也对 SQL 是否超过最大长度限制做了检查,如果接近 SQL 最大长度限制(maxSQLLength),将会立即执行 SQL。为了减少 SQL 此时,建议将 maxSQLLength 适当调大。 +SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提前创建,而是在发生表不存在错误的时候,再以超级表为模板批量建表,然后重新执行 INSERT 语句。对于其它错误会记录当时执行的 SQL, 以便排查错误和故障恢复。这个类也对 SQL 是否超过最大长度限制做了检查,根据 TDengine 3.0 的限制由输入参数 maxSQLLength 传入了支持的最大 SQL 长度,即 1048576 。 SQLWriter diff --git a/docs/zh/07-develop/_sub_java.mdx b/docs/zh/07-develop/_sub_java.mdx index d14b5fd6095dd90f89dd2c2e828858585cfddff9..e7de158cc8d2b0b686b25bbe96e7a092c2a68e51 100644 --- a/docs/zh/07-develop/_sub_java.mdx +++ b/docs/zh/07-develop/_sub_java.mdx @@ -1,7 +1,5 @@ ```java {{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} -{{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}} -{{#include docs/examples/java/src/main/java/com/taos/example/Meters.java}} ``` ```java {{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}} diff --git a/docs/zh/08-connector/09-csharp.mdx b/docs/zh/08-connector/09-csharp.mdx index be27bfb685d5890813aa65199813f021f7e92066..4e49d84835d66622293e607a58699ae93fc7013d 100644 --- a/docs/zh/08-connector/09-csharp.mdx +++ b/docs/zh/08-connector/09-csharp.mdx @@ -169,9 +169,9 @@ namespace TDengineExample ### 第三方驱动 -`Maikebing.Data.Taos` 是一个 TDengine 的 ADO.NET 连接器,支持 Linux,Windows 平台。该连接器由社区贡献者`麦壳饼@@maikebing` 提供,具体请参考: +[`IoTSharp.Data.Taos`](https://github.com/IoTSharp/EntityFrameworkCore.Taos) 是一个 TDengine 的 ADO.NET 连接器,其中包含了用于EntityFrameworkCore 的提供程序 IoTSharp.EntityFrameworkCore.Taos 和健康检查组件 IoTSharp.HealthChecks.Taos ,支持 Linux,Windows 平台。该连接器由社区贡献者`麦壳饼@@maikebing` 提供,具体请参考: -* 接口下载: +* 接口下载: * 用法说明: ## 常见问题 diff --git a/docs/zh/12-taos-sql/01-data-type.md b/docs/zh/12-taos-sql/01-data-type.md index b8ef050fb79fce5e5d2d65753480a6b156cfbc40..ee7b3a4715a11346b9a06da20dbc93ef309c0a3d 100644 --- a/docs/zh/12-taos-sql/01-data-type.md +++ b/docs/zh/12-taos-sql/01-data-type.md @@ -1,6 +1,6 @@ --- -sidebar_label: 支持的数据类型 -title: 支持的数据类型 +sidebar_label: 数据类型 +title: 数据类型 description: "TDengine 支持的数据类型: 时间戳、浮点型、JSON 类型等" --- diff --git a/docs/zh/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md index 1675356c49c3435d6f9dad3ccc6b868da929f08f..c76311f008433f36259b08acaf56cafa729550b7 100644 --- a/docs/zh/12-taos-sql/02-database.md +++ b/docs/zh/12-taos-sql/02-database.md @@ -1,6 +1,6 @@ --- -sidebar_label: 数据库管理 -title: 数据库管理 +sidebar_label: 数据库 +title: 数据库 description: "创建、删除数据库,查看、修改数据库参数" --- @@ -71,9 +71,9 @@ database_option: { - SINGLE_STABLE:表示此数据库中是否只可以创建一个超级表,用于超级表列非常多的情况。 - 0:表示可以创建多张超级表。 - 1:表示只可以创建一张超级表。 -- WAL_RETENTION_PERIOD:wal 文件的额外保留策略,用于数据订阅。wal 的保存时长,单位为 s。默认为 0,即落盘后立即删除。-1 表示不删除。 -- WAL_RETENTION_SIZE:wal 文件的额外保留策略,用于数据订阅。wal 的保存的最大上限,单位为 KB。默认为 0,即落盘后立即删除。-1 表示不删除。 -- WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当 wal 文件创建并写入后,经过该时间,会自动创建一个新的 wal 文件。默认为 0,即仅在落盘时创建新文件。 +- WAL_RETENTION_PERIOD:wal 文件的额外保留策略,用于数据订阅。wal 的保存时长,单位为 s。单副本默认为 0,即落盘后立即删除。-1 表示不删除。多副本默认为 4 天。 +- WAL_RETENTION_SIZE:wal 文件的额外保留策略,用于数据订阅。wal 的保存的最大上限,单位为 KB。单副本默认为 0,即落盘后立即删除。多副本默认为-1,表示不删除。 +- WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当 wal 文件创建并写入后,经过该时间,会自动创建一个新的 wal 文件。单副本默认为 0,即仅在落盘时创建新文件。多副本默认为 1 天。 - WAL_SEGMENT_SIZE:wal 单个文件大小,单位为 KB。当前写入文件大小超过上限后会自动创建一个新的 wal 文件。默认为 0,即仅在落盘时创建新文件。 ### 创建数据库示例 diff --git a/docs/zh/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md index 9c33c45efcf006344ba5d84a0cbce7bc683f8559..2337f2a272cad45ae762349d2bf355594615cbb5 100644 --- a/docs/zh/12-taos-sql/03-table.md +++ b/docs/zh/12-taos-sql/03-table.md @@ -1,5 +1,5 @@ --- -title: 表管理 +title: 表 sidebar_label: 表 description: 对表的各种管理操作 --- diff --git a/docs/zh/12-taos-sql/04-stable.md b/docs/zh/12-taos-sql/04-stable.md index 450ff07fd8eb636b3ee185e5594d77d645195c56..95ef405fa780e831628e21766e1b3c3b18265059 100644 --- a/docs/zh/12-taos-sql/04-stable.md +++ b/docs/zh/12-taos-sql/04-stable.md @@ -1,6 +1,6 @@ --- -sidebar_label: 超级表管理 -title: 超级表 STable 管理 +sidebar_label: 超级表 +title: 超级表 description: 对超级表的各种管理操作 --- diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index d8ff3f04ed261ade9f8253d57a33e9c56adfefd6..b0a7d88efea4811b193117f220871af64341ff97 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -53,11 +53,6 @@ window_clause: { | STATE_WINDOW(col) | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] -changes_option: { - DURATION duration_val - | ROWS rows_val -} - group_by_clause: GROUP BY expr [, expr] ... HAVING condition @@ -127,7 +122,6 @@ SELECT DISTINCT col_name [, col_name ...] FROM tb_name; 1. cfg 文件中的配置参数 maxNumOfDistinctRes 将对 DISTINCT 能够输出的数据行数进行限制。其最小值是 100000,最大值是 100000000,默认值是 10000000。如果实际计算结果超出了这个限制,那么会仅输出这个数量范围内的部分。 2. 由于浮点数天然的精度机制原因,在特定情况下,对 FLOAT 和 DOUBLE 列使用 DISTINCT 并不能保证输出值的完全唯一性。 -3. 在当前版本下,DISTINCT 不能在嵌套查询的子查询中使用,也不能与聚合函数、GROUP BY、或 JOIN 在同一条语句中混用。 ::: diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 9f999181c40c4f51e1499f9189fe63bacf2222df..9c5b7f771ecaf52da55a693ed5c789197ab57b05 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -614,6 +614,7 @@ SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHER **说明**: - P值范围是[0,100],当为0时等同于MIN,为100时等同于MAX。 - algo_type 取值为 "default" 或 "t-digest"。 输入为 "default" 时函数使用基于直方图算法进行计算。输入为 "t-digest" 时使用t-digest算法计算分位数的近似结果。如果不指定 algo_type 则使用 "default" 算法。 +- "t-digest"算法的近似结果对于输入数据顺序敏感,对超级表查询时不同的输入排序结果可能会有微小的误差。 ### AVG @@ -917,7 +918,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; **返回数据类型**:同应用的字段。 -**适用数据类型**:数值类型。 +**适用数据类型**:数值类型,时间戳类型。 **适用于**:表和超级表。 @@ -932,7 +933,7 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **返回数据类型**:同应用的字段。 -**适用数据类型**:数值类型。 +**适用数据类型**:数值类型,时间戳类型。 **适用于**:表和超级表。 diff --git a/docs/zh/12-taos-sql/12-distinguished.md b/docs/zh/12-taos-sql/12-distinguished.md index 016c1929fe5bd016f8327dc9fae587fe015786b8..268712e757304fe22848318befd16d1a93de5dac 100644 --- a/docs/zh/12-taos-sql/12-distinguished.md +++ b/docs/zh/12-taos-sql/12-distinguished.md @@ -1,6 +1,6 @@ --- -sidebar_label: 时序数据特色查询 -title: 时序数据特色查询 +sidebar_label: 特色查询 +title: 特色查询 description: TDengine 提供的时序数据特有的查询功能 --- diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index 70b062a6ca28549347f78f8eea21c54b1e3bcb81..cd726e0a0ea644f575e16c656eeb4bb2cabf425d 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -44,7 +44,7 @@ window_clause: { ```sql CREATE STREAM avg_vol_s INTO avg_vol AS -SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s); +SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s); ``` ## 流式计算的 partition @@ -58,7 +58,7 @@ SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVA ## 删除流式计算 ```sql -DROP STREAM [IF NOT EXISTS] stream_name; +DROP STREAM [IF EXISTS] stream_name; ``` 仅删除流式计算任务,由流式计算写入的数据不会被删除。 diff --git a/docs/zh/12-taos-sql/17-json.md b/docs/zh/12-taos-sql/17-json.md index 4cbd8eef364b1ea4e4285a34bb419a8ab3c7fc1d..18c25cfe230f81bf0b0e421634c1a768ae8e4628 100644 --- a/docs/zh/12-taos-sql/17-json.md +++ b/docs/zh/12-taos-sql/17-json.md @@ -1,6 +1,6 @@ --- -sidebar_label: JSON 类型使用说明 -title: JSON 类型使用说明 +sidebar_label: JSON 类型 +title: JSON 类型 description: 对 JSON 类型如何使用的详细说明 --- diff --git a/docs/zh/12-taos-sql/18-escape.md b/docs/zh/12-taos-sql/18-escape.md index 7e543743a30aeaa125375b14ad8baf49b634d248..5e0d292d396fdb54bd3df553544353a900415283 100644 --- a/docs/zh/12-taos-sql/18-escape.md +++ b/docs/zh/12-taos-sql/18-escape.md @@ -1,5 +1,5 @@ --- -title: 转义字符说明 +title: 转义字符 sidebar_label: 转义字符 description: TDengine 中使用转义字符的详细规则 --- diff --git a/docs/zh/12-taos-sql/19-limit.md b/docs/zh/12-taos-sql/19-limit.md index 0dbe00f80063bbc62cae38c540e3e7b6627d53d3..a9743adddabe96440ffca8c8585787081d29398f 100644 --- a/docs/zh/12-taos-sql/19-limit.md +++ b/docs/zh/12-taos-sql/19-limit.md @@ -1,6 +1,6 @@ --- -sidebar_label: 命名与边界限制 -title: 命名与边界限制 +sidebar_label: 命名与边界 +title: 命名与边界 description: 合法字符集和命名中的限制规则 --- diff --git a/docs/zh/12-taos-sql/20-keywords.md b/docs/zh/12-taos-sql/20-keywords.md index 047c6b08c9646927fc8ec16a2fd390569e4404fb..92c814067e8823b89ff4bd81198d2b1950d20d51 100644 --- a/docs/zh/12-taos-sql/20-keywords.md +++ b/docs/zh/12-taos-sql/20-keywords.md @@ -1,6 +1,6 @@ --- sidebar_label: 保留关键字 -title: TDengine 保留关键字 +title: 保留关键字 description: TDengine 保留关键字的详细列表 --- diff --git a/docs/zh/12-taos-sql/22-meta.md b/docs/zh/12-taos-sql/22-meta.md index e9cda45b0fa85319234572b236c936d907311796..c1ffc4a757500276f348d08cd577f63072dfece2 100644 --- a/docs/zh/12-taos-sql/22-meta.md +++ b/docs/zh/12-taos-sql/22-meta.md @@ -1,6 +1,6 @@ --- sidebar_label: 元数据 -title: 存储元数据的 Information_Schema 数据库 +title: 元数据 description: Information_Schema 数据库中存储了系统中所有的元数据信息 --- @@ -246,3 +246,35 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们 | 1 | dnode_id | INT | dnode 的 ID | | 2 | name | BINARY(32) | 配置项名称 | | 3 | value | BINARY(64) | 该配置项的值 | + +## INS_TOPICS + +| # | **列名** | **数据类型** | **说明** | +| --- | :---------: | ------------ | ------------------------------ | +| 1 | topic_name | BINARY(192) | topic 名称 | +| 2 | db_name | BINARY(64) | topic 相关的 DB | +| 3 | create_time | TIMESTAMP | topic 的 创建时间 | +| 4 | sql | BINARY(1024) | 创建该 topic 时所用的 SQL 语句 | + +## INS_SUBSCRIPTIONS + +| # | **列名** | **数据类型** | **说明** | +| --- | :------------: | ------------ | ------------------------ | +| 1 | topic_name | BINARY(204) | 被订阅的 topic | +| 2 | consumer_group | BINARY(193) | 订阅者的消费者组 | +| 3 | vgroup_id | INT | 消费者被分配的 vgroup id | +| 4 | consumer_id | BIGINT | 消费者的唯一 id | + +## INS_STREAMS + +| # | **列名** | **数据类型** | **说明** | +| --- | :----------: | ------------ | --------------------------------------- | +| 1 | stream_name | BINARY(64) | 流计算名称 | +| 2 | create_time | TIMESTAMP | 创建时间 | +| 3 | sql | BINARY(1024) | 创建流计算时提供的 SQL 语句 | +| 4 | status | BIANRY(20) | 流当前状态 | +| 5 | source_db | BINARY(64) | 源数据库 | +| 6 | target_db | BIANRY(64) | 目的数据库 | +| 7 | target_table | BINARY(192) | 流计算写入的目标表 | +| 8 | watermark | BIGINT | watermark,详见 SQL 手册流式计算 | +| 9 | trigger | INT | 计算结果推送模式,详见 SQL 手册流式计算 | diff --git a/docs/zh/12-taos-sql/23-perf.md b/docs/zh/12-taos-sql/23-perf.md index e6ff4960a7c0148eb7b65d06dc37a6355a6e289c..d4ee0e178c02e65eb3f1ceaa73e170893f65cc88 100644 --- a/docs/zh/12-taos-sql/23-perf.md +++ b/docs/zh/12-taos-sql/23-perf.md @@ -1,6 +1,6 @@ --- sidebar_label: 统计数据 -title: 存储统计数据的 Performance_Schema 数据库 +title: 统计数据 description: Performance_Schema 数据库中存储了系统中的各种统计信息 --- @@ -62,15 +62,6 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其 | 12 | sub_status | BINARY(1000) | 子查询状态 | | 13 | sql | BINARY(1024) | SQL 语句 | -## PERF_TOPICS - -| # | **列名** | **数据类型** | **说明** | -| --- | :---------: | ------------ | ------------------------------ | -| 1 | topic_name | BINARY(192) | topic 名称 | -| 2 | db_name | BINARY(64) | topic 相关的 DB | -| 3 | create_time | TIMESTAMP | topic 的 创建时间 | -| 4 | sql | BINARY(1024) | 创建该 topic 时所用的 SQL 语句 | - ## PERF_CONSUMERS | # | **列名** | **数据类型** | **说明** | @@ -84,15 +75,6 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其 | 7 | subscribe_time | TIMESTAMP | 上一次发起订阅的时间 | | 8 | rebalance_time | TIMESTAMP | 上一次触发 rebalance 的时间 | -## PERF_SUBSCRIPTIONS - -| # | **列名** | **数据类型** | **说明** | -| --- | :------------: | ------------ | ------------------------ | -| 1 | topic_name | BINARY(204) | 被订阅的 topic | -| 2 | consumer_group | BINARY(193) | 订阅者的消费者组 | -| 3 | vgroup_id | INT | 消费者被分配的 vgroup id | -| 4 | consumer_id | BIGINT | 消费者的唯一 id | - ## PERF_TRANS | # | **列名** | **数据类型** | **说明** | @@ -114,17 +96,3 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其 | 2 | create_time | TIMESTAMP | sma 创建时间 | | 3 | stable_name | BINARY(192) | sma 所属的超级表名称 | | 4 | vgroup_id | INT | sma 专属的 vgroup 名称 | - -## PERF_STREAMS - -| # | **列名** | **数据类型** | **说明** | -| --- | :----------: | ------------ | --------------------------------------- | -| 1 | stream_name | BINARY(64) | 流计算名称 | -| 2 | create_time | TIMESTAMP | 创建时间 | -| 3 | sql | BINARY(1024) | 创建流计算时提供的 SQL 语句 | -| 4 | status | BIANRY(20) | 流当前状态 | -| 5 | source_db | BINARY(64) | 源数据库 | -| 6 | target_db | BIANRY(64) | 目的数据库 | -| 7 | target_table | BINARY(192) | 流计算写入的目标表 | -| 8 | watermark | BIGINT | watermark,详见 SQL 手册流式计算 | -| 9 | trigger | INT | 计算结果推送模式,详见 SQL 手册流式计算 | diff --git a/docs/zh/12-taos-sql/24-show.md b/docs/zh/12-taos-sql/24-show.md index b4aafdaa0af644e05e47106b76e0c7ab074a61b8..31b7c085a1ba97630223c16e06022ec9dfd9ea50 100644 --- a/docs/zh/12-taos-sql/24-show.md +++ b/docs/zh/12-taos-sql/24-show.md @@ -1,21 +1,11 @@ --- sidebar_label: SHOW 命令 -title: 使用 SHOW 命令查看系统元数据 +title: SHOW 命令 description: SHOW 命令的完整列表 --- SHOW 命令可以用来获取简要的系统信息。若想获取系统中详细的各种元数据、系统信息和状态,请使用 select 语句查询 INFORMATION_SCHEMA 数据库中的表。 -## SHOW ACCOUNTS - -```sql -SHOW ACCOUNTS; -``` - -显示当前系统中所有租户的信息。 - -注:企业版独有 - ## SHOW APPS ```sql diff --git a/docs/zh/12-taos-sql/26-udf.md b/docs/zh/12-taos-sql/26-udf.md index 764fde6e1f2e8aa38b90b4b8bc0131c9eaf44da6..6dc1b6eb5fbe346ae65993e4e290566179b0e6ee 100644 --- a/docs/zh/12-taos-sql/26-udf.md +++ b/docs/zh/12-taos-sql/26-udf.md @@ -1,6 +1,6 @@ --- sidebar_label: 自定义函数 -title: 用户自定义函数 +title: 自定义函数 description: 使用 UDF 的详细指南 --- diff --git a/docs/zh/12-taos-sql/27-index.md b/docs/zh/12-taos-sql/27-index.md index f88c6cf4ffe53ae19926e09c760bedd2997a952d..aa84140296832f79a6498d0da2b5a8f500cd1e90 100644 --- a/docs/zh/12-taos-sql/27-index.md +++ b/docs/zh/12-taos-sql/27-index.md @@ -1,6 +1,6 @@ --- sidebar_label: 索引 -title: 使用索引 +title: 索引 description: 索引功能的使用细节 --- diff --git a/docs/zh/12-taos-sql/29-changes.md b/docs/zh/12-taos-sql/29-changes.md index d653c59a5cd1309fbdcd6ef7e3706e33c4a43dee..e63825045d5ddc26d289af4bbd7fa808719bb99c 100644 --- a/docs/zh/12-taos-sql/29-changes.md +++ b/docs/zh/12-taos-sql/29-changes.md @@ -1,6 +1,6 @@ --- -sidebar_label: 3.0 版本语法变更 -title: 3.0 版本语法变更 +sidebar_label: 语法变更 +title: 语法变更 description: "TDengine 3.0 版本的语法变更说明" --- diff --git a/docs/zh/14-reference/05-taosbenchmark.md b/docs/zh/14-reference/05-taosbenchmark.md index f84ec65b4c8574c0812567a65213d7605b306c99..0d6aad62401daf76737caf803461c187189cb76f 100644 --- a/docs/zh/14-reference/05-taosbenchmark.md +++ b/docs/zh/14-reference/05-taosbenchmark.md @@ -405,37 +405,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) 订阅子表或者普通表的配置参数在 `specified_table_query` 中设置。 -- **threads** : 执行 SQL 的线程数,默认为 1。 - -- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。 - -- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 - -- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 - -- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 +- **threads/concurrent** : 执行 SQL 的线程数,默认为 1。 - **sqls** : - **sql** : 执行的 SQL 命令,必填。 - - **result** : 保存查询结果的文件,未指定则不保存。 - -#### 订阅超级表的配置参数 - -订阅超级表的配置参数在 `super_table_query` 中设置。 - -- **stblname** : 要订阅的超级表名称,必填。 - -- **threads** : 执行 SQL 的线程数,默认为 1。 - -- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。 - -- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 - -- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 - -- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 - -- **sqls** : - - **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。 - 替换为超级表中所有的子表名。 - - **result** : 保存查询结果的文件,未指定则不保存。 diff --git a/docs/zh/14-reference/11-docker/index.md b/docs/zh/14-reference/11-docker/index.md index d712e9aba8bf5d79c98abbe65222722497c66dee..58bbe1e1178fbb1a1aa649508b0e36b331964753 100644 --- a/docs/zh/14-reference/11-docker/index.md +++ b/docs/zh/14-reference/11-docker/index.md @@ -119,7 +119,7 @@ taos -h tdengine -P 6030 FROM ubuntu:20.04 RUN apt-get update && apt-get install -y wget ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://www.tdengine.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ @@ -234,7 +234,7 @@ go mod tidy ```dockerfile FROM golang:1.19.0-buster as builder ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://www.tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ @@ -250,7 +250,7 @@ RUN go build FROM ubuntu:20.04 RUN apt-get update && apt-get install -y wget ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://www.tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ diff --git a/docs/zh/14-reference/14-taosKeeper.md b/docs/zh/14-reference/14-taosKeeper.md index f1165c9d0f01b6812c261c6f095f38fca55c44d8..ae0a496f03e8e545525fce49ae2394a10696c09c 100644 --- a/docs/zh/14-reference/14-taosKeeper.md +++ b/docs/zh/14-reference/14-taosKeeper.md @@ -1,7 +1,7 @@ --- sidebar_label: taosKeeper title: taosKeeper -description: TDengine taosKeeper 使用说明 +description: TDengine 3.0 版本监控指标的导出工具 --- ## 简介 @@ -22,26 +22,36 @@ taosKeeper 安装方式: ### 配置和运行方式 - -taosKeeper 需要在操作系统终端执行,该工具支持 [配置文件启动](#配置文件启动)。 +taosKeeper 需要在操作系统终端执行,该工具支持三种配置方式:[命令行参数](#命令行参数启动)、[环境变量](#环境变量启动) 和 [配置文件](#配置文件启动)。优先级为:命令行参数、环境变量、配置文件参数。 **在运行 taosKeeper 之前要确保 TDengine 集群与 taosAdapter 已经在正确运行。** 并且 TDengine 已经开启监控服务,具体请参考:[TDengine 监控配置](../config/#监控相关)。 - + +### 环境变量启动 + +通过设置环境变量达到控制启动参数的目的,通常在容器中运行时使用。 + +```shell +$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3 + +$ taoskeeper +``` + +具体参数列表请参照 `taoskeeper -h` 输入结果。 + ### 配置文件启动 执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 `/etc/taos/keeper.toml` 配置,否则将使用默认配置。 ```shell -taoskeeper -c +$ taoskeeper -c ``` **下面是配置文件的示例:** @@ -110,7 +120,7 @@ Query OK, 1 rows in database (0.036162s) #### 导出监控指标 ```shell -curl http://127.0.0.1:6043/metrics +$ curl http://127.0.0.1:6043/metrics ``` 部分结果集: diff --git a/docs/zh/20-third-party/12-google-data-studio.md b/docs/zh/20-third-party/12-google-data-studio.md new file mode 100644 index 0000000000000000000000000000000000000000..bc06f0ea3261bcd93247e0c7b8e1d6c3628f3121 --- /dev/null +++ b/docs/zh/20-third-party/12-google-data-studio.md @@ -0,0 +1,39 @@ +--- +sidebar_label: Google Data Studio +title: TDengine Google Data Studio Connector +description: 使用 Google Data Studio 存取 TDengine 数据的详细指南 +--- + +Google Data Studio 是一个强大的报表可视化工具,它提供了丰富的数据图表和数据连接,可以非常方便地按照既定模板生成报表。因其简便易用和生态丰富而在数据分析领域得到一众数据科学家的青睐。 + +Data Studio 可以支持多种数据来源,除了诸如 Google Analytics、Google AdWords、Search Console、BigQuery 等 Google 自己的服务之外,用户也可以直接将离线文件上传至 Google Cloud Storage,或是通过连接器来接入其它数据源。 + +![01](gds/gds-01.webp) + +目前 TDengine 连接器已经发布到 Google Data Studio 应用商店,你可以在 “Connect to Data” 页面下直接搜索 TDengine,将其选作数据源。 + +![02](gds/gds-02.png.webp) + +接下来选择 AUTHORIZE 按钮。 + +![03](gds/gds-03.png.webp) + +设置允许连接自己的账号到外部服务。 + +![04](gds/gds-04.png.webp) + +在接下来的页面选择运行 TDengine REST 服务的 URL,并输入用户名、密码、数据库名称、表名称以及查询时间范围,并点击右上角的 CONNECT 按钮。 + +![05](gds/gds-05.png.webp) + +连接成功后,就可以使用 GDS 方便地进行数据处理并创建报表了。 + +![06](gds/gds-06.png.webp) + +目前的维度和指标规则是:timestamp 类型的字段和 tag 字段会被连接器定义为维度,而其他类型的字段是指标。用户还可以根据自己的需求创建不同的表。 + +![07](gds/gds-07.png.webp) +![08](gds/gds-08.png.webp) +![09](gds/gds-09.png.webp) +![10](gds/gds-10.png.webp) +![11](gds/gds-11.png.webp) diff --git a/docs/zh/20-third-party/gds/gds-01.webp b/docs/zh/20-third-party/gds/gds-01.webp new file mode 100644 index 0000000000000000000000000000000000000000..2e5f9e4ff5db1e37718e2397c9a13a9f0e05602d Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-01.webp differ diff --git a/docs/zh/20-third-party/gds/gds-02.png.webp b/docs/zh/20-third-party/gds/gds-02.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..3b3537f5a488019482f94452e70bd1bd79867ab5 Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-02.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-03.png.webp b/docs/zh/20-third-party/gds/gds-03.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..5719436d5b2f21aa861067b966511e4b34d17dce Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-03.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-04.png.webp b/docs/zh/20-third-party/gds/gds-04.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..ddaae5c1a63b6b4db692e12491df55b88dcaadee Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-04.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-05.png.webp b/docs/zh/20-third-party/gds/gds-05.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..9a917678fc7e60f0a739fa1e2b0f4fa010d12708 Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-05.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-06.png.webp b/docs/zh/20-third-party/gds/gds-06.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..c76b68d32b5907bd5ba4e4010456f2ca5303448f Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-06.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-07.png.webp b/docs/zh/20-third-party/gds/gds-07.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..1386ae9c4db4f2465dd071afc5a047658b47031c Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-07.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-08.png.webp b/docs/zh/20-third-party/gds/gds-08.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..59dcf8b31df8bde8d4073ee0c7b1c7bdd7bd439d Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-08.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-09.png.webp b/docs/zh/20-third-party/gds/gds-09.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..b94439f211a814f66d41231c9386c57f3ffe8322 Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-09.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-10.png.webp b/docs/zh/20-third-party/gds/gds-10.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..a63cad9e9a3d412b1132359506530498fb1a0e57 Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-10.png.webp differ diff --git a/docs/zh/20-third-party/gds/gds-11.png.webp b/docs/zh/20-third-party/gds/gds-11.png.webp new file mode 100644 index 0000000000000000000000000000000000000000..fc38cd9a29c00afa48238741c33b439f737a7b8f Binary files /dev/null and b/docs/zh/20-third-party/gds/gds-11.png.webp differ diff --git a/include/client/taos.h b/include/client/taos.h index f260b84f4aaf238badb1de3a6446b639b5681fa9..49cfbb52b80e88103fe6befc6d2818641e731fcf 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -254,6 +254,7 @@ enum tmq_res_t { TMQ_RES_INVALID = -1, TMQ_RES_DATA = 1, TMQ_RES_TABLE_META = 2, + TMQ_RES_TAOSX = 3, }; typedef struct tmq_raw_data { diff --git a/include/common/systable.h b/include/common/systable.h index 01c9807627c9e0ead401ffe873a4e7f7f08b8282..882c54de952dc044ed30aa6a1aed66145c0db804 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -43,17 +43,17 @@ extern "C" { #define TSDB_INS_TABLE_VNODES "ins_vnodes" #define TSDB_INS_TABLE_CONFIGS "ins_configs" #define TSDB_INS_TABLE_DNODE_VARIABLES "ins_dnode_variables" +#define TSDB_INS_TABLE_SUBSCRIPTIONS "ins_subscriptions" +#define TSDB_INS_TABLE_TOPICS "ins_topics" +#define TSDB_INS_TABLE_STREAMS "ins_streams" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" #define TSDB_PERFS_TABLE_CONNECTIONS "perf_connections" #define TSDB_PERFS_TABLE_QUERIES "perf_queries" -#define TSDB_PERFS_TABLE_TOPICS "perf_topics" #define TSDB_PERFS_TABLE_CONSUMERS "perf_consumers" -#define TSDB_PERFS_TABLE_SUBSCRIPTIONS "perf_subscriptions" #define TSDB_PERFS_TABLE_OFFSETS "perf_offsets" #define TSDB_PERFS_TABLE_TRANS "perf_trans" -#define TSDB_PERFS_TABLE_STREAMS "perf_streams" #define TSDB_PERFS_TABLE_APPS "perf_apps" typedef struct SSysDbTableSchema { diff --git a/include/common/taosdef.h b/include/common/taosdef.h index 9bfee56e2974832593578c9c2b1c984373763088..bf4de9d4ded1d0955bef05b1e3000be0bf34d8aa 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -65,13 +65,6 @@ typedef enum { TSDB_STATIS_NONE = 1, // statis part not exist } ETsdbStatisStatus; -typedef enum { - TSDB_SMA_STAT_UNKNOWN = -1, // unknown - TSDB_SMA_STAT_OK = 0, // ready to provide service - TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired - TSDB_SMA_STAT_DROPPED = 2, // sma dropped -} ETsdbSmaStat; // bit operation - typedef enum { TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA TSDB_SMA_TYPE_TIME_RANGE = 1, // Time-range-wise SMA diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 03672f96f3040cbee40b2105812c2d038c751789..37db574d98c731699e68b49c4d68108ddf1a670b 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -73,6 +73,7 @@ enum { TMQ_MSG_TYPE__POLL_RSP, TMQ_MSG_TYPE__POLL_META_RSP, TMQ_MSG_TYPE__EP_RSP, + TMQ_MSG_TYPE__TAOSX_RSP, TMQ_MSG_TYPE__END_RSP, }; @@ -129,7 +130,6 @@ typedef struct SDataBlockInfo { uint32_t capacity; // TODO: optimize and remove following int64_t version; // used for stream, and need serialization - int64_t ts; // used for stream, and need serialization int32_t childId; // used for stream, do not serialize EStreamType type; // used for stream, do not serialize STimeWindow calWin; // used for stream, do not serialize @@ -184,7 +184,6 @@ typedef struct SQueryTableDataCond { STimeWindow twindows; int64_t startVersion; int64_t endVersion; - int64_t schemaVersion; } SQueryTableDataCond; int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock); diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 410fa02ded3c16bd0e1fd2c669b5c8c46a7e1801..73d043b2d0ac680d69b517d042b02dfa71167435 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -184,7 +184,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u int32_t getJsonValueLen(const char* data); int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull); -int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows); +int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, + uint32_t numOfRows); int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource, int32_t numOfRow2); int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows, @@ -225,15 +226,16 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize); int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n); int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n); -int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src); -int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); +int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src); +int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src); SSDataBlock* createDataBlock(); void* blockDataDestroy(SSDataBlock* pBlock); void blockDataFreeRes(SSDataBlock* pBlock); SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData); +SSDataBlock* createSpecialDataBlock(EStreamType type); -int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData); +int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData); SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId); SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index); @@ -249,7 +251,6 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf); int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlocks, STSchema* pTSchema, int32_t vgId, tb_uid_t suid); - char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId); static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) { diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 03e15ed8e705c598c444847c94741d0c6b56fdfe..2de4ffdc17347f2e3afb2793a95e32b4cea966e6 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -89,11 +89,12 @@ extern uint16_t tsTelemPort; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing -extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node +extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node // query client extern int32_t tsQueryPolicy; extern int32_t tsQuerySmaOptimize; +extern bool tsQueryPlannerTrace; // client extern int32_t tsMinSlidingTime; @@ -144,10 +145,10 @@ void taosCfgDynamicOptions(const char *option, const char *value); struct SConfig *taosGetCfg(); -void taosSetAllDebugFlag(int32_t flag); -void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal); +void taosSetAllDebugFlag(int32_t flag, bool rewrite); +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal, bool rewrite); int32_t taosSetCfg(SConfig *pCfg, char *name); -void taosLocalCfgForbiddenToChange(char* name, bool* forbidden); +void taosLocalCfgForbiddenToChange(char *name, bool *forbidden); #ifdef __cplusplus } diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 681094471a7aae3b824c6c28667389c3f08f47d2..d826f312e513eeab49bc1135fd9b9a138a6c21a2 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -276,7 +276,6 @@ struct SSchema { char name[TSDB_COL_NAME_LEN]; }; - typedef struct { char tbName[TSDB_TABLE_NAME_LEN]; char stbName[TSDB_TABLE_NAME_LEN]; @@ -295,17 +294,15 @@ typedef struct { SSchema* pSchemas; } STableMetaRsp; - - typedef struct { - int32_t code; - int8_t hashMeta; - int64_t uid; - char* tblFName; - int32_t numOfRows; - int32_t affectedRows; - int64_t sver; - STableMetaRsp* pMeta; + int32_t code; + int8_t hashMeta; + int64_t uid; + char* tblFName; + int32_t numOfRows; + int32_t affectedRows; + int64_t sver; + STableMetaRsp* pMeta; } SSubmitBlkRsp; typedef struct { @@ -320,7 +317,7 @@ typedef struct { int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp); int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp); -void tFreeSSubmitBlkRsp(void* param); +void tFreeSSubmitBlkRsp(void* param); void tFreeSSubmitRsp(SSubmitRsp* pRsp); #define COL_SMA_ON ((int8_t)0x1) @@ -787,6 +784,9 @@ typedef struct { int64_t walRetentionSize; int32_t walRollPeriod; int64_t walSegmentSize; + int32_t sstTrigger; + int16_t hashPrefix; + int16_t hashSuffix; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); @@ -808,6 +808,7 @@ typedef struct { int8_t strict; int8_t cacheLast; int8_t replications; + int32_t sstTrigger; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); @@ -1069,6 +1070,7 @@ typedef struct { typedef struct { int32_t vgId; int32_t syncState; + int64_t cacheUsage; int64_t numOfTables; int64_t numOfTimeSeries; int64_t totalStorage; @@ -1193,6 +1195,9 @@ typedef struct { int64_t walRetentionSize; int32_t walRollPeriod; int64_t walSegmentSize; + int16_t sstTrigger; + int16_t hashPrefix; + int16_t hashSuffix; } SCreateVnodeReq; int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq); @@ -2049,8 +2054,8 @@ typedef struct { STableMetaRsp* pMeta; } SVCreateTbRsp, SVUpdateTbRsp; -int tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp); -int tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp); +int tEncodeSVCreateTbRsp(SEncoder* pCoder, const SVCreateTbRsp* pRsp); +int tDecodeSVCreateTbRsp(SDecoder* pCoder, SVCreateTbRsp* pRsp); void tFreeSVCreateTbRsp(void* param); int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq); @@ -2072,8 +2077,9 @@ int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatc // TDMT_VND_DROP_TABLE ================= typedef struct { - char* name; - int8_t igNotExists; + char* name; + uint64_t suid; // for tmq in wal format + int8_t igNotExists; } SVDropTbReq; typedef struct { @@ -2629,6 +2635,22 @@ typedef struct { }; } STqOffsetVal; +static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) { + pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA; + pOffsetVal->uid = uid; + pOffsetVal->ts = ts; +} + +static FORCE_INLINE void tqOffsetResetToMeta(STqOffsetVal* pOffsetVal, int64_t uid) { + pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_META; + pOffsetVal->uid = uid; +} + +static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) { + pOffsetVal->type = TMQ_OFFSET__LOG; + pOffsetVal->version = ver; +} + int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); @@ -2960,6 +2982,27 @@ typedef struct { int32_t tEncodeSMqDataRsp(SEncoder* pEncoder, const SMqDataRsp* pRsp); int32_t tDecodeSMqDataRsp(SDecoder* pDecoder, SMqDataRsp* pRsp); +void tDeleteSMqDataRsp(SMqDataRsp* pRsp); + +typedef struct { + SMqRspHead head; + STqOffsetVal reqOffset; + STqOffsetVal rspOffset; + int32_t blockNum; + int8_t withTbName; + int8_t withSchema; + SArray* blockDataLen; + SArray* blockData; + SArray* blockTbName; + SArray* blockSchema; + int32_t createTableNum; + SArray* createTableLen; + SArray* createTableReq; +} STaosxRsp; + +int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const STaosxRsp* pRsp); +int32_t tDecodeSTaosxRsp(SDecoder* pDecoder, STaosxRsp* pRsp); +void tDeleteSTaosxRsp(STaosxRsp* pRsp); typedef struct { SMqRspHead head; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index b38ec664358d08622c06d8f941873b59e43b9455..c7cce6a1837f0afae40c01cae68a1bc4c83ee597 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -102,224 +102,227 @@ #define TK_WAL_RETENTION_SIZE 84 #define TK_WAL_ROLL_PERIOD 85 #define TK_WAL_SEGMENT_SIZE 86 -#define TK_NK_COLON 87 -#define TK_TABLE 88 -#define TK_NK_LP 89 -#define TK_NK_RP 90 -#define TK_STABLE 91 -#define TK_ADD 92 -#define TK_COLUMN 93 -#define TK_MODIFY 94 -#define TK_RENAME 95 -#define TK_TAG 96 -#define TK_SET 97 -#define TK_NK_EQ 98 -#define TK_USING 99 -#define TK_TAGS 100 -#define TK_COMMENT 101 -#define TK_BOOL 102 -#define TK_TINYINT 103 -#define TK_SMALLINT 104 -#define TK_INT 105 -#define TK_INTEGER 106 -#define TK_BIGINT 107 -#define TK_FLOAT 108 -#define TK_DOUBLE 109 -#define TK_BINARY 110 -#define TK_TIMESTAMP 111 -#define TK_NCHAR 112 -#define TK_UNSIGNED 113 -#define TK_JSON 114 -#define TK_VARCHAR 115 -#define TK_MEDIUMBLOB 116 -#define TK_BLOB 117 -#define TK_VARBINARY 118 -#define TK_DECIMAL 119 -#define TK_MAX_DELAY 120 -#define TK_WATERMARK 121 -#define TK_ROLLUP 122 -#define TK_TTL 123 -#define TK_SMA 124 -#define TK_FIRST 125 -#define TK_LAST 126 -#define TK_SHOW 127 -#define TK_DATABASES 128 -#define TK_TABLES 129 -#define TK_STABLES 130 -#define TK_MNODES 131 -#define TK_MODULES 132 -#define TK_QNODES 133 -#define TK_FUNCTIONS 134 -#define TK_INDEXES 135 -#define TK_ACCOUNTS 136 -#define TK_APPS 137 -#define TK_CONNECTIONS 138 -#define TK_LICENCES 139 -#define TK_GRANTS 140 -#define TK_QUERIES 141 -#define TK_SCORES 142 -#define TK_TOPICS 143 -#define TK_VARIABLES 144 -#define TK_BNODES 145 -#define TK_SNODES 146 -#define TK_CLUSTER 147 -#define TK_TRANSACTIONS 148 -#define TK_DISTRIBUTED 149 -#define TK_CONSUMERS 150 -#define TK_SUBSCRIPTIONS 151 -#define TK_LIKE 152 -#define TK_INDEX 153 -#define TK_FUNCTION 154 -#define TK_INTERVAL 155 -#define TK_TOPIC 156 -#define TK_AS 157 -#define TK_WITH 158 -#define TK_META 159 -#define TK_CONSUMER 160 -#define TK_GROUP 161 -#define TK_DESC 162 -#define TK_DESCRIBE 163 -#define TK_RESET 164 -#define TK_QUERY 165 -#define TK_CACHE 166 -#define TK_EXPLAIN 167 -#define TK_ANALYZE 168 -#define TK_VERBOSE 169 -#define TK_NK_BOOL 170 -#define TK_RATIO 171 -#define TK_NK_FLOAT 172 -#define TK_OUTPUTTYPE 173 -#define TK_AGGREGATE 174 -#define TK_BUFSIZE 175 -#define TK_STREAM 176 -#define TK_INTO 177 -#define TK_TRIGGER 178 -#define TK_AT_ONCE 179 -#define TK_WINDOW_CLOSE 180 -#define TK_IGNORE 181 -#define TK_EXPIRED 182 -#define TK_KILL 183 -#define TK_CONNECTION 184 -#define TK_TRANSACTION 185 -#define TK_BALANCE 186 -#define TK_VGROUP 187 -#define TK_MERGE 188 -#define TK_REDISTRIBUTE 189 -#define TK_SPLIT 190 -#define TK_DELETE 191 -#define TK_INSERT 192 -#define TK_NULL 193 -#define TK_NK_QUESTION 194 -#define TK_NK_ARROW 195 -#define TK_ROWTS 196 -#define TK_TBNAME 197 -#define TK_QSTART 198 -#define TK_QEND 199 -#define TK_QDURATION 200 -#define TK_WSTART 201 -#define TK_WEND 202 -#define TK_WDURATION 203 -#define TK_CAST 204 -#define TK_NOW 205 -#define TK_TODAY 206 -#define TK_TIMEZONE 207 -#define TK_CLIENT_VERSION 208 -#define TK_SERVER_VERSION 209 -#define TK_SERVER_STATUS 210 -#define TK_CURRENT_USER 211 -#define TK_COUNT 212 -#define TK_LAST_ROW 213 -#define TK_BETWEEN 214 -#define TK_IS 215 -#define TK_NK_LT 216 -#define TK_NK_GT 217 -#define TK_NK_LE 218 -#define TK_NK_GE 219 -#define TK_NK_NE 220 -#define TK_MATCH 221 -#define TK_NMATCH 222 -#define TK_CONTAINS 223 -#define TK_IN 224 -#define TK_JOIN 225 -#define TK_INNER 226 -#define TK_SELECT 227 -#define TK_DISTINCT 228 -#define TK_WHERE 229 -#define TK_PARTITION 230 -#define TK_BY 231 -#define TK_SESSION 232 -#define TK_STATE_WINDOW 233 -#define TK_SLIDING 234 -#define TK_FILL 235 -#define TK_VALUE 236 -#define TK_NONE 237 -#define TK_PREV 238 -#define TK_LINEAR 239 -#define TK_NEXT 240 -#define TK_HAVING 241 -#define TK_RANGE 242 -#define TK_EVERY 243 -#define TK_ORDER 244 -#define TK_SLIMIT 245 -#define TK_SOFFSET 246 -#define TK_LIMIT 247 -#define TK_OFFSET 248 -#define TK_ASC 249 -#define TK_NULLS 250 -#define TK_ABORT 251 -#define TK_AFTER 252 -#define TK_ATTACH 253 -#define TK_BEFORE 254 -#define TK_BEGIN 255 -#define TK_BITAND 256 -#define TK_BITNOT 257 -#define TK_BITOR 258 -#define TK_BLOCKS 259 -#define TK_CHANGE 260 -#define TK_COMMA 261 -#define TK_COMPACT 262 -#define TK_CONCAT 263 -#define TK_CONFLICT 264 -#define TK_COPY 265 -#define TK_DEFERRED 266 -#define TK_DELIMITERS 267 -#define TK_DETACH 268 -#define TK_DIVIDE 269 -#define TK_DOT 270 -#define TK_EACH 271 -#define TK_END 272 -#define TK_FAIL 273 -#define TK_FILE 274 -#define TK_FOR 275 -#define TK_GLOB 276 -#define TK_ID 277 -#define TK_IMMEDIATE 278 -#define TK_IMPORT 279 -#define TK_INITIALLY 280 -#define TK_INSTEAD 281 -#define TK_ISNULL 282 -#define TK_KEY 283 -#define TK_NK_BITNOT 284 -#define TK_NK_SEMI 285 -#define TK_NOTNULL 286 -#define TK_OF 287 -#define TK_PLUS 288 -#define TK_PRIVILEGE 289 -#define TK_RAISE 290 -#define TK_REPLACE 291 -#define TK_RESTRICT 292 -#define TK_ROW 293 -#define TK_SEMI 294 -#define TK_STAR 295 -#define TK_STATEMENT 296 -#define TK_STRING 297 -#define TK_TIMES 298 -#define TK_UPDATE 299 -#define TK_VALUES 300 -#define TK_VARIABLE 301 -#define TK_VIEW 302 -#define TK_VNODES 303 -#define TK_WAL 304 +#define TK_SST_TRIGGER 87 +#define TK_TABLE_PREFIX 88 +#define TK_TABLE_SUFFIX 89 +#define TK_NK_COLON 90 +#define TK_TABLE 91 +#define TK_NK_LP 92 +#define TK_NK_RP 93 +#define TK_STABLE 94 +#define TK_ADD 95 +#define TK_COLUMN 96 +#define TK_MODIFY 97 +#define TK_RENAME 98 +#define TK_TAG 99 +#define TK_SET 100 +#define TK_NK_EQ 101 +#define TK_USING 102 +#define TK_TAGS 103 +#define TK_COMMENT 104 +#define TK_BOOL 105 +#define TK_TINYINT 106 +#define TK_SMALLINT 107 +#define TK_INT 108 +#define TK_INTEGER 109 +#define TK_BIGINT 110 +#define TK_FLOAT 111 +#define TK_DOUBLE 112 +#define TK_BINARY 113 +#define TK_TIMESTAMP 114 +#define TK_NCHAR 115 +#define TK_UNSIGNED 116 +#define TK_JSON 117 +#define TK_VARCHAR 118 +#define TK_MEDIUMBLOB 119 +#define TK_BLOB 120 +#define TK_VARBINARY 121 +#define TK_DECIMAL 122 +#define TK_MAX_DELAY 123 +#define TK_WATERMARK 124 +#define TK_ROLLUP 125 +#define TK_TTL 126 +#define TK_SMA 127 +#define TK_FIRST 128 +#define TK_LAST 129 +#define TK_SHOW 130 +#define TK_DATABASES 131 +#define TK_TABLES 132 +#define TK_STABLES 133 +#define TK_MNODES 134 +#define TK_MODULES 135 +#define TK_QNODES 136 +#define TK_FUNCTIONS 137 +#define TK_INDEXES 138 +#define TK_ACCOUNTS 139 +#define TK_APPS 140 +#define TK_CONNECTIONS 141 +#define TK_LICENCES 142 +#define TK_GRANTS 143 +#define TK_QUERIES 144 +#define TK_SCORES 145 +#define TK_TOPICS 146 +#define TK_VARIABLES 147 +#define TK_BNODES 148 +#define TK_SNODES 149 +#define TK_CLUSTER 150 +#define TK_TRANSACTIONS 151 +#define TK_DISTRIBUTED 152 +#define TK_CONSUMERS 153 +#define TK_SUBSCRIPTIONS 154 +#define TK_VNODES 155 +#define TK_LIKE 156 +#define TK_INDEX 157 +#define TK_FUNCTION 158 +#define TK_INTERVAL 159 +#define TK_TOPIC 160 +#define TK_AS 161 +#define TK_WITH 162 +#define TK_META 163 +#define TK_CONSUMER 164 +#define TK_GROUP 165 +#define TK_DESC 166 +#define TK_DESCRIBE 167 +#define TK_RESET 168 +#define TK_QUERY 169 +#define TK_CACHE 170 +#define TK_EXPLAIN 171 +#define TK_ANALYZE 172 +#define TK_VERBOSE 173 +#define TK_NK_BOOL 174 +#define TK_RATIO 175 +#define TK_NK_FLOAT 176 +#define TK_OUTPUTTYPE 177 +#define TK_AGGREGATE 178 +#define TK_BUFSIZE 179 +#define TK_STREAM 180 +#define TK_INTO 181 +#define TK_TRIGGER 182 +#define TK_AT_ONCE 183 +#define TK_WINDOW_CLOSE 184 +#define TK_IGNORE 185 +#define TK_EXPIRED 186 +#define TK_KILL 187 +#define TK_CONNECTION 188 +#define TK_TRANSACTION 189 +#define TK_BALANCE 190 +#define TK_VGROUP 191 +#define TK_MERGE 192 +#define TK_REDISTRIBUTE 193 +#define TK_SPLIT 194 +#define TK_DELETE 195 +#define TK_INSERT 196 +#define TK_NULL 197 +#define TK_NK_QUESTION 198 +#define TK_NK_ARROW 199 +#define TK_ROWTS 200 +#define TK_TBNAME 201 +#define TK_QSTART 202 +#define TK_QEND 203 +#define TK_QDURATION 204 +#define TK_WSTART 205 +#define TK_WEND 206 +#define TK_WDURATION 207 +#define TK_CAST 208 +#define TK_NOW 209 +#define TK_TODAY 210 +#define TK_TIMEZONE 211 +#define TK_CLIENT_VERSION 212 +#define TK_SERVER_VERSION 213 +#define TK_SERVER_STATUS 214 +#define TK_CURRENT_USER 215 +#define TK_COUNT 216 +#define TK_LAST_ROW 217 +#define TK_BETWEEN 218 +#define TK_IS 219 +#define TK_NK_LT 220 +#define TK_NK_GT 221 +#define TK_NK_LE 222 +#define TK_NK_GE 223 +#define TK_NK_NE 224 +#define TK_MATCH 225 +#define TK_NMATCH 226 +#define TK_CONTAINS 227 +#define TK_IN 228 +#define TK_JOIN 229 +#define TK_INNER 230 +#define TK_SELECT 231 +#define TK_DISTINCT 232 +#define TK_WHERE 233 +#define TK_PARTITION 234 +#define TK_BY 235 +#define TK_SESSION 236 +#define TK_STATE_WINDOW 237 +#define TK_SLIDING 238 +#define TK_FILL 239 +#define TK_VALUE 240 +#define TK_NONE 241 +#define TK_PREV 242 +#define TK_LINEAR 243 +#define TK_NEXT 244 +#define TK_HAVING 245 +#define TK_RANGE 246 +#define TK_EVERY 247 +#define TK_ORDER 248 +#define TK_SLIMIT 249 +#define TK_SOFFSET 250 +#define TK_LIMIT 251 +#define TK_OFFSET 252 +#define TK_ASC 253 +#define TK_NULLS 254 +#define TK_ABORT 255 +#define TK_AFTER 256 +#define TK_ATTACH 257 +#define TK_BEFORE 258 +#define TK_BEGIN 259 +#define TK_BITAND 260 +#define TK_BITNOT 261 +#define TK_BITOR 262 +#define TK_BLOCKS 263 +#define TK_CHANGE 264 +#define TK_COMMA 265 +#define TK_COMPACT 266 +#define TK_CONCAT 267 +#define TK_CONFLICT 268 +#define TK_COPY 269 +#define TK_DEFERRED 270 +#define TK_DELIMITERS 271 +#define TK_DETACH 272 +#define TK_DIVIDE 273 +#define TK_DOT 274 +#define TK_EACH 275 +#define TK_END 276 +#define TK_FAIL 277 +#define TK_FILE 278 +#define TK_FOR 279 +#define TK_GLOB 280 +#define TK_ID 281 +#define TK_IMMEDIATE 282 +#define TK_IMPORT 283 +#define TK_INITIALLY 284 +#define TK_INSTEAD 285 +#define TK_ISNULL 286 +#define TK_KEY 287 +#define TK_NK_BITNOT 288 +#define TK_NK_SEMI 289 +#define TK_NOTNULL 290 +#define TK_OF 291 +#define TK_PLUS 292 +#define TK_PRIVILEGE 293 +#define TK_RAISE 294 +#define TK_REPLACE 295 +#define TK_RESTRICT 296 +#define TK_ROW 297 +#define TK_SEMI 298 +#define TK_STAR 299 +#define TK_STATEMENT 300 +#define TK_STRING 301 +#define TK_TIMES 302 +#define TK_UPDATE 303 +#define TK_VALUES 304 +#define TK_VARIABLE 305 +#define TK_VIEW 306 +#define TK_WAL 307 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index ceb3eae0338455ab207034fca707473c6c44940d..a88f65f6acf69d552073ab0ede31a0b027b25692 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -49,9 +49,6 @@ typedef struct { #define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v)) #define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE)) #define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len)) -#define IS_VAR_DATA_TYPE(t) \ - (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) -#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) #define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0])) #define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v)) @@ -268,11 +265,16 @@ typedef struct { #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) #define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t))) +#define IS_TIMESTAMP_TYPE(_t) ((_t) == TSDB_DATA_TYPE_TIMESTAMP) #define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t))) #define IS_MATHABLE_TYPE(_t) \ (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP)) +#define IS_VAR_DATA_TYPE(t) \ + (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) +#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) + #define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX) #define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX) #define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 741b0fddebf36cd1a8f16d0d2265742bcb9ac16c..c9c19579cb1c6943c5914aebed20668a1c1ff156 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -176,7 +176,8 @@ int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen); EFuncReturnRows fmGetFuncReturnRows(SFunctionNode* pFunc); -bool fmIsBuiltinFunc(const char* pFunc); +bool fmIsBuiltinFunc(const char* pFunc); +EFunctionType fmGetFuncType(const char* pFunc); bool fmIsAggFunc(int32_t funcId); bool fmIsScalarFunc(int32_t funcId); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 3223d4cdb8dfd36284f3d36922451166226fdd3e..ea70a421477bb4f13365b16510c52128d592ea14 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -78,6 +78,12 @@ typedef struct SDatabaseOptions { int32_t walRetentionSize; int32_t walRollPeriod; int32_t walSegmentSize; + bool walRetentionPeriodIsSet; + bool walRetentionSizeIsSet; + bool walRollPeriodIsSet; + int32_t sstTrigger; + int32_t tablePrefix; + int32_t tableSuffix; } SDatabaseOptions; typedef struct SCreateDatabaseStmt { @@ -268,6 +274,12 @@ typedef struct SShowDnodeVariablesStmt { SNode* pDnodeId; } SShowDnodeVariablesStmt; +typedef struct SShowVnodesStmt { + ENodeType type; + SNode* pDnodeId; + SNode* pDnodeEndpoint; +} SShowVnodesStmt; + typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT } EIndexType; typedef struct SIndexOptions { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 5743d3360857dab460841d89e50360ba53d36b39..9c2fdf587b16e3148ba99ebe75dbe102c97e38a2 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -183,12 +183,12 @@ typedef enum ENodeType { QUERY_NODE_SHOW_DNODE_VARIABLES_STMT, QUERY_NODE_SHOW_TRANSACTIONS_STMT, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, + QUERY_NODE_SHOW_VNODES_STMT, QUERY_NODE_SHOW_CREATE_DATABASE_STMT, QUERY_NODE_SHOW_CREATE_TABLE_STMT, QUERY_NODE_SHOW_CREATE_STABLE_STMT, QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT, - QUERY_NODE_SHOW_VNODES_STMT, QUERY_NODE_SHOW_SCORES_STMT, QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, @@ -244,6 +244,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, QUERY_NODE_PHYSICAL_PLAN_PARTITION, + QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION, QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC, QUERY_NODE_PHYSICAL_PLAN_DISPATCH, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6fd6a316ebd1bd6b0dcdb9b0b222716cfa33203e..8aeb86102a7b4237276f59f25fe50d36c6f99efa 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -488,6 +488,8 @@ typedef struct SPartitionPhysiNode { SNodeList* pTargets; } SPartitionPhysiNode; +typedef SPartitionPhysiNode SStreamPartitionPhysiNode; + typedef struct SDataSinkNode { ENodeType type; SDataBlockDescNode* pInputDataBlockDesc; diff --git a/include/os/osDir.h b/include/os/osDir.h index 9019d4f80240b2335824cb5626488bf4d0957f06..95b1a6ee1d00ab18e31522063102ff0ec9a2bab8 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -56,6 +56,7 @@ void taosRemoveDir(const char *dirname); bool taosDirExist(const char *dirname); int32_t taosMkDir(const char *dirname); int32_t taosMulMkDir(const char *dirname); +int32_t taosMulModeMkDir(const char *dirname, int mode); void taosRemoveOldFiles(const char *dirname, int32_t keepDays); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index e39172d74e52e852f0fa1812634e494d61ac6213..d16a599811255f987adb38cc553c8c5734a5ea60 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -616,6 +616,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155) #define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156) #define TSDB_CODE_RSMA_INVALID_SCHEMA TAOS_DEF_ERROR_CODE(0, 0x3157) +#define TSDB_CODE_RSMA_REGEX_MATCH TAOS_DEF_ERROR_CODE(0, 0x3158) //index #define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200) diff --git a/include/util/tdef.h b/include/util/tdef.h index 2bc821b8736edf745a30e0e103734e4e7b7b31e4..57fde32bed5d27bee4f429644a4b4623c2abe64e 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -359,15 +359,27 @@ typedef enum ELogicConditionType { #define TSDB_DB_SCHEMALESS_ON 1 #define TSDB_DB_SCHEMALESS_OFF 0 #define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF - -#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1 -#define TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD (24 * 60 * 60 * 4) -#define TSDB_DB_MIN_WAL_RETENTION_SIZE -1 -#define TSDB_DEFAULT_DB_WAL_RETENTION_SIZE -1 -#define TSDB_DB_MIN_WAL_ROLL_PERIOD 0 -#define TSDB_DEFAULT_DB_WAL_ROLL_PERIOD (24 * 60 * 60 * 1) -#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0 -#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0 +#define TSDB_MIN_SST_TRIGGER 1 +#define TSDB_MAX_SST_TRIGGER 128 +#define TSDB_DEFAULT_SST_TRIGGER 8 +#define TSDB_MIN_HASH_PREFIX 0 +#define TSDB_MAX_HASH_PREFIX 128 +#define TSDB_DEFAULT_HASH_PREFIX 0 +#define TSDB_MIN_HASH_SUFFIX 0 +#define TSDB_MAX_HASH_SUFFIX 128 +#define TSDB_DEFAULT_HASH_SUFFIX 0 + +#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1 +#define TSDB_REP_DEF_DB_WAL_RET_PERIOD 0 +#define TSDB_REPS_DEF_DB_WAL_RET_PERIOD (24 * 60 * 60 * 4) +#define TSDB_DB_MIN_WAL_RETENTION_SIZE -1 +#define TSDB_REP_DEF_DB_WAL_RET_SIZE 0 +#define TSDB_REPS_DEF_DB_WAL_RET_SIZE -1 +#define TSDB_DB_MIN_WAL_ROLL_PERIOD 0 +#define TSDB_REP_DEF_DB_WAL_ROLL_PERIOD 0 +#define TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD (24 * 60 * 60 * 1) +#define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0 +#define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0 #define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond #define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000) @@ -386,7 +398,7 @@ typedef enum ELogicConditionType { #define TSDB_DEFAULT_EXPLAIN_VERBOSE false -#define TSDB_EXPLAIN_RESULT_ROW_SIZE (16*1024) +#define TSDB_EXPLAIN_RESULT_ROW_SIZE (16 * 1024) #define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY_PLAN" #define TSDB_MAX_FIELD_LEN 16384 diff --git a/include/util/tencode.h b/include/util/tencode.h index ad642cd612db4d1bb31f57b7a49d977e90978ee5..a6dd58297e8c1dba644d86eb5145b273406fbf9e 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -264,12 +264,14 @@ static FORCE_INLINE int32_t tEncodeDouble(SEncoder* pCoder, double val) { static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len) { if (tEncodeU32v(pCoder, len) < 0) return -1; - if (pCoder->data) { - if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, len)) return -1; - memcpy(TD_CODER_CURRENT(pCoder), val, len); - } + if (len) { + if (pCoder->data) { + if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, len)) return -1; + memcpy(TD_CODER_CURRENT(pCoder), val, len); + } - TD_CODER_MOVE_POS(pCoder, len); + TD_CODER_MOVE_POS(pCoder, len); + } return 0; } @@ -414,14 +416,18 @@ static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) { static FORCE_INLINE int32_t tDecodeBinaryAlloc(SDecoder* pCoder, void** val, uint64_t* len) { uint64_t length = 0; if (tDecodeU64v(pCoder, &length) < 0) return -1; - if (len) *len = length; + if (length) { + if (len) *len = length; - if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, length)) return -1; - *val = taosMemoryMalloc(length); - if (*val == NULL) return -1; - memcpy(*val, TD_CODER_CURRENT(pCoder), length); + if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, length)) return -1; + *val = taosMemoryMalloc(length); + if (*val == NULL) return -1; + memcpy(*val, TD_CODER_CURRENT(pCoder), length); - TD_CODER_MOVE_POS(pCoder, length); + TD_CODER_MOVE_POS(pCoder, length); + } else { + *val = NULL; + } return 0; } diff --git a/include/util/trbtree.h b/include/util/trbtree.h new file mode 100644 index 0000000000000000000000000000000000000000..f6d37e3d753de71fdf312b795935cb9014149f23 --- /dev/null +++ b/include/util/trbtree.h @@ -0,0 +1,78 @@ +/* + * 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_UTIL_RBTREE_H_ +#define _TD_UTIL_RBTREE_H_ + +#include "os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SRBTree SRBTree; +typedef struct SRBTreeNode SRBTreeNode; +typedef struct SRBTreeIter SRBTreeIter; + +typedef int32_t (*tRBTreeCmprFn)(const void *, const void *); + +// SRBTree ============================================= +#define tRBTreeMin(T) ((T)->min == ((T)->NIL) ? NULL : (T)->min) +#define tRBTreeMax(T) ((T)->max == ((T)->NIL) ? NULL : (T)->max) + +void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn); +SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z); +void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z); +SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey); +SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey); + +// SRBTreeIter ============================================= +#define tRBTreeIterCreate(tree, ascend) \ + (SRBTreeIter) { .asc = (ascend), .pTree = (tree), .pNode = (ascend) ? (tree)->min : (tree)->max } + +SRBTreeNode *tRBTreeIterNext(SRBTreeIter *pIter); + +// STRUCT ============================================= +typedef enum { RED, BLACK } ECOLOR; +struct SRBTreeNode { + ECOLOR color; + SRBTreeNode *parent; + SRBTreeNode *left; + SRBTreeNode *right; +}; + +#define RBTREE_NODE_PAYLOAD(N) ((const void *)&(N)[1]) + +struct SRBTree { + tRBTreeCmprFn cmprFn; + int64_t n; + SRBTreeNode *root; + SRBTreeNode *min; + SRBTreeNode *max; + SRBTreeNode *NIL; + SRBTreeNode NILNODE; +}; + +struct SRBTreeIter { + int8_t asc; + SRBTree *pTree; + SRBTreeNode *pNode; +}; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_UTIL_RBTREE_H_*/ \ No newline at end of file diff --git a/include/util/tutil.h b/include/util/tutil.h index 6a1a40f14ccb865533f117524ffdfef3c84e20ad..a0c7b3d7ad9826ec8ed6879c85e92315de70591b 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -20,6 +20,7 @@ #include "tcrc32c.h" #include "tdef.h" #include "tmd5.h" +#include "thash.h" #ifdef __cplusplus extern "C" { @@ -68,6 +69,8 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar memcpy(target, buf, TSDB_PASSWORD_LEN); } +#define taosGetTbHashVal(tbname, tblen, method, prefix, suffix) MurmurHash3_32((tbname), (tblen)) + #ifdef __cplusplus } #endif diff --git a/packaging/MPtestJenkinsfile b/packaging/MPtestJenkinsfile index a003bf354c4a8f28d9c50769cb1badb772fae9a8..77f642180a59932d8f8e4deaa2d91ac37e7268fc 100644 --- a/packaging/MPtestJenkinsfile +++ b/packaging/MPtestJenkinsfile @@ -64,6 +64,11 @@ pipeline { defaultValue:'2.1.2', description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1' ) + string ( + name:'nasPassword', + defaultValue:'password', + description: 'the pasword of the NAS server which has installPackage-192.168.1.131' + ) } environment{ WORK_DIR = '/var/lib/jenkins/workspace' @@ -111,17 +116,17 @@ pipeline { sync_source("${BRANCH_NAME}") sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' } @@ -134,17 +139,22 @@ pipeline { sync_source("${BRANCH_NAME}") sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} + python3 checkPackageRuning.py + ''' + sh ''' + cd ${TDENGINE_ROOT_DIR}/packaging + bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_DEB} ${baseVersion} server + bash testpackage.sh ${TD_CLIENT_TAR} ${version} ${BASE_TD_CLIENT_TAR} ${baseVersion} client ${nasPassword} python3 checkPackageRuning.py ''' } @@ -157,17 +167,17 @@ pipeline { sync_source("${BRANCH_NAME}") sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' } @@ -179,19 +189,42 @@ pipeline { timeout(time: 30, unit: 'MINUTES'){ sync_source("${BRANCH_NAME}") sh ''' + cd ${TDENGINE_ROOT_DIR}/packaging + bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} + python3 checkPackageRuning.py + ''' + sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py - rmtaos ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server + bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword} + python3 checkPackageRuning.py + ''' + sh ''' + cd ${TDENGINE_ROOT_DIR}/packaging + bash testpackage.sh ${TD_CLIENT_LITE_TAR} ${version} ${BASE_TD_CLIENT_LITE_TAR} ${baseVersion} client ${nasPassword} + python3 checkPackageRuning.py + ''' + } + } + } + + stage('arm64') { + agent{label 'linux_arm64'} + steps { + timeout(time: 30, unit: 'MINUTES'){ + sync_source("${BRANCH_NAME}") + sh ''' + cd ${TDENGINE_ROOT_DIR}/packaging + bash testpackage.sh ${TD_SERVER_ARM_TAR} ${version} ${BASE_TD_SERVER_ARM_TAR} ${baseVersion} server ${nasPassword} python3 checkPackageRuning.py ''' sh ''' cd ${TDENGINE_ROOT_DIR}/packaging - bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server + bash testpackage.sh ${TD_CLIENT_ARM_TAR} ${version} ${BASE_TD_CLIENT_ARM_TAR} ${baseVersion} client ${nasPassword} python3 checkPackageRuning.py ''' } diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 3db9005f95a3027c42dd05b9f28d448ade5852cb..94a24a41487e8d7b82571bcc524392e4335d7fae 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -45,6 +45,7 @@ mkdir -p ${pkg_dir}${install_home_path}/include mkdir -p ${pkg_dir}${install_home_path}/script cp ${compile_dir}/../packaging/cfg/taos.cfg ${pkg_dir}${install_home_path}/cfg +cp ${compile_dir}/../packaging/cfg/taosd.service ${pkg_dir}${install_home_path}/cfg if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then cp ${compile_dir}/test/cfg/taosadapter.toml ${pkg_dir}${install_home_path}/cfg || : fi diff --git a/packaging/debRpmAutoInstall.sh b/packaging/debRpmAutoInstall.sh new file mode 100755 index 0000000000000000000000000000000000000000..1f51378c91d14b5fcfd1eb4cca87a6cd472161cc --- /dev/null +++ b/packaging/debRpmAutoInstall.sh @@ -0,0 +1,13 @@ +#!/usr/bin/expect +set packgeName [lindex $argv 0] +set packageSuffix [lindex $argv 1] +set timeout 3 +if { ${packageSuffix} == "deb" } { + spawn dpkg -i ${packgeName} +} elseif { ${packageSuffix} == "rpm"} { + spawn rpm -ivh ${packgeName} +} +expect "*one:" +send "\r" +expect "*skip:" +send "\r" diff --git a/packaging/testpackage.sh b/packaging/testpackage.sh index 054c24eb5d42a959bd2c9df86b8fff820d3746fd..56da9e59be9379af9a1b96eadc88fe0e052e9863 100755 --- a/packaging/testpackage.sh +++ b/packaging/testpackage.sh @@ -1,12 +1,24 @@ #!/bin/sh - - +#parameter +scriptDir=$(dirname $(readlink -f $0)) packgeName=$1 version=$2 originPackageName=$3 originversion=$4 testFile=$5 subFile="taos.tar.gz" +password=$6 + +# Color setting +RED='\033[41;30m' +GREEN='\033[1;32m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +GREEN_DARK='\033[0;32m' +YELLOW_DARK='\033[0;33m' +BLUE_DARK='\033[0;34m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' if [ ${testFile} = "server" ];then tdPath="TDengine-server-${version}" @@ -23,111 +35,211 @@ elif [ ${testFile} = "tools" ];then fi function cmdInstall { -comd=$1 -if command -v ${comd} ;then - echo "${comd} is already installed" +command=$1 +if command -v ${command} ;then + echoColor YD "${command} is already installed" else if command -v apt ;then - apt-get install ${comd} -y + apt-get install ${command} -y elif command -v yum ;then - yum -y install ${comd} - echo "you should install ${comd} manually" + yum -y install ${command} + echoColor YD "you should install ${command} manually" fi fi } +function echoColor { +color=$1 +command=$2 + +if [ ${color} = 'Y' ];then + echo -e "${YELLOW}${command}${NC}" +elif [ ${color} = 'YD' ];then + echo -e "${YELLOW_DARK}${command}${NC}" +elif [ ${color} = 'R' ];then + echo -e "${RED}${command}${NC}" +elif [ ${color} = 'G' ];then + echo -e "${GREEN}${command}${NC}\r\n" +elif [ ${color} = 'B' ];then + echo -e "${BLUE}${command}${NC}" +elif [ ${color} = 'BD' ];then + echo -e "${BLUE_DARK}${command}${NC}" +fi +} + -echo "Uninstall all components of TDeingne" +echoColor G "===== install basesoft =====" + +cmdInstall tree +cmdInstall wget +cmdInstall sshpass + +echoColor G "===== Uninstall all components of TDeingne =====" if command -v rmtaos ;then - echo "uninstall all components of TDeingne:rmtaos" + echoColor YD "uninstall all components of TDeingne:rmtaos" rmtaos else - echo "os doesn't include TDengine " + echoColor YD "os doesn't include TDengine" fi if command -v rmtaostools ;then - echo "uninstall all components of TDeingne:rmtaostools" + echoColor YD "uninstall all components of TDeingne:rmtaostools" rmtaostools else - echo "os doesn't include rmtaostools " + echoColor YD "os doesn't include rmtaostools " fi -cmdInstall tree -cmdInstall wget -echo "new workroom path" + +echoColor G "===== new workroom path =====" installPath="/usr/local/src/packageTest" oriInstallPath="/usr/local/src/packageTest/3.1" if [ ! -d ${installPath} ] ;then + echoColor BD "mkdir -p ${installPath}" mkdir -p ${installPath} else - echo "${installPath} already exists" + echoColor YD "${installPath} already exists" fi +if [ -d ${installPath}/${tdPath} ] ;then + echoColor BD "rm -rf ${installPath}/${tdPath}/*" + rm -rf ${installPath}/${tdPath}/* +fi if [ ! -d ${oriInstallPath} ] ;then + echoColor BD "mkdir -p ${oriInstallPath}" mkdir -p ${oriInstallPath} else - echo "${oriInstallPath} already exists" + echoColor YD "${oriInstallPath} already exists" fi -echo "decompress installPackage" +if [ -d ${oriInstallPath}/${originTdpPath} ] ;then + echoColor BD "rm -rf ${oriInstallPath}/${originTdpPath}/*" + rm -rf ${oriInstallPath}/${originTdpPath}/* +fi + + +echoColor G "===== download installPackage =====" +# cd ${installPath} +# wget https://www.taosdata.com/assets-download/3.0/${packgeName} +# cd ${oriInstallPath} +# wget https://www.taosdata.com/assets-download/3.0/${originPackageName} cd ${installPath} -wget https://www.taosdata.com/assets-download/3.0/${packgeName} -cd ${oriInstallPath} -wget https://www.taosdata.com/assets-download/3.0/${originPackageName} +cp -r ${scriptDir}/debRpmAutoInstall.sh . + +if [ ! -f {packgeName} ];then + echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} ." + sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} . +fi + +packageSuffix=$(echo ${packgeName} | awk -F '.' '{print $NF}') + + +if [ ! -f debRpmAutoInstall.sh ];then + echo '#!/usr/bin/expect ' > debRpmAutoInstall.sh + echo 'set packgeName [lindex $argv 0]' >> debRpmAutoInstall.sh + echo 'set packageSuffix [lindex $argv 1]' >> debRpmAutoInstall.sh + echo 'set timeout 3 ' >> debRpmAutoInstall.sh + echo 'if { ${packageSuffix} == "deb" } {' >> debRpmAutoInstall.sh + echo ' spawn dpkg -i ${packgeName} ' >> debRpmAutoInstall.sh + echo '} elseif { ${packageSuffix} == "rpm"} {' >> debRpmAutoInstall.sh + echo ' spawn rpm -ivh ${packgeName}' >> debRpmAutoInstall.sh + echo '}' >> debRpmAutoInstall.sh + echo 'expect "*one:"' >> debRpmAutoInstall.sh + echo 'send "\r"' >> debRpmAutoInstall.sh + echo 'expect "*skip:"' >> debRpmAutoInstall.sh + echo 'send "\r" ' >> debRpmAutoInstall.sh +fi + +echoColor G "===== instal Package =====" if [[ ${packgeName} =~ "deb" ]];then cd ${installPath} - echo "dpkg ${packgeName}" && dpkg -i ${packgeName} + dpkg -r taostools + dpkg -r tdengine + if [[ ${packgeName} =~ "TDengine" ]];then + echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix} + else + echoColor BD "dpkg -i ${packgeName}" && dpkg -i ${packgeName} + fi elif [[ ${packgeName} =~ "rpm" ]];then cd ${installPath} - echo "rpm ${packgeName}" && rpm -ivh ${packgeName} + sudo rpm -e tdengine + sudo rpm -e taostools + if [[ ${packgeName} =~ "TDengine" ]];then + echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix} + else + echoColor BD "rpm -ivh ${packgeName}" && rpm -ivh ${packgeName} + fi elif [[ ${packgeName} =~ "tar" ]];then - echo "tar ${packgeName}" && tar -xvf ${packgeName} - cd ${oriInstallPath} - echo "tar -xvf ${originPackageName}" && tar -xvf ${originPackageName} + echoColor G "===== check installPackage File of tar =====" + cd ${oriInstallPath} + if [ ! -f {originPackageName} ];then + echoColor YD "download base installPackage" + echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} ." + sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} . + fi + echoColor YD "unzip the base installation package" + echoColor BD "tar -xf ${originPackageName}" && tar -xf ${originPackageName} cd ${installPath} - echo "tar -xvf ${packgeName}" && tar -xvf ${packgeName} - + echoColor YD "unzip the new installation package" + echoColor BD "tar -xf ${packgeName}" && tar -xf ${packgeName} if [ ${testFile} != "tools" ] ;then - cd ${installPath}/${tdPath} && tar vxf ${subFile} - cd ${oriInstallPath}/${originTdpPath} && tar vxf ${subFile} + cd ${installPath}/${tdPath} && tar xf ${subFile} + cd ${oriInstallPath}/${originTdpPath} && tar xf ${subFile} fi - echo "check installPackage File" - + cd ${oriInstallPath}/${originTdpPath} && tree > ${installPath}/base_${originversion}_checkfile + cd ${installPath}/${tdPath} && tree > ${installPath}/now_${version}_checkfile + cd ${installPath} - - tree ${oriInstallPath}/${originTdpPath} > ${originPackageName}_checkfile - tree ${installPath}/${tdPath} > ${packgeName}_checkfile - - diff ${packgeName}_checkfile ${originPackageName}_checkfile > ${installPath}/diffFile.log + diff ${installPath}/base_${originversion}_checkfile ${installPath}/now_${version}_checkfile > ${installPath}/diffFile.log diffNumbers=`cat ${installPath}/diffFile.log |wc -l ` + if [ ${diffNumbers} != 0 ];then - echo "The number and names of files have changed from the previous installation package" - echo `cat ${installPath}/diffFile.log` + echoColor R "The number and names of files is different from the previous installation package" + echoColor Y `cat ${installPath}/diffFile.log` exit -1 + else + echoColor G "The number and names of files are the same as previous installation packages" fi - + echoColor YD "===== install Package of tar =====" cd ${installPath}/${tdPath} if [ ${testFile} = "server" ];then + echoColor BD "bash ${installCmd} -e no " bash ${installCmd} -e no else + echoColor BD "bash ${installCmd} " bash ${installCmd} fi - if [[ ${packgeName} =~ "Lite" ]];then - cd ${installPath} - wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz - tar xvf taosTools-2.1.2-Linux-x64.tar.gz - cd taosTools-2.1.2 && bash install-taostools.sh - fi - fi +cd ${installPath} + +if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then + echoColor G "===== install taos-tools when package is lite or client =====" + cd ${installPath} + sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz . + # wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz + tar xf taosTools-2.1.2-Linux-x64.tar.gz + cd taosTools-2.1.2 && bash install-taostools.sh +elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then + echoColor G "===== install taos-tools when package is lite or client =====" + cd ${installPath} + sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz . + tar xf taosTools-2.1.2-Linux-x64.tar.gz + cd taosTools-2.1.2 && bash install-taostools.sh +elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then + echoColor G "===== install taos-tools when package is lite or client =====" + cd ${installPath} + sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz . + tar xf taosTools-2.1.2-Linux-x64.tar.gz + cd taosTools-2.1.2 && bash install-taostools.sh +fi + diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 39606ead300c8c603b9f25360d19e3af49b642ff..f2f72acafa9e5cda273d26933723d4328146d7cd 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -33,6 +33,7 @@ adapterName="taosadapter" benchmarkName="taosBenchmark" dumpName="taosdump" demoName="taosdemo" +xname="taosx" data_dir=${dataDir} log_dir=${logDir} @@ -199,6 +200,7 @@ function install_bin() { ${csudo}rm -f ${bin_link_dir}/${demoName} || : ${csudo}rm -f ${bin_link_dir}/${benchmarkName} || : ${csudo}rm -f ${bin_link_dir}/${dumpName} || : + ${csudo}rm -f ${bin_link_dir}/${xname} || : ${csudo}rm -f ${bin_link_dir}/set_core || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : @@ -212,6 +214,7 @@ function install_bin() { [ -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/${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/${dumpName} ${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 || : diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index f554942ce330767b45ef5ec2ee0df422c273c5ed..a6dceeeaadaf53ae510b38439df9e5130f88b35d 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -172,6 +172,7 @@ function install_bin() { ${csudo}rm -f ${bin_link_dir}/udfd || : ${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/taosx || : if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${bin_link_dir}/perfMonitor || : @@ -184,6 +185,7 @@ function install_bin() { [ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || : [ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || : [ -f ${binary_dir}/build/bin/udfd ] && ${csudo}cp -r ${binary_dir}/build/bin/udfd ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosx ] && ${csudo}cp -r ${binary_dir}/build/bin/taosx ${install_main_dir}/bin || : ${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || : @@ -199,6 +201,7 @@ function install_bin() { [ -x ${install_main_dir}/bin/udfd ] && ${csudo}ln -s ${install_main_dir}/bin/udfd ${bin_link_dir}/udfd || : [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/taosx ] && ${csudo}ln -s ${install_main_dir}/bin/taosx ${bin_link_dir}/taosx || : [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : [ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : @@ -215,6 +218,7 @@ function install_bin() { [ -x ${install_main_dir}/bin/udfd ] || [ -x ${install_main_2_dir}/bin/udfd ] && ${csudo}ln -s ${install_main_dir}/bin/udfd ${bin_link_dir}/udfd || ${csudo}ln -s ${install_main_2_dir}/bin/udfd || : [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/taosx ] || [ -x ${install_main_2_dir}/bin/taosx ] && ${csudo}ln -s ${install_main_dir}/bin/taosx ${bin_link_dir}/taosx || ln -s ${install_main_2_dir}/bin/taosx ${bin_link_dir}/taosx || : fi } diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index f5e3bf18822676f54ee2f20412b5ebb4ce57fd3a..2305b96b3663c3c52ca84988518de3fd00769af8 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -80,10 +80,12 @@ else ${build_dir}/bin/taosBenchmark \ ${build_dir}/bin/TDinsight.sh \ $tdinsight_caches" + [ -f ${build_dir}/bin/taosx ] && taosx_bin="${build_dir}/bin/taosx" bin_files="${build_dir}/bin/${serverName} \ ${build_dir}/bin/${clientName} \ ${taostools_bin_files} \ + ${taosx_bin} \ ${build_dir}/bin/taosadapter \ ${build_dir}/bin/udfd \ ${script_dir}/remove.sh \ diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 07e5f75e87904e8b7998717224214d2f15dccce0..b8fa9580e70c1c7aa17a1402ce6c8113a7f8e094 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -52,15 +52,17 @@ enum { RES_TYPE__QUERY = 1, RES_TYPE__TMQ, RES_TYPE__TMQ_META, + RES_TYPE__TAOSX, }; #define SHOW_VARIABLES_RESULT_COLS 2 #define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) -#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ || *(int8_t*)res == RES_TYPE__TAOSX) +#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) +#define TD_RES_TMQ_TAOSX(res) (*(int8_t*)res == RES_TYPE__TAOSX) typedef struct SAppInstInfo SAppInstInfo; @@ -101,6 +103,8 @@ typedef struct SQueryExecMetric { int64_t ctgStart; // start to parse, us int64_t ctgEnd; // end to parse, us int64_t semanticEnd; + int64_t planEnd; + int64_t resultReady; int64_t execEnd; int64_t send; // start to send to server, us int64_t rsp; // receive response from server, us @@ -198,8 +202,8 @@ typedef struct { int32_t vgId; SSchemaWrapper schema; int32_t resIter; - SMqDataRsp rsp; SReqResultInfo resInfo; + SMqDataRsp rsp; } SMqRspObj; typedef struct { @@ -210,6 +214,17 @@ typedef struct { SMqMetaRsp metaRsp; } SMqMetaRspObj; +typedef struct { + int8_t resType; + char topic[TSDB_TOPIC_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int32_t vgId; + SSchemaWrapper schema; + int32_t resIter; + SReqResultInfo resInfo; + STaosxRsp rsp; +} SMqTaosxRspObj; + typedef struct SRequestObj { int8_t resType; // query or tmq uint64_t requestId; @@ -369,7 +384,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest); int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList); void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta); -int32_t removeMeta(STscObj* pTscObj, SArray* tbList); +int32_t removeMeta(STscObj* pTscObj, SArray* tbList); int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog); int32_t handleCreateTbExecRes(void* res, SCatalog* pCatalog); bool qnodeRequired(SRequestObj* pRequest); diff --git a/source/client/src/TMQConnector.c b/source/client/src/TMQConnector.c index 17d3a212c482c3462e542721d7d57f516250ff13..fcf6957df92e92b990c60cd3b41342dbbf90ae9e 100644 --- a/source/client/src/TMQConnector.c +++ b/source/client/src/TMQConnector.c @@ -42,6 +42,7 @@ void commit_cb(tmq_t *tmq, int32_t code, void *param) { JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConfNewImp(JNIEnv *env, jobject jobj) { tmq_conf_t *conf = tmq_conf_new(); + jniGetGlobalMethod(env); return (jlong)conf; } diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 1342e89b523ac0a2ae2fc1eca7584aff2a340f1d..bf92a9ba6af41d8c3048684ed36eec84cc0a6235 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -76,18 +76,19 @@ static void deregisterRequest(SRequestObj *pRequest) { pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000, num, currentInst); if (QUERY_NODE_VNODE_MODIF_STMT == pRequest->stmtType) { - tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, exec:%" PRId64 "us", - duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, - pRequest->metric.ctgEnd - pRequest->metric.ctgStart, - pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, + tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 + "us, exec:%" PRId64 "us", + duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, + pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, pRequest->metric.execEnd - pRequest->metric.semanticEnd); atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration); } else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) { - tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, exec:%" PRId64 "us", - duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, - pRequest->metric.ctgEnd - pRequest->metric.ctgStart, - pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, - pRequest->metric.execEnd - pRequest->metric.semanticEnd); + tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 + "us, planner:%" PRId64 "us, exec:%" PRId64 "us", + duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, + pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, + pRequest->metric.planEnd - pRequest->metric.semanticEnd, + pRequest->metric.resultReady - pRequest->metric.planEnd); atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration); } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 2baca1288fe086388cc3e5a424ab289586a864f5..5ebc2729f8b4a2d87316c5d317e0b4c8667edf88 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -728,7 +728,7 @@ int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog tFreeSTableMetaRsp(blk->pMeta); taosMemoryFreeClear(blk->pMeta); } - + if (NULL == blk->tblFName || 0 == blk->tblFName[0]) { continue; } @@ -851,6 +851,8 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { SRequestObj* pRequest = (SRequestObj*)param; pRequest->code = code; + pRequest->metric.resultReady = taosGetTimestampUs(); + if (pResult) { memcpy(&pRequest->body.resInfo.execRes, pResult, sizeof(*pResult)); } @@ -1030,6 +1032,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM pRequest->body.subplanNum = pDag->numOfSubplans; } + pRequest->metric.planEnd = taosGetTimestampUs(); + if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta); @@ -1668,7 +1672,12 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int break; } } - if (!needConvert) return TSDB_CODE_SUCCESS; + + if (!needConvert) { + return TSDB_CODE_SUCCESS; + } + + tscDebug("start to convert form json format string"); char* p = (char*)pResultInfo->pData; int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 9ceb6e068375a67cb1230200e28aad6a74395661..30860780807a820b041e27729f8e351fb46c99b3 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -184,6 +184,19 @@ void taos_free_result(TAOS_RES *res) { SRequestObj *pRequest = (SRequestObj *)res; tscDebug("0x%" PRIx64 " taos_free_result start to free query", pRequest->requestId); destroyRequest(pRequest); + } else if (TD_RES_TMQ_TAOSX(res)) { + SMqTaosxRspObj *pRsp = (SMqTaosxRspObj *)res; + if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree); + if (pRsp->rsp.blockDataLen) taosArrayDestroy(pRsp->rsp.blockDataLen); + if (pRsp->rsp.withTbName) taosArrayDestroyP(pRsp->rsp.blockTbName, taosMemoryFree); + if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); + // taosx + taosArrayDestroy(pRsp->rsp.createTableLen); + taosArrayDestroyP(pRsp->rsp.createTableReq, taosMemoryFree); + + pRsp->resInfo.pRspMsg = NULL; + doFreeReqResultInfo(&pRsp->resInfo); + taosMemoryFree(pRsp); } else if (TD_RES_TMQ(res)) { SMqRspObj *pRsp = (SMqRspObj *)res; if (pRsp->rsp.blockData) taosArrayDestroyP(pRsp->rsp.blockData, taosMemoryFree); diff --git a/source/client/src/taosx.c b/source/client/src/clientRawBlockWrite.c similarity index 97% rename from source/client/src/taosx.c rename to source/client/src/clientRawBlockWrite.c index f016120a1f5cbe1b4baf4e42f76a0fea7c80d353..c135965f07454c46e20780d029c18b2359110877 100644 --- a/source/client/src/taosx.c +++ b/source/client/src/clientRawBlockWrite.c @@ -765,23 +765,25 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { } taosArrayPush(pRequest->tableList, &pName); + pCreateReq->flags |= TD_CREATE_IF_NOT_EXISTS; // change tag cid to new cid - if(pCreateReq->type == TSDB_CHILD_TABLE){ + if (pCreateReq->type == TSDB_CHILD_TABLE) { STableMeta* pTableMeta = NULL; SName sName = {0}; toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.name, &sName); code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta); - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", pCreateReq->ctb.name); goto end; } - for(int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++){ + for (int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++) { char* tName = taosArrayGet(pCreateReq->ctb.tagName, i); - for(int32_t j = pTableMeta->tableInfo.numOfColumns; j < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; j++){ - SSchema *tag = &pTableMeta->schema[j]; - if(strcmp(tag->name, tName) == 0 && tag->type != TSDB_DATA_TYPE_JSON){ - tTagSetCid((STag *)pCreateReq->ctb.pTag, i, tag->colId); + for (int32_t j = pTableMeta->tableInfo.numOfColumns; + j < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; j++) { + SSchema* tag = &pTableMeta->schema[j]; + if (strcmp(tag->name, tName) == 0 && tag->type != TSDB_DATA_TYPE_JSON) { + tTagSetCid((STag*)pCreateReq->ctb.pTag, i, tag->colId); } } } @@ -1322,12 +1324,12 @@ end: return code; } -static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) { - int32_t code = TSDB_CODE_SUCCESS; - SHashObj* pVgHash = NULL; - SQuery* pQuery = NULL; - SMqRspObj rspObj = {0}; - SDecoder decoder = {0}; +static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { + int32_t code = TSDB_CODE_SUCCESS; + SHashObj* pVgHash = NULL; + SQuery* pQuery = NULL; + SMqRspObj rspObj = {0}; + SDecoder decoder = {0}; STableMeta* pTableMeta = NULL; terrno = TSDB_CODE_SUCCESS; @@ -1405,7 +1407,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) { } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); - if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST){ + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); code = TSDB_CODE_SUCCESS; continue; @@ -1466,7 +1468,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) { } // pSW->pSchema should be same as pTableMeta->schema -// ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns); + // ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns); uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid); uint64_t uid = pTableMeta->uid; int16_t sver = pTableMeta->sversion; @@ -1494,10 +1496,10 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) { int32_t offset = 0; for (int32_t k = 0; k < pTableMeta->tableInfo.numOfColumns; k++) { const SSchema* pColumn = &pTableMeta->schema[k]; - int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name)); - if(!index){ + int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name)); + if (!index) { tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); - }else{ + } else { char* colData = rspObj.resInfo.row[*index]; if (!colData) { tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k); @@ -1668,7 +1670,7 @@ int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) { } else if (raw.raw_type == TDMT_VND_DELETE) { return taosDeleteData(taos, raw.raw, raw.raw_len); } else if (raw.raw_type == RES_TYPE__TMQ) { - return tmqWriteRaw(taos, raw.raw, raw.raw_len); + return tmqWriteRawDataImpl(taos, raw.raw, raw.raw_len); } return TSDB_CODE_INVALID_PARA; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 4968c5c68d37637da471d2fc65a1d4a780dd1603..f2493f6c57daf5654524f2c0e4f49d14df40b022 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -356,6 +356,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray* pColumns, goto end; } + pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; goto end; @@ -456,7 +457,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname); goto end; } info->cost.numOfCreateSTables++; @@ -492,7 +493,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname); goto end; } } @@ -536,7 +537,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable); + uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname); goto end; } } @@ -546,6 +547,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { goto end; } needCheckMeta = true; + taosHashCleanup(hashTmp); + hashTmp = NULL; } else { uError("SML:0x%" PRIx64 " load table meta error: %s", info->id, tstrerror(code)); goto end; @@ -554,7 +557,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, (char *)superTable); + uError("SML:0x%" PRIx64 " catalogGetSTableMeta failed. super table name %s", info->id, pName.tname); goto end; } @@ -562,12 +565,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = smlCheckMeta(&(pTableMeta->schema[pTableMeta->tableInfo.numOfColumns]), pTableMeta->tableInfo.numOfTags, sTableData->tags, true); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " check tag failed. super table name %s", info->id, (char *)superTable); + uError("SML:0x%" PRIx64 " check tag failed. super table name %s", info->id, pName.tname); goto end; } code = smlCheckMeta(&(pTableMeta->schema[0]), pTableMeta->tableInfo.numOfColumns, sTableData->cols, false); if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " check cols failed. super table name %s", info->id, (char *)superTable); + uError("SML:0x%" PRIx64 " check cols failed. super table name %s", info->id, pName.tname); goto end; } } @@ -575,7 +578,6 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { sTableData->tableMeta = pTableMeta; tableMetaSml = (SSmlSTableMeta **)taosHashIterate(info->superTables, tableMetaSml); - taosHashCleanup(hashTmp); } return 0; @@ -1558,7 +1560,7 @@ cleanup: /************* TSDB_SML_JSON_PROTOCOL function start **************/ static int32_t smlJsonCreateSring(const char **output, char *input, int32_t inputLen) { - *output = (const char *)taosMemoryMalloc(inputLen); + *output = (const char *)taosMemoryCalloc(1, inputLen); if (*output == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -2449,9 +2451,11 @@ static void smlInsertCallback(void *param, void *res, int32_t code) { uDebug("SML:0x%" PRIx64 " result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); // lock taosThreadSpinLock(&info->params->lock); - info->params->request->body.resInfo.numOfRows += rows; if (code != TSDB_CODE_SUCCESS) { info->params->request->code = code; + info->params->request->body.resInfo.numOfRows += rows; + }else{ + info->params->request->body.resInfo.numOfRows += info->affectedRows; } taosThreadSpinUnlock(&info->params->lock); // unlock diff --git a/source/client/src/tmq.c b/source/client/src/clientTmq.c similarity index 94% rename from source/client/src/tmq.c rename to source/client/src/clientTmq.c index fa657fcb1042527a5ac444700c1f4e2009ba656c..9f9a14952e75bdac29564c39dd4ef60da0d07ef0 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/clientTmq.c @@ -164,6 +164,7 @@ typedef struct { union { SMqDataRsp dataRsp; SMqMetaRsp metaRsp; + STaosxRsp taosxRsp; }; } SMqPollRspWrapper; @@ -810,8 +811,19 @@ int32_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) { } int32_t tmq_unsubscribe(tmq_t* tmq) { + int32_t rsp; + int32_t retryCnt = 0; tmq_list_t* lst = tmq_list_new(); - int32_t rsp = tmq_subscribe(tmq, lst); + while (1) { + rsp = tmq_subscribe(tmq, lst); + if (rsp != TSDB_CODE_MND_CONSUMER_NOT_READY || retryCnt > 5) { + break; + } else { + retryCnt++; + taosMsleep(500); + } + } + tmq_list_destroy(lst); return rsp; } @@ -1130,21 +1142,29 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tDecodeSMqDataRsp(&decoder, &pRspWrapper->dataRsp); tDecoderClear(&decoder); memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead)); - } else { - ASSERT(rspType == TMQ_MSG_TYPE__POLL_META_RSP); + + tscDebug("consumer:%" PRId64 ", recv poll: vgId:%d, req offset %" PRId64 ", rsp offset %" PRId64 " type %d", + tmq->consumerId, pVg->vgId, pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, + rspType); + + } else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) { SDecoder decoder; tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); tDecodeSMqMetaRsp(&decoder, &pRspWrapper->metaRsp); tDecoderClear(&decoder); memcpy(&pRspWrapper->metaRsp, pMsg->pData, sizeof(SMqRspHead)); + } else if (rspType == TMQ_MSG_TYPE__TAOSX_RSP) { + SDecoder decoder; + tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); + tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp); + tDecoderClear(&decoder); + memcpy(&pRspWrapper->taosxRsp, pMsg->pData, sizeof(SMqRspHead)); + } else { + ASSERT(0); } taosMemoryFree(pMsg->pData); - tscDebug("consumer:%" PRId64 ", recv poll: vgId:%d, req offset %" PRId64 ", rsp offset %" PRId64 " type %d", - tmq->consumerId, pVg->vgId, pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, - rspType); - taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); @@ -1443,6 +1463,24 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { return pRspObj; } +SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper) { + SMqTaosxRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqTaosxRspObj)); + pRspObj->resType = RES_TYPE__TAOSX; + tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN); + tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN); + pRspObj->vgId = pWrapper->vgHandle->vgId; + pRspObj->resIter = -1; + memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqTaosxRspObj)); + + pRspObj->resInfo.totalRows = 0; + pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI; + if (!pWrapper->dataRsp.withSchema) { + setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols); + } + + return pRspObj; +} + int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { /*tscDebug("call poll");*/ for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { @@ -1595,6 +1633,30 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { pollRspWrapper->metaRsp.head.epoch, consumerEpoch); taosFreeQitem(pollRspWrapper); } + } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) { + SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; + /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ + int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + if (pollRspWrapper->taosxRsp.head.epoch == consumerEpoch) { + SMqClientVg* pVg = pollRspWrapper->vgHandle; + /*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, + * rspMsg->msg.rspOffset);*/ + pVg->currentOffset = pollRspWrapper->taosxRsp.rspOffset; + atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); + if (pollRspWrapper->taosxRsp.blockNum == 0) { + taosFreeQitem(pollRspWrapper); + rspWrapper = NULL; + continue; + } + // build rsp + SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper); + taosFreeQitem(pollRspWrapper); + return pRsp; + } else { + tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", + pollRspWrapper->taosxRsp.head.epoch, consumerEpoch); + taosFreeQitem(pollRspWrapper); + } } else { /*printf("handle ep rsp %d\n", rspMsg->head.mqMsgType);*/ bool reset = false; @@ -1707,9 +1769,11 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) { } else if (TD_RES_TMQ_META(res)) { SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; if (pMetaRspObj->metaRsp.resMsgType == TDMT_VND_DELETE) { - return TMQ_RES_DATA; + return TMQ_RES_TAOSX; } return TMQ_RES_TABLE_META; + } else if (TD_RES_TMQ_TAOSX(res)) { + return TMQ_RES_DATA; } else { return TMQ_RES_INVALID; } diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 9ca896c9ee624740b0602f35544219425db74779..61fc530f575c7ce1b0789e1b24da3f554e9eedfe 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -90,7 +90,7 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, - {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, {.name = "retentions", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true}, @@ -102,6 +102,7 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "wal_retention_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true}, {.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "wal_segment_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true}, + {.name = "sst_trigger", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, }; static const SSysDbTableSchema userFuncSchema[] = { @@ -206,6 +207,7 @@ static const SSysDbTableSchema vgroupsSchema[] = { {.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, @@ -240,6 +242,31 @@ static const SSysDbTableSchema variablesSchema[] = { {.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; +static const SSysDbTableSchema topicSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + // TODO config +}; + + +static const SSysDbTableSchema subscriptionSchema[] = { + {.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, +}; + +static const SSysDbTableSchema vnodesSchema[] = { + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, + {.name = "status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "dnode_ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, +}; + static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true}, {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true}, @@ -260,6 +287,10 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema), true}, {TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema), true}, {TSDB_INS_TABLE_DNODE_VARIABLES, variablesSchema, tListLen(variablesSchema), true}, + {TSDB_INS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false}, + {TSDB_INS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false}, + {TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false}, + {TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true}, }; static const SSysDbTableSchema connectionsSchema[] = { @@ -272,13 +303,6 @@ static const SSysDbTableSchema connectionsSchema[] = { {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; -static const SSysDbTableSchema topicSchema[] = { - {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, - {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - // TODO config -}; static const SSysDbTableSchema consumerSchema[] = { {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, @@ -292,13 +316,6 @@ static const SSysDbTableSchema consumerSchema[] = { {.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; -static const SSysDbTableSchema subscriptionSchema[] = { - {.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, - {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, - {.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false}, -}; - static const SSysDbTableSchema offsetSchema[] = { {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false}, @@ -345,13 +362,10 @@ static const SSysDbTableSchema appSchema[] = { static const SSysTableMeta perfsMeta[] = { {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema), false}, {TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema), false}, - {TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false}, {TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema), false}, - {TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false}, // {TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)}, {TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema), false}, // {TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema), false}, - {TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false}, {TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema), false}}; // clang-format on diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index c7f372f17b3c174290396c0e0ca49229ff8df73b..16b8e55cf7a1fe57d9e984ad6d434297794aa07d 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -140,7 +140,8 @@ int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) { return TSDB_CODE_SUCCESS; } -static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, int32_t itemLen, int32_t numOfRows) { +static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, + int32_t itemLen, int32_t numOfRows) { ASSERT(pColumnInfoData->info.bytes >= itemLen); size_t start = 1; @@ -148,21 +149,23 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren memcpy(pColumnInfoData->pData, pData, itemLen); int32_t t = 0; - int32_t count = log(numOfRows)/log(2); - while(t < count) { + int32_t count = log(numOfRows) / log(2); + while (t < count) { int32_t xlen = 1 << t; - memcpy(pColumnInfoData->pData + start * itemLen + pColumnInfoData->varmeta.length, pColumnInfoData->pData, xlen * itemLen); + memcpy(pColumnInfoData->pData + start * itemLen + pColumnInfoData->varmeta.length, pColumnInfoData->pData, + xlen * itemLen); t += 1; start += xlen; } // the tail part if (numOfRows > start) { - memcpy(pColumnInfoData->pData + start * itemLen + currentRow * itemLen, pColumnInfoData->pData, (numOfRows - start) * itemLen); + memcpy(pColumnInfoData->pData + start * itemLen + currentRow * itemLen, pColumnInfoData->pData, + (numOfRows - start) * itemLen); } if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { - for(int32_t i = 0; i < numOfRows; ++i) { + for (int32_t i = 0; i < numOfRows; ++i) { pColumnInfoData->varmeta.offset[i + currentRow] = pColumnInfoData->varmeta.length + i * itemLen; } @@ -170,7 +173,8 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren } } -int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows) { +int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, + uint32_t numOfRows) { ASSERT(pData != NULL && pColumnInfoData != NULL); int32_t len = pColumnInfoData->info.bytes; @@ -278,7 +282,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int } else { if (finalNumOfRows > *capacity || (numOfRow1 == 0 && pColumnInfoData->info.bytes != 0)) { // all data may be null, when the pColumnInfoData->info.type == 0, bytes == 0; -// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes); + // ASSERT(finalNumOfRows * pColumnInfoData->info.bytes); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes); if (tmp == NULL) { return TSDB_CODE_VND_OUT_OF_MEMORY; @@ -557,7 +561,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) { } int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { - int32_t numOfRows = *(int32_t*) buf; + int32_t numOfRows = *(int32_t*)buf; blockDataEnsureCapacity(pBlock, numOfRows); pBlock->info.rows = numOfRows; @@ -676,7 +680,8 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) { * @return */ size_t blockDataGetSerialMetaSize(uint32_t numOfCols) { - // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length | + // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column + // length | return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t); } @@ -1302,6 +1307,40 @@ int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src) { return TSDB_CODE_SUCCESS; } +SSDataBlock* createSpecialDataBlock(EStreamType type) { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + pBlock->info.hasVarCol = false; + pBlock->info.groupId = 0; + pBlock->info.rows = 0; + pBlock->info.type = type; + pBlock->info.rowSize = + sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY); + pBlock->info.watermark = INT64_MIN; + + pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData)); + SColumnInfoData infoData = {0}; + infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP; + infoData.info.bytes = sizeof(TSKEY); + // window start ts + taosArrayPush(pBlock->pDataBlock, &infoData); + // window end ts + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_UBIGINT; + infoData.info.bytes = sizeof(uint64_t); + // uid + taosArrayPush(pBlock->pDataBlock, &infoData); + // group id + taosArrayPush(pBlock->pDataBlock, &infoData); + + // calculate start ts + taosArrayPush(pBlock->pDataBlock, &infoData); + // calculate end ts + taosArrayPush(pBlock->pDataBlock, &infoData); + + return pBlock; +} + SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) { if (pDataBlock == NULL) { return NULL; @@ -1426,7 +1465,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { } void colDataDestroy(SColumnInfoData* pColData) { - if(!pColData) return; + if (!pColData) return; if (IS_VAR_DATA_TYPE(pColData->info.type)) { taosMemoryFreeClear(pColData->varmeta.offset); } else { @@ -1693,7 +1732,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { } struct tm ptm = {0}; taosLocalTime(&tt, &ptm); - size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm); + size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm); if (precision == TSDB_TIME_PRECISION_NANO) { sprintf(buf + pos, ".%09d", ms); @@ -1847,20 +1886,20 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) break; case TSDB_DATA_TYPE_VARCHAR: { memset(pBuf, 0, sizeof(pBuf)); - char* pData = colDataGetVarData(pColInfoData, j); + char* pData = colDataGetVarData(pColInfoData, j); int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData)); memcpy(pBuf, varDataVal(pData), dataSize); len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf); if (len >= size - 1) return dumpBuf; - } break; + } break; case TSDB_DATA_TYPE_NCHAR: { - char* pData = colDataGetVarData(pColInfoData, j); + char* pData = colDataGetVarData(pColInfoData, j); int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData)); memset(pBuf, 0, sizeof(pBuf)); - taosUcs4ToMbs((TdUcs4 *)varDataVal(pData), dataSize, pBuf); + taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf); len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf); if (len >= size - 1) return dumpBuf; - } break; + } break; } } len += snprintf(dumpBuf + len, size - len, "\n"); @@ -1877,7 +1916,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) * @param pDataBlocks * @param vgId * @param suid - * + * */ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlock, STSchema* pTSchema, int32_t vgId, tb_uid_t suid) { @@ -1904,8 +1943,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB tdSRowInit(&rb, pTSchema->version); for (int32_t i = 0; i < sz; ++i) { - int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); - int32_t rows = pDataBlock->info.rows; + int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); + int32_t rows = pDataBlock->info.rows; // int32_t rowSize = pDataBlock->info.rowSize; // int64_t groupId = pDataBlock->info.groupId; @@ -1926,7 +1965,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB msgLen += sizeof(SSubmitBlk); int32_t dataLen = 0; - for (int32_t j = 0; j < rows; ++j) { // iterate by row + for (int32_t j = 0; j < rows; ++j) { // iterate by row tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen + dataLen)); // set row buf bool isStartKey = false; int32_t offset = 0; @@ -2081,6 +2120,7 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_ int32_t* rows = (int32_t*)data; *rows = pBlock->info.rows; data += sizeof(int32_t); + ASSERT(*rows > 0); int32_t* cols = (int32_t*)data; *cols = numOfCols; @@ -2089,7 +2129,7 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_ // flag segment. // the inital bit is for column info int32_t* flagSegment = (int32_t*)data; - *flagSegment = (1<<31); + *flagSegment = (1 << 31); data += sizeof(int32_t); @@ -2144,12 +2184,14 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_ *actualLen = *dataLen; *groupId = pBlock->info.groupId; + ASSERT(*dataLen > 0); + uDebug("build data block, actualLen:%d, rows:%d, cols:%d", *dataLen, *rows, *cols); } const char* blockDecode(SSDataBlock* pBlock, const char* pData) { const char* pStart = pData; - int32_t version = *(int32_t*) pStart; + int32_t version = *(int32_t*)pStart; pStart += sizeof(int32_t); ASSERT(version == 1); @@ -2158,7 +2200,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) { pStart += sizeof(int32_t); // total rows sizeof(int32_t) - int32_t numOfRows = *(int32_t*)pStart; + int32_t numOfRows = *(int32_t*)pStart; pStart += sizeof(int32_t); // total columns sizeof(int32_t) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index ee9d75155563a9892ce952e50032b47e5b5c1eb5..c436e4ffd2ef8f68ea9a13484d5f167529614c9f 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -91,6 +91,7 @@ bool tsSmlDataFormat = // query int32_t tsQueryPolicy = 1; int32_t tsQuerySmaOptimize = 0; +bool tsQueryPlannerTrace = false; /* * denote if the server needs to compress response message at the application layer to client, including query rsp, @@ -128,10 +129,6 @@ int32_t tsMinIntervalTime = 1; int32_t tsQueryBufferSize = -1; int64_t tsQueryBufferSizeBytes = -1; -// tsdb config -// For backward compatibility -bool tsdbForceKeepFile = false; - int32_t tsDiskCfgNum = 0; SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0}; @@ -286,6 +283,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "compressColData", tsCompressColData, -1, 100000000, 1) != 0) return -1; if (cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 3, 1) != 0) return -1; if (cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, 1) != 0) return -1; + if (cfgAddBool(pCfg, "queryPlannerTrace", tsQueryPlannerTrace, true) != 0) return -1; if (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; @@ -427,6 +425,151 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { return 0; } +static int32_t taosUpdateServerCfg(SConfig *pCfg) { + SConfigItem *pItem; + ECfgSrcType stype; + int32_t numOfCores; + int64_t totalMemoryKB; + + pItem = cfgGetItem(tsCfg, "numOfCores"); + if (pItem == NULL) { + return -1; + } else { + stype = pItem->stype; + numOfCores = pItem->fval; + } + + pItem = cfgGetItem(tsCfg, "supportVnodes"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfSupportVnodes = numOfCores * 2; + tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2); + pItem->i32 = tsNumOfSupportVnodes; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfRpcThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfRpcThreads = numOfCores / 2; + tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, 4); + pItem->i32 = tsNumOfRpcThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfCommitThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfCommitThreads = numOfCores / 2; + tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4); + pItem->i32 = tsNumOfCommitThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfMnodeReadThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfMnodeReadThreads = numOfCores / 8; + tsNumOfMnodeReadThreads = TRANGE(tsNumOfMnodeReadThreads, 1, 4); + pItem->i32 = tsNumOfMnodeReadThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeQueryThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeQueryThreads = numOfCores * 2; + tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4); + pItem->i32 = tsNumOfVnodeQueryThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeStreamThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeStreamThreads = numOfCores / 4; + tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4); + pItem->i32 = tsNumOfVnodeStreamThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeFetchThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeFetchThreads = numOfCores / 4; + tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4); + pItem->i32 = tsNumOfVnodeFetchThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeWriteThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeWriteThreads = numOfCores; + tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1); + pItem->i32 = tsNumOfVnodeWriteThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeSyncThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeSyncThreads = numOfCores * 2; + tsNumOfVnodeSyncThreads = TMAX(tsNumOfVnodeSyncThreads, 16); + pItem->i32 = tsNumOfVnodeSyncThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfVnodeRsmaThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfVnodeRsmaThreads = numOfCores; + tsNumOfVnodeRsmaThreads = TMAX(tsNumOfVnodeRsmaThreads, 4); + pItem->i32 = tsNumOfVnodeRsmaThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfQnodeQueryThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfQnodeQueryThreads = numOfCores * 2; + tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4); + pItem->i32 = tsNumOfQnodeQueryThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfQnodeFetchThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfQnodeFetchThreads = numOfCores / 2; + tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); + pItem->i32 = tsNumOfQnodeFetchThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfSnodeSharedThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfSnodeSharedThreads = numOfCores / 4; + tsNumOfSnodeSharedThreads = TRANGE(tsNumOfSnodeSharedThreads, 2, 4); + pItem->i32 = tsNumOfSnodeSharedThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "numOfSnodeUniqueThreads"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsNumOfSnodeUniqueThreads = numOfCores / 4; + tsNumOfSnodeUniqueThreads = TRANGE(tsNumOfSnodeUniqueThreads, 2, 4); + pItem->i32 = tsNumOfSnodeUniqueThreads; + pItem->stype = stype; + } + + pItem = cfgGetItem(tsCfg, "totalMemoryKB"); + if (pItem == NULL) { + return -1; + } else { + stype = pItem->stype; + totalMemoryKB = pItem->i64; + } + + pItem = cfgGetItem(tsCfg, "rpcQueueMemoryAllowed"); + if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { + tsRpcQueueMemoryAllowed = totalMemoryKB * 1024 * 0.1; + tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL); + pItem->i64 = tsRpcQueueMemoryAllowed; + pItem->stype = stype; + } + + return 0; +} + static void taosSetClientLogCfg(SConfig *pCfg) { SConfigItem *pItem = cfgGetItem(pCfg, "logDir"); tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX); @@ -497,6 +640,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32; tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; + tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; return 0; } @@ -826,6 +970,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32; } else if (strcasecmp("qDebugFlag", name) == 0) { qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32; + } else if (strcasecmp("queryPlannerTrace", name) == 0) { + tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; } break; } @@ -981,9 +1127,9 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi taosSetServerLogCfg(pCfg); } - taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32); + taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32, false); - if (taosMulMkDir(tsLogDir) != 0) { + if (taosMulModeMkDir(tsLogDir, 0777) != 0) { uError("failed to create dir:%s since %s", tsLogDir, terrstr()); cfgCleanup(pCfg); return -1; @@ -1048,6 +1194,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile if (taosSetClientCfg(tsCfg)) return -1; } else { if (taosSetClientCfg(tsCfg)) return -1; + if (taosUpdateServerCfg(tsCfg)) return -1; if (taosSetServerCfg(tsCfg)) return -1; if (taosSetTfsCfg(tsCfg) != 0) return -1; } @@ -1072,7 +1219,7 @@ void taosCleanupCfg() { void taosCfgDynamicOptions(const char *option, const char *value) { if (strncasecmp(option, "debugFlag", 9) == 0) { int32_t flag = atoi(value); - taosSetAllDebugFlag(flag); + taosSetAllDebugFlag(flag, true); return; } @@ -1094,14 +1241,14 @@ void taosCfgDynamicOptions(const char *option, const char *value) { } const char *options[] = { - "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", - "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", - "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", + "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", "tqDebugFlag", + "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", + "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag", "jniDebugFlag", }; int32_t *optionVars[] = { - &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, - &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, - &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag, + &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, &tqDebugFlag, + &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, &tmrDebugFlag, &uDebugFlag, + &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag, &jniDebugFlag, }; int32_t optionSize = tListLen(options); @@ -1113,41 +1260,42 @@ void taosCfgDynamicOptions(const char *option, const char *value) { int32_t flag = atoi(value); uInfo("%s set from %d to %d", optName, *optionVars[d], flag); *optionVars[d] = flag; - taosSetDebugFlag(optionVars[d], optName, flag); + taosSetDebugFlag(optionVars[d], optName, flag, true); return; } uError("failed to cfg dynamic option:%s value:%s", option, value); } -void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal) { +void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal, bool rewrite) { SConfigItem *pItem = cfgGetItem(tsCfg, flagName); - if (pItem != NULL) { + if (pItem != NULL && (rewrite || pItem->i32 == 0)) { pItem->i32 = flagVal; } *pFlagPtr = flagVal; } -void taosSetAllDebugFlag(int32_t flag) { +void taosSetAllDebugFlag(int32_t flag, bool rewrite) { if (flag <= 0) return; - taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag); - taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag); - taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag); - taosSetDebugFlag(&qDebugFlag, "qDebugFlag", flag); - taosSetDebugFlag(&cDebugFlag, "cDebugFlag", flag); - taosSetDebugFlag(&dDebugFlag, "dDebugFlag", flag); - taosSetDebugFlag(&vDebugFlag, "vDebugFlag", flag); - taosSetDebugFlag(&mDebugFlag, "mDebugFlag", flag); - taosSetDebugFlag(&wDebugFlag, "wDebugFlag", flag); - taosSetDebugFlag(&sDebugFlag, "sDebugFlag", flag); - taosSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag); - taosSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag); - taosSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag); - taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag); - taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); - taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); - taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag); - taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag); + taosSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, rewrite); + taosSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, rewrite); + taosSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, rewrite); + taosSetDebugFlag(&qDebugFlag, "qDebugFlag", flag, rewrite); + taosSetDebugFlag(&cDebugFlag, "cDebugFlag", flag, rewrite); + taosSetDebugFlag(&dDebugFlag, "dDebugFlag", flag, rewrite); + taosSetDebugFlag(&vDebugFlag, "vDebugFlag", flag, rewrite); + taosSetDebugFlag(&mDebugFlag, "mDebugFlag", flag, rewrite); + taosSetDebugFlag(&wDebugFlag, "wDebugFlag", flag, rewrite); + taosSetDebugFlag(&sDebugFlag, "sDebugFlag", flag, rewrite); + taosSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag, rewrite); + taosSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag, rewrite); + taosSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag, rewrite); + taosSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag, rewrite); + taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag, rewrite); + taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, rewrite); + taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, rewrite); + taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite); + taosSetDebugFlag(&metaDebugFlag, "tmrDebugFlag", flag, rewrite); uInfo("all debug flag are set to %d", flag); } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 8dc4931573a131f0b3873f0fc2364c96c73d6db3..c08817aaf495a04813886571304d874d78f08896 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -994,6 +994,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i); if (tEncodeI32(&encoder, pload->vgId) < 0) return -1; if (tEncodeI32(&encoder, pload->syncState) < 0) return -1; + if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1; if (tEncodeI64(&encoder, pload->totalStorage) < 0) return -1; @@ -1063,6 +1064,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { SVnodeLoad vload = {0}; if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1; if (tDecodeI32(&decoder, &vload.syncState) < 0) return -1; + if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1; if (tDecodeI64(&decoder, &vload.totalStorage) < 0) return -1; @@ -2024,6 +2026,9 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI64(&encoder, pReq->walRetentionSize) < 0) return -1; if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1; if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1; + if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1; + if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1; + if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1; if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1; for (int32_t i = 0; i < pReq->numOfRetensions; ++i) { @@ -2070,6 +2075,9 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) if (tDecodeI64(&decoder, &pReq->walRetentionSize) < 0) return -1; if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1; if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1; + if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1; + if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1; if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1; pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention)); @@ -2120,6 +2128,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1; if (tEncodeI8(&encoder, pReq->replications) < 0) return -1; + if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -2146,6 +2155,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1; if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); @@ -3330,7 +3340,7 @@ int32_t tDeserializeSSTbHbRsp(void *buf, int32_t bufLen, SSTbHbRsp *pRsp) { return 0; } -void tFreeSTableMetaRsp(void *pRsp) { taosMemoryFreeClear(((STableMetaRsp*)pRsp)->pSchemas); } +void tFreeSTableMetaRsp(void *pRsp) { taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pSchemas); } void tFreeSTableIndexRsp(void *info) { if (NULL == info) { @@ -3762,6 +3772,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR if (tEncodeI64(&encoder, pReq->walRetentionSize) < 0) return -1; if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1; if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1; + if (tEncodeI16(&encoder, pReq->sstTrigger) < 0) return -1; + if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1; + if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1; tEndEncode(&encoder); @@ -3834,6 +3847,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * if (tDecodeI64(&decoder, &pReq->walRetentionSize) < 0) return -1; if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1; if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1; + if (tDecodeI16(&decoder, &pReq->sstTrigger) < 0) return -1; + if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1; + if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); @@ -5119,17 +5135,17 @@ int tDecodeSVCreateTbRsp(SDecoder *pCoder, SVCreateTbRsp *pRsp) { } else { pRsp->pMeta = NULL; } - + tEndDecode(pCoder); return 0; } -void tFreeSVCreateTbRsp(void* param) { +void tFreeSVCreateTbRsp(void *param) { if (NULL == param) { return; } - - SVCreateTbRsp* pRsp = (SVCreateTbRsp*)param; + + SVCreateTbRsp *pRsp = (SVCreateTbRsp *)param; if (pRsp->pMeta) { taosMemoryFree(pRsp->pMeta->pSchemas); taosMemoryFree(pRsp->pMeta); @@ -5141,6 +5157,7 @@ static int32_t tEncodeSVDropTbReq(SEncoder *pCoder, const SVDropTbReq *pReq) { if (tStartEncode(pCoder) < 0) return -1; if (tEncodeCStr(pCoder, pReq->name) < 0) return -1; + if (tEncodeU64(pCoder, pReq->suid) < 0) return -1; if (tEncodeI8(pCoder, pReq->igNotExists) < 0) return -1; tEndEncode(pCoder); @@ -5151,6 +5168,7 @@ static int32_t tDecodeSVDropTbReq(SDecoder *pCoder, SVDropTbReq *pReq) { if (tStartDecode(pCoder) < 0) return -1; if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1; + if (tDecodeU64(pCoder, &pReq->suid) < 0) return -1; if (tDecodeI8(pCoder, &pReq->igNotExists) < 0) return -1; tEndDecode(pCoder); @@ -5345,7 +5363,7 @@ static int32_t tDecodeSSubmitBlkRsp(SDecoder *pDecoder, SSubmitBlkRsp *pBlock) { if (tDecodeI32v(pDecoder, &pBlock->numOfRows) < 0) return -1; if (tDecodeI32v(pDecoder, &pBlock->affectedRows) < 0) return -1; if (tDecodeI64v(pDecoder, &pBlock->sver) < 0) return -1; - + int32_t meta = 0; if (tDecodeI32(pDecoder, &meta) < 0) return -1; if (meta) { @@ -5393,12 +5411,12 @@ int32_t tDecodeSSubmitRsp(SDecoder *pDecoder, SSubmitRsp *pRsp) { return 0; } -void tFreeSSubmitBlkRsp(void* param) { +void tFreeSSubmitBlkRsp(void *param) { if (NULL == param) { return; } - - SSubmitBlkRsp* pRsp = (SSubmitBlkRsp*)param; + + SSubmitBlkRsp *pRsp = (SSubmitBlkRsp *)param; taosMemoryFree(pRsp->tblFName); if (pRsp->pMeta) { @@ -5407,7 +5425,6 @@ void tFreeSSubmitBlkRsp(void* param) { } } - void tFreeSSubmitRsp(SSubmitRsp *pRsp) { if (NULL == pRsp) return; @@ -5619,7 +5636,6 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp *pRsp) { } } - int32_t tEncodeSMCreateStbRsp(SEncoder *pEncoder, const SMCreateStbRsp *pRsp) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->pMeta->pSchemas ? 1 : 0) < 0) return -1; @@ -5671,8 +5687,6 @@ void tFreeSMCreateStbRsp(SMCreateStbRsp *pRsp) { } } - - int32_t tEncodeSTqOffsetVal(SEncoder *pEncoder, const STqOffsetVal *pOffsetVal) { if (tEncodeI8(pEncoder, pOffsetVal->type) < 0) return -1; if (pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_META) { @@ -5690,7 +5704,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder *pEncoder, const STqOffsetVal *pOffsetVal) int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) { if (tDecodeI8(pDecoder, &pOffsetVal->type) < 0) return -1; - if (pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_META) { + if (pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pOffsetVal->type == TMQ_OFFSET__SNAPSHOT_META) { if (tDecodeI64(pDecoder, &pOffsetVal->uid) < 0) return -1; if (tDecodeI64(pDecoder, &pOffsetVal->ts) < 0) return -1; } else if (pOffsetVal->type == TMQ_OFFSET__LOG) { @@ -5712,7 +5726,7 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { snprintf(buf, maxLen, "offset(reset to latest)"); } else if (pVal->type == TMQ_OFFSET__LOG) { snprintf(buf, maxLen, "offset(log) ver:%" PRId64, pVal->version); - } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) { + } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) { snprintf(buf, maxLen, "offset(ss data) uid:%" PRId64 ", ts:%" PRId64, pVal->uid, pVal->ts); } else { ASSERT(0); @@ -5813,17 +5827,17 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) { return 0; } -int32_t tEncodeSMqMetaRsp(SEncoder* pEncoder, const SMqMetaRsp* pRsp) { +int32_t tEncodeSMqMetaRsp(SEncoder *pEncoder, const SMqMetaRsp *pRsp) { if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1; - if(tEncodeI16(pEncoder, pRsp->resMsgType)) return -1; - if(tEncodeBinary(pEncoder, pRsp->metaRsp, pRsp->metaRspLen)) return -1; + if (tEncodeI16(pEncoder, pRsp->resMsgType)) return -1; + if (tEncodeBinary(pEncoder, pRsp->metaRsp, pRsp->metaRspLen)) return -1; return 0; } -int32_t tDecodeSMqMetaRsp(SDecoder* pDecoder, SMqMetaRsp* pRsp) { +int32_t tDecodeSMqMetaRsp(SDecoder *pDecoder, SMqMetaRsp *pRsp) { if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1; if (tDecodeI16(pDecoder, &pRsp->resMsgType) < 0) return -1; - if (tDecodeBinaryAlloc(pDecoder, &pRsp->metaRsp, (uint64_t*)&pRsp->metaRspLen) < 0) return -1; + if (tDecodeBinaryAlloc(pDecoder, &pRsp->metaRsp, (uint64_t *)&pRsp->metaRspLen) < 0) return -1; return 0; } @@ -5893,6 +5907,110 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { return 0; } +void tDeleteSMqDataRsp(SMqDataRsp *pRsp) { + taosArrayDestroy(pRsp->blockDataLen); + taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); + taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSSchemaWrapper); + taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree); +} + +int32_t tEncodeSTaosxRsp(SEncoder *pEncoder, const STaosxRsp *pRsp) { + if (tEncodeSTqOffsetVal(pEncoder, &pRsp->reqOffset) < 0) return -1; + if (tEncodeSTqOffsetVal(pEncoder, &pRsp->rspOffset) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->blockNum) < 0) return -1; + if (pRsp->blockNum != 0) { + if (tEncodeI8(pEncoder, pRsp->withTbName) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->withSchema) < 0) return -1; + + for (int32_t i = 0; i < pRsp->blockNum; i++) { + int32_t bLen = *(int32_t *)taosArrayGet(pRsp->blockDataLen, i); + void *data = taosArrayGetP(pRsp->blockData, i); + if (tEncodeBinary(pEncoder, (const uint8_t *)data, bLen) < 0) return -1; + if (pRsp->withSchema) { + SSchemaWrapper *pSW = (SSchemaWrapper *)taosArrayGetP(pRsp->blockSchema, i); + if (tEncodeSSchemaWrapper(pEncoder, pSW) < 0) return -1; + } + if (pRsp->withTbName) { + char *tbName = (char *)taosArrayGetP(pRsp->blockTbName, i); + if (tEncodeCStr(pEncoder, tbName) < 0) return -1; + } + } + } + if (tEncodeI32(pEncoder, pRsp->createTableNum) < 0) return -1; + if (pRsp->createTableNum) { + for (int32_t i = 0; i < pRsp->createTableNum; i++) { + void *createTableReq = taosArrayGetP(pRsp->createTableReq, i); + int32_t createTableLen = *(int32_t *)taosArrayGet(pRsp->createTableLen, i); + if (tEncodeBinary(pEncoder, createTableReq, createTableLen) < 0) return -1; + } + } + return 0; +} + +int32_t tDecodeSTaosxRsp(SDecoder *pDecoder, STaosxRsp *pRsp) { + if (tDecodeSTqOffsetVal(pDecoder, &pRsp->reqOffset) < 0) return -1; + if (tDecodeSTqOffsetVal(pDecoder, &pRsp->rspOffset) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->blockNum) < 0) return -1; + if (pRsp->blockNum != 0) { + pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void *)); + pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t)); + if (tDecodeI8(pDecoder, &pRsp->withTbName) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->withSchema) < 0) return -1; + if (pRsp->withTbName) { + pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void *)); + } + if (pRsp->withSchema) { + pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void *)); + } + + for (int32_t i = 0; i < pRsp->blockNum; i++) { + void *data; + uint64_t bLen; + if (tDecodeBinaryAlloc(pDecoder, &data, &bLen) < 0) return -1; + taosArrayPush(pRsp->blockData, &data); + int32_t len = bLen; + taosArrayPush(pRsp->blockDataLen, &len); + + if (pRsp->withSchema) { + SSchemaWrapper *pSW = (SSchemaWrapper *)taosMemoryCalloc(1, sizeof(SSchemaWrapper)); + if (pSW == NULL) return -1; + if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; + taosArrayPush(pRsp->blockSchema, &pSW); + } + + if (pRsp->withTbName) { + char *tbName; + if (tDecodeCStrAlloc(pDecoder, &tbName) < 0) return -1; + taosArrayPush(pRsp->blockTbName, &tbName); + } + } + } + if (tDecodeI32(pDecoder, &pRsp->createTableNum) < 0) return -1; + if (pRsp->createTableNum) { + pRsp->createTableLen = taosArrayInit(pRsp->createTableNum, sizeof(int32_t)); + pRsp->createTableReq = taosArrayInit(pRsp->createTableNum, sizeof(void *)); + for (int32_t i = 0; i < pRsp->createTableNum; i++) { + void *pCreate = NULL; + uint64_t len; + if (tDecodeBinaryAlloc(pDecoder, &pCreate, &len) < 0) return -1; + int32_t l = (int32_t)len; + taosArrayPush(pRsp->createTableLen, &l); + taosArrayPush(pRsp->createTableReq, &pCreate); + } + } + return 0; +} + +void tDeleteSTaosxRsp(STaosxRsp *pRsp) { + taosArrayDestroy(pRsp->blockDataLen); + taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); + taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSSchemaWrapper); + taosArrayDestroyP(pRsp->blockTbName, (FDelete)taosMemoryFree); + + taosArrayDestroy(pRsp->createTableLen); + taosArrayDestroyP(pRsp->createTableReq, (FDelete)taosMemoryFree); +} + int32_t tEncodeSSingleDeleteReq(SEncoder *pEncoder, const SSingleDeleteReq *pReq) { if (tEncodeI64(pEncoder, pReq->uid) < 0) return -1; if (tEncodeI64(pEncoder, pReq->ts) < 0) return -1; diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 565498a47bb28bc5e76bb5a33911c86f8f42da5d..9880fe362eb55e909842cb0e9aec007667426c71 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -538,12 +538,12 @@ bool tdSTSRowIterGetTpVal(STSRowIter *pIter, col_type_t colType, int32_t offset, } else { pVal->val = POINTER_SHIFT(TD_ROW_DATA(pRow), offset); } - return TSDB_CODE_SUCCESS; + return true; } if (tdGetBitmapValType(pIter->pBitmap, pIter->colIdx - 1, &pVal->valType, 0) != TSDB_CODE_SUCCESS) { pVal->valType = TD_VTYPE_NONE; - return terrno; + return true; } if (pVal->valType == TD_VTYPE_NORM) { diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 0810be149716e58fdac74b67db6946fde7db62e9..a01c393441c0a4b6945226ba2c77ffe1a23ced57 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -155,8 +155,8 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin void taosVariantDestroy(SVariant *pVar) { if (pVar == NULL) return; - if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR - || pVar->nType == TSDB_DATA_TYPE_JSON) { + if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR || + pVar->nType == TSDB_DATA_TYPE_JSON) { taosMemoryFreeClear(pVar->pz); pVar->nLen = 0; } @@ -185,8 +185,8 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { if (pSrc == NULL || pDst == NULL) return; pDst->nType = pSrc->nType; - if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR - || pSrc->nType == TSDB_DATA_TYPE_JSON) { + if (pSrc->nType == TSDB_DATA_TYPE_BINARY || pSrc->nType == TSDB_DATA_TYPE_NCHAR || + pSrc->nType == TSDB_DATA_TYPE_JSON) { int32_t len = pSrc->nLen + TSDB_NCHAR_SIZE; char *p = taosMemoryRealloc(pDst->pz, len); assert(p); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index e610b41a04dc7792638a251fa379bcacb37e0050..830bf9523a60e703f797ab60160717d39c0e615f 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -167,9 +167,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->walCfg.segSize = pCreate->walSegmentSize; pCfg->walCfg.level = pCreate->walLevel; + pCfg->sstTrigger = pCreate->sstTrigger; pCfg->hashBegin = pCreate->hashBegin; pCfg->hashEnd = pCreate->hashEnd; pCfg->hashMethod = pCreate->hashMethod; + pCfg->hashPrefix = pCreate->hashPrefix; + pCfg->hashSuffix = pCreate->hashSuffix; pCfg->standby = pCfg->standby; pCfg->syncCfg.myIndex = pCreate->selfIndex; @@ -219,8 +222,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - dDebug("vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d", createReq.vgId, - createReq.isTsma, createReq.standby, createReq.cacheLast, createReq.cacheLastSize); + dInfo("vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d", + createReq.vgId, createReq.isTsma, createReq.standby, createReq.cacheLast, createReq.cacheLastSize, + createReq.sstTrigger); + dInfo("vgId:%d, hashMethod:%d begin:%u end:%u prefix:%d surfix:%d", createReq.vgId, createReq.hashMethod, + createReq.hashBegin, createReq.hashEnd, createReq.hashPrefix, createReq.hashSuffix); vmGenerateVnodeCfg(&createReq, &vnodeCfg); if (vmTsmaAdjustDays(&vnodeCfg, &createReq) < 0) { diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index a059db6b00b7896289346eae0016dedfe95db400..b91b82b72e9cfd730bba4382136d427c215bf844 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -301,7 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; - strncpy(rpcInit.localFqdn, tsLocalFqdn, strlen(tsLocalFqdn)); + strncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN); rpcInit.localPort = tsServerPort; rpcInit.label = "DND-S"; rpcInit.numOfThreads = tsNumOfRpcThreads; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index ea05215fe90d30708013fe4b1c8fc08d2be8d3d6..9632be1b24ba4561804a1f7ec0e7bf1205f23e4c 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -305,11 +305,14 @@ typedef struct { int8_t hashMethod; // default is 1 int8_t cacheLast; int8_t schemaless; + int16_t hashPrefix; + int16_t hashSuffix; + int16_t sstTrigger; int32_t numOfRetensions; SArray* pRetensions; int32_t walRetentionPeriod; - int64_t walRetentionSize; int32_t walRollPeriod; + int64_t walRetentionSize; int64_t walSegmentSize; } SDbCfg; @@ -340,6 +343,7 @@ typedef struct { uint32_t hashEnd; char dbName[TSDB_DB_FNAME_LEN]; int64_t dbUid; + int64_t cacheUsage; int64_t numOfTables; int64_t numOfTimeSeries; int64_t totalStorage; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 8c1c3ba8735f21684b5f9577b9fad20beec110a7..77c9d0bb791ecf7e81fc9a40a4bb0f7dc6028652 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -30,7 +30,7 @@ #include "systable.h" #define DB_VER_NUMBER 1 -#define DB_RESERVE_SIZE 64 +#define DB_RESERVE_SIZE 58 static SSdbRaw *mndDbActionEncode(SDbObj *pDb); static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw); @@ -124,6 +124,9 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT64(pRaw, dataPos, pDb->cfg.walRetentionSize, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.walRollPeriod, _OVER) SDB_SET_INT64(pRaw, dataPos, pDb->cfg.walSegmentSize, _OVER) + SDB_SET_INT16(pRaw, dataPos, pDb->cfg.sstTrigger, _OVER) + SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashPrefix, _OVER) + SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashSuffix, _OVER) SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -207,6 +210,9 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pDb->cfg.walRetentionSize, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.walRollPeriod, _OVER) SDB_GET_INT64(pRaw, dataPos, &pDb->cfg.walSegmentSize, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.sstTrigger, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashPrefix, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER) SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) taosInitRWLatch(&pDb->lock); @@ -254,6 +260,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { pOld->cfg.strict = pNew->cfg.strict; pOld->cfg.cacheLast = pNew->cfg.cacheLast; pOld->cfg.replications = pNew->cfg.replications; + pOld->cfg.sstTrigger = pNew->cfg.sstTrigger; taosWUnLockLatch(&pOld->lock); return 0; } @@ -330,6 +337,9 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return -1; if (pCfg->walRollPeriod < TSDB_DB_MIN_WAL_ROLL_PERIOD) return -1; if (pCfg->walSegmentSize < TSDB_DB_MIN_WAL_SEGMENT_SIZE) return -1; + if (pCfg->sstTrigger < TSDB_MIN_SST_TRIGGER || pCfg->sstTrigger > TSDB_MAX_SST_TRIGGER) return -1; + if (pCfg->hashPrefix < TSDB_MIN_HASH_PREFIX || pCfg->hashPrefix > TSDB_MAX_HASH_PREFIX) return -1; + if (pCfg->hashSuffix < TSDB_MIN_HASH_SUFFIX || pCfg->hashSuffix > TSDB_MAX_HASH_SUFFIX) return -1; terrno = 0; return terrno; @@ -358,11 +368,14 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0; if (pCfg->schemaless < 0) pCfg->schemaless = TSDB_DB_SCHEMALESS_OFF; if (pCfg->walRetentionPeriod < 0 && pCfg->walRetentionPeriod != -1) - pCfg->walRetentionPeriod = TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD; + pCfg->walRetentionPeriod = TSDB_REPS_DEF_DB_WAL_RET_PERIOD; if (pCfg->walRetentionSize < 0 && pCfg->walRetentionSize != -1) - pCfg->walRetentionSize = TSDB_DEFAULT_DB_WAL_RETENTION_SIZE; - if (pCfg->walRollPeriod < 0) pCfg->walRollPeriod = TSDB_DEFAULT_DB_WAL_ROLL_PERIOD; + pCfg->walRetentionSize = TSDB_REPS_DEF_DB_WAL_RET_SIZE; + if (pCfg->walRollPeriod < 0) pCfg->walRollPeriod = TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD; if (pCfg->walSegmentSize < 0) pCfg->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE; + if (pCfg->sstTrigger <= 0) pCfg->sstTrigger = TSDB_DEFAULT_SST_TRIGGER; + if (pCfg->hashPrefix < 0) pCfg->hashPrefix = TSDB_DEFAULT_HASH_PREFIX; + if (pCfg->hashSuffix < 0) pCfg->hashSuffix = TSDB_DEFAULT_HASH_SUFFIX; } static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) { @@ -479,6 +492,9 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, .walRetentionSize = pCreate->walRetentionSize, .walRollPeriod = pCreate->walRollPeriod, .walSegmentSize = pCreate->walSegmentSize, + .sstTrigger = pCreate->sstTrigger, + .hashPrefix = pCreate->hashPrefix, + .hashSuffix = pCreate->hashSuffix, }; dbObj.cfg.numOfRetensions = pCreate->numOfRetensions; @@ -1536,6 +1552,24 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, STR_WITH_MAXSIZE_TO_VARSTR(buf, "NULL", bytes); } + const char *precStr = NULL; + switch (pDb->cfg.precision) { + case TSDB_TIME_PRECISION_MILLI: + precStr = TSDB_TIME_PRECISION_MILLI_STR; + break; + case TSDB_TIME_PRECISION_MICRO: + precStr = TSDB_TIME_PRECISION_MICRO_STR; + break; + case TSDB_TIME_PRECISION_NANO: + precStr = TSDB_TIME_PRECISION_NANO_STR; + break; + default: + precStr = "none"; + break; + } + char precVstr[10] = {0}; + STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2); + char *statusStr = "ready"; if (objStatus == SDB_STATUS_CREATING) { statusStr = "creating"; @@ -1546,7 +1580,6 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, statusStr = "unsynced"; } } - char statusVstr[24] = {0}; STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr)); @@ -1557,6 +1590,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, colDataAppend(pColInfo, rows, buf, false); } else if (i == 3) { colDataAppend(pColInfo, rows, (const char *)&numOfTables, false); + } else if (i == 14) { + colDataAppend(pColInfo, rows, precVstr, false); } else if (i == 15) { colDataAppend(pColInfo, rows, statusVstr, false); } else { @@ -1621,23 +1656,6 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false); - const char *precStr = NULL; - switch (pDb->cfg.precision) { - case TSDB_TIME_PRECISION_MILLI: - precStr = TSDB_TIME_PRECISION_MILLI_STR; - break; - case TSDB_TIME_PRECISION_MICRO: - precStr = TSDB_TIME_PRECISION_MICRO_STR; - break; - case TSDB_TIME_PRECISION_NANO: - precStr = TSDB_TIME_PRECISION_NANO_STR; - break; - default: - precStr = "none"; - break; - } - char precVstr[10] = {0}; - STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)precVstr, false); @@ -1682,6 +1700,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walSegmentSize, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.sstTrigger, false); } taosMemoryFree(buf); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index fc5e20ef288d733927499484675acddd042fb3ca..26b4080d14288bee23740394fa4e96755b90feb9 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -347,6 +347,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId); if (pVgroup != NULL) { if (pVload->syncState == TAOS_SYNC_STATE_LEADER) { + pVgroup->cacheUsage = pVload->cacheUsage; pVgroup->numOfTables = pVload->numOfTables; pVgroup->numOfTimeSeries = pVload->numOfTimeSeries; pVgroup->totalStorage = pVload->totalStorage; @@ -853,8 +854,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } int32_t code = -1; - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; while (1) { SDnodeObj *pDnode = NULL; pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode); @@ -877,7 +878,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { sdbRelease(pSdb, pDnode); } - + if (code == -1) { terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 9499c90c57c59e3600c701668dd17671f641d919..5a998dfe986d9f012e066f45810604b7ca9d728f 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -88,7 +88,7 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_VGROUP; } else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) { type = TSDB_MGMT_TABLE_CONSUMERS; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_SUBSCRIPTIONS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) { type = TSDB_MGMT_TABLE_SUBSCRIPTIONS; } else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) { type = TSDB_MGMT_TABLE_TRANS; @@ -102,9 +102,9 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_QUERIES; } else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) { type = TSDB_MGMT_TABLE_VNODES; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_TOPICS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) { type = TSDB_MGMT_TABLE_TOPICS; - } else if (strncasecmp(name, TSDB_PERFS_TABLE_STREAMS, len) == 0) { + } else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) { type = TSDB_MGMT_TABLE_STREAMS; } else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) { type = TSDB_MGMT_TABLE_APPS; diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 10e520d9ec49a53e5fcedcf668a40732480aa75b..1452c5ae2fd3e9cde7cb9052d22e10bfd31afb0f 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -287,6 +287,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR if (consumerVgNum > minVgCnt) { if (imbCnt < imbConsumerNum) { if (consumerVgNum == minVgCnt + 1) { + imbCnt++; continue; } else { // pop until equal minVg + 1 diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index ff208eae607ab0fa57be7431771f209e18e02ce5..eb072d013d0024e5b05a172c3c3d5d55ce41cd40 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -763,8 +763,9 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl int32_t cols = 0; char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&n, varDataVal(topicName)); + strcpy(varDataVal(topicName), mndGetDbStr(pTopic->name)); + /*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/ + /*tNameGetDbName(&n, varDataVal(topicName));*/ varDataSetLen(topicName, strlen(varDataVal(topicName))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)topicName, false); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 09eed7fb32e8831e6b6c863b44edd3e9e28110a3..de29dea511c169f5b584dded1c07da48b82f4552 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -234,6 +234,9 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg createReq.walRetentionSize = pDb->cfg.walRetentionSize; createReq.walRollPeriod = pDb->cfg.walRollPeriod; createReq.walSegmentSize = pDb->cfg.walSegmentSize; + createReq.sstTrigger = pDb->cfg.sstTrigger; + createReq.hashPrefix = pDb->cfg.hashPrefix; + createReq.hashSuffix = pDb->cfg.hashSuffix; for (int32_t v = 0; v < pVgroup->replica; ++v) { SReplica *pReplica = &createReq.replicas[v]; @@ -693,6 +696,9 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppendNULL(pColInfo, numOfRows); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->cacheUsage, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppendNULL(pColInfo, numOfRows); @@ -791,32 +797,43 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB if (pShow->pIter == NULL) break; for (int32_t i = 0; i < pVgroup->replica && numOfRows < rows; ++i) { - SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; + SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; + SColumnInfoData *pColInfo = NULL; cols = 0; - SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); - - SName name = {0}; - char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); - varDataSetLen(db, strlen(varDataVal(db))); - pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)db, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); - uint32_t val = 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)&val, false); + colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->replica, false); char buf[20] = {0}; STR_TO_VARSTR(buf, syncStr(pVgid->role)); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)buf, false); + const char *dbname = mndGetDbStr(pVgroup->dbName); + char b1[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + if (dbname != NULL) { + STR_WITH_MAXSIZE_TO_VARSTR(b1, dbname, TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); + } else { + STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); + } + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)b1, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pVgid->dnodeId, false); + + SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); + char b2[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; + if (pDnode != NULL) { + STR_WITH_MAXSIZE_TO_VARSTR(b2, pDnode->ep, TSDB_EP_LEN + VARSTR_HEADER_SIZE); + } else { + STR_WITH_MAXSIZE_TO_VARSTR(b2, "NULL", TSDB_EP_LEN + VARSTR_HEADER_SIZE); + } pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->replica, false); // onlines + colDataAppend(pColInfo, numOfRows, (const char *)b2, false); numOfRows++; } diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index a3e17f53774c82ea9fca1ff0a88943c8e7971725..7a99d26683bf08b2595c51ff9c34b4aea588f800 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -29,6 +29,7 @@ target_sources( # sma "src/sma/smaEnv.c" "src/sma/smaUtil.c" + "src/sma/smaFS.c" "src/sma/smaOpen.c" "src/sma/smaCommit.c" "src/sma/smaRollup.c" @@ -49,6 +50,10 @@ target_sources( "src/tsdb/tsdbSnapshot.c" "src/tsdb/tsdbCacheRead.c" "src/tsdb/tsdbRetention.c" + "src/tsdb/tsdbDiskData.c" + "src/tsdb/tsdbCompress.c" + "src/tsdb/tsdbCompact.c" + "src/tsdb/tsdbMergeTree.c" # tq "src/tq/tq.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 3a3cbe72ba15320638baeb0f5c615c4a1b7a735b..8e545eb5279ad31893af6ad72a1a091157eebf37 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -155,19 +155,20 @@ int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int6 void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity); size_t tsdbCacheGetCapacity(SVnode *pVnode); +size_t tsdbCacheGetUsage(SVnode *pVnode); // tq -typedef struct SMetaTableInfo{ +typedef struct SMetaTableInfo { int64_t suid; int64_t uid; SSchemaWrapper *schema; char tbName[TSDB_TABLE_NAME_LEN]; -}SMetaTableInfo; +} SMetaTableInfo; -typedef struct SIdInfo{ - int64_t version; - int32_t index; -}SIdInfo; +typedef struct SIdInfo { + int64_t version; + int32_t index; +} SIdInfo; typedef struct SSnapContext { SMeta *pMeta; @@ -180,8 +181,8 @@ typedef struct SSnapContext { SArray *idList; int32_t index; bool withMeta; - bool queryMetaOrData; // true-get meta, false-get data -}SSnapContext; + bool queryMetaOrData; // true-get meta, false-get data +} SSnapContext; typedef struct STqReader { int64_t ver; @@ -232,11 +233,12 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot); int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData); -int32_t buildSnapContext(SMeta* pMeta, int64_t snapVersion, int64_t suid, int8_t subType, bool withMeta, SSnapContext** ctxRet); -int32_t getMetafromSnapShot(SSnapContext* ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid); -SMetaTableInfo getUidfromSnapShot(SSnapContext* ctx); -int32_t setForSnapShot(SSnapContext* ctx, int64_t uid); -int32_t destroySnapContext(SSnapContext* ctx); +int32_t buildSnapContext(SMeta *pMeta, int64_t snapVersion, int64_t suid, int8_t subType, bool withMeta, + SSnapContext **ctxRet); +int32_t getMetafromSnapShot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid); +SMetaTableInfo getUidfromSnapShot(SSnapContext *ctx); +int32_t setForSnapShot(SSnapContext *ctx, int64_t uid); +int32_t destroySnapContext(SSnapContext *ctx); // structs struct STsdbCfg { @@ -259,6 +261,7 @@ typedef struct { int64_t numOfNTables; int64_t numOfNTimeSeries; int64_t numOfTimeSeries; + int64_t itvTimeSeries; int64_t pointsWritten; int64_t totalStorage; int64_t compStorage; @@ -285,6 +288,9 @@ struct SVnodeCfg { SVnodeStats vndStats; uint32_t hashBegin; uint32_t hashEnd; + int16_t sstTrigger; + int16_t hashPrefix; + int16_t hashSuffix; }; typedef struct { diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index abfffc045f3ba5abeac1d171e0751bfeeadcb1cb..e303faf7deee95410471266af3a32474d7991c92 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -38,9 +38,10 @@ typedef struct SSmaEnv SSmaEnv; typedef struct SSmaStat SSmaStat; typedef struct STSmaStat STSmaStat; typedef struct SRSmaStat SRSmaStat; -typedef struct SSmaKey SSmaKey; +typedef struct SRSmaRef SRSmaRef; typedef struct SRSmaInfo SRSmaInfo; typedef struct SRSmaInfoItem SRSmaInfoItem; +typedef struct SRSmaFS SRSmaFS; typedef struct SQTaskFile SQTaskFile; typedef struct SQTaskFReader SQTaskFReader; typedef struct SQTaskFWriter SQTaskFWriter; @@ -54,10 +55,21 @@ struct SSmaEnv { #define SMA_ENV_FLG_CLOSE ((int8_t)0x1) +struct SRSmaRef { + int64_t refId; // for SRSmaStat + int64_t suid; +}; + typedef struct { int8_t inited; int32_t rsetId; void *tmrHandle; // shared by all fetch tasks + /** + * @brief key: void* of SRSmaInfoItem, value: SRSmaRef + * N.B. Although there is a very small possibility that "void*" point to different objects while with the same + * address after release/renew, the functionality is not affected as it just used to fetch the rsma results. + */ + SHashObj *refHash; // shared by all vgroups } SSmaMgmt; #define SMA_ENV_LOCK(env) (&(env)->lock) @@ -73,20 +85,25 @@ struct STSmaStat { struct SQTaskFile { volatile int32_t nRef; - int64_t commitID; + int32_t padding; + int64_t version; int64_t size; }; struct SQTaskFReader { - SSma *pSma; - SQTaskFile fTask; - TdFilePtr pReadH; + SSma *pSma; + int64_t version; + TdFilePtr pReadH; }; struct SQTaskFWriter { - SSma *pSma; - SQTaskFile fTask; - TdFilePtr pWriteH; - char *fname; + SSma *pSma; + int64_t version; + TdFilePtr pWriteH; + char *fname; +}; + +struct SRSmaFS { + SArray *aQTaskInf; // array of SQTaskFile }; struct SRSmaStat { @@ -95,9 +112,10 @@ struct SRSmaStat { int64_t refId; // shared by fetch tasks volatile int64_t nBufItems; // number of items in queue buffer SRWLatch lock; // r/w lock for rsma fs(e.g. qtaskinfo) + volatile int32_t nFetchAll; // active number of fetch all int8_t triggerStat; // shared by fetch tasks int8_t commitStat; // 0 not in committing, 1 in committing - SArray *aTaskFile; // qTaskFiles committed recently(for recovery/snapshot r/w) + SRSmaFS fs; // for recovery/snapshot r/w SHashObj *infoHash; // key: suid, value: SRSmaInfo tsem_t notEmpty; // has items in queue buffer }; @@ -117,6 +135,7 @@ struct SSmaStat { #define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat) #define RSMA_COMMIT_STAT(r) (&(r)->commitStat) #define RSMA_REF_ID(r) ((r)->refId) +#define RSMA_FS(r) (&(r)->fs) #define RSMA_FS_LOCK(r) (&(r)->lock) struct SRSmaInfoItem { @@ -131,7 +150,6 @@ struct SRSmaInfoItem { struct SRSmaInfo { STSchema *pTSchema; int64_t suid; - int64_t refId; // refId of SRSmaStat int64_t lastRecv; // ms int8_t assigned; // 0 idle, 1 assgined for exec int8_t delFlag; @@ -162,14 +180,6 @@ enum { TASK_TRIGGER_STAT_DROPPED = 5, }; -enum { - RSMA_ROLE_CREATE = 0, - RSMA_ROLE_DROP = 1, - RSMA_ROLE_SUBMIT = 2, - RSMA_ROLE_FETCH = 3, - RSMA_ROLE_ITERATE = 4, -}; - enum { RSMA_RESTORE_REBOOT = 1, RSMA_RESTORE_SYNC = 2, @@ -181,88 +191,34 @@ typedef enum { RSMA_EXEC_COMMIT = 3, // triggered by commit } ERsmaExecType; -void tdDestroySmaEnv(SSmaEnv *pSmaEnv); -void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); - -int32_t tdDropTSma(SSma *pSma, char *pMsg); -int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid); -int32_t tdInsertRSmaData(SSma *pSma, char *msg); - +// sma +int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType); +void tdDestroySmaEnv(SSmaEnv *pSmaEnv); +void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat); int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat); -int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo); -int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo); - -void *tdAcquireSmaRef(int32_t rsetId, int64_t refId); -int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId); - -int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType); - int32_t tdLockSma(SSma *pSma); int32_t tdUnLockSma(SSma *pSma); +void *tdAcquireSmaRef(int32_t rsetId, int64_t refId); +int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId); -static FORCE_INLINE int8_t tdSmaStat(STSmaStat *pTStat) { - if (pTStat) { - return atomic_load_8(&pTStat->state); - } - return TSDB_SMA_STAT_UNKNOWN; -} - -static FORCE_INLINE bool tdSmaStatIsOK(STSmaStat *pTStat, int8_t *state) { - if (!pTStat) { - return false; - } - - if (state) { - *state = atomic_load_8(&pTStat->state); - return *state == TSDB_SMA_STAT_OK; - } - return atomic_load_8(&pTStat->state) == TSDB_SMA_STAT_OK; -} - -static FORCE_INLINE bool tdSmaStatIsExpired(STSmaStat *pTStat) { - return pTStat ? (atomic_load_8(&pTStat->state) & TSDB_SMA_STAT_EXPIRED) : true; -} - -static FORCE_INLINE bool tdSmaStatIsDropped(STSmaStat *pTStat) { - return pTStat ? (atomic_load_8(&pTStat->state) & TSDB_SMA_STAT_DROPPED) : true; -} - -static FORCE_INLINE void tdSmaStatSetOK(STSmaStat *pTStat) { - if (pTStat) { - atomic_store_8(&pTStat->state, TSDB_SMA_STAT_OK); - } -} - -static FORCE_INLINE void tdSmaStatSetExpired(STSmaStat *pTStat) { - if (pTStat) { - atomic_or_fetch_8(&pTStat->state, TSDB_SMA_STAT_EXPIRED); - } -} - -static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) { - if (pTStat) { - atomic_or_fetch_8(&pTStat->state, TSDB_SMA_STAT_DROPPED); - } -} - -void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName); -void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName); -int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pInfo); -void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level); -static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); -void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); -void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree); -int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); -int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type); - -int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); -int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer); -int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer); - -int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); -int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); -int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); +// rsma +int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo); +int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo); +void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree); +int32_t tdRSmaFSOpen(SSma *pSma, int64_t version); +void tdRSmaFSClose(SRSmaFS *fs); +int32_t tdRSmaFSRef(SSma *pSma, SRSmaStat *pStat, int64_t version); +void tdRSmaFSUnRef(SSma *pSma, SRSmaStat *pStat, int64_t version); +int32_t tdRSmaFSUpsertQTaskFile(SRSmaFS *pFS, SQTaskFile *qTaskFile); +int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer); +int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); +int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type); +int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); +int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer); + +void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName); +void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName); // smaFileUtil ================ diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index a97c8ff132be35cd89ae0c4b32fab7efdd85cf32..c3441a43f0e736881fc8bc491dd5717223645ed4 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -67,21 +67,21 @@ typedef struct { // tqExec typedef struct { - char* qmsg; + char* qmsg; } STqExecCol; typedef struct { - int64_t suid; + int64_t suid; } STqExecTb; typedef struct { - SHashObj* pFilterOutTbUid; + SHashObj* pFilterOutTbUid; } STqExecDb; typedef struct { int8_t subType; - STqReader* pExecReader; + STqReader* pExecReader; qTaskInfo_t task; union { STqExecCol execCol; @@ -140,11 +140,12 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle); int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle); // tqRead -int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset); +int32_t tqScan(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset); +int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset); int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum); // tqExec -int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp); +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp); int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); // tqMeta @@ -175,22 +176,6 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data); char* tqOffsetBuildFName(const char* path, int32_t ver); int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname); -static FORCE_INLINE void tqOffsetResetToData(STqOffsetVal* pOffsetVal, int64_t uid, int64_t ts) { - pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_DATA; - pOffsetVal->uid = uid; - pOffsetVal->ts = ts; -} - -static FORCE_INLINE void tqOffsetResetToMeta(STqOffsetVal* pOffsetVal, int64_t uid) { - pOffsetVal->type = TMQ_OFFSET__SNAPSHOT_META; - pOffsetVal->uid = uid; -} - -static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ver) { - pOffsetVal->type = TMQ_OFFSET__LOG; - pOffsetVal->version = ver; -} - // tqStream int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index d1f5cfb122d6fdfee2cb8f54911a07a25cbb078c..7546b0943e5642317a735626b01a2e0c393e2751 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -42,15 +42,15 @@ typedef struct SMemTable SMemTable; typedef struct STbDataIter STbDataIter; typedef struct SMapData SMapData; typedef struct SBlockIdx SBlockIdx; -typedef struct SBlock SBlock; -typedef struct SBlockL SBlockL; +typedef struct SDataBlk SDataBlk; +typedef struct SSstBlk SSstBlk; typedef struct SColData SColData; typedef struct SDiskDataHdr SDiskDataHdr; typedef struct SBlockData SBlockData; typedef struct SDelFile SDelFile; typedef struct SHeadFile SHeadFile; typedef struct SDataFile SDataFile; -typedef struct SLastFile SLastFile; +typedef struct SSstFile SSstFile; typedef struct SSmaFile SSmaFile; typedef struct SDFileSet SDFileSet; typedef struct SDataFWriter SDataFWriter; @@ -64,10 +64,13 @@ typedef struct STsdbReadSnap STsdbReadSnap; typedef struct SBlockInfo SBlockInfo; typedef struct SSmaInfo SSmaInfo; typedef struct SBlockCol SBlockCol; +typedef struct SVersionRange SVersionRange; -#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F) -#define TSDB_MAX_SUBBLOCKS 8 -#define TSDB_FHDR_SIZE 512 +#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F) +#define TSDB_MAX_SUBBLOCKS 8 +#define TSDB_MAX_LAST_FILE 16 +#define TSDB_DEFAULT_LAST_FILE 8 +#define TSDB_FHDR_SIZE 512 #define HAS_NONE ((int8_t)0x1) #define HAS_NULL ((int8_t)0x2) @@ -111,15 +114,15 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2); int32_t tPutBlockCol(uint8_t *p, void *ph); int32_t tGetBlockCol(uint8_t *p, void *ph); int32_t tBlockColCmprFn(const void *p1, const void *p2); -// SBlock -void tBlockReset(SBlock *pBlock); -int32_t tPutBlock(uint8_t *p, void *ph); -int32_t tGetBlock(uint8_t *p, void *ph); -int32_t tBlockCmprFn(const void *p1, const void *p2); -bool tBlockHasSma(SBlock *pBlock); -// SBlockL -int32_t tPutBlockL(uint8_t *p, void *ph); -int32_t tGetBlockL(uint8_t *p, void *ph); +// SDataBlk +void tDataBlkReset(SDataBlk *pBlock); +int32_t tPutDataBlk(uint8_t *p, void *ph); +int32_t tGetDataBlk(uint8_t *p, void *ph); +int32_t tDataBlkCmprFn(const void *p1, const void *p2); +bool tDataBlkHasSma(SDataBlk *pDataBlk); +// SSstBlk +int32_t tPutSstBlk(uint8_t *p, void *ph); +int32_t tGetSstBlk(uint8_t *p, void *ph); // SBlockIdx int32_t tPutBlockIdx(uint8_t *p, void *ph); int32_t tGetBlockIdx(uint8_t *p, void *ph); @@ -170,6 +173,7 @@ int32_t tGetDelData(uint8_t *p, void *ph); void tMapDataReset(SMapData *pMapData); void tMapDataClear(SMapData *pMapData); int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *)); +int32_t tMapDataCopy(SMapData *pFrom, SMapData *pTo); void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)); int32_t tMapDataSearch(SMapData *pMapData, void *pSearchItem, int32_t (*tGetItemFn)(uint8_t *, void *), int32_t (*tItemCmprFn)(const void *, const void *), void *pItem); @@ -215,7 +219,7 @@ bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2); int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype); int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile); int32_t tPutDataFile(uint8_t *p, SDataFile *pDataFile); -int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile); +int32_t tPutSstFile(uint8_t *p, SSstFile *pSstFile); int32_t tPutSmaFile(uint8_t *p, SSmaFile *pSmaFile); int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile); int32_t tGetDelFile(uint8_t *p, SDelFile *pDelFile); @@ -224,7 +228,7 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet); void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]); void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]); -void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]); +void tsdbSstFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSstFile *pSstF, char fname[]); void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]); // SDelFile void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]); @@ -250,7 +254,7 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync); int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter); int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx); int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *pMapData, SBlockIdx *pBlockIdx); -int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL); +int32_t tsdbWriteSstBlk(SDataFWriter *pWriter, SArray *aSstBlk); int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlockInfo *pBlkInfo, SSmaInfo *pSmaInfo, int8_t cmprAlg, int8_t toLast); @@ -260,10 +264,10 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS int32_t tsdbDataFReaderClose(SDataFReader **ppReader); int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx); int32_t tsdbReadBlock(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *pMapData); -int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL); -int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnDataAgg); -int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBlockData); -int32_t tsdbReadLastBlock(SDataFReader *pReader, SBlockL *pBlockL, SBlockData *pBlockData); +int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk); +int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pBlock, SArray *aColumnDataAgg); +int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pBlock, SBlockData *pBlockData); +int32_t tsdbReadSstBlock(SDataFReader *pReader, int32_t iSst, SSstBlk *pSstBlk, SBlockData *pBlockData); // SDelFWriter int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb); int32_t tsdbDelFWriterClose(SDelFWriter **ppWriter, int8_t sync); @@ -278,6 +282,8 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx); // tsdbRead.c ============================================================================================== int32_t tsdbTakeReadSnap(STsdb *pTsdb, STsdbReadSnap **ppSnap); void tsdbUntakeReadSnap(STsdb *pTsdb, STsdbReadSnap *pSnap); +// tsdbMerge.c ============================================================================================== +int32_t tsdbMerge(STsdb *pTsdb); #define TSDB_CACHE_NO(c) ((c).cacheLast == 0) #define TSDB_CACHE_LAST_ROW(c) (((c).cacheLast & 1) > 0) @@ -324,6 +330,11 @@ struct TSDBKEY { TSKEY ts; }; +struct SVersionRange { + uint64_t minVer; + uint64_t maxVer; +}; + typedef struct SMemSkipListNode SMemSkipListNode; struct SMemSkipListNode { int8_t level; @@ -416,7 +427,7 @@ struct SSmaInfo { int32_t size; }; -struct SBlock { +struct SDataBlk { TSDBKEY minKey; TSDBKEY maxKey; int64_t minVer; @@ -428,7 +439,7 @@ struct SBlock { SSmaInfo smaInfo; }; -struct SBlockL { +struct SSstBlk { int64_t suid; int64_t minUid; int64_t maxUid; @@ -467,12 +478,6 @@ struct SBlockData { SArray *aColData; // SArray }; -// ================== TSDB global config -extern bool tsdbForceKeepFile; - -#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC -#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC - struct TABLEID { tb_uid_t suid; tb_uid_t uid; @@ -536,7 +541,7 @@ struct SDataFile { int64_t size; }; -struct SLastFile { +struct SSstFile { volatile int32_t nRef; int64_t commitID; @@ -556,8 +561,9 @@ struct SDFileSet { int32_t fid; SHeadFile *pHeadF; SDataFile *pDataF; - SLastFile *pLastF; SSmaFile *pSmaF; + uint8_t nSstF; + SSstFile *aSstF[TSDB_MAX_LAST_FILE]; }; struct SRowIter { @@ -586,13 +592,13 @@ struct SDataFWriter { TdFilePtr pHeadFD; TdFilePtr pDataFD; - TdFilePtr pLastFD; TdFilePtr pSmaFD; + TdFilePtr pLastFD; SHeadFile fHead; SDataFile fData; - SLastFile fLast; SSmaFile fSma; + SSstFile fSst[TSDB_MAX_LAST_FILE]; uint8_t *aBuf[4]; }; @@ -603,6 +609,36 @@ struct STsdbReadSnap { STsdbFS fs; }; +struct SDataFReader { + STsdb *pTsdb; + SDFileSet *pSet; + TdFilePtr pHeadFD; + TdFilePtr pDataFD; + TdFilePtr pSmaFD; + TdFilePtr aLastFD[TSDB_MAX_LAST_FILE]; + + uint8_t *aBuf[3]; +}; + +typedef struct { + int64_t suid; + int64_t uid; + TSDBROW row; +} SRowInfo; + +typedef struct SMergeTree { + int8_t backward; + SRBTree rbt; + SArray *pIterList; + struct SLDataIter *pIter; +} SMergeTree; + +int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader* pFReader, uint64_t uid, STimeWindow* pTimeWindow, SVersionRange* pVerRange); +void tMergeTreeAddIter(SMergeTree *pMTree, struct SLDataIter *pIter); +bool tMergeTreeNext(SMergeTree *pMTree); +TSDBROW tMergeTreeGetRow(SMergeTree *pMTree); +void tMergeTreeClose(SMergeTree *pMTree); + // ========== inline functions ========== static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) { TSDBKEY *pKey1 = (TSDBKEY *)p1; diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 9b252df58b2a87c4baf8453ad597d62e50b61a33..93f96916758992f68c500e994ac467af24f24235 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -36,6 +36,7 @@ #include "tlosertree.h" #include "tlrucache.h" #include "tmsgcb.h" +#include "trbtree.h" #include "tref.h" #include "tskiplist.h" #include "tstream.h" @@ -70,8 +71,8 @@ typedef struct SStreamTaskReader SStreamTaskReader; typedef struct SStreamTaskWriter SStreamTaskWriter; typedef struct SStreamStateReader SStreamStateReader; typedef struct SStreamStateWriter SStreamStateWriter; -typedef struct SRsmaSnapReader SRsmaSnapReader; -typedef struct SRsmaSnapWriter SRsmaSnapWriter; +typedef struct SRSmaSnapReader SRSmaSnapReader; +typedef struct SRSmaSnapWriter SRSmaSnapWriter; typedef struct SSnapDataHdr SSnapDataHdr; #define VNODE_META_DIR "meta" @@ -102,7 +103,7 @@ int metaCommit(SMeta* pMeta); int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq); int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq); int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq, SArray* tbUidList); -int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp **pMetaRsp); +int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** pMetaRsp); int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids); int metaTtlDropTable(SMeta* pMeta, int64_t ttl, SArray* tbUids); int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp); @@ -173,7 +174,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg); // tq-stream int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen); int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen); -int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data, int64_t ver); +int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* data, int64_t ver); +int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver); int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec); int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg); @@ -246,14 +248,14 @@ int32_t tqOffsetSnapWrite(STqOffsetWriter* pWriter, uint8_t* pData, uint32_t nDa // SStreamTaskReader ====================================== // SStreamStateWriter ===================================== // SStreamStateReader ===================================== -// SRsmaSnapReader ======================================== -int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader); -int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader); -int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData); -// SRsmaSnapWriter ======================================== -int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter); -int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); -int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback); +// SRSmaSnapReader ======================================== +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapReader** ppReader); +int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader); +int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData); +// SRSmaSnapWriter ======================================== +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWriter** ppWriter); +int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback); typedef struct { int8_t streamType; // sma or other diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 9d3b4d82ebd6041d2c310e622d9ae19c57f2bfad..a34569b08ecdd87483dbf31e8c6d7e406e8ae766 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -129,10 +129,16 @@ _err: bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) { // query uid.idx + metaRLock(pMeta); + if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), NULL, NULL) < 0) { + metaULock(pMeta); + return false; } + metaULock(pMeta); + return true; } @@ -182,9 +188,14 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { } int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { + int code = 0; SMetaReader mr = {0}; metaReaderInit(&mr, (SMeta *)meta, 0); - metaGetTableEntryByUid(&mr, uid); + code = metaGetTableEntryByUid(&mr, uid); + if (code < 0) { + metaReaderClear(&mr); + return -1; + } STR_TO_VARSTR(tbName, mr.me.name); metaReaderClear(&mr); @@ -280,6 +291,38 @@ _query: tDecoderClear(&dc); goto _exit; } + { // Traverse to find the previous qualified data + TBC *pCur; + tdbTbcOpen(pMeta->pTbDb, &pCur, NULL); + STbDbKey key = {.version = sver, .uid = INT64_MAX}; + int c = 0; + tdbTbcMoveTo(pCur, &key, sizeof(key), &c); + if(c < 0){ + tdbTbcMoveToPrev(pCur); + } + + void *pKey = NULL; + void *pVal = NULL; + int vLen = 0, kLen = 0; + while(1){ + int32_t ret = tdbTbcPrev(pCur, &pKey, &kLen, &pVal, &vLen); + if (ret < 0) break; + + STbDbKey *tmp = (STbDbKey*)pKey; + if(tmp->uid != uid){ + continue; + } + SDecoder dcNew = {0}; + SMetaEntry meNew = {0}; + tDecoderInit(&dcNew, pVal, vLen); + metaDecodeEntry(&dcNew, &meNew); + pSchema = tCloneSSchemaWrapper(&meNew.stbEntry.schemaRow); + tDecoderClear(&dcNew); + tdbTbcClose(pCur); + goto _exit; + } + tdbTbcClose(pCur); + } } else if (me.type == TSDB_CHILD_TABLE) { uid = me.ctbEntry.suid; tDecoderClear(&dc); @@ -615,9 +658,13 @@ int64_t metaGetTbNum(SMeta *pMeta) { // N.B. Called by statusReq per second int64_t metaGetTimeSeriesNum(SMeta *pMeta) { // sum of (number of columns of stable - 1) * number of ctables (excluding timestamp column) - int64_t num = 0; - vnodeGetTimeSeriesNum(pMeta->pVnode, &num); - pMeta->pVnode->config.vndStats.numOfTimeSeries = num; + if (pMeta->pVnode->config.vndStats.numOfTimeSeries <= 0 || ++pMeta->pVnode->config.vndStats.itvTimeSeries % 60 == 0) { + int64_t num = 0; + vnodeGetTimeSeriesNum(pMeta->pVnode, &num); + pMeta->pVnode->config.vndStats.numOfTimeSeries = num; + + pMeta->pVnode->config.vndStats.itvTimeSeries = 0; + } return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries; } @@ -890,7 +937,7 @@ const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) { #ifdef TAG_FILTER_DEBUG if (IS_VAR_DATA_TYPE(val->type)) { - char* buf = taosMemoryCalloc(val->nData + 1, 1); + char *buf = taosMemoryCalloc(val->nData + 1, 1); memcpy(buf, val->pData, val->nData); metaDebug("metaTag table val varchar index:%d cid:%d type:%d value:%s", 1, val->cid, val->type, buf); taosMemoryFree(buf); @@ -900,13 +947,13 @@ const void *metaGetTableTagVal(void *pTag, int16_t type, STagVal *val) { metaDebug("metaTag table val number index:%d cid:%d type:%d value:%f", 1, val->cid, val->type, dval); } - SArray* pTagVals = NULL; - tTagToValArray((STag*)pTag, &pTagVals); + SArray *pTagVals = NULL; + tTagToValArray((STag *)pTag, &pTagVals); for (int i = 0; i < taosArrayGetSize(pTagVals); i++) { - STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, i); + STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i); if (IS_VAR_DATA_TYPE(pTagVal->type)) { - char* buf = taosMemoryCalloc(pTagVal->nData + 1, 1); + char *buf = taosMemoryCalloc(pTagVal->nData + 1, 1); memcpy(buf, pTagVal->pData, pTagVal->nData); metaDebug("metaTag table varchar index:%d cid:%d type:%d value:%s", i, pTagVal->cid, pTagVal->type, buf); taosMemoryFree(buf); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index ca5367f39714ed1f3a979068b0a9a7204d385f8c..6d3db47b18e18d3664d5c19983834712d35b4998 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -15,13 +15,15 @@ #include "sma.h" +extern SSmaMgmt smaMgmt; + static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma); static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma); static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma); static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma); static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma); static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma); -static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat); +static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat); /** * @brief Only applicable to Rollup SMA @@ -166,114 +168,49 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma) { return TSDB_CODE_SUCCESS; } -static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) { - SVnode *pVnode = pSma->pVnode; - int64_t committed = pRSmaStat->commitAppliedVer; - TdDirPtr pDir = NULL; - TdDirEntryPtr pDirEntry = NULL; - char dir[TSDB_FILENAME_LEN]; - const char *pattern = "v[0-9]+qtaskinfo\\.ver([0-9]+)?$"; - regex_t regex; - int code = 0; - - tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir); - - // Resource allocation and init - if ((code = regcomp(®ex, pattern, REG_EXTENDED)) != 0) { - char errbuf[128]; - regerror(code, ®ex, errbuf, sizeof(errbuf)); - smaWarn("vgId:%d, rsma post commit, regcomp for %s failed since %s", TD_VID(pVnode), dir, errbuf); - return TSDB_CODE_FAILED; - } - - if ((pDir = taosOpenDir(dir)) == NULL) { - regfree(®ex); - terrno = TAOS_SYSTEM_ERROR(errno); - smaDebug("vgId:%d, rsma post commit, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr()); - return TSDB_CODE_FAILED; - } - - int32_t dirLen = strlen(dir); - char *dirEnd = POINTER_SHIFT(dir, dirLen); - regmatch_t regMatch[2]; - while ((pDirEntry = taosReadDir(pDir)) != NULL) { - char *entryName = taosGetDirEntryName(pDirEntry); - if (!entryName) { - continue; - } - - code = regexec(®ex, entryName, 2, regMatch, 0); - - if (code == 0) { - // match - int64_t version = -1; - sscanf((const char *)POINTER_SHIFT(entryName, regMatch[1].rm_so), "%" PRIi64, &version); - if ((version < committed) && (version > -1)) { - strncpy(dirEnd, entryName, TSDB_FILENAME_LEN - dirLen); - if (taosRemoveFile(dir) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - smaWarn("vgId:%d, committed version:%" PRIi64 ", failed to remove %s since %s", TD_VID(pVnode), committed, - dir, terrstr()); - } else { - smaDebug("vgId:%d, committed version:%" PRIi64 ", success to remove %s", TD_VID(pVnode), committed, dir); - } - } - } else if (code == REG_NOMATCH) { - // not match - smaTrace("vgId:%d, rsma post commit, not match %s", TD_VID(pVnode), entryName); - continue; - } else { - // has other error - char errbuf[128]; - regerror(code, ®ex, errbuf, sizeof(errbuf)); - smaWarn("vgId:%d, rsma post commit, regexec failed since %s", TD_VID(pVnode), errbuf); - - taosCloseDir(&pDir); - regfree(®ex); - return TSDB_CODE_FAILED; - } - } - - taosCloseDir(&pDir); - regfree(®ex); - - return TSDB_CODE_SUCCESS; -} - // SQTaskFile ====================================================== -// int32_t tCmprQTaskFile(void const *lhs, void const *rhs) { -// int64_t *lCommitted = *(int64_t *)lhs; -// SQTaskFile *rQTaskF = (SQTaskFile *)rhs; - -// if (lCommitted < rQTaskF->commitID) { -// return -1; -// } else if (lCommitted > rQTaskF->commitID) { -// return 1; -// } - -// return 0; -// } -#if 0 /** * @brief At most time, there is only one qtaskinfo file committed latest in aTaskFile. Sometimes, there would be * multiple qtaskinfo files supporting snapshot replication. * * @param pSma - * @param pRSmaStat + * @param pStat * @return int32_t */ -static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) { - SVnode *pVnode = pSma->pVnode; - int64_t committed = pRSmaStat->commitAppliedVer; - SArray *aTaskFile = pRSmaStat->aTaskFile; +static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) { + SVnode *pVnode = pSma->pVnode; + SRSmaFS *pFS = RSMA_FS(pStat); + int64_t committed = pStat->commitAppliedVer; + char qTaskInfoFullName[TSDB_FILENAME_LEN]; + + taosWLockLatch(RSMA_FS_LOCK(pStat)); + + for (int32_t i = 0; i < taosArrayGetSize(pFS->aQTaskInf);) { + SQTaskFile *pTaskF = taosArrayGet(pFS->aQTaskInf, i); + if (atomic_sub_fetch_32(&pTaskF->nRef, 1) <= 0) { + tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->version, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); + if (taosRemoveFile(qTaskInfoFullName) < 0) { + smaWarn("vgId:%d, cleanup qinf, failed to remove %s since %s", TD_VID(pVnode), qTaskInfoFullName, + tstrerror(TAOS_SYSTEM_ERROR(errno))); + } else { + smaDebug("vgId:%d, cleanup qinf, success to remove %s", TD_VID(pVnode), qTaskInfoFullName); + } + taosArrayRemove(pFS->aQTaskInf, i); + continue; + } + ++i; + } - void *qTaskFile = taosArraySearch(aTaskFile, committed, tCmprQTaskFile, TD_LE); - + SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0}; + if (tdRSmaFSUpsertQTaskFile(pFS, &qFile) < 0) { + taosWUnLockLatch(RSMA_FS_LOCK(pStat)); + return TSDB_CODE_FAILED; + } + taosWUnLockLatch(RSMA_FS_LOCK(pStat)); return TSDB_CODE_SUCCESS; } -#endif /** * @brief post-commit for rollup sma @@ -290,8 +227,7 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) { SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSma); - // cleanup outdated qtaskinfo files - tdCleanupQTaskInfoFiles(pSma, pRSmaStat); + tdUpdateQTaskInfoFiles(pSma, pRSmaStat); return TSDB_CODE_SUCCESS; } @@ -312,15 +248,22 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { SSmaStat *pStat = SMA_ENV_STAT(pEnv); SRSmaStat *pRSmaStat = SMA_STAT_RSMA(pStat); + int32_t nLoops = 0; // step 1: set rsma stat atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_PAUSED); - atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 1); + 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; ASSERT(pRSmaStat->commitAppliedVer > 0); // step 2: wait for all triggered fetch tasks to finish - int32_t nLoops = 0; + nLoops = 0; while (1) { if (T_REF_VAL_GET(pStat) == 0) { smaDebug("vgId:%d, rsma commit, fetch tasks are all finished", SMA_VID(pSma)); @@ -344,7 +287,8 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { return TSDB_CODE_FAILED; } - smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma), (void*)taosGetSelfPthreadId()); + smaInfo("vgId:%d, rsma commit, wait for all items to be consumed, TID:%p", SMA_VID(pSma), + (void *)taosGetSelfPthreadId()); nLoops = 0; while (atomic_load_64(&pRSmaStat->nBufItems) > 0) { ++nLoops; @@ -359,7 +303,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { } smaInfo("vgId:%d, rsma commit, operator state commited, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); -#if 0 // consuming task of qTaskInfo clone +#if 0 // consuming task of qTaskInfo clone // step 4: swap queue/qall and iQueue/iQall // lock // taosWLockLatch(SMA_ENV_LOCK(pEnv)); @@ -419,8 +363,8 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { return TSDB_CODE_SUCCESS; } - SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); - SArray *rsmaDeleted = NULL; + SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); + SRSmaInfoItem *pItem = NULL; // step 1: merge qTaskInfo and iQTaskInfo // lock @@ -433,11 +377,7 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { if (RSMA_INFO_IS_DEL(pRSmaInfo)) { int32_t refVal = T_REF_VAL_GET(pRSmaInfo); if (refVal == 0) { - if (!rsmaDeleted) { - if ((rsmaDeleted = taosArrayInit(1, sizeof(tb_uid_t)))) { - taosArrayPush(rsmaDeleted, pSuid); - } - } + taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid)); } else { smaDebug( "vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for " @@ -463,25 +403,10 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { #endif } - for (int32_t i = 0; i < taosArrayGetSize(rsmaDeleted); ++i) { - tb_uid_t *pSuid = taosArrayGet(rsmaDeleted, i); - void *pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t)); - if ((pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { - tdFreeRSmaInfo(pSma, pRSmaInfo, true); - smaDebug( - "vgId:%d, rsma async post commit, free rsma info since already deleted and ref is 0 for " - "table:%" PRIi64, - SMA_VID(pSma), *pSuid); - } - taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t)); - } - taosArrayDestroy(rsmaDeleted); - // unlock // taosWUnLockLatch(SMA_ENV_LOCK(pEnv)); - // step 2: cleanup outdated qtaskinfo files - tdCleanupQTaskInfoFiles(pSma, pRSmaStat); + tdUpdateQTaskInfoFiles(pSma, pRSmaStat); atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0); diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 32a419022a312f9ab21681b9bc6f819c7792f51e..8bf79ca30e54554757dc7ab5d294ab448aea5e32 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -28,6 +28,8 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv); static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma); static int32_t tdRsmaStartExecutor(const SSma *pSma); static int32_t tdRsmaStopExecutor(const SSma *pSma); +static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); +static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); static void *tdFreeTSmaStat(STSmaStat *pStat); static void tdDestroyRSmaStat(void *pRSmaStat); @@ -59,12 +61,23 @@ int32_t smaInit() { return TSDB_CODE_FAILED; } + int32_t type = (8 == POINTER_BYTES) ? TSDB_DATA_TYPE_UBIGINT : TSDB_DATA_TYPE_UINT; + smaMgmt.refHash = taosHashInit(1, taosGetDefaultHashFunction(type), true, HASH_ENTRY_LOCK); + if (!smaMgmt.refHash) { + taosCloseRef(smaMgmt.rsetId); + atomic_store_8(&smaMgmt.inited, 0); + smaError("failed to init sma tmr hanle since %s", terrstr()); + return TSDB_CODE_FAILED; + } + // init fetch timer handle smaMgmt.tmrHandle = taosTmrInit(10000, 100, 10000, "RSMA"); if (!smaMgmt.tmrHandle) { taosCloseRef(smaMgmt.rsetId); + taosHashCleanup(smaMgmt.refHash); + smaMgmt.refHash = NULL; atomic_store_8(&smaMgmt.inited, 0); - smaError("failed to init sma tmr hanle since %s", terrstr()); + smaError("failed to init sma tmr handle since %s", terrstr()); return TSDB_CODE_FAILED; } @@ -93,6 +106,7 @@ void smaCleanUp() { if (old == 1) { taosCloseRef(smaMgmt.rsetId); + taosHashCleanup(smaMgmt.refHash); taosTmrCleanUp(smaMgmt.tmrHandle); smaInfo("sma mgmt env is cleaned up, rsetId:%d, tmrHandle:%p", smaMgmt.rsetId, smaMgmt.tmrHandle); atomic_store_8(&smaMgmt.inited, 0); @@ -195,6 +209,21 @@ int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) { return 0; } +static void tRSmaInfoHashFreeNode(void *data) { + SRSmaInfo *pRSmaInfo = NULL; + SRSmaInfoItem *pItem = NULL; + + if ((pRSmaInfo = *(SRSmaInfo **)data)) { + if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 0)) && pItem->level) { + taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES); + } + if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 1)) && pItem->level) { + taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES); + } + tdFreeRSmaInfo(NULL, pRSmaInfo, true); + } +} + static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma) { ASSERT(pSmaStat != NULL); @@ -240,10 +269,16 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS if (!RSMA_INFO_HASH(pRSmaStat)) { return TSDB_CODE_FAILED; } + taosHashSetFreeFp(RSMA_INFO_HASH(pRSmaStat), tRSmaInfoHashFreeNode); if (tdRsmaStartExecutor(pSma) < 0) { return TSDB_CODE_FAILED; } + + if (!(RSMA_FS(pRSmaStat)->aQTaskInf = taosArrayInit(1, sizeof(SQTaskFile)))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } } else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { // TODO } else { @@ -278,14 +313,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { tsem_destroy(&(pStat->notEmpty)); // step 2: destroy the rsma info and associated fetch tasks - if (taosHashGetSize(RSMA_INFO_HASH(pStat)) > 0) { - void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL); - while (infoHash) { - SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash; - tdFreeRSmaInfo(pSma, pSmaInfo, true); - infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash); - } - } taosHashCleanup(RSMA_INFO_HASH(pStat)); // step 3: wait for all triggered fetch tasks to finish @@ -307,12 +334,15 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { // step 4: tdRsmaStopExecutor(pSma); - // step 5: free pStat + // step 5: + tdRSmaFSClose(RSMA_FS(pStat)); + + // step 6: free pStat taosMemoryFreeClear(pStat); } } -void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { +static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { tdDestroySmaState(pSmaStat, smaType); if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { taosMemoryFreeClear(pSmaStat); @@ -329,7 +359,7 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { * @return int32_t */ -int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { +static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { tdDestroyTSmaStat(SMA_STAT_TSMA(pSmaStat)); @@ -337,7 +367,7 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { SRSmaStat *pRSmaStat = &pSmaStat->rsmaStat; int32_t vid = SMA_VID(pRSmaStat->pSma); int64_t refId = RSMA_REF_ID(pRSmaStat); - if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) { + if (taosRemoveRef(smaMgmt.rsetId, refId) < 0) { smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", vid, refId, smaMgmt.rsetId, terrstr()); } else { diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c new file mode 100644 index 0000000000000000000000000000000000000000..4387db553e6cfe21c0e14ff7b57ea388552ec969 --- /dev/null +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -0,0 +1,252 @@ +/* + * 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 "sma.h" + +// ================================================================================================= + +static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **output); +static int32_t tdQTaskInfCmprFn1(const void *p1, const void *p2); +static int32_t tdQTaskInfCmprFn2(const void *p1, const void *p2); +/** + * @brief Open RSma FS from qTaskInfo files + * + * @param pSma + * @param version + * @return int32_t + */ +int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) { + SVnode *pVnode = pSma->pVnode; + int64_t commitID = pVnode->state.commitID; + SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); + SRSmaStat *pStat = NULL; + SArray *output = NULL; + + terrno = TSDB_CODE_SUCCESS; + + if (!pEnv) { + return TSDB_CODE_SUCCESS; + } + + if (tdFetchQTaskInfoFiles(pSma, version, &output) < 0) { + goto _end; + } + + pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); + + for (int32_t i = 0; i < taosArrayGetSize(output); ++i) { + int32_t vid = 0; + int64_t version = -1; + sscanf((const char *)taosArrayGetP(output, i), "v%dqinfo.v%" PRIi64, &vid, &version); + SQTaskFile qTaskFile = {.version = version, .nRef = 1}; + if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) { + goto _end; + } + smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%" PRIi64, TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef); + } + +_end: + for (int32_t i = 0; i < taosArrayGetSize(output); ++i) { + void *ptr = taosArrayGetP(output, i); + taosMemoryFreeClear(ptr); + } + taosArrayDestroy(output); + + if (terrno != TSDB_CODE_SUCCESS) { + smaError("vgId:%d, open rsma fs failed since %s", TD_VID(pVnode), terrstr()); + return TSDB_CODE_FAILED; + } + return TSDB_CODE_SUCCESS; +} + +void tdRSmaFSClose(SRSmaFS *fs) { taosArrayDestroy(fs->aQTaskInf); } + +static int32_t tdQTaskInfCmprFn1(const void *p1, const void *p2) { + if (*(int64_t *)p1 < ((SQTaskFile *)p2)->version) { + return -1; + } else if (*(int64_t *)p1 > ((SQTaskFile *)p2)->version) { + return 1; + } + return 0; +} + +int32_t tdRSmaFSRef(SSma *pSma, SRSmaStat *pStat, int64_t version) { + SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf; + SQTaskFile *pTaskF = NULL; + int32_t oldVal = 0; + + taosRLockLatch(RSMA_FS_LOCK(pStat)); + if ((pTaskF = taosArraySearch(aQTaskInf, &version, tdQTaskInfCmprFn1, TD_EQ))) { + oldVal = atomic_fetch_add_32(&pTaskF->nRef, 1); + ASSERT(oldVal > 0); + } + taosRUnLockLatch(RSMA_FS_LOCK(pStat)); + return oldVal; +} + +void tdRSmaFSUnRef(SSma *pSma, SRSmaStat *pStat, int64_t version) { + SVnode *pVnode = pSma->pVnode; + SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf; + char qTaskFullName[TSDB_FILENAME_LEN]; + SQTaskFile *pTaskF = NULL; + int32_t idx = -1; + + taosWLockLatch(RSMA_FS_LOCK(pStat)); + if ((idx = taosArraySearchIdx(aQTaskInf, &version, tdQTaskInfCmprFn1, TD_EQ)) >= 0) { + ASSERT(idx < taosArrayGetSize(aQTaskInf)); + pTaskF = taosArrayGet(aQTaskInf, idx); + if (atomic_sub_fetch_32(&pTaskF->nRef, 1) <= 0) { + tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->version, tfsGetPrimaryPath(pVnode->pTfs), qTaskFullName); + if (taosRemoveFile(qTaskFullName) < 0) { + smaWarn("vgId:%d, failed to remove %s since %s", TD_VID(pVnode), qTaskFullName, + tstrerror(TAOS_SYSTEM_ERROR(errno))); + } else { + smaDebug("vgId:%d, success to remove %s", TD_VID(pVnode), qTaskFullName); + } + taosArrayRemove(aQTaskInf, idx); + } + } + taosWUnLockLatch(RSMA_FS_LOCK(pStat)); +} + +/** + * @brief Fetch qtaskfiles LE than version + * + * @param pSma + * @param version + * @param output + * @return int32_t + */ +static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **output) { + SVnode *pVnode = pSma->pVnode; + TdDirPtr pDir = NULL; + TdDirEntryPtr pDirEntry = NULL; + char dir[TSDB_FILENAME_LEN]; + const char *pattern = "v[0-9]+qinf\\.v([0-9]+)?$"; + regex_t regex; + int code = 0; + + tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir); + + if (!taosCheckExistFile(dir)) { + smaDebug("vgId:%d, fetch qtask files, no need as dir %s not exist", TD_VID(pVnode), dir); + return TSDB_CODE_SUCCESS; + } + + // Resource allocation and init + if ((code = regcomp(®ex, pattern, REG_EXTENDED)) != 0) { + terrno = TSDB_CODE_RSMA_REGEX_MATCH; + char errbuf[128]; + regerror(code, ®ex, errbuf, sizeof(errbuf)); + smaWarn("vgId:%d, fetch qtask files, regcomp for %s failed since %s", TD_VID(pVnode), dir, errbuf); + return TSDB_CODE_FAILED; + } + + if (!(pDir = taosOpenDir(dir))) { + regfree(®ex); + terrno = TAOS_SYSTEM_ERROR(errno); + smaError("vgId:%d, fetch qtask files, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr()); + return TSDB_CODE_FAILED; + } + + int32_t dirLen = strlen(dir); + char *dirEnd = POINTER_SHIFT(dir, dirLen); + regmatch_t regMatch[2]; + while ((pDirEntry = taosReadDir(pDir))) { + char *entryName = taosGetDirEntryName(pDirEntry); + if (!entryName) { + continue; + } + + code = regexec(®ex, entryName, 2, regMatch, 0); + + if (code == 0) { + // match + smaInfo("vgId:%d, fetch qtask files, max ver:%" PRIi64 ", %s found", TD_VID(pVnode), version, entryName); + + int64_t ver = -1; + sscanf((const char *)POINTER_SHIFT(entryName, regMatch[1].rm_so), "%" PRIi64, &ver); + if ((ver <= version) && (ver > -1)) { + if (!(*output)) { + if (!(*output = taosArrayInit(1, POINTER_BYTES))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + } + char *entryDup = strdup(entryName); + if (!entryDup) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + if (!taosArrayPush(*output, &entryDup)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + } else { + } + } else if (code == REG_NOMATCH) { + // not match + smaTrace("vgId:%d, fetch qtask files, not match %s", TD_VID(pVnode), entryName); + continue; + } else { + // has other error + char errbuf[128]; + regerror(code, ®ex, errbuf, sizeof(errbuf)); + smaWarn("vgId:%d, fetch qtask files, regexec failed since %s", TD_VID(pVnode), errbuf); + terrno = TSDB_CODE_RSMA_REGEX_MATCH; + goto _end; + } + } +_end: + taosCloseDir(&pDir); + regfree(®ex); + return terrno == 0 ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED; +} + +static int32_t tdQTaskFileCmprFn2(const void *p1, const void *p2) { + if (((SQTaskFile *)p1)->version < ((SQTaskFile *)p2)->version) { + return -1; + } else if (((SQTaskFile *)p1)->version > ((SQTaskFile *)p2)->version) { + return 1; + } + + return 0; +} + +int32_t tdRSmaFSUpsertQTaskFile(SRSmaFS *pFS, SQTaskFile *qTaskFile) { + int32_t code = 0; + int32_t idx = taosArraySearchIdx(pFS->aQTaskInf, qTaskFile, tdQTaskFileCmprFn2, TD_GE); + + if (idx < 0) { + idx = taosArrayGetSize(pFS->aQTaskInf); + } else { + SQTaskFile *pTaskF = (SQTaskFile *)taosArrayGet(pFS->aQTaskInf, idx); + int32_t c = tdQTaskFileCmprFn2(pTaskF, qTaskFile); + if (c == 0) { + pTaskF->nRef = qTaskFile->nRef; + pTaskF->version = qTaskFile->version; + pTaskF->size = qTaskFile->size; + goto _exit; + } + } + + if (taosArrayInsert(pFS->aQTaskInf, idx, qTaskFile) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + +_exit: + return code; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 235fb1f94161256721dcb1f87ad3a2cc6a3e98f8..d9ffda279f16501ac8f39fde7fe14728640db676 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -16,17 +16,17 @@ #include "sma.h" #include "tsdb.h" -static int32_t smaEvalDays(SRetention *r, int8_t precision); -static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); +static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration); +static int32_t smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); static int32_t rsmaRestore(SSma *pSma); -#define SMA_SET_KEEP_CFG(l) \ +#define SMA_SET_KEEP_CFG(v, l) \ do { \ SRetention *r = &pCfg->retentions[l]; \ pKeepCfg->keep2 = convertTimeFromPrecisionToUnit(r->keep, pCfg->precision, TIME_UNIT_MINUTE); \ pKeepCfg->keep0 = pKeepCfg->keep2; \ pKeepCfg->keep1 = pKeepCfg->keep2; \ - pKeepCfg->days = smaEvalDays(r, pCfg->precision); \ + pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \ } while (0) #define SMA_OPEN_RSMA_IMPL(v, l) \ @@ -38,51 +38,78 @@ static int32_t rsmaRestore(SSma *pSma); } \ break; \ } \ - smaSetKeepCfg(&keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ + smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg) < 0) { \ goto _err; \ } \ } while (0) -#define RETENTION_DAYS_SPLIT_RATIO 10 -#define RETENTION_DAYS_SPLIT_MIN 1 -#define RETENTION_DAYS_SPLIT_MAX 30 +/** + * @brief Evaluate days(duration) for rsma level 1/2/3. + * 1) level 1: duration from "create database" + * 2) level 2/3: duration * (freq/freqL1) + * @param pVnode + * @param r + * @param level + * @param precision + * @param duration + * @return int32_t + */ +static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration) { + int32_t freqDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->freq, precision, TIME_UNIT_MINUTE); + int32_t keepDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->keep, precision, TIME_UNIT_MINUTE); + int32_t days = duration; // min -static int32_t smaEvalDays(SRetention *r, int8_t precision) { - int32_t keepDays = convertTimeFromPrecisionToUnit(r->keep, precision, TIME_UNIT_DAY); - int32_t freqDays = convertTimeFromPrecisionToUnit(r->freq, precision, TIME_UNIT_DAY); + if (days < freqDuration) { + days = freqDuration; + } - int32_t days = keepDays / RETENTION_DAYS_SPLIT_RATIO; - if (days <= RETENTION_DAYS_SPLIT_MIN) { - days = RETENTION_DAYS_SPLIT_MIN; - if (days < freqDays) { - days = freqDays + 1; - } - } else { - if (days > RETENTION_DAYS_SPLIT_MAX) { - days = RETENTION_DAYS_SPLIT_MAX; - } - if (days < freqDays) { - days = freqDays + 1; - } + if (days > keepDuration) { + days = keepDuration; + } + + if (level == TSDB_RETENTION_L0) { + goto end; } - return days * 1440; + + ASSERT(level >= TSDB_RETENTION_L1 && level <= TSDB_RETENTION_L2); + + freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); + keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); + + int32_t nFreqTimes = (r + level)->freq / (r + TSDB_RETENTION_L0)->freq; + days *= (nFreqTimes > 1 ? nFreqTimes : 1); + + if (days > keepDuration) { + days = keepDuration; + } + + if (days > TSDB_MAX_DURATION_PER_FILE) { + days = TSDB_MAX_DURATION_PER_FILE; + } + + if (days < freqDuration) { + days = freqDuration; + } +end: + smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); + return days; } -int smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type) { +int smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type) { pKeepCfg->precision = pCfg->precision; switch (type) { case TSDB_TYPE_TSMA: ASSERT(0); break; case TSDB_TYPE_RSMA_L0: - SMA_SET_KEEP_CFG(0); + SMA_SET_KEEP_CFG(pVnode, 0); break; case TSDB_TYPE_RSMA_L1: - SMA_SET_KEEP_CFG(1); + SMA_SET_KEEP_CFG(pVnode, 1); break; case TSDB_TYPE_RSMA_L2: - SMA_SET_KEEP_CFG(2); + SMA_SET_KEEP_CFG(pVnode, 2); break; default: ASSERT(0); @@ -123,7 +150,7 @@ int32_t smaOpen(SVnode *pVnode) { } // restore the rsma - if (tdRsmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed) < 0) { + if (tdRSmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed) < 0) { goto _err; } } @@ -148,14 +175,14 @@ int32_t smaClose(SSma *pSma) { /** * @brief rsma env restore - * - * @param pSma - * @param type - * @param committedVer - * @return int32_t + * + * @param pSma + * @param type + * @param committedVer + * @return int32_t */ -int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer) { +int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer) { ASSERT(VND_IS_RSMA(pSma->pVnode)); - return tdProcessRSmaRestoreImpl(pSma, type, committedVer); + return tdRSmaProcessRestoreImpl(pSma, type, committedVer); } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 426ab521fdd16e3d0907fd1c056da15d7d6937cc..6732403846cd7cde989ee1cc9a3d4b024e14cfee 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -20,18 +20,18 @@ #define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt #define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt #define RSMA_FETCH_DELAY_MAX (900000) // ms -#define RSMA_FETCH_ACTIVE_MAX (1800) // ms +#define RSMA_FETCH_ACTIVE_MAX (1000) // ms +#define RSMA_FETCH_INTERVAL (5000) // ms SSmaMgmt smaMgmt = { .inited = 0, .rsetId = -1, }; -#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver" -#define TD_RSMAINFO_DEL_FILE "rsmainfo.del" +#define TD_QTASKINFO_FNAME_PREFIX "qinf.v" + typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter; -typedef struct SRSmaExecQItem SRSmaExecQItem; static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); @@ -42,10 +42,12 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSiz static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid); static void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo); static void tdFreeRSmaSubmitItems(SArray *pItems); -static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmitArr); +static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo); static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSmaInfoItem *pItem, STSchema *pTSchema, int64_t suid); static void tdRSmaFetchTrigger(void *param, void *tmrId); +static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo); +static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level); static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile); static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish); static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter); @@ -82,11 +84,6 @@ struct SRSmaQTaskInfoIter { int32_t nBufPos; }; -struct SRSmaExecQItem { - void *pRSmaInfo; - void *qall; -}; - void tdRSmaQTaskInfoGetFileName(int32_t vgId, int64_t version, char *outputName) { tdGetVndFileName(vgId, NULL, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, version, outputName); } @@ -101,7 +98,7 @@ static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); } -void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { +static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { // Note: free/kill may in RC if (!taskHandle || !(*taskHandle)) return; qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); @@ -124,27 +121,27 @@ void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { */ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) { if (pInfo) { + int32_t vid = pSma ? SMA_VID(pSma) : -1; for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = &pInfo->items[i]; if (isDeepFree && pItem->tmrId) { - smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid, - pItem->tmrId, i + 1); + smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", vid, pItem->tmrId, pInfo->suid, i + 1); taosTmrStopA(&pItem->tmrId); } if (isDeepFree && pInfo->taskInfo[i]) { - tdFreeQTaskInfo(&pInfo->taskInfo[i], SMA_VID(pSma), i + 1); + tdRSmaQTaskInfoFree(&pInfo->taskInfo[i], vid, i + 1); } else { - smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma), + smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", vid, pInfo->suid, i + 1); } if (pInfo->iTaskInfo[i]) { - tdFreeQTaskInfo(&pInfo->iTaskInfo[i], SMA_VID(pSma), i + 1); + tdRSmaQTaskInfoFree(&pInfo->iTaskInfo[i], vid, i + 1); } else { - smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty iTaskInfo", - SMA_VID(pSma), pInfo->suid, i + 1); + smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty iTaskInfo", vid, + pInfo->suid, i + 1); } } if (isDeepFree) { @@ -318,10 +315,17 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat } pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2; + ASSERT(pItem->level > 0); + + SRSmaRef rsmaRef = {.refId = pStat->refId, .suid = pRSmaInfo->suid}; + taosHashPut(smaMgmt.refHash, &pItem, POINTER_BYTES, &rsmaRef, sizeof(rsmaRef)); + taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId); - smaInfo("vgId:%d, table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 + + smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 ", finally maxdelay:%" PRIi32, - TD_VID(pVnode), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay); + TD_VID(pVnode), pItem, pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], + pItem->maxDelay); } return TSDB_CODE_SUCCESS; } @@ -335,7 +339,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat * @param tbName * @return int32_t */ -int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) { +int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) { if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) { smaDebug("vgId:%d, no qmsg1/qmsg2 for rollup table %s %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; @@ -388,7 +392,6 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con goto _err; } pRSmaInfo->suid = suid; - pRSmaInfo->refId = RSMA_REF_ID(pStat); T_REF_INIT_VAL(pRSmaInfo, 1); if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 0) < 0) { @@ -432,7 +435,7 @@ int32_t tdProcessRSmaCreate(SSma *pSma, SVCreateStbReq *pReq) { return TSDB_CODE_SUCCESS; } - return tdProcessRSmaCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name); + return tdRSmaProcessCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name); } /** @@ -659,15 +662,15 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma if (taosArrayGetSize(pResList) == 0) { if (terrno == 0) { - // smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); + // smaDebug("vgId:%d, no rsma level %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); } else { - smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr()); + smaDebug("vgId:%d, no rsma level %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr()); goto _err; } break; } else { - smaDebug("vgId:%d, rsma %" PRIi8 " data fetched", SMA_VID(pSma), pItem->level); + smaDebug("vgId:%d, rsma level %" PRIi8 " data fetched", SMA_VID(pSma), pItem->level); } #if 0 char flag[10] = {0}; @@ -681,21 +684,22 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma // TODO: the schema update should be handled later(TD-17965) if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) { - smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", - SMA_VID(pSma), suid, pItem->level, terrstr()); + smaError("vgId:%d, build submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), + suid, pItem->level, terrstr()); goto _err; } if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) { taosMemoryFreeClear(pReq); - smaError("vgId:%d, process submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s", + smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, pItem->level, terrstr()); goto _err; } - taosMemoryFreeClear(pReq); - smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64, - SMA_VID(pSma), suid, pItem->level, output->info.version); + smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " ver %" PRIi64 " len %" PRIu32, + SMA_VID(pSma), suid, pItem->level, output->info.version, htonl(pReq->header.contLen)); + + taosMemoryFreeClear(pReq); } } @@ -822,6 +826,95 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize, return TSDB_CODE_SUCCESS; } +static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param, + tb_uid_t suid, int8_t idx) { + SVnode *pVnode = pSma->pVnode; + char *pOutput = NULL; + int32_t len = 0; + + if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) { + smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid, + terrstr()); + goto _err; + } + + SReadHandle handle = { + .meta = pVnode->pMeta, + .vnode = pVnode, + .initTqReader = 1, + }; + ASSERT(!dstTaskInfo); + dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); + if (!dstTaskInfo) { + terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; + goto _err; + } + + if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) { + smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, + terrstr()); + goto _err; + } + + smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid); + + taosMemoryFreeClear(pOutput); + return TSDB_CODE_SUCCESS; +_err: + taosMemoryFreeClear(pOutput); + tdRSmaQTaskInfoFree(dstTaskInfo, TD_VID(pVnode), idx + 1); + smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, + terrstr()); + return TSDB_CODE_FAILED; +} + +/** + * @brief Clone qTaskInfo of SRSmaInfo + * + * @param pSma + * @param pInfo + * @return int32_t + */ +static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo) { + SRSmaParam *param = NULL; + if (!pInfo) { + return TSDB_CODE_SUCCESS; + } + + SMetaReader mr = {0}; + metaReaderInit(&mr, SMA_META(pSma), 0); + smaDebug("vgId:%d, rsma clone qTaskInfo for suid:%" PRIi64, SMA_VID(pSma), pInfo->suid); + if (metaGetTableEntryByUid(&mr, pInfo->suid) < 0) { + smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, + terrstr()); + goto _err; + } + ASSERT(mr.me.type == TSDB_SUPER_TABLE); + ASSERT(mr.me.uid == pInfo->suid); + if (TABLE_IS_ROLLUP(mr.me.flags)) { + param = &mr.me.stbEntry.rsmaParam; + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + if (!pInfo->iTaskInfo[i]) { + continue; + } + if (tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i) < 0) { + goto _err; + } + } + smaDebug("vgId:%d, rsma clone env success for %" PRIi64, SMA_VID(pSma), pInfo->suid); + } else { + terrno = TSDB_CODE_RSMA_INVALID_SCHEMA; + goto _err; + } + + metaReaderClear(&mr); + return TSDB_CODE_SUCCESS; +_err: + metaReaderClear(&mr); + smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, terrstr()); + return TSDB_CODE_FAILED; +} + /** * @brief During async commit, the SRSmaInfo object would be COW from iRSmaInfoHash and write lock should be applied. * @@ -853,7 +946,7 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) { return NULL; } if (!pRSmaInfo->taskInfo[0]) { - if (tdCloneRSmaInfo(pSma, pRSmaInfo) < 0) { + if (tdRSmaInfoClone(pSma, pRSmaInfo) < 0) { // taosRUnLockLatch(SMA_ENV_LOCK(pEnv)); return NULL; } @@ -1011,7 +1104,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { " qmsgLen:%" PRIi32, TD_VID(pVnode), suid, i, param->maxdelay[i], param->watermark[i], param->qmsgLen[i]); } - if (tdProcessRSmaCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) { + if (tdRSmaProcessCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) { smaError("vgId:%d, rsma restore env failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr()); goto _err; } @@ -1083,9 +1176,6 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTa goto _err; } - SSmaEnv *pRSmaEnv = pSma->pRSmaEnv; - SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pRSmaEnv); - SRSmaQTaskInfoIter fIter = {0}; if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) { tdRSmaQTaskInfoIterDestroy(&fIter); @@ -1126,7 +1216,7 @@ static int32_t tdRSmaRestoreTSDataReload(SSma *pSma) { return TSDB_CODE_SUCCESS; } -int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) { +int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) { // step 1: iterate all stables to restore the rsma env int64_t nTables = 0; if (tdRSmaRestoreQTaskInfoInit(pSma, &nTables) < 0) { @@ -1147,6 +1237,12 @@ int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) if (tdRSmaRestoreTSDataReload(pSma) < 0) { goto _err; } + + // step 4: open SRSmaFS for qTaskFiles + if (tdRSmaFSOpen(pSma, qtaskFileVer) < 0) { + goto _err; + } + smaInfo("vgId:%d, restore rsma task %" PRIi8 " from qtaskf %" PRIi64 " succeed", SMA_VID(pSma), type, qtaskFileVer); return TSDB_CODE_SUCCESS; _err: @@ -1476,38 +1572,59 @@ _err: * @param tmrId */ static void tdRSmaFetchTrigger(void *param, void *tmrId) { - SRSmaInfoItem *pItem = param; + SRSmaRef *pRSmaRef = NULL; SSma *pSma = NULL; - SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem); + SRSmaStat *pStat = NULL; + SRSmaInfo *pRSmaInfo = NULL; + SRSmaInfoItem *pItem = NULL; - if (RSMA_INFO_IS_DEL(pRSmaInfo)) { - smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, - pRSmaInfo->refId); + if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, ¶m, POINTER_BYTES))) { + smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%" PRIi64, param, + *(int64_t *)¶m, smaMgmt.refHash, smaMgmt.rsetId); return; } - SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaInfo->refId); - - if (!pStat) { + if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) { smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)", - smaMgmt.rsetId, pRSmaInfo->refId); + smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove + taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); return; } pSma = pStat->pSma; + if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) { + smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, + pRSmaRef->refId); // pRSmaRef freed in taosHashRemove + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); + taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); + return; + } + + if (RSMA_INFO_IS_DEL(pRSmaInfo)) { + smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId, + pRSmaRef->refId); // pRSmaRef freed in taosHashRemove + tdReleaseRSmaInfo(pSma, pRSmaInfo); + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); + taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); + return; + } + + pItem = *(SRSmaInfoItem **)¶m; + // if rsma trigger stat in paused, cancelled or finished, not start fetch task int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); switch (rsmaTriggerStat) { case TASK_TRIGGER_STAT_PAUSED: case TASK_TRIGGER_STAT_CANCELLED: { - tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId); smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8 ", rsetId rsetId:%" PRIi64 " refId:%d", - SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaInfo->refId); + SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId); if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { - taosTmrReset(tdRSmaFetchTrigger, 5000, pItem, smaMgmt.tmrHandle, &pItem->tmrId); + taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); } + tdReleaseRSmaInfo(pSma, pRSmaInfo); + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); return; } default: @@ -1518,8 +1635,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); switch (fetchTriggerStat) { case TASK_TRIGGER_STAT_ACTIVE: { - smaDebug("vgId:%d, rsma fetch task started for level:%" PRIi8 " suid:%" PRIi64 " since stat is active", - SMA_VID(pSma), pItem->level, pRSmaInfo->suid); + smaDebug("vgId:%d, rsma fetch task planned for level:%" PRIi8 " suid:%" PRIi64 " since stat is active", + SMA_VID(pSma), pItem->level, pRSmaInfo->suid); // async process pItem->fetchLevel = pItem->level; #if 0 @@ -1531,8 +1648,6 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { if (atomic_load_8(&pRSmaInfo->assigned) == 0) { tsem_post(&(pStat->notEmpty)); } - smaInfo("vgId:%d, rsma fetch task planned for level:%" PRIi8 " suid:%" PRIi64, SMA_VID(pSma), pItem->level, - pRSmaInfo->suid); } break; case TASK_TRIGGER_STAT_PAUSED: { smaDebug("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid:%" PRIi64 " since stat is paused", @@ -1554,11 +1669,11 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { _end: taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId); - tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId); + tdReleaseRSmaInfo(pSma, pRSmaInfo); + tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); } static void tdFreeRSmaSubmitItems(SArray *pItems) { - ASSERT(taosArrayGetSize(pItems) > 0); for (int32_t i = 0; i < taosArrayGetSize(pItems); ++i) { taosFreeQitem(*(void **)taosArrayGet(pItems, i)); } @@ -1570,10 +1685,9 @@ static void tdFreeRSmaSubmitItems(SArray *pItems) { * * @param pSma * @param pInfo - * @param pSubmitArr * @return int32_t */ -static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmitArr) { +static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) { SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; for (int8_t i = 1; i <= TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pInfo, i - 1); @@ -1619,10 +1733,8 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmi } _end: - tdReleaseRSmaInfo(pSma, pInfo); return TSDB_CODE_SUCCESS; _err: - tdReleaseRSmaInfo(pSma, pInfo); return TSDB_CODE_FAILED; } @@ -1715,21 +1827,36 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi8, SMA_VID(pSma), qallItemSize, type); } - if (type == RSMA_EXEC_OVERFLOW) { - tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr); + int8_t oldStat = atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 2); + if (oldStat == 0 || + ((oldStat == 2) && atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)) < TASK_TRIGGER_STAT_PAUSED)) { + atomic_fetch_add_32(&pRSmaStat->nFetchAll, 1); + tdRSmaFetchAllResult(pSma, pInfo); + if (0 == atomic_sub_fetch_32(&pRSmaStat->nFetchAll, 1)) { + atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0); + } } if (qallItemSize > 0) { atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); continue; } else if (RSMA_INFO_ITEM(pInfo, 0)->fetchLevel || RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) { - continue; + if (atomic_load_8(RSMA_COMMIT_STAT(pRSmaStat)) == 0) { + continue; + } + for (int32_t j = 0; j < TSDB_RETENTION_L2; ++j) { + SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pInfo, j); + if (pItem->fetchLevel) { + pItem->fetchLevel = 0; + taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); + } + } } break; } } - ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0)); + atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); } } if (type == RSMA_EXEC_COMMIT) { @@ -1758,7 +1885,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { } // tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr); - ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0)); + atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); } } ASSERT(taosQueueItemSize(pInfo->iQueue) == 0); @@ -1775,7 +1902,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { if (pEnv->flag & SMA_ENV_FLG_CLOSE) { break; } - + tsem_wait(&pRSmaStat->notEmpty); if ((pEnv->flag & SMA_ENV_FLG_CLOSE) && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) { diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c index 335c15a539ef31d66d83377f90da225e45ffd893..5a0167a75fc799366396015f8323e770a217a1cb 100644 --- a/source/dnode/vnode/src/sma/smaSnapshot.c +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -15,11 +15,13 @@ #include "sma.h" -static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData); -static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +static int32_t rsmaSnapReadQTaskInfo(SRSmaSnapReader* pReader, uint8_t** ppData); +static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t version); +static int32_t rsmaQTaskInfSnapReaderClose(SQTaskFReader** ppReader); -// SRsmaSnapReader ======================================== -struct SRsmaSnapReader { +// SRSmaSnapReader ======================================== +struct SRSmaSnapReader { SSma* pSma; int64_t sver; int64_t ever; @@ -33,13 +35,13 @@ struct SRsmaSnapReader { SQTaskFReader* pQTaskFReader; }; -int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) { +int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapReader** ppReader) { int32_t code = 0; SVnode* pVnode = pSma->pVnode; - SRsmaSnapReader* pReader = NULL; + SRSmaSnapReader* pReader = NULL; // alloc - pReader = (SRsmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + pReader = (SRSmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); if (pReader == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -48,7 +50,7 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead pReader->sver = sver; pReader->ever = ever; - // rsma1/rsma2 + // open rsma1/rsma2 for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { if (pSma->pRSmaTsdb[i]) { code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, i == 0 ? SNAP_DATA_RSMA1 : SNAP_DATA_RSMA2, @@ -59,51 +61,112 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead } } - // qtaskinfo - // 1. add ref to qtaskinfo.v${ever} if exists and then start to replicate + // open qtaskinfo + if ((code = rsmaQTaskInfSnapReaderOpen(pReader, ever)) < 0) { + goto _err; + } + + *ppReader = pReader; + + return TSDB_CODE_SUCCESS; +_err: + smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code)); + return TSDB_CODE_FAILED; +} + +static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t version) { + int32_t code = 0; + SSma* pSma = pReader->pSma; + SVnode* pVnode = pSma->pVnode; + SSmaEnv* pEnv = NULL; + SRSmaStat* pStat = NULL; + + if (!(pEnv = SMA_RSMA_ENV(pSma))) { + smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as env is NULL", + TD_VID(pVnode), version); + return TSDB_CODE_SUCCESS; + } + + pStat = (SRSmaStat*)SMA_ENV_STAT(pEnv); + + int32_t ref = tdRSmaFSRef(pReader->pSma, pStat, version); + if (ref < 1) { + smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as ref is %d", + TD_VID(pVnode), version, ref); + return TSDB_CODE_SUCCESS; + } + char qTaskInfoFullName[TSDB_FILENAME_LEN]; - tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), ever, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); + tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), version, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName); if (!taosCheckExistFile(qTaskInfoFullName)) { - smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo not need as %s not exists", TD_VID(pVnode), - qTaskInfoFullName); - } else { - pReader->pQTaskFReader = taosMemoryCalloc(1, sizeof(SQTaskFReader)); - if (!pReader->pQTaskFReader) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } + tdRSmaFSUnRef(pSma, pStat, version); + smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exists", + TD_VID(pVnode), qTaskInfoFullName); + return TSDB_CODE_SUCCESS; + } - TdFilePtr qTaskF = taosOpenFile(qTaskInfoFullName, TD_FILE_READ); - if (!qTaskF) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - pReader->pQTaskFReader->pReadH = qTaskF; -#if 0 - SQTaskFile* pQTaskF = &pReader->pQTaskFReader->fTask; - pQTaskF->nRef = 1; -#endif + pReader->pQTaskFReader = taosMemoryCalloc(1, sizeof(SQTaskFReader)); + if (!pReader->pQTaskFReader) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; } - *ppReader = pReader; - smaInfo("vgId:%d, vnode snapshot rsma reader opened %s succeed", TD_VID(pVnode), qTaskInfoFullName); + TdFilePtr fp = taosOpenFile(qTaskInfoFullName, TD_FILE_READ); + if (!fp) { + code = TAOS_SYSTEM_ERROR(errno); + taosMemoryFreeClear(pReader->pQTaskFReader); + goto _end; + } + + pReader->pQTaskFReader->pReadH = fp; + pReader->pQTaskFReader->pSma = pSma; + pReader->pQTaskFReader->version = pReader->ever; + +_end: + if (code < 0) { + tdRSmaFSUnRef(pSma, pStat, version); + smaError("vgId:%d, vnode snapshot rsma reader open %s succeed", TD_VID(pVnode), qTaskInfoFullName); + return TSDB_CODE_FAILED; + } + + smaInfo("vgId:%d, vnode snapshot rsma reader open %s succeed", TD_VID(pVnode), qTaskInfoFullName); + return TSDB_CODE_SUCCESS; +} + +static int32_t rsmaQTaskInfSnapReaderClose(SQTaskFReader** ppReader) { + if (!(*ppReader)) { + return TSDB_CODE_SUCCESS; + } + + SSma* pSma = (*ppReader)->pSma; + SRSmaStat* pStat = SMA_RSMA_STAT(pSma); + int64_t version = (*ppReader)->version; + + taosCloseFile(&(*ppReader)->pReadH); + tdRSmaFSUnRef(pSma, pStat, version); + taosMemoryFreeClear(*ppReader); + smaInfo("vgId:%d, vnode snapshot rsma reader closed for qTaskInfo version %" PRIi64, SMA_VID(pSma), version); + return TSDB_CODE_SUCCESS; -_err: - smaError("vgId:%d, vnode snapshot rsma reader opened failed since %s", TD_VID(pVnode), tstrerror(code)); - return TSDB_CODE_FAILED; } -static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppBuf) { +static int32_t rsmaSnapReadQTaskInfo(SRSmaSnapReader* pReader, uint8_t** ppBuf) { int32_t code = 0; SSma* pSma = pReader->pSma; int64_t n = 0; uint8_t* pBuf = NULL; SQTaskFReader* qReader = pReader->pQTaskFReader; + if (!qReader) { + *ppBuf = NULL; + smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, qTaskReader is NULL", SMA_VID(pSma)); + return 0; + } + if (!qReader->pReadH) { *ppBuf = NULL; - smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, readh is empty", SMA_VID(pSma)); + smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, readh is NULL", SMA_VID(pSma)); return 0; } @@ -153,7 +216,7 @@ _err: return code; } -int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) { +int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData) { int32_t code = 0; *ppData = NULL; @@ -205,9 +268,9 @@ _err: return code; } -int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { +int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader) { int32_t code = 0; - SRsmaSnapReader* pReader = *ppReader; + SRSmaSnapReader* pReader = *ppReader; for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { if (pReader->pDataReader[i]) { @@ -215,11 +278,7 @@ int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { } } - if (pReader->pQTaskFReader) { - taosCloseFile(&pReader->pQTaskFReader->pReadH); - taosMemoryFreeClear(pReader->pQTaskFReader); - smaInfo("vgId:%d, vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma)); - } + rsmaQTaskInfSnapReaderClose(&pReader->pQTaskFReader); smaInfo("vgId:%d, vnode snapshot rsma reader closed", SMA_VID(pReader->pSma)); @@ -227,8 +286,8 @@ int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) { return code; } -// SRsmaSnapWriter ======================================== -struct SRsmaSnapWriter { +// SRSmaSnapWriter ======================================== +struct SRSmaSnapWriter { SSma* pSma; int64_t sver; int64_t ever; @@ -244,13 +303,13 @@ struct SRsmaSnapWriter { SQTaskFWriter* pQTaskFWriter; }; -int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) { +int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWriter** ppWriter) { int32_t code = 0; - SRsmaSnapWriter* pWriter = NULL; + SRSmaSnapWriter* pWriter = NULL; SVnode* pVnode = pSma->pVnode; // alloc - pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + pWriter = (SRSmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); if (pWriter == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -301,9 +360,9 @@ _err: return code; } -int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) { +int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback) { int32_t code = 0; - SRsmaSnapWriter* pWriter = *ppWriter; + SRSmaSnapWriter* pWriter = *ppWriter; SVnode* pVnode = pWriter->pSma->pVnode; if (rollback) { @@ -332,7 +391,7 @@ int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) { pWriter->pQTaskFWriter->fname, qTaskInfoFullName); // rsma restore - if ((code = tdRsmaRestore(pWriter->pSma, RSMA_RESTORE_SYNC, pWriter->ever)) < 0) { + if ((code = tdRSmaRestore(pWriter->pSma, RSMA_RESTORE_SYNC, pWriter->ever)) < 0) { goto _err; } smaInfo("vgId:%d, vnode snapshot rsma writer restore from %s succeed", SMA_VID(pWriter->pSma), qTaskInfoFullName); @@ -349,7 +408,7 @@ _err: return code; } -int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { +int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { int32_t code = 0; SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; @@ -377,7 +436,7 @@ _err: return code; } -static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { +static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { int32_t code = 0; SQTaskFWriter* qWriter = pWriter->pQTaskFWriter; diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 1687cd46a07a7b0a70107eb825fb06b6f9314441..173391b7694072a3bc02a9f74f63c9425c42160b 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -20,6 +20,10 @@ #define SMA_STORAGE_MINUTES_DAY 1440 #define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file +static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); +static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); +static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); + // TODO: Who is responsible for resource allocate and release? int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) { int32_t code = TSDB_CODE_SUCCESS; @@ -59,7 +63,7 @@ int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t * * @param days unit is minute * @return int32_t */ -int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) { +static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) { SDecoder coder = {0}; tDecoderInit(&coder, pCont, contLen); @@ -106,7 +110,7 @@ _err: * @param pMsg * @return int32_t */ -int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { +static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { SSmaCfg *pCfg = (SSmaCfg *)pMsg; if (TD_VID(pSma->pVnode) == pCfg->dstVgId) { @@ -145,7 +149,7 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) { * @param msg * @return int32_t */ -int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { +static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { const SArray *pDataBlocks = (const SArray *)msg; // TODO: destroy SSDataBlocks(msg) if (!pDataBlocks) { diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index d771797963a5cd9d242fea1f4d65a5634f12b5e8..a4ba0a61a57b781ff062328fe18920f3ce15dacc 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -305,93 +305,4 @@ int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) { smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId); return TSDB_CODE_SUCCESS; -} - -static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param, - tb_uid_t suid, int8_t idx) { - SVnode *pVnode = pSma->pVnode; - char *pOutput = NULL; - int32_t len = 0; - - if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) { - smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; - } - - SReadHandle handle = { - .meta = pVnode->pMeta, - .vnode = pVnode, - .initTqReader = 1, - }; - ASSERT(!dstTaskInfo); - dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); - if (!dstTaskInfo) { - terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; - goto _err; - } - - if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) { - smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, - terrstr()); - goto _err; - } - - smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid); - - taosMemoryFreeClear(pOutput); - return TSDB_CODE_SUCCESS; -_err: - taosMemoryFreeClear(pOutput); - tdFreeQTaskInfo(dstTaskInfo, TD_VID(pVnode), idx + 1); - smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid, - terrstr()); - return TSDB_CODE_FAILED; -} - -/** - * @brief Clone qTaskInfo of SRSmaInfo - * - * @param pSma - * @param pInfo - * @return int32_t - */ -int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) { - SRSmaParam *param = NULL; - if (!pInfo) { - return TSDB_CODE_SUCCESS; - } - - SMetaReader mr = {0}; - metaReaderInit(&mr, SMA_META(pSma), 0); - smaDebug("vgId:%d, rsma clone qTaskInfo for suid:%" PRIi64, SMA_VID(pSma), pInfo->suid); - if (metaGetTableEntryByUid(&mr, pInfo->suid) < 0) { - smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, - terrstr()); - goto _err; - } - ASSERT(mr.me.type == TSDB_SUPER_TABLE); - ASSERT(mr.me.uid == pInfo->suid); - if (TABLE_IS_ROLLUP(mr.me.flags)) { - param = &mr.me.stbEntry.rsmaParam; - for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { - if (!pInfo->iTaskInfo[i]) { - continue; - } - if (tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i) < 0) { - goto _err; - } - } - smaDebug("vgId:%d, rsma clone env success for %" PRIi64, SMA_VID(pSma), pInfo->suid); - } else { - terrno = TSDB_CODE_RSMA_INVALID_SCHEMA; - goto _err; - } - - metaReaderClear(&mr); - return TSDB_CODE_SUCCESS; -_err: - metaReaderClear(&mr); - smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, terrstr()); - return TSDB_CODE_FAILED; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 54f764c6b335811a37095fe7ce58ddcf00a831ef..f9c2757c3778446dfc75cca2fa55556e54d28d44 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -196,6 +196,66 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con return 0; } +int32_t tqSendTaosxRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const STaosxRsp* pRsp) { + ASSERT(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); + ASSERT(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); + + if (pRsp->withSchema) { + ASSERT(taosArrayGetSize(pRsp->blockSchema) == pRsp->blockNum); + } else { + ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0); + } + + if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { + if (pRsp->blockNum > 0) { + ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version); + } else { + ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version); + } + } + + int32_t len = 0; + int32_t code = 0; + tEncodeSize(tEncodeSTaosxRsp, pRsp, len, code); + if (code < 0) { + return -1; + } + int32_t tlen = sizeof(SMqRspHead) + len; + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + return -1; + } + + ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__TAOSX_RSP; + ((SMqRspHead*)buf)->epoch = pReq->epoch; + ((SMqRspHead*)buf)->consumerId = pReq->consumerId; + + void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + + SEncoder encoder = {0}; + tEncoderInit(&encoder, abuf, len); + tEncodeSTaosxRsp(&encoder, pRsp); + tEncoderClear(&encoder); + + SRpcMsg rsp = { + .info = pMsg->info, + .pCont = buf, + .contLen = tlen, + .code = 0, + }; + tmsgSendRsp(&rsp); + + char buf1[80] = {0}; + char buf2[80] = {0}; + tFormatOffset(buf1, 80, &pRsp->reqOffset); + tFormatOffset(buf2, 80, &pRsp->rspOffset); + tqDebug("taosx rsp, vgId:%d, from consumer:%" PRId64 + ", (epoch %d) send rsp, block num: %d, reqOffset:%s, rspOffset:%s", + TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); + + return 0; +} + static FORCE_INLINE bool tqOffsetLessOrEqual(const STqOffset* pLeft, const STqOffset* pRight) { return pLeft->val.type == TMQ_OFFSET__LOG && pRight->val.type == TMQ_OFFSET__LOG && pLeft->val.version <= pRight->val.version; @@ -303,6 +363,22 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su return 0; } +static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) { + pRsp->reqOffset = pReq->reqOffset; + + pRsp->withTbName = 1; + pRsp->withSchema = 1; + pRsp->blockData = taosArrayInit(0, sizeof(void*)); + pRsp->blockDataLen = taosArrayInit(0, sizeof(int32_t)); + pRsp->blockTbName = taosArrayInit(0, sizeof(void*)); + pRsp->blockSchema = taosArrayInit(0, sizeof(void*)); + + if (pRsp->blockData == NULL || pRsp->blockDataLen == NULL || pRsp->blockTbName == NULL || pRsp->blockSchema == NULL) { + return -1; + } + return 0; +} + int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { SMqPollReq* pReq = pMsg->pCont; int64_t consumerId = pReq->consumerId; @@ -341,9 +417,6 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { tqDebug("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, recv poll req in vg %d, req offset %s", consumerId, pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf); - SMqDataRsp dataRsp = {0}; - tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); - // 2.reset offset if needed if (reqOffset.type > 0) { fetchOffsetNew = reqOffset; @@ -357,8 +430,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { TD_VID(pTq->pVnode), formatBuf); } else { if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { - if (pReq->useSnapshot){ - if (pHandle->fetchMeta){ + if (pReq->useSnapshot) { + if (pHandle->fetchMeta) { tqOffsetResetToMeta(&fetchOffsetNew, 0); } else { tqOffsetResetToData(&fetchOffsetNew, 0, 0); @@ -367,57 +440,87 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { tqOffsetResetToLog(&fetchOffsetNew, walGetFirstVer(pTq->pVnode->pWal)); } } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, offset reset to %" PRId64, consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.rspOffset.version); if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { code = -1; } - goto OVER; + tDeleteSMqDataRsp(&dataRsp); + return code; } else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) { tqError("tmq poll: subkey %s, no offset committed for consumer %" PRId64 " in vg %d, subkey %s, reset none failed", pHandle->subKey, consumerId, TD_VID(pTq->pVnode), pReq->subKey); terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; - code = -1; - goto OVER; + return -1; } } } - if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN || fetchOffsetNew.type != TMQ_OFFSET__LOG){ - SMqMetaRsp metaRsp = {0}; - tqScan(pTq, pHandle, &dataRsp, &metaRsp, &fetchOffsetNew); + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType); + tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew); + + if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + code = -1; + } + + tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%ld, version:%ld", + consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type, + dataRsp.rspOffset.uid, dataRsp.rspOffset.version); + + tDeleteSMqDataRsp(&dataRsp); + return code; + } - if(metaRsp.metaRspLen > 0){ + // for taosx + ASSERT(pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN); + + SMqMetaRsp metaRsp = {0}; + + STaosxRsp taosxRsp = {0}; + tqInitTaosxRsp(&taosxRsp, pReq); + + if (fetchOffsetNew.type != TMQ_OFFSET__LOG) { + tqScan(pTq, pHandle, &taosxRsp, &metaRsp, &fetchOffsetNew); + + if (metaRsp.metaRspLen > 0) { if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { code = -1; } - tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send meta offset type:%d,uid:%ld,version:%ld", consumerId, pHandle->subKey, - TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid, metaRsp.rspOffset.version); + tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send meta offset type:%d,uid:%ld,version:%ld", consumerId, + pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid, + metaRsp.rspOffset.version); taosMemoryFree(metaRsp.metaRsp); - goto OVER; + tDeleteSTaosxRsp(&taosxRsp); + return code; } - if (dataRsp.blockNum > 0){ - if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + if (taosxRsp.blockNum > 0) { + if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) { code = -1; } - goto OVER; - }else{ - fetchOffsetNew = dataRsp.rspOffset; + tDeleteSTaosxRsp(&taosxRsp); + return code; + } else { + fetchOffsetNew = taosxRsp.rspOffset; } - tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%ld,version:%ld", consumerId, pHandle->subKey, - TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type, dataRsp.rspOffset.uid, dataRsp.rspOffset.version); + tqDebug("taosx poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%ld,version:%ld", + consumerId, pHandle->subKey, TD_VID(pTq->pVnode), taosxRsp.blockNum, taosxRsp.rspOffset.type, + taosxRsp.rspOffset.uid, taosxRsp.rspOffset.version); } - if (pHandle->execHandle.subType != TOPIC_SUB_TYPE__COLUMN && fetchOffsetNew.type == TMQ_OFFSET__LOG) { + if (fetchOffsetNew.type == TMQ_OFFSET__LOG) { int64_t fetchVer = fetchOffsetNew.version + 1; pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); if (pCkHead == NULL) { - code = -1; - goto OVER; + return -1; } walSetReaderCapacity(pHandle->pWalReader, 2048); @@ -426,19 +529,19 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { consumerEpoch = atomic_load_32(&pHandle->epoch); if (consumerEpoch > reqEpoch) { tqWarn("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, vg %d offset %" PRId64 - ", found new consumer epoch %d, discard req epoch %d", + ", found new consumer epoch %d, discard req epoch %d", consumerId, pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch); break; } if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead) < 0) { - // TODO add push mgr - - tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer); - if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); + if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) { code = -1; } - goto OVER; + tDeleteSTaosxRsp(&taosxRsp); + if (pCkHead) taosMemoryFree(pCkHead); + return code; } SWalCont* pHead = &pCkHead->head; @@ -449,17 +552,19 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { if (pHead->msgType == TDMT_VND_SUBMIT) { SSubmitReq* pCont = (SSubmitReq*)&pHead->body; - if (tqLogScanExec(pTq, &pHandle->execHandle, pCont, &dataRsp) < 0) { + if (tqTaosxScanLog(pTq, pHandle, pCont, &taosxRsp) < 0) { /*ASSERT(0);*/ } // TODO batch optimization: // TODO continue scan until meeting batch requirement - if (dataRsp.blockNum > 0 /* threshold */) { - tqOffsetResetToLog(&dataRsp.rspOffset, fetchVer); - if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { + if (taosxRsp.blockNum > 0 /* threshold */) { + tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); + if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) { code = -1; } - goto OVER; + tDeleteSTaosxRsp(&taosxRsp); + if (pCkHead) taosMemoryFree(pCkHead); + return code; } else { fetchVer++; } @@ -468,41 +573,22 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { ASSERT(pHandle->fetchMeta); ASSERT(IS_META_MSG(pHead->msgType)); tqDebug("fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); - SMqMetaRsp metaRsp = {0}; tqOffsetResetToLog(&metaRsp.rspOffset, fetchVer); metaRsp.resMsgType = pHead->msgType; metaRsp.metaRspLen = pHead->bodyLen; metaRsp.metaRsp = pHead->body; if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { code = -1; - goto OVER; + taosMemoryFree(pCkHead); + return code; } code = 0; - goto OVER; + if (pCkHead) taosMemoryFree(pCkHead); + return code; } } } - - // send empty to client - if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) { - code = -1; - } - -OVER: - if (pCkHead) taosMemoryFree(pCkHead); - // TODO wrap in destroy func - taosArrayDestroy(dataRsp.blockDataLen); - taosArrayDestroyP(dataRsp.blockData, (FDelete)taosMemoryFree); - - if (dataRsp.withSchema) { - taosArrayDestroyP(dataRsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); - } - - if (dataRsp.withTbName) { - taosArrayDestroyP(dataRsp.blockTbName, (FDelete)taosMemoryFree); - } - - return code; + return 0; } int32_t tqProcessVgDeleteReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) { @@ -609,10 +695,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode); pHandle->execHandle.execDb.pFilterOutTbUid = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - buildSnapContext(handle.meta, handle.version, 0, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext **)(&handle.sContext)); + buildSnapContext(handle.meta, handle.version, 0, pHandle->execHandle.subType, pHandle->fetchMeta, + (SSnapContext**)(&handle.sContext)); - pHandle->execHandle.task = - qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { pHandle->pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); @@ -629,9 +715,9 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe tqReaderSetTbUidList(pHandle->execHandle.pExecReader, tbUidList); taosArrayDestroy(tbUidList); - buildSnapContext(handle.meta, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext **)(&handle.sContext)); - pHandle->execHandle.task = - qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); + buildSnapContext(handle.meta, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta, + (SSnapContext**)(&handle.sContext)); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); } taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle)); tqDebug("try to persist handle %s consumer %" PRId64, req.subKey, pHandle->consumerId); @@ -730,7 +816,86 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msg return streamMetaAddSerializedTask(pTq->pStreamMeta, version, msg, msgLen); } -int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq, int64_t ver) { +int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) { + bool failed = false; + SDecoder* pCoder = &(SDecoder){0}; + SDeleteRes* pRes = &(SDeleteRes){0}; + + pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t)); + if (pRes->uidList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + failed = true; + } + + tDecoderInit(pCoder, pReq, len); + tDecodeDeleteRes(pCoder, pRes); + tDecoderClear(pCoder); + + int32_t sz = taosArrayGetSize(pRes->uidList); + if (sz == 0) { + taosArrayDestroy(pRes->uidList); + return 0; + } + SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA); + blockDataEnsureCapacity(pDelBlock, sz); + pDelBlock->info.rows = sz; + pDelBlock->info.version = ver; + + for (int32_t i = 0; i < sz; i++) { + // start key column + SColumnInfoData* pStartCol = taosArrayGet(pDelBlock->pDataBlock, START_TS_COLUMN_INDEX); + colDataAppend(pStartCol, i, (const char*)&pRes->skey, false); // end key column + SColumnInfoData* pEndCol = taosArrayGet(pDelBlock->pDataBlock, END_TS_COLUMN_INDEX); + colDataAppend(pEndCol, i, (const char*)&pRes->ekey, false); + // uid column + SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX); + int64_t* pUid = taosArrayGet(pRes->uidList, i); + colDataAppend(pUidCol, i, (const char*)pUid, false); + + colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX), i); + colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX), i); + colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX), i); + } + + taosArrayDestroy(pRes->uidList); + + void* pIter = NULL; + while (1) { + pIter = taosHashIterate(pTq->pStreamMeta->pTasks, pIter); + if (pIter == NULL) break; + SStreamTask* pTask = *(SStreamTask**)pIter; + if (pTask->taskLevel != TASK_LEVEL__SOURCE) continue; + + qDebug("delete req enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver); + + SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); + pStreamBlock->type = STREAM_INPUT__DATA_BLOCK; + pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock)); + SSDataBlock block = {0}; + assignOneDataBlock(&block, pDelBlock); + block.info.type = STREAM_DELETE_DATA; + taosArrayPush(pStreamBlock->blocks, &block); + + if (!failed) { + if (streamTaskInput(pTask, (SStreamQueueItem*)pStreamBlock) < 0) { + qError("stream task input del failed, task id %d", pTask->taskId); + continue; + } + + if (streamSchedExec(pTask) < 0) { + qError("stream task launch failed, task id %d", pTask->taskId); + continue; + } + } else { + streamTaskInputFail(pTask); + } + } + blockDataDestroy(pDelBlock); + + return 0; +} + +int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) { void* pIter = NULL; bool failed = false; SStreamDataSubmit* pSubmit = NULL; diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index a0b8141cfb3987d40bd4a077f0be184998c272d7..d00907f6778d176d1eabe77f92a243a1c5dd3cbd 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -60,7 +60,70 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) { return 0; } -int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* pOffset) { +int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset) { + const STqExecHandle* pExec = &pHandle->execHandle; + ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); + + qTaskInfo_t task = pExec->task; + + if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { + tqDebug("prepare scan failed, return"); + if (pOffset->type == TMQ_OFFSET__LOG) { + pRsp->rspOffset = *pOffset; + return 0; + } else { + tqOffsetResetToLog(pOffset, pHandle->snapshotVer); + if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { + tqDebug("prepare scan failed, return"); + pRsp->rspOffset = *pOffset; + return 0; + } + } + } + + int32_t rowCnt = 0; + while (1) { + SSDataBlock* pDataBlock = NULL; + uint64_t ts = 0; + tqDebug("tmq task start to execute"); + if (qExecTask(task, &pDataBlock, &ts) < 0) { + ASSERT(0); + } + tqDebug("tmq task executed, get %p", pDataBlock); + + if (pDataBlock == NULL) { + break; + } + + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols); + pRsp->blockNum++; + + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + rowCnt += pDataBlock->info.rows; + if (rowCnt >= 4096) break; + } + } + + if (qStreamExtractOffset(task, &pRsp->rspOffset) < 0) { + ASSERT(0); + return -1; + } + ASSERT(pRsp->rspOffset.type != 0); + + if (pRsp->withTbName) { + if (pRsp->rspOffset.type == TMQ_OFFSET__LOG) { + int64_t uid = pExec->pExecReader->msgIter.uid; + tqAddTbNameToRsp(pTq, uid, pRsp); + } else { + pRsp->withTbName = false; + } + } + ASSERT(pRsp->withSchema == false); + + return 0; +} + +int32_t tqScan(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* pOffset) { const STqExecHandle* pExec = &pHandle->execHandle; qTaskInfo_t task = pExec->task; @@ -94,7 +157,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* int64_t uid = 0; if (pOffset->type == TMQ_OFFSET__LOG) { uid = pExec->pExecReader->msgIter.uid; - if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) { + if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) { continue; } } else { @@ -102,20 +165,16 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* taosArrayPush(pRsp->blockTbName, &tbName); } } - if(pRsp->withSchema){ + if (pRsp->withSchema) { if (pOffset->type == TMQ_OFFSET__LOG) { - tqAddBlockSchemaToRsp(pExec, pRsp); - }else{ + tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp); + } else { SSchemaWrapper* pSW = tCloneSSchemaWrapper(qExtractSchemaFromTask(task)); taosArrayPush(pRsp->blockSchema, &pSW); } } - if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN){ - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols); - }else{ - tqAddBlockDataToRsp(pDataBlock, pRsp, taosArrayGetSize(pDataBlock->pDataBlock)); - } + tqAddBlockDataToRsp(pDataBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pDataBlock->pDataBlock)); pRsp->blockNum++; if (pOffset->type == TMQ_OFFSET__LOG) { continue; @@ -125,42 +184,32 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* } } - if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN){ - if (pRsp->blockNum == 0 && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - tqDebug("vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), - pHandle->snapshotVer + 1); - tqOffsetResetToLog(pOffset, pHandle->snapshotVer); - qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType); + if (pDataBlock == NULL && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + if (qStreamExtractPrepareUid(task) != 0) { continue; } - }else{ - if (pDataBlock == NULL && pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA){ - if(qStreamExtractPrepareUid(task) != 0){ - continue; - } - tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), - pHandle->snapshotVer + 1); - break; - } - - if (pRsp->blockNum > 0){ - tqDebug("tmqsnap task exec exited, get data"); - break; - } + tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), + pHandle->snapshotVer + 1); + break; + } - SMqMetaRsp* tmp = qStreamExtractMetaMsg(task); - if(tmp->rspOffset.type == TMQ_OFFSET__SNAPSHOT_DATA){ - tqOffsetResetToData(pOffset, tmp->rspOffset.uid, tmp->rspOffset.ts); - qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType); - tmp->rspOffset.type = TMQ_OFFSET__SNAPSHOT_META; - tqDebug("tmqsnap task exec change to get data"); - continue; - } + if (pRsp->blockNum > 0) { + tqDebug("tmqsnap task exec exited, get data"); + break; + } - *pMetaRsp = *tmp; - tqDebug("tmqsnap task exec exited, get meta"); + SMqMetaRsp* tmp = qStreamExtractMetaMsg(task); + if (tmp->rspOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { + tqOffsetResetToData(pOffset, tmp->rspOffset.uid, tmp->rspOffset.ts); + qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType); + tmp->rspOffset.type = TMQ_OFFSET__SNAPSHOT_META; + tqDebug("tmqsnap task exec change to get data"); + continue; } + *pMetaRsp = *tmp; + tqDebug("tmqsnap task exec exited, get meta"); + tqDebug("task exec exited"); break; } @@ -173,61 +222,11 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, SMqMetaRsp* return 0; } -#if 0 -int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) { - ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN); - qTaskInfo_t task = pExec->execCol.task[workerId]; - - if (qStreamPrepareTsdbScan(task, offset.uid, offset.ts) < 0) { - ASSERT(0); - } - - int32_t rowCnt = 0; - while (1) { - SSDataBlock* pDataBlock = NULL; - uint64_t ts = 0; - if (qExecTask(task, &pDataBlock, &ts) < 0) { - ASSERT(0); - } - if (pDataBlock == NULL) break; - - ASSERT(pDataBlock->info.rows != 0); - ASSERT(taosArrayGetSize(pDataBlock->pDataBlock) != 0); - - tqAddBlockDataToRsp(pDataBlock, pRsp); - - if (pRsp->withTbName) { - pRsp->withTbName = 0; -#if 0 - int64_t uid; - int64_t ts; - if (qGetStreamScanStatus(task, &uid, &ts) < 0) { - ASSERT(0); - } - tqAddTbNameToRsp(pTq, uid, pRsp); -#endif - } - pRsp->blockNum++; - - rowCnt += pDataBlock->info.rows; - if (rowCnt >= 4096) break; - } - int64_t uid; - int64_t ts; - if (qGetStreamScanStatus(task, &uid, &ts) < 0) { - ASSERT(0); - } - tqOffsetResetToData(&pRsp->rspOffset, uid, ts); - - return 0; -} -#endif - -int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataRsp* pRsp) { +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp) { + STqExecHandle* pExec = &pHandle->execHandle; ASSERT(pExec->subType != TOPIC_SUB_TYPE__COLUMN); if (pExec->subType == TOPIC_SUB_TYPE__TABLE) { - pRsp->withSchema = 1; STqReader* pReader = pExec->pExecReader; tqReaderSetDataMsg(pReader, pReq, 0); while (tqNextDataBlock(pReader)) { @@ -237,18 +236,31 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR } if (pRsp->withTbName) { int64_t uid = pExec->pExecReader->msgIter.uid; - if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) { + if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) { blockDataFreeRes(&block); continue; } } - tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock)); + if (pHandle->fetchMeta) { + SSubmitBlk* pBlk = pReader->pBlock; + if (pBlk->schemaLen > 0) { + if (pRsp->createTableNum == 0) { + pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); + pRsp->createTableReq = taosArrayInit(0, sizeof(void*)); + } + void* createReq = taosMemoryCalloc(1, pBlk->schemaLen); + memcpy(createReq, pBlk->data, pBlk->schemaLen); + taosArrayPush(pRsp->createTableLen, &pBlk->schemaLen); + taosArrayPush(pRsp->createTableReq, &createReq); + pRsp->createTableNum++; + } + } + tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock)); blockDataFreeRes(&block); - tqAddBlockSchemaToRsp(pExec, pRsp); + tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp); pRsp->blockNum++; } } else if (pExec->subType == TOPIC_SUB_TYPE__DB) { - pRsp->withSchema = 1; STqReader* pReader = pExec->pExecReader; tqReaderSetDataMsg(pReader, pReq, 0); while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) { @@ -258,14 +270,28 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR } if (pRsp->withTbName) { int64_t uid = pExec->pExecReader->msgIter.uid; - if (tqAddTbNameToRsp(pTq, uid, pRsp) < 0) { + if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) { blockDataFreeRes(&block); continue; } } - tqAddBlockDataToRsp(&block, pRsp, taosArrayGetSize(block.pDataBlock)); + if (pHandle->fetchMeta) { + SSubmitBlk* pBlk = pReader->pBlock; + if (pBlk->schemaLen > 0) { + if (pRsp->createTableNum == 0) { + pRsp->createTableLen = taosArrayInit(0, sizeof(int32_t)); + pRsp->createTableReq = taosArrayInit(0, sizeof(void*)); + } + void* createReq = taosMemoryCalloc(1, pBlk->schemaLen); + memcpy(createReq, pBlk->data, pBlk->schemaLen); + taosArrayPush(pRsp->createTableLen, &pBlk->schemaLen); + taosArrayPush(pRsp->createTableReq, &createReq); + pRsp->createTableNum++; + } + } + tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock)); blockDataFreeRes(&block); - tqAddBlockSchemaToRsp(pExec, pRsp); + tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp); pRsp->blockNum++; } } diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index a192d1f863819f560a2b7b3ce92fe15c603c0fc1..62f8debccb8ff9c478de0fb331cc5741b503b011 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -18,12 +18,25 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeCStr(pEncoder, pHandle->subKey) < 0) return -1; + if (tEncodeI8(pEncoder, pHandle->fetchMeta) < 0) return -1; if (tEncodeI64(pEncoder, pHandle->consumerId) < 0) return -1; if (tEncodeI64(pEncoder, pHandle->snapshotVer) < 0) return -1; if (tEncodeI32(pEncoder, pHandle->epoch) < 0) return -1; if (tEncodeI8(pEncoder, pHandle->execHandle.subType) < 0) return -1; if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (tEncodeCStr(pEncoder, pHandle->execHandle.execCol.qmsg) < 0) return -1; + } else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){ + int32_t size = taosHashGetSize(pHandle->execHandle.execDb.pFilterOutTbUid); + if (tEncodeI32(pEncoder, size) < 0) return -1; + void *pIter = NULL; + pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter); + while(pIter){ + int64_t *tbUid = (int64_t *)taosHashGetKey(pIter, NULL); + if (tEncodeI64(pEncoder, *tbUid) < 0) return -1; + pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter); + } + } else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){ + if (tEncodeI64(pEncoder, pHandle->execHandle.execTb.suid) < 0) return -1; } tEndEncode(pEncoder); return pEncoder->pos; @@ -32,12 +45,25 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) { int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeCStrTo(pDecoder, pHandle->subKey) < 0) return -1; + if (tDecodeI8(pDecoder, &pHandle->fetchMeta) < 0) return -1; if (tDecodeI64(pDecoder, &pHandle->consumerId) < 0) return -1; if (tDecodeI64(pDecoder, &pHandle->snapshotVer) < 0) return -1; if (tDecodeI32(pDecoder, &pHandle->epoch) < 0) return -1; if (tDecodeI8(pDecoder, &pHandle->execHandle.subType) < 0) return -1; if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (tDecodeCStrAlloc(pDecoder, &pHandle->execHandle.execCol.qmsg) < 0) return -1; + }else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){ + pHandle->execHandle.execDb.pFilterOutTbUid = + taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + int32_t size = 0; + if (tDecodeI32(pDecoder, &size) < 0) return -1; + for(int32_t i = 0; i < size; i++){ + int64_t tbUid = 0; + if (tDecodeI64(pDecoder, &tbUid) < 0) return -1; + taosHashPut(pHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0); + } + } else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){ + if (tDecodeI64(pDecoder, &pHandle->execHandle.execTb.suid) < 0) return -1; } tEndDecode(pDecoder); return 0; @@ -267,14 +293,28 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { ASSERT(scanner); handle.execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner); ASSERT(handle.execHandle.pExecReader); - } else { - + } else if (handle.execHandle.subType == TOPIC_SUB_TYPE__DB) { handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); - handle.execHandle.execDb.pFilterOutTbUid = - taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); -// handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode); + handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode); + buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext)); + handle.execHandle.task = + qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL); + } else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) { + handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); + SArray* tbUidList = taosArrayInit(0, sizeof(int64_t)); + vnodeGetCtbIdList(pTq->pVnode, handle.execHandle.execTb.suid, tbUidList); + tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid); + for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { + int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i); + tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid); + } + handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode); + tqReaderSetTbUidList(handle.execHandle.pExecReader, tbUidList); + taosArrayDestroy(tbUidList); + + buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext)); handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL); } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index ed7fa80c476fff2d6436232b0e610f0b6f61f1cd..a57e8174fee9f82fd35c425e9214e48fba91f709 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -213,20 +213,25 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ #endif int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { - if (vnodeIsRoleLeader(pTq->pVnode) && msgType == TDMT_VND_SUBMIT) { - if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0; - - void* data = taosMemoryMalloc(msgLen); - if (data == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - tqError("failed to copy data for stream since out of memory"); - return -1; + if (vnodeIsRoleLeader(pTq->pVnode)) { + if (msgType == TDMT_VND_SUBMIT) { + if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0; + + void* data = taosMemoryMalloc(msgLen); + if (data == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + tqError("failed to copy data for stream since out of memory"); + return -1; + } + memcpy(data, msg, msgLen); + SSubmitReq* pReq = (SSubmitReq*)data; + pReq->version = ver; + + tqProcessSubmitReq(pTq, data, ver); + } + if (msgType == TDMT_VND_DELETE) { + tqProcessDelReq(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver); } - memcpy(data, msg, msgLen); - SSubmitReq* pReq = (SSubmitReq*)data; - pReq->version = ver; - - tqProcessStreamTrigger(pTq, data, ver); } return 0; diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 6e2a6fdb7126f5e81bcb64ab6e10af64725c75ff..375130fa2c34f5b954e3fe3710914dc01e8f6363 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -15,6 +15,162 @@ #include "tq.h" + +bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){ + if(pHandle->execHandle.subType != TOPIC_SUB_TYPE__TABLE){ + return true; + } + + int16_t msgType = pHead->msgType; + char* body = pHead->body; + int32_t bodyLen = pHead->bodyLen; + + int64_t tbSuid = pHandle->execHandle.execTb.suid; + int64_t realTbSuid = 0; + SDecoder coder; + void* data = POINTER_SHIFT(body, sizeof(SMsgHead)); + int32_t len = bodyLen - sizeof(SMsgHead); + tDecoderInit(&coder, data, len); + + if (msgType == TDMT_VND_CREATE_STB || msgType == TDMT_VND_ALTER_STB) { + SVCreateStbReq req = {0}; + if (tDecodeSVCreateStbReq(&coder, &req) < 0) { + goto end; + } + realTbSuid = req.suid; + } else if (msgType == TDMT_VND_DROP_STB) { + SVDropStbReq req = {0}; + if (tDecodeSVDropStbReq(&coder, &req) < 0) { + goto end; + } + realTbSuid = req.suid; + } else if (msgType == TDMT_VND_CREATE_TABLE) { + SVCreateTbBatchReq req = {0}; + if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) { + goto end; + } + + int32_t needRebuild = 0; + SVCreateTbReq* pCreateReq = NULL; + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){ + needRebuild++; + } + } + if(needRebuild == 0){ + // do nothing + }else if(needRebuild == req.nReqs){ + realTbSuid = tbSuid; + }else{ + realTbSuid = tbSuid; + SVCreateTbBatchReq reqNew = {0}; + reqNew.pArray = taosArrayInit(req.nReqs, sizeof(struct SVCreateTbReq)); + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){ + reqNew.nReqs++; + taosArrayPush(reqNew.pArray, pCreateReq); + } + } + + int tlen; + int32_t ret = 0; + tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret); + void* buf = taosMemoryMalloc(tlen); + if (NULL == buf) { + taosArrayDestroy(reqNew.pArray); + goto end; + } + SEncoder coderNew = {0}; + tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead)); + tEncodeSVCreateTbBatchReq(&coderNew, &reqNew); + tEncoderClear(&coderNew); + memcpy(pHead->body + sizeof(SMsgHead), buf, tlen); + pHead->bodyLen = tlen + sizeof(SMsgHead); + taosMemoryFree(buf); + taosArrayDestroy(reqNew.pArray); + } + } else if (msgType == TDMT_VND_ALTER_TABLE) { + SVAlterTbReq req = {0}; + + if (tDecodeSVAlterTbReq(&coder, &req) < 0) { + goto end; + } + + SMetaReader mr = {0}; + metaReaderInit(&mr, pHandle->execHandle.pExecReader->pVnodeMeta, 0); + + if (metaGetTableEntryByName(&mr, req.tbName) < 0) { + metaReaderClear(&mr); + goto end; + } + realTbSuid = mr.me.ctbEntry.suid; + metaReaderClear(&mr); + } else if (msgType == TDMT_VND_DROP_TABLE) { + SVDropTbBatchReq req = {0}; + + if (tDecodeSVDropTbBatchReq(&coder, &req) < 0) { + goto end; + } + + int32_t needRebuild = 0; + SVDropTbReq* pDropReq = NULL; + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pDropReq = req.pReqs + iReq; + + if(pDropReq->suid == tbSuid){ + needRebuild++; + } + } + if(needRebuild == 0){ + // do nothing + }else if(needRebuild == req.nReqs){ + realTbSuid = tbSuid; + }else{ + realTbSuid = tbSuid; + SVDropTbBatchReq reqNew = {0}; + reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq)); + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pDropReq = req.pReqs + iReq; + if(pDropReq->suid == tbSuid){ + reqNew.nReqs++; + taosArrayPush(reqNew.pArray, pDropReq); + } + } + + int tlen; + int32_t ret = 0; + tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret); + void* buf = taosMemoryMalloc(tlen); + if (NULL == buf) { + taosArrayDestroy(reqNew.pArray); + goto end; + } + SEncoder coderNew = {0}; + tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead)); + tEncodeSVDropTbBatchReq(&coderNew, &reqNew); + tEncoderClear(&coderNew); + memcpy(pHead->body + sizeof(SMsgHead), buf, tlen); + pHead->bodyLen = tlen + sizeof(SMsgHead); + taosMemoryFree(buf); + taosArrayDestroy(reqNew.pArray); + } + } else if (msgType == TDMT_VND_DELETE) { + SDeleteRes req = {0}; + if (tDecodeDeleteRes(&coder, &req) < 0) { + goto end; + } + realTbSuid = req.suid; + } else{ + ASSERT(0); + } + + end: + tDecoderClear(&coder); + return tbSuid == realTbSuid; +} + int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) { int32_t code = 0; taosThreadMutexLock(&pHandle->pWalReader->mutex); @@ -53,9 +209,11 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea code = -1; goto END; } - *fetchOffset = offset; - code = 0; - goto END; + if(isValValidForTable(pHandle, pHead)){ + *fetchOffset = offset; + code = 0; + goto END; + } } } code = walSkipFetchBody(pHandle->pWalReader, *ppCkHead); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 61c68775559ebcbaca1853fdadecaaa1456c170c..64caff1542fffa53efe731cc957c473322253012 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -418,31 +418,16 @@ typedef enum { } SFSLASTNEXTROWSTATES; typedef struct { - SFSLASTNEXTROWSTATES state; // [input] - STsdb *pTsdb; // [input] - SBlockIdx *pBlockIdxExp; // [input] - STSchema *pTSchema; // [input] - tb_uid_t suid; + SFSLASTNEXTROWSTATES state; // [input] + STsdb *pTsdb; // [input] tb_uid_t uid; int32_t nFileSet; int32_t iFileSet; SArray *aDFileSet; SDataFReader *pDataFReader; - SArray *aBlockL; - SBlockL *pBlockL; - SBlockData *pBlockDataL; - SBlockData blockDataL; - int32_t nRow; - int32_t iRow; TSDBROW row; - /* - SArray *aBlockIdx; - SBlockIdx *pBlockIdx; - SMapData blockMap; - int32_t nBlock; - int32_t iBlock; - SBlock block; - */ + + SMergeTree mergeTree; } SFSLastNextRowIter; static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { @@ -451,22 +436,16 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { switch (state->state) { case SFSLASTNEXTROW_FS: - // state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet; state->nFileSet = taosArrayGetSize(state->aDFileSet); state->iFileSet = state->nFileSet; - state->pBlockDataL = NULL; - case SFSLASTNEXTROW_FILESET: { SDFileSet *pFileSet = NULL; _next_fileset: if (--state->iFileSet >= 0) { pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet); } else { - if (state->pBlockDataL) { - tBlockDataDestroy(state->pBlockDataL, 1); - state->pBlockDataL = NULL; - } + // tMergeTreeClose(&state->mergeTree); *ppRow = NULL; return code; @@ -475,68 +454,24 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { code = tsdbDataFReaderOpen(&state->pDataFReader, state->pTsdb, pFileSet); if (code) goto _err; - if (!state->aBlockL) { - state->aBlockL = taosArrayInit(0, sizeof(SBlockL)); - } else { - taosArrayClear(state->aBlockL); - } - - code = tsdbReadBlockL(state->pDataFReader, state->aBlockL); - if (code) goto _err; - - // SBlockL *pBlockL = (SBlockL *)taosArrayGet(state->aBlockL, state->iBlockL); - - state->pBlockL = taosArraySearch(state->aBlockL, state->pBlockIdxExp, tCmprBlockL, TD_EQ); - if (!state->pBlockL) { + tMergeTreeOpen(&state->mergeTree, 1, state->pDataFReader, state->uid, + &(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX}, + &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}); + bool hasVal = tMergeTreeNext(&state->mergeTree); + if (!hasVal) { + state->state = SFSLASTNEXTROW_FILESET; + // tMergeTreeClose(&state->mergeTree); goto _next_fileset; } - - int64_t suid = state->pBlockL->suid; - int64_t uid = state->pBlockL->maxUid; - - if (!state->pBlockDataL) { - state->pBlockDataL = &state->blockDataL; - - tBlockDataCreate(state->pBlockDataL); - } - code = tBlockDataInit(state->pBlockDataL, suid, suid ? 0 : uid, state->pTSchema); - if (code) goto _err; - } - case SFSLASTNEXTROW_BLOCKDATA: - code = tsdbReadLastBlock(state->pDataFReader, state->pBlockL, state->pBlockDataL); - if (code) goto _err; - - state->nRow = state->blockDataL.nRow; - state->iRow = state->nRow - 1; - - if (!state->pBlockDataL->uid) { - while (state->pBlockIdxExp->uid != state->pBlockDataL->aUid[state->iRow]) { - --state->iRow; - } - } - state->state = SFSLASTNEXTROW_BLOCKROW; + } case SFSLASTNEXTROW_BLOCKROW: - if (state->pBlockDataL->uid) { - if (state->iRow >= 0) { - state->row = tsdbRowFromBlockData(state->pBlockDataL, state->iRow); - *ppRow = &state->row; - - if (--state->iRow < 0) { - state->state = SFSLASTNEXTROW_FILESET; - } - } - } else { - if (state->iRow >= 0 && state->pBlockIdxExp->uid == state->pBlockDataL->aUid[state->iRow]) { - state->row = tsdbRowFromBlockData(state->pBlockDataL, state->iRow); - *ppRow = &state->row; - - if (--state->iRow < 0 || state->pBlockIdxExp->uid != state->pBlockDataL->aUid[state->iRow]) { - state->state = SFSLASTNEXTROW_FILESET; - } - } + state->row = tMergeTreeGetRow(&state->mergeTree); + *ppRow = &state->row; + bool hasVal = tMergeTreeNext(&state->mergeTree); + if (!hasVal) { + state->state = SFSLASTNEXTROW_FILESET; } - return code; default: ASSERT(0); @@ -548,15 +483,6 @@ _err: tsdbDataFReaderClose(&state->pDataFReader); state->pDataFReader = NULL; } - if (state->aBlockL) { - taosArrayDestroy(state->aBlockL); - state->aBlockL = NULL; - } - if (state->pBlockDataL) { - tBlockDataDestroy(state->pBlockDataL, 1); - state->pBlockDataL = NULL; - } - *ppRow = NULL; return code; @@ -574,14 +500,6 @@ int32_t clearNextRowFromFSLast(void *iter) { tsdbDataFReaderClose(&state->pDataFReader); state->pDataFReader = NULL; } - if (state->aBlockL) { - taosArrayDestroy(state->aBlockL); - state->aBlockL = NULL; - } - if (state->pBlockDataL) { - tBlockDataDestroy(state->pBlockDataL, 1); - state->pBlockDataL = NULL; - } return code; } @@ -609,7 +527,7 @@ typedef struct SFSNextRowIter { SMapData blockMap; int32_t nBlock; int32_t iBlock; - SBlock block; + SDataBlk block; SBlockData blockData; SBlockData *pBlockData; int32_t nRow; @@ -684,13 +602,13 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { } case SFSNEXTROW_BLOCKDATA: if (state->iBlock >= 0) { - SBlock block = {0}; + SDataBlk block = {0}; - tBlockReset(&block); + tDataBlkReset(&block); // tBlockDataReset(&state->blockData); tBlockDataReset(state->pBlockData); - tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetBlock); + tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetDataBlk); /* code = tsdbReadBlockData(state->pDataFReader, &state->blockIdx, &block, &state->blockData, NULL, NULL); */ tBlockDataReset(state->pBlockData); code = tBlockDataInit(state->pBlockData, state->suid, state->uid, state->pTSchema); @@ -972,9 +890,6 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs pIter->fsLastState.state = (SFSLASTNEXTROWSTATES)SFSNEXTROW_FS; pIter->fsLastState.pTsdb = pTsdb; pIter->fsLastState.aDFileSet = pIter->pReadSnap->fs.aDFileSet; - pIter->fsLastState.pBlockIdxExp = &pIter->idx; - pIter->fsLastState.pTSchema = pTSchema; - pIter->fsLastState.suid = suid; pIter->fsLastState.uid = uid; pIter->fsState.state = SFSNEXTROW_FS; @@ -1372,25 +1287,33 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand // getTableCacheKeyS(uid, "l", key, &keyLen); getTableCacheKey(uid, 1, key, &keyLen); LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); - if (h) { - } else { - SArray *pLastArray = NULL; - code = mergeLast(uid, pTsdb, &pLastArray); - // if table's empty or error, return code of -1 - // if (code < 0 || pRow == NULL) { - if (code < 0 || pLastArray == NULL) { - *handle = NULL; - return 0; - } - - _taos_lru_deleter_t deleter = deleteTableCacheLast; - LRUStatus status = - taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL, TAOS_LRU_PRIORITY_LOW); - if (status != TAOS_LRU_STATUS_OK) { - code = -1; - } + if (!h) { + taosThreadMutexLock(&pTsdb->lruMutex); h = taosLRUCacheLookup(pCache, key, keyLen); + if (!h) { + SArray *pLastArray = NULL; + code = mergeLast(uid, pTsdb, &pLastArray); + // if table's empty or error, return code of -1 + // if (code < 0 || pRow == NULL) { + if (code < 0 || pLastArray == NULL) { + *handle = NULL; + return 0; + } + + _taos_lru_deleter_t deleter = deleteTableCacheLast; + LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL, + TAOS_LRU_PRIORITY_LOW); + if (status != TAOS_LRU_STATUS_OK) { + code = -1; + } + + taosThreadMutexUnlock(&pTsdb->lruMutex); + + h = taosLRUCacheLookup(pCache, key, keyLen); + } else { + taosThreadMutexUnlock(&pTsdb->lruMutex); + } } *handle = h; @@ -1411,3 +1334,5 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) { } size_t tsdbCacheGetCapacity(SVnode *pVnode) { return taosLRUCacheGetCapacity(pVnode->pTsdb->lruCache); } + +size_t tsdbCacheGetUsage(SVnode *pVnode) { return taosLRUCacheGetUsage(pVnode->pTsdb->lruCache); } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 04a6de8472ade43b3e7e2b420f8e2d0c0656a2c8..acbdc65f12260f662e99ad47a44e9ed809632a22 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -20,11 +20,26 @@ typedef struct { STSchema *pTSchema; } SSkmInfo; +typedef enum { MEMORY_DATA_ITER = 0, LAST_DATA_ITER } EDataIterT; + typedef struct { - int64_t suid; - int64_t uid; - TSDBROW row; -} SRowInfo; + SRBTreeNode n; + SRowInfo r; + EDataIterT type; + union { + struct { + int32_t iTbDataP; + STbDataIter iter; + }; // memory data iter + struct { + int32_t iSst; + SArray *aSstBlk; + int32_t iSstBlk; + SBlockData bData; + int32_t iRow; + }; // sst file data iter + }; +} SDataIter; typedef struct { STsdb *pTsdb; @@ -35,8 +50,9 @@ typedef struct { int32_t minRow; int32_t maxRow; int8_t cmprAlg; - SArray *aTbDataP; - STsdbFS fs; + int8_t maxLast; + SArray *aTbDataP; // memory + STsdbFS fs; // disk // -------------- TSKEY nextKey; // reset by each table commit int32_t commitFid; @@ -45,25 +61,24 @@ typedef struct { // commit file data struct { SDataFReader *pReader; - // data - SArray *aBlockIdx; // SArray - int32_t iBlockIdx; - SBlockIdx *pBlockIdx; - SMapData mBlock; // SMapData - SBlockData bData; - // last - SArray *aBlockL; // SArray - int32_t iBlockL; - SBlockData bDatal; - int32_t iRow; - SRowInfo *pRowInfo; - SRowInfo rowInfo; + SArray *aBlockIdx; // SArray + int32_t iBlockIdx; + SBlockIdx *pBlockIdx; + SMapData mBlock; // SMapData + SBlockData bData; } dReader; + struct { + SDataIter *pIter; + SRBTree rbt; + SDataIter dataIter; + SDataIter aDataIter[TSDB_MAX_LAST_FILE]; + int8_t toLastOnly; + }; struct { SDataFWriter *pWriter; SArray *aBlockIdx; // SArray - SArray *aBlockL; // SArray - SMapData mBlock; // SMapData + SArray *aSstBlk; // SArray + SMapData mBlock; // SMapData SBlockData bData; SBlockData bDatal; } dWriter; @@ -77,11 +92,34 @@ typedef struct { SArray *aDelData; // SArray } SCommitter; +extern int32_t tsdbReadSstBlockEx(SDataFReader *pReader, int32_t iSst, SSstBlk *aSstBlk, + SBlockData *pBlockData); // todo + static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter); static int32_t tsdbCommitData(SCommitter *pCommitter); static int32_t tsdbCommitDel(SCommitter *pCommitter); static int32_t tsdbCommitCache(SCommitter *pCommitter); static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno); +static int32_t tsdbNextCommitRow(SCommitter *pCommitter); + +static int32_t tRowInfoCmprFn(const void *p1, const void *p2) { + SRowInfo *pInfo1 = (SRowInfo *)p1; + SRowInfo *pInfo2 = (SRowInfo *)p2; + + if (pInfo1->suid < pInfo2->suid) { + return -1; + } else if (pInfo1->suid > pInfo2->suid) { + return 1; + } + + if (pInfo1->uid < pInfo2->uid) { + return -1; + } else if (pInfo1->uid > pInfo2->uid) { + return 1; + } + + return tsdbRowCmprFn(&pInfo1->row, &pInfo2->row); +} int32_t tsdbBegin(STsdb *pTsdb) { int32_t code = 0; @@ -294,7 +332,10 @@ static int32_t tsdbCommitterUpdateTableSchema(SCommitter *pCommitter, int64_t su int32_t code = 0; if (suid) { - if (pCommitter->skmTable.suid == suid) goto _exit; + if (pCommitter->skmTable.suid == suid) { + pCommitter->skmTable.uid = uid; + goto _exit; + } } else { if (pCommitter->skmTable.uid == uid) goto _exit; } @@ -334,54 +375,6 @@ _exit: return code; } -static int32_t tsdbCommitterNextLastRow(SCommitter *pCommitter) { - int32_t code = 0; - - ASSERT(pCommitter->dReader.pReader); - ASSERT(pCommitter->dReader.pRowInfo); - - SBlockData *pBlockDatal = &pCommitter->dReader.bDatal; - pCommitter->dReader.iRow++; - if (pCommitter->dReader.iRow < pBlockDatal->nRow) { - if (pBlockDatal->uid) { - pCommitter->dReader.pRowInfo->uid = pBlockDatal->uid; - } else { - pCommitter->dReader.pRowInfo->uid = pBlockDatal->aUid[pCommitter->dReader.iRow]; - } - pCommitter->dReader.pRowInfo->row = tsdbRowFromBlockData(pBlockDatal, pCommitter->dReader.iRow); - } else { - pCommitter->dReader.iBlockL++; - if (pCommitter->dReader.iBlockL < taosArrayGetSize(pCommitter->dReader.aBlockL)) { - SBlockL *pBlockL = (SBlockL *)taosArrayGet(pCommitter->dReader.aBlockL, pCommitter->dReader.iBlockL); - int64_t suid = pBlockL->suid; - int64_t uid = pBlockL->maxUid; - - code = tsdbCommitterUpdateTableSchema(pCommitter, suid, uid); - if (code) goto _exit; - - code = tBlockDataInit(pBlockDatal, suid, suid ? 0 : uid, pCommitter->skmTable.pTSchema); - if (code) goto _exit; - - code = tsdbReadLastBlock(pCommitter->dReader.pReader, pBlockL, pBlockDatal); - if (code) goto _exit; - - pCommitter->dReader.iRow = 0; - pCommitter->dReader.pRowInfo->suid = pBlockDatal->suid; - if (pBlockDatal->uid) { - pCommitter->dReader.pRowInfo->uid = pBlockDatal->uid; - } else { - pCommitter->dReader.pRowInfo->uid = pBlockDatal->aUid[0]; - } - pCommitter->dReader.pRowInfo->row = tsdbRowFromBlockData(pBlockDatal, pCommitter->dReader.iRow); - } else { - pCommitter->dReader.pRowInfo = NULL; - } - } - -_exit: - return code; -} - static int32_t tsdbCommitterNextTableData(SCommitter *pCommitter) { int32_t code = 0; @@ -404,6 +397,85 @@ _exit: return code; } +static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) { + int32_t code = 0; + + pCommitter->pIter = NULL; + tRBTreeCreate(&pCommitter->rbt, tRowInfoCmprFn); + + // memory + TSDBKEY tKey = {.ts = pCommitter->minKey, .version = VERSION_MIN}; + SDataIter *pIter = &pCommitter->dataIter; + pIter->type = MEMORY_DATA_ITER; + pIter->iTbDataP = 0; + for (; pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP); pIter->iTbDataP++) { + STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, pIter->iTbDataP); + tsdbTbDataIterOpen(pTbData, &tKey, 0, &pIter->iter); + TSDBROW *pRow = tsdbTbDataIterGet(&pIter->iter); + if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { + pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow)); + pRow = NULL; + } + + if (pRow == NULL) continue; + + pIter->r.suid = pTbData->suid; + pIter->r.uid = pTbData->uid; + pIter->r.row = *pRow; + break; + } + ASSERT(pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP)); + tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pIter); + + // disk + pCommitter->toLastOnly = 0; + SDataFReader *pReader = pCommitter->dReader.pReader; + if (pReader) { + if (pReader->pSet->nSstF >= pCommitter->maxLast) { + int8_t iIter = 0; + for (int32_t iSst = 0; iSst < pReader->pSet->nSstF; iSst++) { + pIter = &pCommitter->aDataIter[iIter]; + pIter->type = LAST_DATA_ITER; + pIter->iSst = iSst; + + code = tsdbReadSstBlk(pCommitter->dReader.pReader, iSst, pIter->aSstBlk); + if (code) goto _err; + + if (taosArrayGetSize(pIter->aSstBlk) == 0) continue; + + pIter->iSstBlk = 0; + SSstBlk *pSstBlk = (SSstBlk *)taosArrayGet(pIter->aSstBlk, 0); + code = tsdbReadSstBlockEx(pCommitter->dReader.pReader, iSst, pSstBlk, &pIter->bData); + if (code) goto _err; + + pIter->iRow = 0; + pIter->r.suid = pIter->bData.suid; + pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[0]; + pIter->r.row = tsdbRowFromBlockData(&pIter->bData, 0); + + tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pIter); + iIter++; + } + } else { + for (int32_t iSst = 0; iSst < pReader->pSet->nSstF; iSst++) { + SSstFile *pSstFile = pReader->pSet->aSstF[iSst]; + if (pSstFile->size > pSstFile->offset) { + pCommitter->toLastOnly = 1; + break; + } + } + } + } + + code = tsdbNextCommitRow(pCommitter); + if (code) goto _err; + + return code; + +_err: + return code; +} + static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { int32_t code = 0; STsdb *pTsdb = pCommitter->pTsdb; @@ -416,8 +488,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { pCommitter->nextKey = TSKEY_MAX; // Reader - pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &(SDFileSet){.fid = pCommitter->commitFid}, - tDFileSetCmprFn, TD_EQ); + SDFileSet tDFileSet = {.fid = pCommitter->commitFid}; + pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &tDFileSet, tDFileSetCmprFn, TD_EQ); if (pRSet) { code = tsdbDataFReaderOpen(&pCommitter->dReader.pReader, pTsdb, pRSet); if (code) goto _err; @@ -427,68 +499,58 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { if (code) goto _err; pCommitter->dReader.iBlockIdx = 0; - if (pCommitter->dReader.iBlockIdx < taosArrayGetSize(pCommitter->dReader.aBlockIdx)) { - pCommitter->dReader.pBlockIdx = - (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, pCommitter->dReader.iBlockIdx); - + if (taosArrayGetSize(pCommitter->dReader.aBlockIdx) > 0) { + pCommitter->dReader.pBlockIdx = (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, 0); code = tsdbReadBlock(pCommitter->dReader.pReader, pCommitter->dReader.pBlockIdx, &pCommitter->dReader.mBlock); if (code) goto _err; } else { pCommitter->dReader.pBlockIdx = NULL; } tBlockDataReset(&pCommitter->dReader.bData); - - // last - code = tsdbReadBlockL(pCommitter->dReader.pReader, pCommitter->dReader.aBlockL); - if (code) goto _err; - - pCommitter->dReader.iBlockL = -1; - pCommitter->dReader.iRow = -1; - pCommitter->dReader.pRowInfo = &pCommitter->dReader.rowInfo; - tBlockDataReset(&pCommitter->dReader.bDatal); - code = tsdbCommitterNextLastRow(pCommitter); - if (code) goto _err; } else { pCommitter->dReader.pBlockIdx = NULL; - pCommitter->dReader.pRowInfo = NULL; } // Writer - SHeadFile fHead; - SDataFile fData; - SLastFile fLast; - SSmaFile fSma; - SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma}; + SHeadFile fHead = {.commitID = pCommitter->commitID}; + SDataFile fData = {.commitID = pCommitter->commitID}; + SSmaFile fSma = {.commitID = pCommitter->commitID}; + SSstFile fSst = {.commitID = pCommitter->commitID}; + SDFileSet wSet = {.fid = pCommitter->commitFid, .pHeadF = &fHead, .pDataF = &fData, .pSmaF = &fSma}; if (pRSet) { - wSet.diskId = pRSet->diskId; - wSet.fid = pCommitter->commitFid; - fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0}; + ASSERT(pRSet->nSstF <= pCommitter->maxLast); fData = *pRSet->pDataF; - fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0}; fSma = *pRSet->pSmaF; + wSet.diskId = pRSet->diskId; + if (pRSet->nSstF < pCommitter->maxLast) { + for (int32_t iSst = 0; iSst < pRSet->nSstF; iSst++) { + wSet.aSstF[iSst] = pRSet->aSstF[iSst]; + } + wSet.nSstF = pRSet->nSstF + 1; + } else { + wSet.nSstF = 1; + } } else { SDiskID did = {0}; - tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did); - tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did); - wSet.diskId = did; - wSet.fid = pCommitter->commitFid; - fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0}; - fData = (SDataFile){.commitID = pCommitter->commitID, .size = 0}; - fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0}; - fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0}; + wSet.nSstF = 1; } + wSet.aSstF[wSet.nSstF - 1] = &fSst; code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet); if (code) goto _err; taosArrayClear(pCommitter->dWriter.aBlockIdx); - taosArrayClear(pCommitter->dWriter.aBlockL); + taosArrayClear(pCommitter->dWriter.aSstBlk); tMapDataReset(&pCommitter->dWriter.mBlock); tBlockDataReset(&pCommitter->dWriter.bData); tBlockDataReset(&pCommitter->dWriter.bDatal); + // open iter + code = tsdbOpenCommitIter(pCommitter); + if (code) goto _err; + _exit: return code; @@ -497,18 +559,14 @@ _err: return code; } -static int32_t tsdbCommitDataBlock(SCommitter *pCommitter, SBlock *pBlock) { +static int32_t tsdbCommitDataBlock(SCommitter *pCommitter) { int32_t code = 0; SBlockData *pBlockData = &pCommitter->dWriter.bData; - SBlock block; + SDataBlk block; ASSERT(pBlockData->nRow > 0); - if (pBlock) { - block = *pBlock; // as a subblock - } else { - tBlockReset(&block); // as a new block - } + tDataBlkReset(&block); // info block.nRow += pBlockData->nRow; @@ -539,8 +597,8 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter, SBlock *pBlock) { ((block.nSubBlock == 1) && !block.hasDup) ? &block.smaInfo : NULL, pCommitter->cmprAlg, 0); if (code) goto _err; - // put SBlock - code = tMapDataPutItem(&pCommitter->dWriter.mBlock, &block, tPutBlock); + // put SDataBlk + code = tMapDataPutItem(&pCommitter->dWriter.mBlock, &block, tPutDataBlk); if (code) goto _err; // clear @@ -555,7 +613,7 @@ _err: static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) { int32_t code = 0; - SBlockL blockL; + SSstBlk blockL; SBlockData *pBlockData = &pCommitter->dWriter.bDatal; ASSERT(pBlockData->nRow > 0); @@ -580,8 +638,8 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) { code = tsdbWriteBlockData(pCommitter->dWriter.pWriter, pBlockData, &blockL.bInfo, NULL, pCommitter->cmprAlg, 1); if (code) goto _err; - // push SBlockL - if (taosArrayPush(pCommitter->dWriter.aBlockL, &blockL) == NULL) { + // push SSstBlk + if (taosArrayPush(pCommitter->dWriter.aSstBlk, &blockL) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -596,929 +654,833 @@ _err: return code; } -static int32_t tsdbMergeCommitData(SCommitter *pCommitter, STbDataIter *pIter, SBlock *pBlock) { - int32_t code = 0; - STbData *pTbData = pIter->pTbData; - SBlockData *pBlockDataR = &pCommitter->dReader.bData; - SBlockData *pBlockDataW = &pCommitter->dWriter.bData; +static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) { + int32_t code = 0; - code = tsdbReadDataBlock(pCommitter->dReader.pReader, pBlock, pBlockDataR); + // write aBlockIdx + code = tsdbWriteBlockIdx(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockIdx); if (code) goto _err; - tBlockDataClear(pBlockDataW); - int32_t iRow = 0; - TSDBROW row; - TSDBROW *pRow1 = tsdbTbDataIterGet(pIter); - TSDBROW *pRow2 = &row; - *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow); - while (pRow1 && pRow2) { - int32_t c = tsdbRowCmprFn(pRow1, pRow2); - - if (c < 0) { - code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow1)); - if (code) goto _err; - - code = tBlockDataAppendRow(pBlockDataW, pRow1, pCommitter->skmRow.pTSchema, pTbData->uid); - if (code) goto _err; - - // next - tsdbTbDataIterNext(pIter); - pRow1 = tsdbTbDataIterGet(pIter); - } else if (c > 0) { - code = tBlockDataAppendRow(pBlockDataW, pRow2, NULL, pTbData->uid); - if (code) goto _err; - - iRow++; - if (iRow < pBlockDataR->nRow) { - *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow); - } else { - pRow2 = NULL; - } - } else { - ASSERT(0); - } - - // check - if (pBlockDataW->nRow >= pCommitter->maxRow * 4 / 5) { - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - } - } + // write aSstBlk + code = tsdbWriteSstBlk(pCommitter->dWriter.pWriter, pCommitter->dWriter.aSstBlk); + if (code) goto _err; - while (pRow2) { - code = tBlockDataAppendRow(pBlockDataW, pRow2, NULL, pTbData->uid); - if (code) goto _err; + // update file header + code = tsdbUpdateDFileSetHeader(pCommitter->dWriter.pWriter); + if (code) goto _err; - iRow++; - if (iRow < pBlockDataR->nRow) { - *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow); - } else { - pRow2 = NULL; - } + // upsert SDFileSet + code = tsdbFSUpsertFSet(&pCommitter->fs, &pCommitter->dWriter.pWriter->wSet); + if (code) goto _err; - // check - if (pBlockDataW->nRow >= pCommitter->maxRow * 4 / 5) { - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - } - } + // close and sync + code = tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 1); + if (code) goto _err; - // check - if (pBlockDataW->nRow > 0) { - code = tsdbCommitDataBlock(pCommitter, NULL); + if (pCommitter->dReader.pReader) { + code = tsdbDataFReaderClose(&pCommitter->dReader.pReader); if (code) goto _err; } +_exit: return code; _err: - tsdbError("vgId:%d, tsdb merge commit data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, commit file data end failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbCommitTableMemData(SCommitter *pCommitter, STbDataIter *pIter, TSDBKEY toKey) { - int32_t code = 0; - STbData *pTbData = pIter->pTbData; - SBlockData *pBlockData = &pCommitter->dWriter.bData; - - tBlockDataClear(pBlockData); - TSDBROW *pRow = tsdbTbDataIterGet(pIter); - while (true) { - if (pRow == NULL) { - if (pBlockData->nRow > 0) { - goto _write_block; - } else { - break; - } - } - - // update schema - code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow)); - if (code) goto _err; +static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) { + int32_t code = 0; - // append - code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid); + while (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, &toTable) < 0) { + SBlockIdx blockIdx = *pCommitter->dReader.pBlockIdx; + code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx); if (code) goto _err; - tsdbTbDataIterNext(pIter); - pRow = tsdbTbDataIterGet(pIter); - if (pRow) { - TSDBKEY rowKey = TSDBROW_KEY(pRow); - if (tsdbKeyCmprFn(&rowKey, &toKey) >= 0) { - pRow = NULL; - } + if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; } - if (pBlockData->nRow >= pCommitter->maxRow * 4 / 5) { - _write_block: - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - } + code = tsdbCommitterNextTableData(pCommitter); + if (code) goto _err; } return code; _err: - tsdbError("vgId:%d, tsdb commit table mem data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb move commit data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbGetNumOfRowsLessThan(STbDataIter *pIter, TSDBKEY key) { - int32_t nRow = 0; - - STbDataIter iter = *pIter; - while (true) { - TSDBROW *pRow = tsdbTbDataIterGet(&iter); - if (pRow == NULL) break; +static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter); +static int32_t tsdbCommitFileData(SCommitter *pCommitter) { + int32_t code = 0; + STsdb *pTsdb = pCommitter->pTsdb; + SMemTable *pMemTable = pTsdb->imem; - int32_t c = tsdbKeyCmprFn(&TSDBROW_KEY(pRow), &key); - if (c < 0) { - nRow++; - tsdbTbDataIterNext(&iter); - } else if (c > 0) { - break; - } else { - ASSERT(0); - } - } + // commit file data start + code = tsdbCommitFileDataStart(pCommitter); + if (code) goto _err; - return nRow; -} + // impl + code = tsdbCommitFileDataImpl(pCommitter); + if (code) goto _err; -static int32_t tsdbMergeAsSubBlock(SCommitter *pCommitter, STbDataIter *pIter, SBlock *pBlock) { - int32_t code = 0; - STbData *pTbData = pIter->pTbData; - SBlockData *pBlockData = &pCommitter->dWriter.bData; + // commit file data end + code = tsdbCommitFileDataEnd(pCommitter); + if (code) goto _err; - tBlockDataClear(pBlockData); - TSDBROW *pRow = tsdbTbDataIterGet(pIter); - while (true) { - if (pRow == NULL) break; + return code; - code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow)); - if (code) goto _err; +_err: + tsdbError("vgId:%d, commit file data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbDataFReaderClose(&pCommitter->dReader.pReader); + tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 0); + return code; +} - code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid); - if (code) goto _err; +// ---------------------------------------------------------------------------- +static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) { + int32_t code = 0; - tsdbTbDataIterNext(pIter); - pRow = tsdbTbDataIterGet(pIter); - if (pRow) { - TSDBKEY rowKey = TSDBROW_KEY(pRow); - if (tsdbKeyCmprFn(&rowKey, &pBlock->maxKey) > 0) { - pRow = NULL; - } - } - } + memset(pCommitter, 0, sizeof(*pCommitter)); + ASSERT(pTsdb->mem && pTsdb->imem == NULL); - ASSERT(pBlockData->nRow > 0 && pBlock->nRow + pBlockData->nRow <= pCommitter->maxRow); + taosThreadRwlockWrlock(&pTsdb->rwLock); + pTsdb->imem = pTsdb->mem; + pTsdb->mem = NULL; + taosThreadRwlockUnlock(&pTsdb->rwLock); - code = tsdbCommitDataBlock(pCommitter, pBlock); + pCommitter->pTsdb = pTsdb; + pCommitter->commitID = pTsdb->pVnode->state.commitID; + pCommitter->minutes = pTsdb->keepCfg.days; + pCommitter->precision = pTsdb->keepCfg.precision; + pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows; + pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows; + pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression; + pCommitter->maxLast = TSDB_DEFAULT_LAST_FILE; // TODO: make it as a config + pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem); + if (pCommitter->aTbDataP == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + code = tsdbFSCopy(pTsdb, &pCommitter->fs); if (code) goto _err; return code; _err: - tsdbError("vgId:%d, tsdb merge as subblock failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, tsdb start commit failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbMergeCommitLast(SCommitter *pCommitter, STbDataIter *pIter) { - int32_t code = 0; - STbData *pTbData = pIter->pTbData; - int32_t nRow = tsdbGetNumOfRowsLessThan(pIter, (TSDBKEY){.ts = pCommitter->maxKey + 1, .version = VERSION_MIN}); +static int32_t tsdbCommitDataStart(SCommitter *pCommitter) { + int32_t code = 0; - if (pCommitter->dReader.pRowInfo && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pRowInfo) == 0) { - if (pCommitter->dReader.pRowInfo->suid) { // super table - for (int32_t iRow = pCommitter->dReader.iRow; iRow < pCommitter->dReader.bDatal.nRow; iRow++) { - if (pTbData->uid != pCommitter->dReader.bDatal.aUid[iRow]) break; - nRow++; - } - } else { // normal table - ASSERT(pCommitter->dReader.iRow == 0); - nRow += pCommitter->dReader.bDatal.nRow; - } + // reader + pCommitter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + if (pCommitter->dReader.aBlockIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; } - if (nRow == 0) goto _exit; + code = tBlockDataCreate(&pCommitter->dReader.bData); + if (code) goto _exit; - TSDBROW *pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } + // merger + for (int32_t iSst = 0; iSst < TSDB_MAX_LAST_FILE; iSst++) { + SDataIter *pIter = &pCommitter->aDataIter[iSst]; + pIter->aSstBlk = taosArrayInit(0, sizeof(SSstBlk)); + if (pIter->aSstBlk == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } - SRowInfo *pRowInfo = pCommitter->dReader.pRowInfo; - if (pRowInfo && pRowInfo->uid != pTbData->uid) { - pRowInfo = NULL; + code = tBlockDataCreate(&pIter->bData); + if (code) goto _exit; } - while (nRow) { - SBlockData *pBlockData; - int8_t toData; + // writer + pCommitter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); + if (pCommitter->dWriter.aBlockIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } - if (nRow < pCommitter->minRow) { // to .last - toData = 0; - pBlockData = &pCommitter->dWriter.bDatal; + pCommitter->dWriter.aSstBlk = taosArrayInit(0, sizeof(SSstBlk)); + if (pCommitter->dWriter.aSstBlk == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } - // commit and reset block data schema if need - // QUESTION: Is there a case that pBlockData->nRow == 0 but need to change schema ? - if (pBlockData->suid || pBlockData->uid) { - if (pBlockData->suid != pTbData->suid || pBlockData->suid == 0) { - if (pBlockData->nRow > 0) { - code = tsdbCommitLastBlock(pCommitter); - if (code) goto _err; - } + code = tBlockDataCreate(&pCommitter->dWriter.bData); + if (code) goto _exit; - tBlockDataReset(pBlockData); - } - } + code = tBlockDataCreate(&pCommitter->dWriter.bDatal); + if (code) goto _exit; - // set block data schema if need - if (pBlockData->suid == 0 && pBlockData->uid == 0) { - code = tsdbCommitterUpdateTableSchema(pCommitter, pTbData->suid, pTbData->uid); - if (code) goto _err; +_exit: + return code; +} - code = - tBlockDataInit(pBlockData, pTbData->suid, pTbData->suid ? 0 : pTbData->uid, pCommitter->skmTable.pTSchema); - if (code) goto _err; - } +static void tsdbCommitDataEnd(SCommitter *pCommitter) { + // reader + taosArrayDestroy(pCommitter->dReader.aBlockIdx); + tMapDataClear(&pCommitter->dReader.mBlock); + tBlockDataDestroy(&pCommitter->dReader.bData, 1); - if (pBlockData->nRow + nRow > pCommitter->maxRow) { - code = tsdbCommitLastBlock(pCommitter); - if (code) goto _err; - } - } else { // to .data - toData = 1; - pBlockData = &pCommitter->dWriter.bData; - ASSERT(pBlockData->nRow == 0); - } + // merger + for (int32_t iSst = 0; iSst < TSDB_MAX_LAST_FILE; iSst++) { + SDataIter *pIter = &pCommitter->aDataIter[iSst]; + taosArrayDestroy(pIter->aSstBlk); + tBlockDataDestroy(&pIter->bData, 1); + } - while (pRow && pRowInfo) { - int32_t c = tsdbRowCmprFn(pRow, &pRowInfo->row); - if (c < 0) { - code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow)); - if (code) goto _err; - - code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid); - if (code) goto _err; - - tsdbTbDataIterNext(pIter); - pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } - } else if (c > 0) { - code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid); - if (code) goto _err; - - code = tsdbCommitterNextLastRow(pCommitter); - if (code) goto _err; - - pRowInfo = pCommitter->dReader.pRowInfo; - if (pRowInfo && pRowInfo->uid != pTbData->uid) { - pRowInfo = NULL; - } - } else { - ASSERT(0); - } - - nRow--; - if (toData) { - if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) { - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - goto _outer_break; - } - } - } - - while (pRow) { - code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow)); - if (code) goto _err; - - code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid); - if (code) goto _err; - - tsdbTbDataIterNext(pIter); - pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } - - nRow--; - if (toData) { - if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) { - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - goto _outer_break; - } - } - } - - while (pRowInfo) { - code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid); - if (code) goto _err; + // writer + taosArrayDestroy(pCommitter->dWriter.aBlockIdx); + taosArrayDestroy(pCommitter->dWriter.aSstBlk); + tMapDataClear(&pCommitter->dWriter.mBlock); + tBlockDataDestroy(&pCommitter->dWriter.bData, 1); + tBlockDataDestroy(&pCommitter->dWriter.bDatal, 1); + tTSchemaDestroy(pCommitter->skmTable.pTSchema); + tTSchemaDestroy(pCommitter->skmRow.pTSchema); +} - code = tsdbCommitterNextLastRow(pCommitter); - if (code) goto _err; +static int32_t tsdbCommitData(SCommitter *pCommitter) { + int32_t code = 0; + STsdb *pTsdb = pCommitter->pTsdb; + SMemTable *pMemTable = pTsdb->imem; - pRowInfo = pCommitter->dReader.pRowInfo; - if (pRowInfo && pRowInfo->uid != pTbData->uid) { - pRowInfo = NULL; - } + // check + if (pMemTable->nRow == 0) goto _exit; - nRow--; - if (toData) { - if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) { - code = tsdbCommitDataBlock(pCommitter, NULL); - if (code) goto _err; - goto _outer_break; - } - } - } + // start ==================== + code = tsdbCommitDataStart(pCommitter); + if (code) goto _err; - _outer_break: - ASSERT(nRow >= 0); + // impl ==================== + pCommitter->nextKey = pMemTable->minKey; + while (pCommitter->nextKey < TSKEY_MAX) { + code = tsdbCommitFileData(pCommitter); + if (code) goto _err; } + // end ==================== + tsdbCommitDataEnd(pCommitter); + _exit: + tsdbInfo("vgId:%d, commit data done, nRow:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nRow); return code; _err: - tsdbError("vgId:%d tsdb merge commit last failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbCommitDataEnd(pCommitter); + tsdbError("vgId:%d, commit data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) { - int32_t code = 0; - - ASSERT(pCommitter->dReader.pBlockIdx == NULL || tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, pTbData) >= 0); - ASSERT(pCommitter->dReader.pRowInfo == NULL || tTABLEIDCmprFn(pCommitter->dReader.pRowInfo, pTbData) >= 0); - - // merge commit table data - STbDataIter iter = {0}; - STbDataIter *pIter = &iter; - TSDBROW *pRow; - - tsdbTbDataIterOpen(pTbData, &(TSDBKEY){.ts = pCommitter->minKey, .version = VERSION_MIN}, 0, pIter); - pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } - - if (pRow == NULL) { - if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, pTbData) == 0) { - SBlockIdx blockIdx = {.suid = pTbData->suid, .uid = pTbData->uid}; - code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx); - if (code) goto _err; - - if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - } +static int32_t tsdbCommitDel(SCommitter *pCommitter) { + int32_t code = 0; + STsdb *pTsdb = pCommitter->pTsdb; + SMemTable *pMemTable = pTsdb->imem; + if (pMemTable->nDel == 0) { goto _exit; } - int32_t iBlock = 0; - SBlock block; - SBlock *pBlock = █ - if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pBlockIdx) == 0) { - tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); - } else { - pBlock = NULL; + // start + code = tsdbCommitDelStart(pCommitter); + if (code) { + goto _err; } - code = tsdbCommitterUpdateTableSchema(pCommitter, pTbData->suid, pTbData->uid); - if (code) goto _err; - - tMapDataReset(&pCommitter->dWriter.mBlock); - code = tBlockDataInit(&pCommitter->dReader.bData, pTbData->suid, pTbData->uid, pCommitter->skmTable.pTSchema); - if (code) goto _err; - code = tBlockDataInit(&pCommitter->dWriter.bData, pTbData->suid, pTbData->uid, pCommitter->skmTable.pTSchema); - if (code) goto _err; - - // .data merge - while (pBlock && pRow) { - int32_t c = tBlockCmprFn(pBlock, &(SBlock){.minKey = TSDBROW_KEY(pRow), .maxKey = TSDBROW_KEY(pRow)}); - if (c < 0) { // disk - code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock); - if (code) goto _err; - - // next - iBlock++; - if (iBlock < pCommitter->dReader.mBlock.nItem) { - tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); - } else { - pBlock = NULL; - } - } else if (c > 0) { // memory - code = tsdbCommitTableMemData(pCommitter, pIter, pBlock->minKey); - if (code) goto _err; + // impl + int32_t iDelIdx = 0; + int32_t nDelIdx = taosArrayGetSize(pCommitter->aDelIdx); + int32_t iTbData = 0; + int32_t nTbData = taosArrayGetSize(pCommitter->aTbDataP); + STbData *pTbData; + SDelIdx *pDelIdx; - // next - pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } - } else { // merge - int32_t nOvlp = tsdbGetNumOfRowsLessThan(pIter, pBlock->maxKey); + ASSERT(nTbData > 0); - ASSERT(nOvlp > 0); + pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData); + pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; + while (true) { + if (pTbData == NULL && pDelIdx == NULL) break; - if (pBlock->nRow + nOvlp <= pCommitter->maxRow && pBlock->nSubBlock < TSDB_MAX_SUBBLOCKS) { - code = tsdbMergeAsSubBlock(pCommitter, pIter, pBlock); - if (code) goto _err; - } else { - code = tsdbMergeCommitData(pCommitter, pIter, pBlock); - if (code) goto _err; - } + if (pTbData && pDelIdx) { + int32_t c = tTABLEIDCmprFn(pTbData, pDelIdx); - // next - pRow = tsdbTbDataIterGet(pIter); - if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { - pRow = NULL; - } - iBlock++; - if (iBlock < pCommitter->dReader.mBlock.nItem) { - tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); + if (c == 0) { + goto _commit_mem_and_disk_del; + } else if (c < 0) { + goto _commit_mem_del; } else { - pBlock = NULL; + goto _commit_disk_del; } + } else if (pTbData) { + goto _commit_mem_del; + } else { + goto _commit_disk_del; } - } - while (pBlock) { - code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock); + _commit_mem_del: + code = tsdbCommitTableDel(pCommitter, pTbData, NULL); if (code) goto _err; - // next - iBlock++; - if (iBlock < pCommitter->dReader.mBlock.nItem) { - tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock); - } else { - pBlock = NULL; - } - } + iTbData++; + pTbData = (iTbData < nTbData) ? (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData) : NULL; + continue; - // .data append and .last merge - code = tsdbMergeCommitLast(pCommitter, pIter); - if (code) goto _err; + _commit_disk_del: + code = tsdbCommitTableDel(pCommitter, NULL, pDelIdx); + if (code) goto _err; - // end - if (pCommitter->dWriter.mBlock.nItem > 0) { - SBlockIdx blockIdx = {.suid = pTbData->suid, .uid = pTbData->uid}; - code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dWriter.mBlock, &blockIdx); + iDelIdx++; + pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; + continue; + + _commit_mem_and_disk_del: + code = tsdbCommitTableDel(pCommitter, pTbData, pDelIdx); if (code) goto _err; - if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } + iTbData++; + pTbData = (iTbData < nTbData) ? (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData) : NULL; + iDelIdx++; + pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; + continue; } -_exit: - pRow = tsdbTbDataIterGet(pIter); - if (pRow) { - pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow)); + // end + code = tsdbCommitDelEnd(pCommitter); + if (code) { + goto _err; } +_exit: + tsdbDebug("vgId:%d, commit del done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel); return code; _err: - tsdbError("vgId:%d tsdb commit table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, commit del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) { - int32_t code = 0; +static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) { + int32_t code = 0; + STsdb *pTsdb = pCommitter->pTsdb; + SMemTable *pMemTable = pTsdb->imem; - // write aBlockIdx - code = tsdbWriteBlockIdx(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockIdx); - if (code) goto _err; + ASSERT(eno == 0); - // write aBlockL - code = tsdbWriteBlockL(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockL); + code = tsdbFSCommit1(pTsdb, &pCommitter->fs); if (code) goto _err; - // update file header - code = tsdbUpdateDFileSetHeader(pCommitter->dWriter.pWriter); - if (code) goto _err; + // lock + taosThreadRwlockWrlock(&pTsdb->rwLock); - // upsert SDFileSet - code = tsdbFSUpsertFSet(&pCommitter->fs, &pCommitter->dWriter.pWriter->wSet); - if (code) goto _err; + // commit or rollback + code = tsdbFSCommit2(pTsdb, &pCommitter->fs); + if (code) { + taosThreadRwlockUnlock(&pTsdb->rwLock); + goto _err; + } - // close and sync - code = tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 1); - if (code) goto _err; + pTsdb->imem = NULL; - if (pCommitter->dReader.pReader) { - code = tsdbDataFReaderClose(&pCommitter->dReader.pReader); - if (code) goto _err; - } + // unlock + taosThreadRwlockUnlock(&pTsdb->rwLock); -_exit: + tsdbUnrefMemTable(pMemTable); + tsdbFSDestroy(&pCommitter->fs); + taosArrayDestroy(pCommitter->aTbDataP); + + // if (pCommitter->toMerge) { + // code = tsdbMerge(pTsdb); + // if (code) goto _err; + // } + + tsdbInfo("vgId:%d, tsdb end commit", TD_VID(pTsdb->pVnode)); return code; _err: - tsdbError("vgId:%d, commit file data end failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, tsdb end commit failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) { - int32_t code = 0; +// ================================================================================ - // .data - while (true) { - if (pCommitter->dReader.pBlockIdx == NULL || tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, &toTable) >= 0) break; +static FORCE_INLINE SRowInfo *tsdbGetCommitRow(SCommitter *pCommitter) { + return (pCommitter->pIter) ? &pCommitter->pIter->r : NULL; +} - SBlockIdx blockIdx = *pCommitter->dReader.pBlockIdx; - code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx); - if (code) goto _err; +static int32_t tsdbNextCommitRow(SCommitter *pCommitter) { + int32_t code = 0; - if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } + if (pCommitter->pIter) { + SDataIter *pIter = pCommitter->pIter; + if (pCommitter->pIter->type == MEMORY_DATA_ITER) { // memory + tsdbTbDataIterNext(&pIter->iter); + TSDBROW *pRow = tsdbTbDataIterGet(&pIter->iter); + while (true) { + if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) { + pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow)); + pRow = NULL; + } - code = tsdbCommitterNextTableData(pCommitter); - if (code) goto _err; - } + if (pRow) { + pIter->r.suid = pIter->iter.pTbData->suid; + pIter->r.uid = pIter->iter.pTbData->uid; + pIter->r.row = *pRow; + break; + } - // .last - while (true) { - if (pCommitter->dReader.pRowInfo == NULL || tTABLEIDCmprFn(pCommitter->dReader.pRowInfo, &toTable) >= 0) break; - - SBlockData *pBlockDataR = &pCommitter->dReader.bDatal; - SBlockData *pBlockDataW = &pCommitter->dWriter.bDatal; - tb_uid_t suid = pCommitter->dReader.pRowInfo->suid; - tb_uid_t uid = pCommitter->dReader.pRowInfo->uid; - - ASSERT((pBlockDataR->suid && !pBlockDataR->uid) || (!pBlockDataR->suid && pBlockDataR->uid)); - ASSERT(pBlockDataR->nRow > 0); - - // commit and reset block data schema if need - if (pBlockDataW->suid || pBlockDataW->uid) { - if (pBlockDataW->suid != suid || pBlockDataW->suid == 0) { - if (pBlockDataW->nRow > 0) { - code = tsdbCommitLastBlock(pCommitter); - if (code) goto _err; + pIter->iTbDataP++; + if (pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP)) { + STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, pIter->iTbDataP); + TSDBKEY keyFrom = {.ts = pCommitter->minKey, .version = VERSION_MIN}; + tsdbTbDataIterOpen(pTbData, &keyFrom, 0, &pIter->iter); + pRow = tsdbTbDataIterGet(&pIter->iter); + continue; + } else { + pCommitter->pIter = NULL; + break; } - tBlockDataReset(pBlockDataW); } - } - - // set block data schema if need - if (pBlockDataW->suid == 0 && pBlockDataW->uid == 0) { - code = tsdbCommitterUpdateTableSchema(pCommitter, suid, uid); - if (code) goto _err; - - code = tBlockDataInit(pBlockDataW, suid, suid ? 0 : uid, pCommitter->skmTable.pTSchema); - if (code) goto _err; - } - - // check if it can make sure that one table data in one block - int32_t nRow = 0; - if (pBlockDataR->suid) { - int32_t iRow = pCommitter->dReader.iRow; - while ((iRow < pBlockDataR->nRow) && (pBlockDataR->aUid[iRow] == uid)) { - nRow++; - iRow++; + } else if (pCommitter->pIter->type == LAST_DATA_ITER) { // last file + pIter->iRow++; + if (pIter->iRow < pIter->bData.nRow) { + pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow]; + pIter->r.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow); + } else { + pIter->iSstBlk++; + if (pIter->iSstBlk < taosArrayGetSize(pIter->aSstBlk)) { + SSstBlk *pSstBlk = (SSstBlk *)taosArrayGet(pIter->aSstBlk, pIter->iSstBlk); + + code = tsdbReadSstBlockEx(pCommitter->dReader.pReader, pIter->iSst, pSstBlk, &pIter->bData); + if (code) goto _exit; + + pIter->iRow = 0; + pIter->r.suid = pIter->bData.suid; + pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[0]; + pIter->r.row = tsdbRowFromBlockData(&pIter->bData, 0); + } else { + pCommitter->pIter = NULL; + } } } else { - ASSERT(pCommitter->dReader.iRow == 0); - nRow = pBlockDataR->nRow; + ASSERT(0); } - ASSERT(nRow > 0 && nRow < pCommitter->minRow); - - if (pBlockDataW->nRow + nRow > pCommitter->maxRow) { - ASSERT(pBlockDataW->nRow > 0); - - code = tsdbCommitLastBlock(pCommitter); - if (code) goto _err; + // compare with min in RB Tree + pIter = (SDataIter *)tRBTreeMin(&pCommitter->rbt); + if (pCommitter->pIter && pIter) { + int32_t c = tRowInfoCmprFn(&pCommitter->pIter->r, &pIter->r); + if (c > 0) { + tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pCommitter->pIter); + pCommitter->pIter = NULL; + } else { + ASSERT(c); + } } + } - while (nRow > 0) { - code = tBlockDataAppendRow(pBlockDataW, &pCommitter->dReader.pRowInfo->row, NULL, uid); - if (code) goto _err; - - code = tsdbCommitterNextLastRow(pCommitter); - if (code) goto _err; - - nRow--; + if (pCommitter->pIter == NULL) { + pCommitter->pIter = (SDataIter *)tRBTreeMin(&pCommitter->rbt); + if (pCommitter->pIter) { + tRBTreeDrop(&pCommitter->rbt, (SRBTreeNode *)pCommitter->pIter); } } - return code; - -_err: - tsdbError("vgId:%d tsdb move commit data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); +_exit: return code; } -static int32_t tsdbCommitFileData(SCommitter *pCommitter) { - int32_t code = 0; - STsdb *pTsdb = pCommitter->pTsdb; - SMemTable *pMemTable = pTsdb->imem; - - // commit file data start - code = tsdbCommitFileDataStart(pCommitter); - if (code) goto _err; +static int32_t tsdbCommitAheadBlock(SCommitter *pCommitter, SDataBlk *pDataBlk) { + int32_t code = 0; + SBlockData *pBlockData = &pCommitter->dWriter.bData; + SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter); + TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid}; - // commit file data impl - for (int32_t iTbData = 0; iTbData < taosArrayGetSize(pCommitter->aTbDataP); iTbData++) { - STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData); + tBlockDataClear(pBlockData); + while (pRowInfo) { + ASSERT(pRowInfo->row.type == 0); + code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row)); + if (code) goto _err; - // move commit until current (suid, uid) - code = tsdbMoveCommitData(pCommitter, *(TABLEID *)pTbData); + code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, pCommitter->skmRow.pTSchema, id.uid); if (code) goto _err; - // commit current table data - code = tsdbCommitTableData(pCommitter, pTbData); + code = tsdbNextCommitRow(pCommitter); if (code) goto _err; - // move next reader table data if need - if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pBlockIdx) == 0) { - code = tsdbCommitterNextTableData(pCommitter); + pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo) { + if (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid) { + pRowInfo = NULL; + } else { + TSDBKEY tKey = TSDBROW_KEY(&pRowInfo->row); + if (tsdbKeyCmprFn(&tKey, &pDataBlk->minKey) >= 0) pRowInfo = NULL; + } + } + + if (pBlockData->nRow >= pCommitter->maxRow) { + code = tsdbCommitDataBlock(pCommitter); if (code) goto _err; } } - code = tsdbMoveCommitData(pCommitter, (TABLEID){.suid = INT64_MAX, .uid = INT64_MAX}); - if (code) goto _err; - - if (pCommitter->dWriter.bDatal.nRow > 0) { - code = tsdbCommitLastBlock(pCommitter); + if (pBlockData->nRow) { + code = tsdbCommitDataBlock(pCommitter); if (code) goto _err; } - // commit file data end - code = tsdbCommitFileDataEnd(pCommitter); - if (code) goto _err; - return code; _err: - tsdbError("vgId:%d, commit file data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); - tsdbDataFReaderClose(&pCommitter->dReader.pReader); - tsdbDataFWriterClose(&pCommitter->dWriter.pWriter, 0); + tsdbError("vgId:%d, tsdb commit ahead block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } -// ---------------------------------------------------------------------------- -static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) { - int32_t code = 0; +static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk) { + int32_t code = 0; + SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter); + TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid}; + SBlockData *pBDataR = &pCommitter->dReader.bData; + SBlockData *pBDataW = &pCommitter->dWriter.bData; + + code = tsdbReadDataBlock(pCommitter->dReader.pReader, pDataBlk, pBDataR); + if (code) goto _err; + + tBlockDataClear(pBDataW); + int32_t iRow = 0; + TSDBROW row = tsdbRowFromBlockData(pBDataR, 0); + TSDBROW *pRow = &row; + + while (pRow && pRowInfo) { + int32_t c = tsdbRowCmprFn(pRow, &pRowInfo->row); + if (c < 0) { + code = tBlockDataAppendRow(pBDataW, pRow, NULL, id.uid); + if (code) goto _err; + + iRow++; + if (iRow < pBDataR->nRow) { + row = tsdbRowFromBlockData(pBDataR, iRow); + } else { + pRow = NULL; + } + } else if (c > 0) { + ASSERT(pRowInfo->row.type == 0); + code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row)); + if (code) goto _err; + + code = tBlockDataAppendRow(pBDataW, &pRowInfo->row, pCommitter->skmRow.pTSchema, id.uid); + if (code) goto _err; + + code = tsdbNextCommitRow(pCommitter); + if (code) goto _err; + + pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo) { + if (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid) { + pRowInfo = NULL; + } else { + TSDBKEY tKey = TSDBROW_KEY(&pRowInfo->row); + if (tsdbKeyCmprFn(&tKey, &pDataBlk->maxKey) > 0) pRowInfo = NULL; + } + } + } else { + ASSERT(0); + } + + if (pBDataW->nRow >= pCommitter->maxRow) { + code = tsdbCommitDataBlock(pCommitter); + if (code) goto _err; + } + } - memset(pCommitter, 0, sizeof(*pCommitter)); - ASSERT(pTsdb->mem && pTsdb->imem == NULL); + while (pRow) { + code = tBlockDataAppendRow(pBDataW, pRow, NULL, id.uid); + if (code) goto _err; - taosThreadRwlockWrlock(&pTsdb->rwLock); - pTsdb->imem = pTsdb->mem; - pTsdb->mem = NULL; - taosThreadRwlockUnlock(&pTsdb->rwLock); + iRow++; + if (iRow < pBDataR->nRow) { + row = tsdbRowFromBlockData(pBDataR, iRow); + } else { + pRow = NULL; + } - pCommitter->pTsdb = pTsdb; - pCommitter->commitID = pTsdb->pVnode->state.commitID; - pCommitter->minutes = pTsdb->keepCfg.days; - pCommitter->precision = pTsdb->keepCfg.precision; - pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows; - pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows; - pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression; - pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem); - if (pCommitter->aTbDataP == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + if (pBDataW->nRow >= pCommitter->maxRow) { + code = tsdbCommitDataBlock(pCommitter); + if (code) goto _err; + } } - code = tsdbFSCopy(pTsdb, &pCommitter->fs); - if (code) goto _err; + if (pBDataW->nRow) { + code = tsdbCommitDataBlock(pCommitter); + if (code) goto _err; + } return code; _err: - tsdbError("vgId:%d, tsdb start commit failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d, tsdb commit merge block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbCommitDataStart(SCommitter *pCommitter) { - int32_t code = 0; +static int32_t tsdbMergeTableData(SCommitter *pCommitter, TABLEID id) { + int32_t code = 0; + SBlockIdx *pBlockIdx = pCommitter->dReader.pBlockIdx; - // Reader - pCommitter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pCommitter->dReader.aBlockIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + ASSERT(pBlockIdx == NULL || tTABLEIDCmprFn(pBlockIdx, &id) >= 0); + if (pBlockIdx && pBlockIdx->suid == id.suid && pBlockIdx->uid == id.uid) { + int32_t iBlock = 0; + SDataBlk block; + SDataBlk *pDataBlk = █ + SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter); - code = tBlockDataCreate(&pCommitter->dReader.bData); - if (code) goto _exit; + ASSERT(pRowInfo->suid == id.suid && pRowInfo->uid == id.uid); - pCommitter->dReader.aBlockL = taosArrayInit(0, sizeof(SBlockL)); - if (pCommitter->dReader.aBlockL == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk); + while (pDataBlk && pRowInfo) { + SDataBlk tBlock = {.minKey = TSDBROW_KEY(&pRowInfo->row), .maxKey = TSDBROW_KEY(&pRowInfo->row)}; + int32_t c = tDataBlkCmprFn(pDataBlk, &tBlock); - code = tBlockDataCreate(&pCommitter->dReader.bDatal); - if (code) goto _exit; + if (c < 0) { + code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pDataBlk, tPutDataBlk); + if (code) goto _err; - // Writer - pCommitter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pCommitter->dWriter.aBlockIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + iBlock++; + if (iBlock < pCommitter->dReader.mBlock.nItem) { + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk); + } else { + pDataBlk = NULL; + } + } else if (c > 0) { + code = tsdbCommitAheadBlock(pCommitter, pDataBlk); + if (code) goto _err; - pCommitter->dWriter.aBlockL = taosArrayInit(0, sizeof(SBlockL)); - if (pCommitter->dWriter.aBlockL == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } + pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) pRowInfo = NULL; + } else { + code = tsdbCommitMergeBlock(pCommitter, pDataBlk); + if (code) goto _err; - code = tBlockDataCreate(&pCommitter->dWriter.bData); - if (code) goto _exit; + iBlock++; + if (iBlock < pCommitter->dReader.mBlock.nItem) { + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk); + } else { + pDataBlk = NULL; + } + pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) pRowInfo = NULL; + } + } - code = tBlockDataCreate(&pCommitter->dWriter.bDatal); - if (code) goto _exit; + while (pDataBlk) { + code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pDataBlk, tPutDataBlk); + if (code) goto _err; + + iBlock++; + if (iBlock < pCommitter->dReader.mBlock.nItem) { + tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk); + } else { + pDataBlk = NULL; + } + } + + code = tsdbCommitterNextTableData(pCommitter); + if (code) goto _err; + } _exit: return code; + +_err: + tsdbError("vgId:%d tsdb merge table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); + return code; } -static void tsdbCommitDataEnd(SCommitter *pCommitter) { - // Reader - taosArrayDestroy(pCommitter->dReader.aBlockIdx); - tMapDataClear(&pCommitter->dReader.mBlock); - tBlockDataDestroy(&pCommitter->dReader.bData, 1); - taosArrayDestroy(pCommitter->dReader.aBlockL); - tBlockDataDestroy(&pCommitter->dReader.bDatal, 1); +static int32_t tsdbInitLastBlockIfNeed(SCommitter *pCommitter, TABLEID id) { + int32_t code = 0; - // Writer - taosArrayDestroy(pCommitter->dWriter.aBlockIdx); - taosArrayDestroy(pCommitter->dWriter.aBlockL); - tMapDataClear(&pCommitter->dWriter.mBlock); - tBlockDataDestroy(&pCommitter->dWriter.bData, 1); - tBlockDataDestroy(&pCommitter->dWriter.bDatal, 1); - tTSchemaDestroy(pCommitter->skmTable.pTSchema); - tTSchemaDestroy(pCommitter->skmRow.pTSchema); + SBlockData *pBDatal = &pCommitter->dWriter.bDatal; + if (pBDatal->suid || pBDatal->uid) { + if ((pBDatal->suid != id.suid) || (id.suid == 0)) { + if (pBDatal->nRow) { + code = tsdbCommitLastBlock(pCommitter); + if (code) goto _exit; + } + tBlockDataReset(pBDatal); + } + } + + if (!pBDatal->suid && !pBDatal->uid) { + ASSERT(pCommitter->skmTable.suid == id.suid); + ASSERT(pCommitter->skmTable.uid == id.uid); + code = tBlockDataInit(pBDatal, id.suid, id.suid ? 0 : id.uid, pCommitter->skmTable.pTSchema); + if (code) goto _exit; + } + +_exit: + return code; } -static int32_t tsdbCommitData(SCommitter *pCommitter) { - int32_t code = 0; - STsdb *pTsdb = pCommitter->pTsdb; - SMemTable *pMemTable = pTsdb->imem; +static int32_t tsdbAppendLastBlock(SCommitter *pCommitter) { + int32_t code = 0; - // check - if (pMemTable->nRow == 0) goto _exit; + SBlockData *pBData = &pCommitter->dWriter.bData; + SBlockData *pBDatal = &pCommitter->dWriter.bDatal; - // start ==================== - code = tsdbCommitDataStart(pCommitter); + TABLEID id = {.suid = pBData->suid, .uid = pBData->uid}; + code = tsdbInitLastBlockIfNeed(pCommitter, id); if (code) goto _err; - // impl ==================== - pCommitter->nextKey = pMemTable->minKey; - while (pCommitter->nextKey < TSKEY_MAX) { - code = tsdbCommitFileData(pCommitter); + for (int32_t iRow = 0; iRow < pBData->nRow; iRow++) { + TSDBROW row = tsdbRowFromBlockData(pBData, iRow); + code = tBlockDataAppendRow(pBDatal, &row, NULL, pBData->uid); if (code) goto _err; - } - // end ==================== - tsdbCommitDataEnd(pCommitter); + if (pBDatal->nRow >= pCommitter->maxRow) { + code = tsdbCommitLastBlock(pCommitter); + if (code) goto _err; + } + } -_exit: - tsdbDebug("vgId:%d, commit data done, nRow:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nRow); return code; _err: - tsdbCommitDataEnd(pCommitter); - tsdbError("vgId:%d, commit data failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbCommitDel(SCommitter *pCommitter) { - int32_t code = 0; - STsdb *pTsdb = pCommitter->pTsdb; - SMemTable *pMemTable = pTsdb->imem; - - if (pMemTable->nDel == 0) { - goto _exit; - } +static int32_t tsdbCommitTableData(SCommitter *pCommitter, TABLEID id) { + int32_t code = 0; - // start - code = tsdbCommitDelStart(pCommitter); - if (code) { - goto _err; + SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) { + pRowInfo = NULL; } - // impl - int32_t iDelIdx = 0; - int32_t nDelIdx = taosArrayGetSize(pCommitter->aDelIdx); - int32_t iTbData = 0; - int32_t nTbData = taosArrayGetSize(pCommitter->aTbDataP); - STbData *pTbData; - SDelIdx *pDelIdx; - - ASSERT(nTbData > 0); - - pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData); - pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; - while (true) { - if (pTbData == NULL && pDelIdx == NULL) break; + if (pRowInfo == NULL) goto _exit; - if (pTbData && pDelIdx) { - int32_t c = tTABLEIDCmprFn(pTbData, pDelIdx); + SBlockData *pBData; + if (pCommitter->toLastOnly) { + pBData = &pCommitter->dWriter.bDatal; + code = tsdbInitLastBlockIfNeed(pCommitter, id); + if (code) goto _err; + } else { + pBData = &pCommitter->dWriter.bData; + ASSERT(pBData->nRow == 0); + } - if (c == 0) { - goto _commit_mem_and_disk_del; - } else if (c < 0) { - goto _commit_mem_del; - } else { - goto _commit_disk_del; - } - } else if (pTbData) { - goto _commit_mem_del; - } else { - goto _commit_disk_del; + while (pRowInfo) { + STSchema *pTSchema = NULL; + if (pRowInfo->row.type == 0) { + code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row)); + if (code) goto _err; + pTSchema = pCommitter->skmRow.pTSchema; } - _commit_mem_del: - code = tsdbCommitTableDel(pCommitter, pTbData, NULL); + code = tBlockDataAppendRow(pBData, &pRowInfo->row, pTSchema, id.uid); if (code) goto _err; - iTbData++; - pTbData = (iTbData < nTbData) ? (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData) : NULL; - continue; - - _commit_disk_del: - code = tsdbCommitTableDel(pCommitter, NULL, pDelIdx); + code = tsdbNextCommitRow(pCommitter); if (code) goto _err; - iDelIdx++; - pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; - continue; - - _commit_mem_and_disk_del: - code = tsdbCommitTableDel(pCommitter, pTbData, pDelIdx); - if (code) goto _err; + pRowInfo = tsdbGetCommitRow(pCommitter); + if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) { + pRowInfo = NULL; + } - iTbData++; - pTbData = (iTbData < nTbData) ? (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData) : NULL; - iDelIdx++; - pDelIdx = (iDelIdx < nDelIdx) ? (SDelIdx *)taosArrayGet(pCommitter->aDelIdx, iDelIdx) : NULL; - continue; + if (pBData->nRow >= pCommitter->maxRow) { + if (pCommitter->toLastOnly) { + code = tsdbCommitLastBlock(pCommitter); + if (code) goto _err; + } else { + code = tsdbCommitDataBlock(pCommitter); + if (code) goto _err; + } + } } - // end - code = tsdbCommitDelEnd(pCommitter); - if (code) { - goto _err; + if (!pCommitter->toLastOnly && pBData->nRow) { + if (pBData->nRow > pCommitter->minRow) { + code = tsdbCommitDataBlock(pCommitter); + if (code) goto _err; + } else { + code = tsdbAppendLastBlock(pCommitter); + if (code) goto _err; + } } _exit: - tsdbDebug("vgId:%d, commit del done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel); return code; _err: - tsdbError("vgId:%d, commit del failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb commit table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } -static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) { - int32_t code = 0; - STsdb *pTsdb = pCommitter->pTsdb; - SMemTable *pMemTable = pTsdb->imem; +static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) { + int32_t code = 0; - ASSERT(eno == 0); + SRowInfo *pRowInfo; + TABLEID id = {0}; + while ((pRowInfo = tsdbGetCommitRow(pCommitter)) != NULL) { + ASSERT(pRowInfo->suid != id.suid || pRowInfo->uid != id.uid); + id.suid = pRowInfo->suid; + id.uid = pRowInfo->uid; - code = tsdbFSCommit1(pTsdb, &pCommitter->fs); - if (code) goto _err; + code = tsdbMoveCommitData(pCommitter, id); + if (code) goto _err; - // lock - taosThreadRwlockWrlock(&pTsdb->rwLock); + // start + tMapDataReset(&pCommitter->dWriter.mBlock); - // commit or rollback - code = tsdbFSCommit2(pTsdb, &pCommitter->fs); - if (code) { - taosThreadRwlockUnlock(&pTsdb->rwLock); - goto _err; - } + // impl + code = tsdbCommitterUpdateTableSchema(pCommitter, id.suid, id.uid); + if (code) goto _err; + code = tBlockDataInit(&pCommitter->dReader.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema); + if (code) goto _err; + code = tBlockDataInit(&pCommitter->dWriter.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema); + if (code) goto _err; - pTsdb->imem = NULL; + /* merge with data in .data file */ + code = tsdbMergeTableData(pCommitter, id); + if (code) goto _err; - // unlock - taosThreadRwlockUnlock(&pTsdb->rwLock); + /* handle remain table data */ + code = tsdbCommitTableData(pCommitter, id); + if (code) goto _err; - tsdbUnrefMemTable(pMemTable); - tsdbFSDestroy(&pCommitter->fs); - taosArrayDestroy(pCommitter->aTbDataP); + // end + if (pCommitter->dWriter.mBlock.nItem > 0) { + SBlockIdx blockIdx = {.suid = id.suid, .uid = id.uid}; + code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dWriter.mBlock, &blockIdx); + if (code) goto _err; + + if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + } + } + + id.suid = INT64_MAX; + id.uid = INT64_MAX; + code = tsdbMoveCommitData(pCommitter, id); + if (code) goto _err; + + if (pCommitter->dWriter.bDatal.nRow > 0) { + code = tsdbCommitLastBlock(pCommitter); + if (code) goto _err; + } - tsdbInfo("vgId:%d, tsdb end commit", TD_VID(pTsdb->pVnode)); return code; _err: - tsdbError("vgId:%d, tsdb end commit failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code)); + tsdbError("vgId:%d tsdb commit file data impl failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code)); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c new file mode 100644 index 0000000000000000000000000000000000000000..fb3917be64faa058b52f1f13a86ec0034486f279 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbCompact.c @@ -0,0 +1,27 @@ +/* + * 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" + +typedef struct { + STsdb *pTsdb; + STsdbFS fs; +} STsdbCompactor; + +int32_t tsdbCompact(STsdb *pTsdb) { + int32_t code = 0; + // TODO + return code; +} diff --git a/source/dnode/vnode/src/tsdb/tsdbCompress.c b/source/dnode/vnode/src/tsdb/tsdbCompress.c new file mode 100644 index 0000000000000000000000000000000000000000..76be7c10708a1150b26953745b3f2cb21aaeb6fa --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbCompress.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tsdb.h" + +// Integer ===================================================== +typedef struct { + int8_t rawCopy; + int64_t prevVal; + int32_t nVal; + int32_t nBuf; + uint8_t *pBuf; +} SIntCompressor; + +#define I64_SAFE_ADD(a, b) (((a) >= 0 && (b) <= INT64_MAX - (b)) || ((a) < 0 && (b) >= INT64_MIN - (a))) +#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL) + +static int32_t tsdbCmprI64(SIntCompressor *pCompressor, int64_t val) { + int32_t code = 0; + + // raw copy + if (pCompressor->rawCopy) { + memcpy(pCompressor->pBuf + pCompressor->nBuf, &val, sizeof(val)); + pCompressor->nBuf += sizeof(val); + pCompressor->nVal++; + goto _exit; + } + + if (!I64_SAFE_ADD(val, pCompressor->prevVal)) { + pCompressor->rawCopy = 1; + // TODO: decompress and copy + pCompressor->nVal++; + goto _exit; + } + + int64_t diff = val - pCompressor->prevVal; + uint8_t zigzag = ZIGZAGE(int64_t, diff); + + if (zigzag >= SIMPLE8B_MAX) { + pCompressor->rawCopy = 1; + // TODO: decompress and copy + pCompressor->nVal++; + goto _exit; + } + +_exit: + return code; +} + +// Timestamp ===================================================== + +// Float ===================================================== \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbDiskData.c b/source/dnode/vnode/src/tsdb/tsdbDiskData.c new file mode 100644 index 0000000000000000000000000000000000000000..3bd71f0ea6465cadcda3924247715a88721be3d8 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbDiskData.c @@ -0,0 +1,84 @@ +/* + * 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" + +typedef struct SDiskColBuilder SDiskColBuilder; +struct SDiskColBuilder { + uint8_t flags; + uint8_t *pBitMap; + int32_t *aOffset; + int32_t nData; + uint8_t *pData; +}; + +int32_t tDiskColAddVal(SDiskColBuilder *pBuilder, SColVal *pColVal) { + int32_t code = 0; + // TODO + return code; +} + +// ================================================================ +typedef struct SDiskDataBuilder SDiskDataBuilder; +struct SDiskDataBuilder { + SDiskDataHdr hdr; + SArray *aBlockCol; // SArray +}; + +int32_t tDiskDataBuilderCreate(SDiskDataBuilder **ppBuilder) { + int32_t code = 0; + // TODO + return code; +} + +void tDiskDataBuilderDestroy(SDiskDataBuilder *pBuilder) { + // TODO +} + +void tDiskDataBuilderInit(SDiskDataBuilder *pBuilder, int64_t suid, int64_t uid, STSchema *pTSchema, int8_t cmprAlg) { + pBuilder->hdr = (SDiskDataHdr){.delimiter = TSDB_FILE_DLMT, // + .fmtVer = 0, + .suid = suid, + .uid = uid, + .cmprAlg = cmprAlg}; +} + +void tDiskDataBuilderReset(SDiskDataBuilder *pBuilder) { + // TODO +} + +int32_t tDiskDataBuilderAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) { + int32_t code = 0; + + // uid (todo) + + // version (todo) + + // TSKEY (todo) + + SRowIter iter = {0}; + tRowIterInit(&iter, pRow, pTSchema); + + for (int32_t iDiskCol = 0; iDiskCol < 0; iDiskCol++) { + } + + return code; +} + +int32_t tDiskDataBuilderGet(SDiskDataBuilder *pBuilder, uint8_t **ppData) { + int32_t code = 0; + // TODO + return code; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index 247de993381d98713fa6a4ca1938c11b044c8cd6..e6bc9d9936610e3ac3baf8bde6c362512b0dae6f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -110,7 +110,7 @@ _err: // taosRemoveFile(fname); // } -// // last +// // sst // if (isSameDisk && pFrom->pLastF->commitID == pTo->pLastF->commitID) { // if (pFrom->pLastF->size > pTo->pLastF->size) { // code = tsdbDFileRollback(pFS->pTsdb, pTo, TSDB_LAST_FILE); @@ -140,7 +140,7 @@ _err: // tsdbDataFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pDataF, fname); // taosRemoveFile(fname); -// // last +// // sst // tsdbLastFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pLastF, fname); // taosRemoveFile(fname); @@ -254,8 +254,10 @@ void tsdbFSDestroy(STsdbFS *pFS) { SDFileSet *pSet = (SDFileSet *)taosArrayGet(pFS->aDFileSet, iSet); taosMemoryFree(pSet->pHeadF); taosMemoryFree(pSet->pDataF); - taosMemoryFree(pSet->pLastF); taosMemoryFree(pSet->pSmaF); + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + taosMemoryFree(pSet->aSstF[iSst]); + } } taosArrayDestroy(pFS->aDFileSet); @@ -309,17 +311,6 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) { if (code) goto _err; } - // last =========== - tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname); - if (taosStatFile(fname, &size, NULL)) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - if (size != pSet->pLastF->size) { - code = TSDB_CODE_FILE_CORRUPTED; - goto _err; - } - // sma ============= tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname); if (taosStatFile(fname, &size, NULL)) { @@ -333,6 +324,19 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) { code = tsdbDFileRollback(pTsdb, pSet, TSDB_SMA_FILE); if (code) goto _err; } + + // sst =========== + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + tsdbSstFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSstF[iSst], fname); + if (taosStatFile(fname, &size, NULL)) { + code = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + if (size != pSet->aSstF[iSst]->size) { + code = TSDB_CODE_FILE_CORRUPTED; + goto _err; + } + } } { @@ -382,41 +386,15 @@ static int32_t tsdbRecoverFS(STsdb *pTsdb, uint8_t *pData, int64_t nData) { taosArrayClear(pTsdb->fs.aDFileSet); n += tGetU32v(pData + n, &nSet); for (uint32_t iSet = 0; iSet < nSet; iSet++) { - SDFileSet fSet; - - // head - fSet.pHeadF = (SHeadFile *)taosMemoryCalloc(1, sizeof(SHeadFile)); - if (fSet.pHeadF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - fSet.pHeadF->nRef = 1; - - // data - fSet.pDataF = (SDataFile *)taosMemoryCalloc(1, sizeof(SDataFile)); - if (fSet.pDataF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - fSet.pDataF->nRef = 1; + SDFileSet fSet = {0}; - // last - fSet.pLastF = (SLastFile *)taosMemoryCalloc(1, sizeof(SLastFile)); - if (fSet.pLastF == NULL) { + int32_t nt = tGetDFileSet(pData + n, &fSet); + if (nt < 0) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - fSet.pLastF->nRef = 1; - // sma - fSet.pSmaF = (SSmaFile *)taosMemoryCalloc(1, sizeof(SSmaFile)); - if (fSet.pSmaF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - fSet.pSmaF->nRef = 1; - - n += tGetDFileSet(pData + n, &fSet); + n += nt; if (taosArrayPush(pTsdb->fs.aDFileSet, &fSet) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -532,13 +510,15 @@ int32_t tsdbFSClose(STsdb *pTsdb) { ASSERT(pSet->pDataF->nRef == 1); taosMemoryFree(pSet->pDataF); - // last - ASSERT(pSet->pLastF->nRef == 1); - taosMemoryFree(pSet->pLastF); - // sma ASSERT(pSet->pSmaF->nRef == 1); taosMemoryFree(pSet->pSmaF); + + // sst + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + ASSERT(pSet->aSstF[iSst]->nRef == 1); + taosMemoryFree(pSet->aSstF[iSst]); + } } taosArrayDestroy(pTsdb->fs.aDFileSet); @@ -586,15 +566,7 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) { } *fSet.pDataF = *pSet->pDataF; - // data - fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile)); - if (fSet.pLastF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - *fSet.pLastF = *pSet->pLastF; - - // last + // sma fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile)); if (fSet.pSmaF == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -602,6 +574,16 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) { } *fSet.pSmaF = *pSet->pSmaF; + // sst + for (fSet.nSstF = 0; fSet.nSstF < pSet->nSstF; fSet.nSstF++) { + fSet.aSstF[fSet.nSstF] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (fSet.aSstF[fSet.nSstF] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + *fSet.aSstF[fSet.nSstF] = *pSet->aSstF[fSet.nSstF]; + } + if (taosArrayPush(pFS->aDFileSet, &fSet) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -651,14 +633,38 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) { if (c == 0) { *pDFileSet->pHeadF = *pSet->pHeadF; *pDFileSet->pDataF = *pSet->pDataF; - *pDFileSet->pLastF = *pSet->pLastF; *pDFileSet->pSmaF = *pSet->pSmaF; + // sst + if (pSet->nSstF > pDFileSet->nSstF) { + ASSERT(pSet->nSstF == pDFileSet->nSstF + 1); + + pDFileSet->aSstF[pDFileSet->nSstF] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (pDFileSet->aSstF[pDFileSet->nSstF] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + *pDFileSet->aSstF[pDFileSet->nSstF] = *pSet->aSstF[pSet->nSstF - 1]; + pDFileSet->nSstF++; + } else if (pSet->nSstF < pDFileSet->nSstF) { + ASSERT(pSet->nSstF == 1); + for (int32_t iSst = 1; iSst < pDFileSet->nSstF; iSst++) { + taosMemoryFree(pDFileSet->aSstF[iSst]); + } + + *pDFileSet->aSstF[0] = *pSet->aSstF[0]; + pDFileSet->nSstF = 1; + } else { + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + *pDFileSet->aSstF[iSst] = *pSet->aSstF[iSst]; + } + } goto _exit; } } - SDFileSet fSet = {.diskId = pSet->diskId, .fid = pSet->fid}; + ASSERT(pSet->nSstF == 1); + SDFileSet fSet = {.diskId = pSet->diskId, .fid = pSet->fid, .nSstF = 1}; // head fSet.pHeadF = (SHeadFile *)taosMemoryMalloc(sizeof(SHeadFile)); @@ -676,21 +682,21 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) { } *fSet.pDataF = *pSet->pDataF; - // data - fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile)); - if (fSet.pLastF == NULL) { + // sma + fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile)); + if (fSet.pSmaF == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - *fSet.pLastF = *pSet->pLastF; + *fSet.pSmaF = *pSet->pSmaF; - // last - fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile)); - if (fSet.pSmaF == NULL) { + // sst + fSet.aSstF[0] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (fSet.aSstF[0] == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - *fSet.pSmaF = *pSet->pSmaF; + *fSet.aSstF[0] = *pSet->aSstF[0]; if (taosArrayInsert(pFS->aDFileSet, idx, &fSet) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -836,27 +842,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { pSetOld->pDataF->size = pSetNew->pDataF->size; } - // last - fSet.pLastF = pSetOld->pLastF; - if ((!sameDisk) || (pSetOld->pLastF->commitID != pSetNew->pLastF->commitID)) { - pSetOld->pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile)); - if (pSetOld->pLastF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - *pSetOld->pLastF = *pSetNew->pLastF; - pSetOld->pLastF->nRef = 1; - - nRef = atomic_sub_fetch_32(&fSet.pLastF->nRef, 1); - if (nRef == 0) { - tsdbLastFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pLastF, fname); - taosRemoveFile(fname); - taosMemoryFree(fSet.pLastF); - } - } else { - ASSERT(pSetOld->pLastF->size == pSetNew->pLastF->size); - } - // sma fSet.pSmaF = pSetOld->pSmaF; if ((!sameDisk) || (pSetOld->pSmaF->commitID != pSetNew->pSmaF->commitID)) { @@ -879,6 +864,84 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { pSetOld->pSmaF->size = pSetNew->pSmaF->size; } + // sst + if (sameDisk) { + if (pSetNew->nSstF > pSetOld->nSstF) { + ASSERT(pSetNew->nSstF = pSetOld->nSstF + 1); + pSetOld->aSstF[pSetOld->nSstF] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (pSetOld->aSstF[pSetOld->nSstF] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + *pSetOld->aSstF[pSetOld->nSstF] = *pSetNew->aSstF[pSetOld->nSstF]; + pSetOld->aSstF[pSetOld->nSstF]->nRef = 1; + pSetOld->nSstF++; + } else if (pSetNew->nSstF < pSetOld->nSstF) { + ASSERT(pSetNew->nSstF == 1); + for (int32_t iSst = 0; iSst < pSetOld->nSstF; iSst++) { + SSstFile *pSstFile = pSetOld->aSstF[iSst]; + nRef = atomic_sub_fetch_32(&pSstFile->nRef, 1); + if (nRef == 0) { + tsdbSstFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSstFile, fname); + taosRemoveFile(fname); + taosMemoryFree(pSstFile); + } + pSetOld->aSstF[iSst] = NULL; + } + + pSetOld->nSstF = 1; + pSetOld->aSstF[0] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (pSetOld->aSstF[0] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + *pSetOld->aSstF[0] = *pSetNew->aSstF[0]; + pSetOld->aSstF[0]->nRef = 1; + } else { + for (int32_t iSst = 0; iSst < pSetOld->nSstF; iSst++) { + if (pSetOld->aSstF[iSst]->commitID != pSetNew->aSstF[iSst]->commitID) { + SSstFile *pSstFile = pSetOld->aSstF[iSst]; + nRef = atomic_sub_fetch_32(&pSstFile->nRef, 1); + if (nRef == 0) { + tsdbSstFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSstFile, fname); + taosRemoveFile(fname); + taosMemoryFree(pSstFile); + } + + pSetOld->aSstF[iSst] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (pSetOld->aSstF[iSst] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + *pSetOld->aSstF[iSst] = *pSetNew->aSstF[iSst]; + pSetOld->aSstF[iSst]->nRef = 1; + } else { + ASSERT(pSetOld->aSstF[iSst]->size == pSetOld->aSstF[iSst]->size); + ASSERT(pSetOld->aSstF[iSst]->offset == pSetOld->aSstF[iSst]->offset); + } + } + } + } else { + ASSERT(pSetOld->nSstF == pSetNew->nSstF); + for (int32_t iSst = 0; iSst < pSetOld->nSstF; iSst++) { + SSstFile *pSstFile = pSetOld->aSstF[iSst]; + nRef = atomic_sub_fetch_32(&pSstFile->nRef, 1); + if (nRef == 0) { + tsdbSstFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSstFile, fname); + taosRemoveFile(fname); + taosMemoryFree(pSstFile); + } + + pSetOld->aSstF[iSst] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (pSetOld->aSstF[iSst] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + *pSetOld->aSstF[iSst] = *pSetNew->aSstF[iSst]; + pSetOld->aSstF[iSst]->nRef = 1; + } + } + if (!sameDisk) { pSetOld->diskId = pSetNew->diskId; } @@ -902,13 +965,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { taosMemoryFree(pSetOld->pDataF); } - nRef = atomic_sub_fetch_32(&pSetOld->pLastF->nRef, 1); - if (nRef == 0) { - tsdbLastFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->pLastF, fname); - taosRemoveFile(fname); - taosMemoryFree(pSetOld->pLastF); - } - nRef = atomic_sub_fetch_32(&pSetOld->pSmaF->nRef, 1); if (nRef == 0) { tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->pSmaF, fname); @@ -916,12 +972,20 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { taosMemoryFree(pSetOld->pSmaF); } + for (int8_t iSst = 0; iSst < pSetOld->nSstF; iSst++) { + nRef = atomic_sub_fetch_32(&pSetOld->aSstF[iSst]->nRef, 1); + if (nRef == 0) { + tsdbSstFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->aSstF[iSst], fname); + taosRemoveFile(fname); + taosMemoryFree(pSetOld->aSstF[iSst]); + } + } + taosArrayRemove(pTsdb->fs.aDFileSet, iOld); continue; _add_new: - fSet.diskId = pSetNew->diskId; - fSet.fid = pSetNew->fid; + fSet = (SDFileSet){.diskId = pSetNew->diskId, .fid = pSetNew->fid, .nSstF = 1}; // head fSet.pHeadF = (SHeadFile *)taosMemoryMalloc(sizeof(SHeadFile)); @@ -941,15 +1005,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { *fSet.pDataF = *pSetNew->pDataF; fSet.pDataF->nRef = 1; - // last - fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile)); - if (fSet.pLastF == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } - *fSet.pLastF = *pSetNew->pLastF; - fSet.pLastF->nRef = 1; - // sma fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile)); if (fSet.pSmaF == NULL) { @@ -959,6 +1014,16 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) { *fSet.pSmaF = *pSetNew->pSmaF; fSet.pSmaF->nRef = 1; + // sst + ASSERT(pSetNew->nSstF == 1); + fSet.aSstF[0] = (SSstFile *)taosMemoryMalloc(sizeof(SSstFile)); + if (fSet.aSstF[0] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + *fSet.aSstF[0] = *pSetNew->aSstF[0]; + fSet.aSstF[0]->nRef = 1; + if (taosArrayInsert(pTsdb->fs.aDFileSet, iOld, &fSet) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -1002,12 +1067,14 @@ int32_t tsdbFSRef(STsdb *pTsdb, STsdbFS *pFS) { nRef = atomic_fetch_add_32(&pSet->pDataF->nRef, 1); ASSERT(nRef > 0); - nRef = atomic_fetch_add_32(&pSet->pLastF->nRef, 1); - ASSERT(nRef > 0); - nRef = atomic_fetch_add_32(&pSet->pSmaF->nRef, 1); ASSERT(nRef > 0); + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + nRef = atomic_fetch_add_32(&pSet->aSstF[iSst]->nRef, 1); + ASSERT(nRef > 0); + } + if (taosArrayPush(pFS->aDFileSet, &fSet) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -1053,15 +1120,6 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) { taosMemoryFree(pSet->pDataF); } - // last - nRef = atomic_sub_fetch_32(&pSet->pLastF->nRef, 1); - ASSERT(nRef >= 0); - if (nRef == 0) { - tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname); - taosRemoveFile(fname); - taosMemoryFree(pSet->pLastF); - } - // sma nRef = atomic_sub_fetch_32(&pSet->pSmaF->nRef, 1); ASSERT(nRef >= 0); @@ -1070,6 +1128,18 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) { taosRemoveFile(fname); taosMemoryFree(pSet->pSmaF); } + + // sst + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + nRef = atomic_sub_fetch_32(&pSet->aSstF[iSst]->nRef, 1); + ASSERT(nRef >= 0); + if (nRef == 0) { + tsdbSstFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSstF[iSst], fname); + taosRemoveFile(fname); + taosMemoryFree(pSet->aSstF[iSst]); + /* code */ + } + } } taosArrayDestroy(pFS->aDFileSet); diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 00d2ac848f6d599fef54d9957047521e27062c89..632a2c827b180a7d41d81634dc072ecbd672dfe1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -53,22 +53,22 @@ static int32_t tGetDataFile(uint8_t *p, SDataFile *pDataFile) { return n; } -int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile) { +int32_t tPutSstFile(uint8_t *p, SSstFile *pSstFile) { int32_t n = 0; - n += tPutI64v(p ? p + n : p, pLastFile->commitID); - n += tPutI64v(p ? p + n : p, pLastFile->size); - n += tPutI64v(p ? p + n : p, pLastFile->offset); + n += tPutI64v(p ? p + n : p, pSstFile->commitID); + n += tPutI64v(p ? p + n : p, pSstFile->size); + n += tPutI64v(p ? p + n : p, pSstFile->offset); return n; } -static int32_t tGetLastFile(uint8_t *p, SLastFile *pLastFile) { +static int32_t tGetSstFile(uint8_t *p, SSstFile *pSstFile) { int32_t n = 0; - n += tGetI64v(p + n, &pLastFile->commitID); - n += tGetI64v(p + n, &pLastFile->size); - n += tGetI64v(p + n, &pLastFile->offset); + n += tGetI64v(p + n, &pSstFile->commitID); + n += tGetI64v(p + n, &pSstFile->size); + n += tGetI64v(p + n, &pSstFile->offset); return n; } @@ -102,9 +102,9 @@ void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pDataF->commitID, ".data"); } -void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]) { +void tsdbSstFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSstFile *pSstF, char fname[]) { snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did), - TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pLastF->commitID, ".last"); + TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pSstF->commitID, ".sst"); } void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]) { @@ -194,9 +194,11 @@ int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) { n += tPutDataFile(p ? p + n : p, pSet->pDataF); n += tPutSmaFile(p ? p + n : p, pSet->pSmaF); - // last - n += tPutU8(p ? p + n : p, 1); // for future compatibility - n += tPutLastFile(p ? p + n : p, pSet->pLastF); + // sst + n += tPutU8(p ? p + n : p, pSet->nSstF); + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + n += tPutSstFile(p ? p + n : p, pSet->aSstF[iSst]); + } return n; } @@ -208,15 +210,40 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) { n += tGetI32v(p + n, &pSet->diskId.id); n += tGetI32v(p + n, &pSet->fid); - // data + // head + pSet->pHeadF = (SHeadFile *)taosMemoryCalloc(1, sizeof(SHeadFile)); + if (pSet->pHeadF == NULL) { + return -1; + } + pSet->pHeadF->nRef = 1; n += tGetHeadFile(p + n, pSet->pHeadF); + + // data + pSet->pDataF = (SDataFile *)taosMemoryCalloc(1, sizeof(SDataFile)); + if (pSet->pDataF == NULL) { + return -1; + } + pSet->pDataF->nRef = 1; n += tGetDataFile(p + n, pSet->pDataF); + + // sma + pSet->pSmaF = (SSmaFile *)taosMemoryCalloc(1, sizeof(SSmaFile)); + if (pSet->pSmaF == NULL) { + return -1; + } + pSet->pSmaF->nRef = 1; n += tGetSmaFile(p + n, pSet->pSmaF); - // last - uint8_t nLast; - n += tGetU8(p + n, &nLast); - n += tGetLastFile(p + n, pSet->pLastF); + // sst + n += tGetU8(p + n, &pSet->nSstF); + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + pSet->aSstF[iSst] = (SSstFile *)taosMemoryCalloc(1, sizeof(SSstFile)); + if (pSet->aSstF[iSst] == NULL) { + return -1; + } + pSet->aSstF[iSst]->nRef = 1; + n += tGetSstFile(p + n, pSet->aSstF[iSst]); + } return n; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c new file mode 100644 index 0000000000000000000000000000000000000000..e85b136c2aaa98020c9348d3ec3b1a97d5d41cb3 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -0,0 +1,378 @@ +/* + * 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" + +// SLDataIter ================================================= +typedef struct SLDataIter { + SRBTreeNode node; + SSstBlk *pSstBlk; + SDataFReader *pReader; + int32_t iSst; + int8_t backward; + SArray *aSstBlk; + int32_t iSstBlk; + SBlockData bData[2]; + int32_t loadIndex; + int32_t iRow; + SRowInfo rInfo; + uint64_t uid; + STimeWindow timeWindow; + SVersionRange verRange; +} SLDataIter; + +static SBlockData* getCurrentBlock(SLDataIter* pIter) { + return &pIter->bData[pIter->loadIndex]; +} + +static SBlockData* getNextBlock(SLDataIter* pIter) { + pIter->loadIndex ^= 1; + return getCurrentBlock(pIter); +} + +int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iSst, int8_t backward, uint64_t uid, + STimeWindow *pTimeWindow, SVersionRange *pRange) { + int32_t code = 0; + *pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); + if (*pIter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + (*pIter)->uid = uid; + (*pIter)->timeWindow = *pTimeWindow; + (*pIter)->verRange = *pRange; + (*pIter)->pReader = pReader; + (*pIter)->iSst = iSst; + (*pIter)->backward = backward; + (*pIter)->aSstBlk = taosArrayInit(0, sizeof(SSstBlk)); + if ((*pIter)->aSstBlk == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + + code = tBlockDataCreate(&(*pIter)->bData[0]); + if (code) { + goto _exit; + } + + code = tBlockDataCreate(&(*pIter)->bData[1]); + if (code) { + goto _exit; + } + + code = tsdbReadSstBlk(pReader, iSst, (*pIter)->aSstBlk); + if (code) { + goto _exit; + } + + size_t size = taosArrayGetSize((*pIter)->aSstBlk); + + // find the start block + int32_t index = -1; + if (!backward) { // asc + for (int32_t i = 0; i < size; ++i) { + SSstBlk *p = taosArrayGet((*pIter)->aSstBlk, i); + if (p->minUid <= uid && p->maxUid >= uid) { + index = i; + break; + } + } + } else { // desc + for (int32_t i = size - 1; i >= 0; --i) { + SSstBlk *p = taosArrayGet((*pIter)->aSstBlk, i); + if (p->minUid <= uid && p->maxUid >= uid) { + index = i; + break; + } + } + } + + (*pIter)->iSstBlk = index; + if (index != -1) { + (*pIter)->pSstBlk = taosArrayGet((*pIter)->aSstBlk, (*pIter)->iSstBlk); + } + +_exit: + return code; +} + +void tLDataIterClose(SLDataIter *pIter) { + tBlockDataDestroy(&pIter->bData[0], 1); + tBlockDataDestroy(&pIter->bData[1], 1); + taosArrayDestroy(pIter->aSstBlk); + taosMemoryFree(pIter); +} + +extern int32_t tsdbReadSstBlockEx(SDataFReader *pReader, int32_t iSst, SSstBlk *pSstBlk, SBlockData *pBlockData); + +void tLDataIterNextBlock(SLDataIter *pIter) { + int32_t step = pIter->backward ? -1 : 1; + pIter->iSstBlk += step; + + int32_t index = -1; + size_t size = taosArrayGetSize(pIter->aSstBlk); + for (int32_t i = pIter->iSstBlk; i < size && i >= 0; i += step) { + SSstBlk *p = taosArrayGet(pIter->aSstBlk, i); + if ((!pIter->backward) && p->minUid > pIter->uid) { + break; + } + + if (pIter->backward && p->maxUid < pIter->uid) { + break; + } + + if (p->minUid <= pIter->uid && p->maxUid >= pIter->uid) { + index = i; + break; + } + } + + if (index == -1) { + pIter->pSstBlk = NULL; + } else { + pIter->pSstBlk = (SSstBlk *)taosArrayGet(pIter->aSstBlk, pIter->iSstBlk); + } +} + +static void findNextValidRow(SLDataIter *pIter) { + int32_t step = pIter->backward ? -1 : 1; + + bool hasVal = false; + int32_t i = pIter->iRow; + SBlockData* pBlockData = getCurrentBlock(pIter); + + for (; i < pBlockData->nRow && i >= 0; i += step) { + if (pBlockData->aUid != NULL) { + if (!pIter->backward) { + if (pBlockData->aUid[i] < pIter->uid) { + continue; + } else if (pBlockData->aUid[i] > pIter->uid) { + break; + } + } else { + if (pBlockData->aUid[i] > pIter->uid) { + continue; + } else if (pBlockData->aUid[i] < pIter->uid) { + break; + } + } + } + + int64_t ts = pBlockData->aTSKEY[i]; + if (!pIter->backward) { // asc + if (ts > pIter->timeWindow.ekey) { // no more data + break; + } else if (ts < pIter->timeWindow.skey) { + continue; + } + } else { + if (ts < pIter->timeWindow.skey) { + break; + } else if (ts > pIter->timeWindow.ekey) { + continue; + } + } + + int64_t ver = pBlockData->aVersion[i]; + if (ver < pIter->verRange.minVer) { + continue; + } + + // todo opt handle desc case + if (ver > pIter->verRange.maxVer) { + continue; + } + + // todo handle delete soon +#if 0 + TSDBKEY k = {.ts = ts, .version = ver}; + if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) { + continue; + } +#endif + + hasVal = true; + break; + } + + pIter->iRow = (hasVal) ? i : -1; +} + +bool tLDataIterNextRow(SLDataIter *pIter) { + int32_t code = 0; + int32_t step = pIter->backward ? -1 : 1; + + // no qualified last file block in current file, no need to fetch row + if (pIter->pSstBlk == NULL) { + return false; + } + + int32_t iBlockL = pIter->iSstBlk; + SBlockData* pBlockData = getCurrentBlock(pIter); + + if (pBlockData->nRow == 0 && pIter->pSstBlk != NULL) { // current block not loaded yet + pBlockData = getNextBlock(pIter); + code = tsdbReadSstBlockEx(pIter->pReader, pIter->iSst, pIter->pSstBlk, pBlockData); + if (code != TSDB_CODE_SUCCESS) { + goto _exit; + } + + pIter->iRow = (pIter->backward) ? pBlockData->nRow : -1; + } + + pIter->iRow += step; + + while (1) { + findNextValidRow(pIter); + + if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) { + tLDataIterNextBlock(pIter); + if (pIter->pSstBlk == NULL) { // no more data + goto _exit; + } + } else { + break; + } + + if (iBlockL != pIter->iSstBlk) { + pBlockData = getNextBlock(pIter); + code = tsdbReadSstBlockEx(pIter->pReader, pIter->iSst, pIter->pSstBlk, pBlockData); + if (code) { + goto _exit; + } + pIter->iRow = pIter->backward ? (pBlockData->nRow - 1) : 0; + } + } + + pIter->rInfo.suid = pBlockData->suid; + pIter->rInfo.uid = pBlockData->uid; + pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow); + +_exit: + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + } + + return (code == TSDB_CODE_SUCCESS) && (pIter->pSstBlk != NULL); +} + +SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; } + +// SMergeTree ================================================= +static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) { + SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - sizeof(SRBTreeNode)); + SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - sizeof(SRBTreeNode)); + + TSDBKEY key1 = TSDBROW_KEY(&pIter1->rInfo.row); + TSDBKEY key2 = TSDBROW_KEY(&pIter2->rInfo.row); + + if (key1.ts < key2.ts) { + return -1; + } else if (key1.ts > key2.ts) { + return 1; + } else { + if (key1.version < key2.version) { + return -1; + } else if (key1.version > key2.version) { + return 1; + } else { + return 0; + } + } +} + +int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t uid, + STimeWindow *pTimeWindow, SVersionRange *pVerRange) { + pMTree->backward = backward; + pMTree->pIter = NULL; + pMTree->pIterList = taosArrayInit(4, POINTER_BYTES); + if (pMTree->pIterList == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn); + int32_t code = TSDB_CODE_OUT_OF_MEMORY; + + struct SLDataIter *pIterList[TSDB_DEFAULT_LAST_FILE] = {0}; + for (int32_t i = 0; i < pFReader->pSet->nSstF; ++i) { // open all last file + code = tLDataIterOpen(&pIterList[i], pFReader, i, pMTree->backward, uid, pTimeWindow, pVerRange); + if (code != TSDB_CODE_SUCCESS) { + goto _end; + } + + bool hasVal = tLDataIterNextRow(pIterList[i]); + if (hasVal) { + taosArrayPush(pMTree->pIterList, &pIterList[i]); + tMergeTreeAddIter(pMTree, pIterList[i]); + } else { + tLDataIterClose(pIterList[i]); + } + } + + return code; + +_end: + tMergeTreeClose(pMTree); + return code; +} + +void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); } + +bool tMergeTreeNext(SMergeTree *pMTree) { + int32_t code = TSDB_CODE_SUCCESS; + if (pMTree->pIter) { + SLDataIter *pIter = pMTree->pIter; + + bool hasVal = tLDataIterNextRow(pIter); + if (!hasVal) { + pMTree->pIter = NULL; + } + + // compare with min in RB Tree + pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt); + if (pMTree->pIter && pIter) { + int32_t c = pMTree->rbt.cmprFn(RBTREE_NODE_PAYLOAD(&pMTree->pIter->node), RBTREE_NODE_PAYLOAD(&pIter->node)); + if (c > 0) { + tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter); + pMTree->pIter = NULL; + } else { + ASSERT(c); + } + } + } + + if (pMTree->pIter == NULL) { + pMTree->pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt); + if (pMTree->pIter) { + tRBTreeDrop(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter); + } + } + + return pMTree->pIter != NULL; +} + +TSDBROW tMergeTreeGetRow(SMergeTree *pMTree) { return pMTree->pIter->rInfo.row; } + +void tMergeTreeClose(SMergeTree *pMTree) { + size_t size = taosArrayGetSize(pMTree->pIterList); + for (int32_t i = 0; i < size; ++i) { + SLDataIter *pIter = taosArrayGetP(pMTree->pIterList, i); + tLDataIterClose(pIter); + } + + pMTree->pIterList = taosArrayDestroy(pMTree->pIterList); + pMTree->pIter = NULL; +} diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 6a2563335754aa553c805b4be7bc24ab4c19d8d4..1828f1e40e8376844b611a4e5bf68d03b2f04183 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -34,21 +34,20 @@ typedef struct { typedef struct { int32_t numOfBlocks; - int32_t numOfLastBlocks; + int32_t numOfLastFiles; } SBlockNumber; typedef struct STableBlockScanInfo { uint64_t uid; TSKEY lastKey; - SMapData mapData; // block info (compressed) - SArray* pBlockList; // block data index list - SIterInfo iter; // mem buffer skip list iterator - SIterInfo iiter; // imem buffer skip list iterator - SArray* delSkyline; // delete info for this table - int32_t fileDelIndex; // file block delete index - int32_t lastBlockDelIndex;// delete index for last block - bool iterInit; // whether to initialize the in-memory skip list iterator or not - int16_t indexInBlockL;// row position in last block + SMapData mapData; // block info (compressed) + SArray* pBlockList; // block data index list + SIterInfo iter; // mem buffer skip list iterator + SIterInfo iiter; // imem buffer skip list iterator + SArray* delSkyline; // delete info for this table + int32_t fileDelIndex; // file block delete index + int32_t lastBlockDelIndex; // delete index for last block + bool iterInit; // whether to initialize the in-memory skip list iterator or not } STableBlockScanInfo; typedef struct SBlockOrderWrapper { @@ -83,28 +82,20 @@ typedef struct SBlockLoadSuppInfo { char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated. } SBlockLoadSuppInfo; -typedef struct SVersionRange { - uint64_t minVer; - uint64_t maxVer; -} SVersionRange; - typedef struct SLastBlockReader { - SArray* pBlockL; - int32_t currentBlockIndex; - SBlockData lastBlockData; STimeWindow window; SVersionRange verRange; int32_t order; uint64_t uid; - int16_t* rowIndex; // row index ptr, usually from the STableBlockScanInfo->indexInBlockL + SMergeTree mergeTree; } SLastBlockReader; typedef struct SFilesetIter { - int32_t numOfFiles; // number of total files - int32_t index; // current accessed index in the list - SArray* pFileList; // data file list + int32_t numOfFiles; // number of total files + int32_t index; // current accessed index in the list + SArray* pFileList; // data file list int32_t order; - SLastBlockReader* pLastBlockReader; // last file block reader + SLastBlockReader* pLastBlockReader; // last file block reader } SFilesetIter; typedef struct SFileDataBlockInfo { @@ -116,9 +107,9 @@ typedef struct SFileDataBlockInfo { typedef struct SDataBlockIter { int32_t numOfBlocks; int32_t index; - SArray* blockList; // SArray + SArray* blockList; // SArray int32_t order; - SBlock block; // current SBlock data + SDataBlk block; // current SDataBlk data SHashObj* pTableMap; } SDataBlockIter; @@ -130,8 +121,8 @@ typedef struct SFileBlockDumpInfo { } SFileBlockDumpInfo; typedef struct SUidOrderCheckInfo { - uint64_t* tableUidList; // access table uid list in uid ascending order list - int32_t currentIndex; // index in table uid list + uint64_t* tableUidList; // access table uid list in uid ascending order list + int32_t currentIndex; // index in table uid list } SUidOrderCheckInfo; typedef struct SReaderStatus { @@ -139,9 +130,9 @@ typedef struct SReaderStatus { bool composedDataBlock; // the returned data block is a composed block or not SHashObj* pTableMap; // SHash STableBlockScanInfo* pTableIter; // table iterator used in building in-memory buffer data blocks. - SUidOrderCheckInfo uidCheckInfo; // check all table in uid order + SUidOrderCheckInfo uidCheckInfo; // check all table in uid order SFileBlockDumpInfo fBlockDumpInfo; - SDFileSet* pCurrentFileset; // current opened file set + SDFileSet* pCurrentFileset; // current opened file set SBlockData fileBlockData; SFilesetIter fileIter; SDataBlockIter blockIter; @@ -175,29 +166,31 @@ static int buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, i static TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader); static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader, SRowMerger* pMerger); -static int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, SRowMerger* pMerger); +static int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, + SRowMerger* pMerger); static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger, STsdbReader* pReader); static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow, uint64_t uid); static int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, - int32_t rowIndex); + int32_t rowIndex); static void setComposedBlockFlag(STsdbReader* pReader, bool composed); static bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order); -static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, STSRow** pTSRow, - STsdbReader* pReader, bool* freeTSRow); -static int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, - STSRow** pTSRow); -static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader); +static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, + STSRow** pTSRow, STsdbReader* pReader, bool* freeTSRow); +static int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, + STsdbReader* pReader, STSRow** pTSRow); +static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, + STsdbReader* pReader); static int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData, STbData* piMemTbData); static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions, const char* idstr, int8_t* pLevel); static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_t level); -static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader); -static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader); -static int32_t doBuildDataBlock(STsdbReader* pReader); +static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader); +static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader); +static int32_t doBuildDataBlock(STsdbReader* pReader); static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) { SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; @@ -234,7 +227,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK } for (int32_t j = 0; j < numOfTables; ++j) { - STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid, .indexInBlockL = INITIAL_ROW_INDEX_VAL}; + STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid}; if (ASCENDING_TRAVERSE(pTsdbReader->order)) { if (info.lastKey == INT64_MIN || info.lastKey < pTsdbReader->window.skey) { info.lastKey = pTsdbReader->window.skey; @@ -266,9 +259,7 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) { p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter); } - p->fileDelIndex = -1; - p->delSkyline = taosArrayDestroy(p->delSkyline); - p->lastBlockDelIndex = INITIAL_ROW_INDEX_VAL; + p->delSkyline = taosArrayDestroy(p->delSkyline); } } @@ -330,7 +321,8 @@ static void limitOutputBufferSize(const SQueryTableDataCond* pCond, int32_t* cap } // init file iterator -static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdbReader* pReader/*int32_t order, const char* idstr*/) { +static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, + STsdbReader* pReader /*int32_t order, const char* idstr*/) { size_t numOfFileset = taosArrayGetSize(aDFileSet); pIter->index = ASCENDING_TRAVERSE(pReader->order) ? -1 : numOfFileset; @@ -345,19 +337,15 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb tsdbError("failed to prepare the last block iterator, code:%d %s", tstrerror(code), pReader->idStr); return code; } + } - SLastBlockReader* pLReader = pIter->pLastBlockReader; - pLReader->pBlockL = taosArrayInit(4, sizeof(SBlockL)); - pLReader->order = pReader->order; - pLReader->window = pReader->window; - pLReader->verRange = pReader->verRange; - pLReader->currentBlockIndex = -1; + SLastBlockReader* pLReader = pIter->pLastBlockReader; + pLReader->order = pReader->order; + pLReader->window = pReader->window; + pLReader->verRange = pReader->verRange; - int32_t code = tBlockDataCreate(&pLReader->lastBlockData); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } + pLReader->uid = 0; + tMergeTreeClose(&pLReader->mergeTree); tsdbDebug("init fileset iterator, total files:%d %s", pIter->numOfFiles, pReader->idStr); return TSDB_CODE_SUCCESS; @@ -372,6 +360,9 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) { return false; } + pIter->pLastBlockReader->uid = 0; + tMergeTreeClose(&pIter->pLastBlockReader->mergeTree); + // check file the time range of coverage STimeWindow win = {0}; @@ -580,14 +571,12 @@ static void cleanupTableScanInfo(SHashObj* pTableMap) { } // reset the index in last block when handing a new file - px->indexInBlockL = INITIAL_ROW_INDEX_VAL; tMapDataClear(&px->mapData); taosArrayClear(px->pBlockList); } } -static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray* pLastBlockIndex, - SBlockNumber * pBlockNum, SArray* pQualifiedLastBlock) { +static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockNumber* pBlockNum) { int32_t numOfQTable = 0; size_t sizeInDisk = 0; size_t numOfTables = taosArrayGetSize(pIndexList); @@ -605,8 +594,8 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray* sizeInDisk += pScanInfo->mapData.nData; for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) { - SBlock block = {0}; - tMapDataGetItemByIdx(&pScanInfo->mapData, j, &block, tGetBlock); + SDataBlk block = {0}; + tMapDataGetItemByIdx(&pScanInfo->mapData, j, &block, tGetDataBlk); // 1. time range check if (block.minKey.ts > pReader->window.ekey || block.maxKey.ts < pReader->window.skey) { @@ -632,36 +621,14 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray* } } - size_t numOfLast = taosArrayGetSize(pLastBlockIndex); - for(int32_t i = 0; i < numOfLast; ++i) { - SBlockL* pLastBlock = taosArrayGet(pLastBlockIndex, i); - if (pLastBlock->suid != pReader->suid) { - continue; - } - - { - // 1. time range check - if (pLastBlock->minKey > pReader->window.ekey || pLastBlock->maxKey < pReader->window.skey) { - continue; - } - - // 2. version range check - if (pLastBlock->minVer > pReader->verRange.maxVer || pLastBlock->maxVer < pReader->verRange.minVer) { - continue; - } - - pBlockNum->numOfLastBlocks += 1; - taosArrayPush(pQualifiedLastBlock, pLastBlock); - } - } - - int32_t total = pBlockNum->numOfLastBlocks + pBlockNum->numOfBlocks; + pBlockNum->numOfLastFiles = pReader->pFileReader->pSet->nSstF; + int32_t total = pBlockNum->numOfLastFiles + pBlockNum->numOfBlocks; double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug( - "load block of %d tables completed, blocks:%d in %d tables, lastBlock:%d, block-info-size:%.2f Kb, elapsed " + "load block of %d tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed " "time:%.2f ms %s", - numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastBlocks, sizeInDisk / 1000.0, el, + numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el, pReader->idStr); pReader->cost.numOfBlocks += total; @@ -702,7 +669,7 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { return pBlockInfo; } -static SBlock* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; } +static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; } static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) { SReaderStatus* pStatus = &pReader->status; @@ -710,7 +677,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn SBlockData* pBlockData = &pStatus->fileBlockData; SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter); - SBlock* pBlock = getCurrentBlock(pBlockIter); + SDataBlk* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock); @@ -795,8 +762,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; ASSERT(pBlockInfo != NULL); - SBlock* pBlock = getCurrentBlock(pBlockIter); - int32_t code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData); + SDataBlk* pBlock = getCurrentBlock(pBlockIter); + int32_t code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData); if (code != TSDB_CODE_SUCCESS) { tsdbError("%p error occurs in loading file block, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, code:%s %s", @@ -872,8 +839,8 @@ static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) { SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); if (pBlockInfo != NULL) { STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); - int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx); - tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetBlock); + int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx); + tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetDataBlk); } #if 0 @@ -924,12 +891,12 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte } sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf; - SBlock block = {0}; + SDataBlk block = {0}; for (int32_t k = 0; k < num; ++k) { SBlockOrderWrapper wrapper = {0}; int32_t* mapDataIndex = taosArrayGet(pTableScanInfo->pBlockList, k); - tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetBlock); + tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetDataBlk); wrapper.uid = pTableScanInfo->uid; wrapper.offset = block.aSubBlock[0].offset; @@ -990,8 +957,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte } int64_t et = taosGetTimestampUs(); - tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, numOfBlocks, (et - st) / 1000.0, - pReader->idStr); + tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, numOfBlocks, + (et - st) / 1000.0, pReader->idStr); cleanupBlockOrderSupporter(&sup); taosMemoryFree(pTree); @@ -1018,15 +985,15 @@ static bool blockIteratorNext(SDataBlockIter* pBlockIter) { /** * This is an two rectangles overlap cases. */ -static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* pVerRange, SBlock* pBlock) { +static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* pVerRange, SDataBlk* pBlock) { return (pWindow->ekey < pBlock->maxKey.ts && pWindow->ekey >= pBlock->minKey.ts) || (pWindow->skey > pBlock->minKey.ts && pWindow->skey <= pBlock->maxKey.ts) || (pVerRange->minVer > pBlock->minVer && pVerRange->minVer <= pBlock->maxVer) || (pVerRange->maxVer < pBlock->maxVer && pVerRange->maxVer >= pBlock->minVer); } -static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, - int32_t* nextIndex, int32_t order) { +static SDataBlk* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, + int32_t* nextIndex, int32_t order) { bool asc = ASCENDING_TRAVERSE(order); if (asc && pFBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockList) - 1) { return NULL; @@ -1039,10 +1006,10 @@ static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STab int32_t step = asc ? 1 : -1; *nextIndex = pFBlockInfo->tbBlockIdx + step; - SBlock* pBlock = taosMemoryCalloc(1, sizeof(SBlock)); - int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); + SDataBlk* pBlock = taosMemoryCalloc(1, sizeof(SDataBlk)); + int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); - tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetBlock); + tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetDataBlk); return pBlock; } @@ -1085,7 +1052,7 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t return TSDB_CODE_SUCCESS; } -static bool overlapWithNeighborBlock(SBlock* pBlock, SBlock* pNeighbor, int32_t order) { +static bool overlapWithNeighborBlock(SDataBlk* pBlock, SDataBlk* pNeighbor, int32_t order) { // it is the last block in current file, no chance to overlap with neighbor blocks. if (ASCENDING_TRAVERSE(order)) { return pBlock->maxKey.ts == pNeighbor->minKey.ts; @@ -1094,19 +1061,19 @@ static bool overlapWithNeighborBlock(SBlock* pBlock, SBlock* pNeighbor, int32_t } } -static bool bufferDataInFileBlockGap(int32_t order, TSDBKEY key, SBlock* pBlock) { +static bool bufferDataInFileBlockGap(int32_t order, TSDBKEY key, SDataBlk* pBlock) { bool ascScan = ASCENDING_TRAVERSE(order); return (ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts <= pBlock->minKey.ts)) || (!ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts >= pBlock->maxKey.ts)); } -static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVerRange) { +static bool keyOverlapFileBlock(TSDBKEY key, SDataBlk* pBlock, SVersionRange* pVerRange) { return (key.ts >= pBlock->minKey.ts && key.ts <= pBlock->maxKey.ts) && (pBlock->maxVer >= pVerRange->minVer) && (pBlock->minVer <= pVerRange->maxVer); } -static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock) { +static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock) { size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline); for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += 1) { @@ -1140,7 +1107,7 @@ static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, cons return false; } -static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) { +static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock, int32_t order) { if (pBlockScanInfo->delSkyline == NULL) { return false; } @@ -1175,10 +1142,10 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBl // 3. current timestamp should not be overlap with each other // 4. output buffer should be large enough to hold all rows in current block // 5. delete info should not overlap with current block data -static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBlock, SBlock* pBlock, +static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBlock, SDataBlk* pBlock, STableBlockScanInfo* pScanInfo, TSDBKEY key, SLastBlockReader* pLastBlockReader) { - int32_t neighborIndex = 0; - SBlock* pNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &neighborIndex, pReader->order); + int32_t neighborIndex = 0; + SDataBlk* pNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &neighborIndex, pReader->order); // overlap with neighbor bool overlapWithNeighbor = false; @@ -1192,11 +1159,14 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBloc bool overlapWithDel = overlapWithDelSkyline(pScanInfo, pBlock, pReader->order); // todo here we need to each key in the last files to identify if it is really overlapped with last block + // todo bool overlapWithlastBlock = false; - if (taosArrayGetSize(pLastBlockReader->pBlockL) > 0 && (pLastBlockReader->currentBlockIndex != -1)) { - SBlockL *pBlockL = taosArrayGet(pLastBlockReader->pBlockL, pLastBlockReader->currentBlockIndex); - overlapWithlastBlock = !(pBlock->maxKey.ts < pBlockL->minKey || pBlock->minKey.ts > pBlockL->maxKey); +#if 0 + if (taosArrayGetSize(pLastBlockReader->pSstBlk) > 0 && (pLastBlockReader->currentBlockIndex != -1)) { + SSstBlk* pSstBlk = taosArrayGet(pLastBlockReader->pSstBlk, pLastBlockReader->currentBlockIndex); + overlapWithlastBlock = !(pBlock->maxKey.ts < pSstBlk->minKey || pBlock->minKey.ts > pSstBlk->maxKey); } +#endif bool moreThanOutputCapacity = pBlock->nRow > pReader->capacity; bool partiallyRequired = dataBlockPartiallyRequired(&pReader->window, &pReader->verRange, pBlock); @@ -1295,18 +1265,16 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; int64_t tsLast = INT64_MIN; - if ((pLastBlockReader->lastBlockData.nRow > 0) && hasDataInLastBlock(pLastBlockReader)) { + if (hasDataInLastBlock(pLastBlockReader)) { tsLast = getCurrentKeyInLastBlock(pLastBlockReader); } - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); - - SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData; + TSDBKEY k = TSDBROW_KEY(pRow); + TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); int64_t minKey = 0; if (pReader->order == TSDB_ORDER_ASC) { - minKey = INT64_MAX; // chosen the minimum value + minKey = INT64_MAX; // chosen the minimum value if (minKey > tsLast && hasDataInLastBlock(pLastBlockReader)) { minKey = tsLast; } @@ -1336,7 +1304,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* bool init = false; // ASC: file block ---> last block -----> imem -----> mem - //DESC: mem -----> imem -----> last block -----> file block + // DESC: mem -----> imem -----> last block -----> file block if (pReader->order == TSDB_ORDER_ASC) { if (minKey == key) { init = true; @@ -1345,7 +1313,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } if (minKey == tsLast) { - TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex); + TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { tRowMerge(&merge, &fRow1); } else { @@ -1374,7 +1342,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* } if (minKey == tsLast) { - TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex); + TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { tRowMerge(&merge, &fRow1); } else { @@ -1411,14 +1379,13 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData, bool mergeBlockData) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData; + // SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData; int64_t tsLastBlock = getCurrentKeyInLastBlock(pLastBlockReader); STSRow* pTSRow = NULL; SRowMerger merge = {0}; - TSDBROW fRow = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex); - + TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); tRowMergerInit(&merge, &fRow, pReader->pSchema); doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge); @@ -1445,7 +1412,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader if (pBlockData->nRow > 0) { // no last block available, only data block exists - if (pLastBlockReader->lastBlockData.nRow == 0 || (!hasDataInLastBlock(pLastBlockReader))) { + if (!hasDataInLastBlock(pLastBlockReader)) { return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); } @@ -1455,7 +1422,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader ASSERT(ts >= key); if (ASCENDING_TRAVERSE(pReader->order)) { - if (key < ts) { // imem, mem are all empty, file blocks (data blocks and last block) exist + if (key < ts) { // imem, mem are all empty, file blocks (data blocks and last block) exist return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); } else if (key == ts) { STSRow* pTSRow = NULL; @@ -1499,7 +1466,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader); ASSERT(pRow != NULL && piRow != NULL); - SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData; int64_t tsLast = INT64_MIN; if (hasDataInLastBlock(pLastBlockReader)) { tsLast = getCurrentKeyInLastBlock(pLastBlockReader); @@ -1529,7 +1495,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = tsLast; } } else { - minKey = INT64_MIN; // let find the maximum ts value + minKey = INT64_MIN; // let find the maximum ts value if (minKey < k.ts) { minKey = k.ts; } @@ -1560,7 +1526,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* } if (minKey == tsLast) { - TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex); + TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { tRowMerge(&merge, &fRow1); } else { @@ -1610,7 +1576,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* } if (minKey == tsLast) { - TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex); + TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); if (init) { tRowMerge(&merge, &fRow1); } else { @@ -1788,6 +1754,70 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* } #endif +static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) { + if (pBlockScanInfo->iterInit) { + return TSDB_CODE_SUCCESS; + } + + int32_t code = TSDB_CODE_SUCCESS; + + TSDBKEY startKey = {0}; + if (ASCENDING_TRAVERSE(pReader->order)) { + startKey = (TSDBKEY){.ts = pReader->window.skey, .version = pReader->verRange.minVer}; + } else { + startKey = (TSDBKEY){.ts = pReader->window.ekey, .version = pReader->verRange.maxVer}; + } + + int32_t backward = (!ASCENDING_TRAVERSE(pReader->order)); + + STbData* d = NULL; + if (pReader->pReadSnap->pMem != NULL) { + d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid); + if (d != NULL) { + code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter); + 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 + "-%" 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, + tstrerror(code), pReader->idStr); + return code; + } + } + } else { + tsdbDebug("%p uid:%" PRId64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); + } + + STbData* di = NULL; + if (pReader->pReadSnap->pIMem != NULL) { + di = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pIMem, pReader->suid, pBlockScanInfo->uid); + if (di != NULL) { + code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter); + 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 + "-%" 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, + tstrerror(code), pReader->idStr); + return code; + } + } + } else { + tsdbDebug("%p uid:%" PRId64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); + } + + initDelSkylineIterator(pBlockScanInfo, pReader, d, di); + + pBlockScanInfo->iterInit = true; + return TSDB_CODE_SUCCESS; +} + static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDumpInfo, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) { // it is an multi-table data block @@ -1819,34 +1849,25 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDum static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); } -static void initLastBlockReader(SLastBlockReader* pLastBlockReader, uint64_t uid, int16_t* startPos) { - pLastBlockReader->uid = uid; - pLastBlockReader->rowIndex = startPos; - - if (*startPos == -1) { - if (ASCENDING_TRAVERSE(pLastBlockReader->order)) { - // do nothing - } else { - *startPos = pLastBlockReader->lastBlockData.nRow; +static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pBlockScanInfo) { + while(1) { + bool hasVal = tMergeTreeNext(&pLastBlockReader->mergeTree); + if (!hasVal) { + return false; } - } -} - -static void setAllRowsChecked(SLastBlockReader *pLastBlockReader) { - *pLastBlockReader->rowIndex = ALL_ROWS_CHECKED_INDEX; -} -static bool nextRowInLastBlock(SLastBlockReader *pLastBlockReader, STableBlockScanInfo* pBlockScanInfo) { - bool asc = ASCENDING_TRAVERSE(pLastBlockReader->order); - int32_t step = (asc) ? 1 : -1; - if (*pLastBlockReader->rowIndex == ALL_ROWS_CHECKED_INDEX) { - return false; + TSDBROW row = tMergeTreeGetRow(&pLastBlockReader->mergeTree); + TSDBKEY k = TSDBROW_KEY(&row); + if (!hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) { + return true; + } } +#if 0 *(pLastBlockReader->rowIndex) += step; SBlockData* pBlockData = &pLastBlockReader->lastBlockData; - for(int32_t i = *(pLastBlockReader->rowIndex); i < pBlockData->nRow && i >= 0; i += step) { + for (int32_t i = *(pLastBlockReader->rowIndex); i < pBlockData->nRow && i >= 0; i += step) { if (pBlockData->aUid != NULL) { if (asc) { if (pBlockData->aUid[i] < pLastBlockReader->uid) { @@ -1895,23 +1916,42 @@ static bool nextRowInLastBlock(SLastBlockReader *pLastBlockReader, STableBlockSc // set all data is consumed in last block setAllRowsChecked(pLastBlockReader); return false; +#endif } -static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) { - SBlockData* pBlockData = &pLastBlockReader->lastBlockData; - return pBlockData->aTSKEY[*pLastBlockReader->rowIndex]; -} +static bool initLastBlockReader(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pBlockScanInfo, + STsdbReader* pReader) { + // the last block reader has been initialized for this table. + if (pLastBlockReader->uid == pBlockScanInfo->uid) { + return true; + } + + if (pLastBlockReader->uid != 0) { + tMergeTreeClose(&pLastBlockReader->mergeTree); + } -static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { - if (*pLastBlockReader->rowIndex == ALL_ROWS_CHECKED_INDEX) { + initMemDataIterator(pBlockScanInfo, pReader); + pLastBlockReader->uid = pBlockScanInfo->uid; + int32_t code = + tMergeTreeOpen(&pLastBlockReader->mergeTree, (pLastBlockReader->order == TSDB_ORDER_DESC), pReader->pFileReader, + pBlockScanInfo->uid, &pLastBlockReader->window, &pLastBlockReader->verRange); + if (code != TSDB_CODE_SUCCESS) { return false; } - ASSERT(pLastBlockReader->lastBlockData.nRow > 0); - return true; + return nextRowFromLastBlocks(pLastBlockReader, pBlockScanInfo); } -int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader) { +static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) { + TSDBROW row = tMergeTreeGetRow(&pLastBlockReader->mergeTree); + TSDBKEY key = TSDBROW_KEY(&row); + return key.ts; +} + +static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; } + +int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, + STsdbReader* pReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); @@ -1943,7 +1983,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - int64_t key = (pBlockData->nRow > 0)? pBlockData->aTSKEY[pDumpInfo->rowIndex]:INT64_MIN; + int64_t key = (pBlockData->nRow > 0) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN; TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader); @@ -1968,7 +2008,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI static int32_t buildComposedDataBlock(STsdbReader* pReader) { SSDataBlock* pResBlock = pReader->pResBlock; - SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); + SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); STableBlockScanInfo* pBlockScanInfo = NULL; if (pBlockInfo != NULL) { @@ -1996,7 +2036,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { pDumpInfo->rowIndex += step; - SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) { setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order); break; @@ -2015,7 +2055,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { // currently loaded file data block is consumed if ((pBlockData->nRow > 0) && (pDumpInfo->rowIndex >= pBlockData->nRow || pDumpInfo->rowIndex < 0)) { - SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order); break; } @@ -2043,70 +2083,6 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; } -static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) { - if (pBlockScanInfo->iterInit) { - return TSDB_CODE_SUCCESS; - } - - int32_t code = TSDB_CODE_SUCCESS; - - TSDBKEY startKey = {0}; - if (ASCENDING_TRAVERSE(pReader->order)) { - startKey = (TSDBKEY){.ts = pReader->window.skey, .version = pReader->verRange.minVer}; - } else { - startKey = (TSDBKEY){.ts = pReader->window.ekey, .version = pReader->verRange.maxVer}; - } - - int32_t backward = (!ASCENDING_TRAVERSE(pReader->order)); - - STbData* d = NULL; - if (pReader->pReadSnap->pMem != NULL) { - d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid); - if (d != NULL) { - code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter); - 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 - "-%" 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, - tstrerror(code), pReader->idStr); - return code; - } - } - } else { - tsdbDebug("%p uid:%" PRId64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); - } - - STbData* di = NULL; - if (pReader->pReadSnap->pIMem != NULL) { - di = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pIMem, pReader->suid, pBlockScanInfo->uid); - if (di != NULL) { - code = tsdbTbDataIterCreate(di, &startKey, backward, &pBlockScanInfo->iiter.iter); - 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 - "-%" 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, - tstrerror(code), pReader->idStr); - return code; - } - } - } else { - tsdbDebug("%p uid:%" PRId64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); - } - - initDelSkylineIterator(pBlockScanInfo, pReader, d, di); - - pBlockScanInfo->iterInit = true; - return TSDB_CODE_SUCCESS; -} - int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData, STbData* piMemTbData) { if (pBlockScanInfo->delSkyline != NULL) { @@ -2191,8 +2167,6 @@ _err: static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) { TSDBKEY key = {.ts = TSKEY_INITIAL_VAL}; - - initMemDataIterator(pScanInfo, pReader); TSDBROW* pRow = getValidMemRow(&pScanInfo->iter, pScanInfo->delSkyline, pReader); if (pRow != NULL) { key = TSDBROW_KEY(pRow); @@ -2212,12 +2186,10 @@ static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* p static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { SReaderStatus* pStatus = &pReader->status; pBlockNum->numOfBlocks = 0; - pBlockNum->numOfLastBlocks = 0; + pBlockNum->numOfLastFiles = 0; size_t numOfTables = taosHashGetSize(pReader->status.pTableMap); SArray* pIndexList = taosArrayInit(numOfTables, sizeof(SBlockIdx)); - SArray* pLastBlocks = pStatus->fileIter.pLastBlockReader->pBlockL; - taosArrayClear(pLastBlocks); while (1) { bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader); @@ -2232,32 +2204,16 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { return code; } - code = tsdbReadBlockL(pReader->pFileReader, pLastBlocks); - if (code != TSDB_CODE_SUCCESS) { - taosArrayDestroy(pIndexList); - return code; - } - - if (taosArrayGetSize(pIndexList) > 0 || taosArrayGetSize(pLastBlocks) > 0) { - SArray* pQLastBlock = taosArrayInit(4, sizeof(SBlockL)); - - code = doLoadFileBlock(pReader, pIndexList, pLastBlocks, pBlockNum, pQLastBlock); + if (taosArrayGetSize(pIndexList) > 0 || pReader->pFileReader->pSet->nSstF > 0) { + code = doLoadFileBlock(pReader, pIndexList, pBlockNum); if (code != TSDB_CODE_SUCCESS) { taosArrayDestroy(pIndexList); - taosArrayDestroy(pQLastBlock); return code; } - if (pBlockNum->numOfBlocks + pBlockNum->numOfLastBlocks > 0) { - ASSERT(taosArrayGetSize(pQLastBlock) == pBlockNum->numOfLastBlocks); - taosArrayClear(pLastBlocks); - taosArrayAddAll(pLastBlocks, pQLastBlock); - - taosArrayDestroy(pQLastBlock); + if (pBlockNum->numOfBlocks + pBlockNum->numOfLastFiles > 0) { break; } - - taosArrayDestroy(pQLastBlock); } // no blocks in current file, try next files @@ -2267,81 +2223,22 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { return TSDB_CODE_SUCCESS; } -static int32_t doLoadRelatedLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo *pBlockScanInfo, STsdbReader* pReader) { - SArray* pBlocks = pLastBlockReader->pBlockL; - SBlockL* pBlock = NULL; - - uint64_t uid = pBlockScanInfo->uid; - int32_t totalLastBlocks = (int32_t)taosArrayGetSize(pBlocks); - - initMemDataIterator(pBlockScanInfo, pReader); - - // find the correct SBlockL. todo binary search - int32_t index = -1; - for (int32_t i = 0; i < totalLastBlocks; ++i) { - SBlockL* p = taosArrayGet(pBlocks, i); - if (p->minUid <= uid && p->maxUid >= uid) { - index = i; - pBlock = p; - break; - } - } - - if (index == -1) { - pLastBlockReader->currentBlockIndex = index; - tBlockDataReset(&pLastBlockReader->lastBlockData); - return TSDB_CODE_SUCCESS; - } - - // the required last datablock has already loaded - if (index == pLastBlockReader->currentBlockIndex) { - return TSDB_CODE_SUCCESS; - } - - int64_t st = taosGetTimestampUs(); - int32_t code = tBlockDataInit(&pLastBlockReader->lastBlockData, pReader->suid, pReader->suid ? 0 : uid, pReader->pSchema); - if (code != TSDB_CODE_SUCCESS) { - tsdbError("%p init block data failed, code:%s %s", pReader, tstrerror(code), pReader->idStr); - return code; - } - - code = tsdbReadLastBlock(pReader->pFileReader, pBlock, &pLastBlockReader->lastBlockData); - - double el = (taosGetTimestampUs() - st) / 1000.0; - if (code != TSDB_CODE_SUCCESS) { - tsdbError("%p error occurs in loading last block into buffer, last block index:%d, total:%d code:%s %s", pReader, - pLastBlockReader->currentBlockIndex, totalLastBlocks, tstrerror(code), pReader->idStr); - } else { - tsdbDebug("%p load last block completed, uid:%" PRIu64 - " last block index:%d, total:%d rows:%d, minVer:%d, maxVer:%d, brange:%" PRId64 "-%" PRId64 - " elapsed time:%.2f ms, %s", - pReader, uid, index, totalLastBlocks, pBlock->nRow, pBlock->minVer, pBlock->maxVer, pBlock->minKey, - pBlock->maxKey, el, pReader->idStr); - } - - pLastBlockReader->currentBlockIndex = index; - pReader->cost.lastBlockLoad += 1; - pReader->cost.lastBlockLoadTime += el; - - return TSDB_CODE_SUCCESS; -} - static int32_t uidComparFunc(const void* p1, const void* p2) { - uint64_t pu1 = *(uint64_t*) p1; - uint64_t pu2 = *(uint64_t*) p2; + uint64_t pu1 = *(uint64_t*)p1; + uint64_t pu2 = *(uint64_t*)p2; if (pu1 == pu2) { return 0; } else { - return (pu1 < pu2)? -1:1; + return (pu1 < pu2) ? -1 : 1; } } -static void extractOrderedTableUidList(SUidOrderCheckInfo *pOrderCheckInfo, SReaderStatus* pStatus) { +static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) { int32_t index = 0; int32_t total = taosHashGetSize(pStatus->pTableMap); void* p = taosHashIterate(pStatus->pTableMap, NULL); - while(p != NULL) { + while (p != NULL) { STableBlockScanInfo* pScanInfo = p; pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid; p = taosHashIterate(pStatus->pTableMap, p); @@ -2351,9 +2248,12 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo *pOrderCheckInfo, SRea } static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) { - if (pOrderCheckInfo->tableUidList == NULL) { - int32_t total = taosHashGetSize(pStatus->pTableMap); + int32_t total = taosHashGetSize(pStatus->pTableMap); + if (total == 0) { + return TSDB_CODE_SUCCESS; + } + if (pOrderCheckInfo->tableUidList == NULL) { pOrderCheckInfo->currentIndex = 0; pOrderCheckInfo->tableUidList = taosMemoryMalloc(total * sizeof(uint64_t)); if (pOrderCheckInfo->tableUidList == NULL) { @@ -2361,20 +2261,17 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt } extractOrderedTableUidList(pOrderCheckInfo, pStatus); - uint64_t uid = pOrderCheckInfo->tableUidList[0]; pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); } else { if (pStatus->pTableIter == NULL) { // it is the last block of a new file -// ASSERT(pOrderCheckInfo->currentIndex == taosHashGetSize(pStatus->pTableMap)); - pOrderCheckInfo->currentIndex = 0; uint64_t uid = pOrderCheckInfo->tableUidList[pOrderCheckInfo->currentIndex]; pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); // the tableMap has already updated if (pStatus->pTableIter == NULL) { - void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, taosHashGetSize(pStatus->pTableMap)*sizeof(uint64_t)); + void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, total * sizeof(uint64_t)); if (p == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -2391,7 +2288,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt return TSDB_CODE_SUCCESS; } -static bool moveToNextTable(SUidOrderCheckInfo *pOrderedCheckInfo, SReaderStatus* pStatus) { +static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus* pStatus) { pOrderedCheckInfo->currentIndex += 1; if (pOrderedCheckInfo->currentIndex >= taosHashGetSize(pStatus->pTableMap)) { pStatus->pTableIter = NULL; @@ -2405,38 +2302,20 @@ static bool moveToNextTable(SUidOrderCheckInfo *pOrderedCheckInfo, SReaderStatus } static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { - SReaderStatus* pStatus = &pReader->status; + SReaderStatus* pStatus = &pReader->status; SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader; - SUidOrderCheckInfo *pOrderedCheckInfo = &pStatus->uidCheckInfo; - int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus); + SUidOrderCheckInfo* pOrderedCheckInfo = &pStatus->uidCheckInfo; + int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus); if (code != TSDB_CODE_SUCCESS || (taosHashGetSize(pStatus->pTableMap) == 0)) { return code; } - while(1) { + while (1) { // load the last data block of current table STableBlockScanInfo* pScanInfo = pStatus->pTableIter; - code = doLoadRelatedLastBlock(pLastBlockReader, pScanInfo, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - if (pLastBlockReader->currentBlockIndex != -1) { - initLastBlockReader(pLastBlockReader, pScanInfo->uid, &pScanInfo->indexInBlockL); - int32_t index = pScanInfo->indexInBlockL; - - if (index == INITIAL_ROW_INDEX_VAL || index == pLastBlockReader->lastBlockData.nRow) { - bool hasData = nextRowInLastBlock(pLastBlockReader, pScanInfo); - if (!hasData) { // current table does not have rows in last block, try next table - bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus); - if (!hasNexTable) { - return TSDB_CODE_SUCCESS; - } - continue; - } - } - } else { // no data in last block, try next table + bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader); + if (!hasVal) { bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus); if (!hasNexTable) { return TSDB_CODE_SUCCESS; @@ -2462,9 +2341,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { } static int32_t doBuildDataBlock(STsdbReader* pReader) { - TSDBKEY key = {0}; - int32_t code = TSDB_CODE_SUCCESS; - SBlock* pBlock = NULL; + int32_t code = TSDB_CODE_SUCCESS; + SDataBlk* pBlock = NULL; SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; @@ -2482,21 +2360,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { pBlock = getCurrentBlock(pBlockIter); } - { - key = getCurrentKeyInBuf(pScanInfo, pReader); - - // load the last data block of current table - code = doLoadRelatedLastBlock(pLastBlockReader, pScanInfo, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - // note: the lastblock may be null here - initLastBlockReader(pLastBlockReader, pScanInfo->uid, &pScanInfo->indexInBlockL); - if (pScanInfo->indexInBlockL == INITIAL_ROW_INDEX_VAL || pScanInfo->indexInBlockL == pLastBlockReader->lastBlockData.nRow) { - bool hasData = nextRowInLastBlock(pLastBlockReader, pScanInfo); - } - } + initLastBlockReader(pLastBlockReader, pScanInfo, pReader); + TSDBKEY key = getCurrentKeyInBuf(pScanInfo, pReader); if (pBlockInfo == NULL) { // build data block from last data file ASSERT(pBlockIter->numOfBlocks == 0); @@ -2524,11 +2389,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { if (hasDataInLastBlock(pLastBlockReader) && !ASCENDING_TRAVERSE(pReader->order)) { // only return the rows in last block int64_t tsLast = getCurrentKeyInLastBlock(pLastBlockReader); - ASSERT (tsLast >= pBlock->maxKey.ts); + ASSERT(tsLast >= pBlock->maxKey.ts); tBlockDataReset(&pReader->status.fileBlockData); code = buildComposedDataBlock(pReader); - } else { // whole block is required, return it directly + } else { // whole block is required, return it directly SDataBlockInfo* pInfo = &pReader->pResBlock->info; pInfo->rows = pBlock->nRow; pInfo->uid = pScanInfo->uid; @@ -2575,7 +2440,7 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { // set the correct start position in case of the first/last file block, according to the query time window static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) { - SBlock* pBlock = getCurrentBlock(pBlockIter); + SDataBlk* pBlock = getCurrentBlock(pBlockIter); SReaderStatus* pStatus = &pReader->status; @@ -2595,7 +2460,7 @@ static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBl } // all data files are consumed, try data in buffer - if (num.numOfBlocks + num.numOfLastBlocks == 0) { + if (num.numOfBlocks + num.numOfLastFiles == 0) { pReader->status.loadFromFile = false; return code; } @@ -2603,14 +2468,11 @@ static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBl // initialize the block iterator for a new fileset if (num.numOfBlocks > 0) { code = initBlockIterator(pReader, pBlockIter, num.numOfBlocks); - } else { // no block data, only last block exists + } else { // no block data, only last block exists tBlockDataReset(&pReader->status.fileBlockData); resetDataBlockIterator(pBlockIter, pReader->order); } - SLastBlockReader* pLReader = pReader->status.fileIter.pLastBlockReader; - pLReader->currentBlockIndex = -1; - // set the correct start position according to the query time window initBlockDumpInfo(pReader, pBlockIter); return code; @@ -2628,7 +2490,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { SDataBlockIter* pBlockIter = &pReader->status.blockIter; if (pBlockIter->numOfBlocks == 0) { - _begin: + _begin: code = doLoadLastBlockSequentially(pReader); if (code != TSDB_CODE_SUCCESS) { return code; @@ -2675,7 +2537,8 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { bool hasNext = blockIteratorNext(&pReader->status.blockIter); if (hasNext) { // check for the next block in the block accessed order list initBlockDumpInfo(pReader, pBlockIter); - } else if (taosArrayGetSize(pReader->status.fileIter.pLastBlockReader->pBlockL) > 0) { // data blocks in current file are exhausted, let's try the next file now + } else if (hasDataInLastBlock(pReader->status.fileIter.pLastBlockReader)) { + // data blocks in current file are exhausted, let's try the next file now tBlockDataReset(&pReader->status.fileBlockData); resetDataBlockIterator(pBlockIter, pReader->order); goto _begin; @@ -2948,7 +2811,7 @@ typedef enum { CHECK_FILEBLOCK_QUIT = 0x2, } CHECK_FILEBLOCK_STATE; -static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanInfo* pScanInfo, SBlock* pBlock, +static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanInfo* pScanInfo, SDataBlk* pBlock, SFileDataBlockInfo* pFBlock, SRowMerger* pMerger, int64_t key, CHECK_FILEBLOCK_STATE* state) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; @@ -2957,8 +2820,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn *state = CHECK_FILEBLOCK_QUIT; int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1; - int32_t nextIndex = -1; - SBlock* pNeighborBlock = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order); + int32_t nextIndex = -1; + SDataBlk* pNeighborBlock = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order); if (pNeighborBlock == NULL) { // do nothing return 0; } @@ -3022,7 +2885,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc CHECK_FILEBLOCK_STATE st; SFileDataBlockInfo* pFileBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter); + SDataBlk* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter); checkForNeighborFileBlock(pReader, pScanInfo, pCurrentBlock, pFileBlockInfo, pMerger, key, &st); if (st == CHECK_FILEBLOCK_QUIT) { break; @@ -3033,11 +2896,12 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc return TSDB_CODE_SUCCESS; } -int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, SRowMerger* pMerger) { - while(nextRowInLastBlock(pLastBlockReader, pScanInfo)) { +int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, + SRowMerger* pMerger) { + while (nextRowFromLastBlocks(pLastBlockReader, pScanInfo)) { int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader); if (next1 == ts) { - TSDBROW fRow1 = tsdbRowFromBlockData(&pLastBlockReader->lastBlockData, *pLastBlockReader->rowIndex); + TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); tRowMerge(pMerger, &fRow1); } else { break; @@ -3101,7 +2965,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, } int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, - STSRow** pTSRow) { + STSRow** pTSRow) { SRowMerger merge = {0}; TSDBKEY k = TSDBROW_KEY(pRow); @@ -3175,7 +3039,8 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR } if (pBlockScanInfo->iter.hasVal && pRow != NULL) { - return doMergeMemTableMultiRows(pRow, pBlockScanInfo->uid, &pBlockScanInfo->iter, pDelList, pTSRow, pReader, freeTSRow); + return doMergeMemTableMultiRows(pRow, pBlockScanInfo->uid, &pBlockScanInfo->iter, pDelList, pTSRow, pReader, + freeTSRow); } if (pBlockScanInfo->iiter.hasVal && piRow != NULL) { @@ -3229,7 +3094,8 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* return TSDB_CODE_SUCCESS; } -int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, int32_t rowIndex) { +int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, + int32_t rowIndex) { int32_t i = 0, j = 0; int32_t outputRowIndex = pResBlock->info.rows; @@ -3306,7 +3172,7 @@ int32_t tsdbSetTableId(STsdbReader* pReader, int64_t uid) { ASSERT(pReader != NULL); taosHashClear(pReader->status.pTableMap); - STableBlockScanInfo info = {.lastKey = 0, .uid = uid, .indexInBlockL = INITIAL_ROW_INDEX_VAL}; + STableBlockScanInfo info = {.lastKey = 0, .uid = uid}; taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info)); return TDB_CODE_SUCCESS; } @@ -3327,7 +3193,6 @@ void* tsdbGetIvtIdx(SMeta* pMeta) { uint64_t getReaderMaxVersion(STsdbReader* pReader) { return pReader->verRange.maxVer; } - // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader, const char* idstr) { @@ -3377,10 +3242,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl } if (pCond->suid != 0) { - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->schemaVersion); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->endVersion); } else if (taosArrayGetSize(pTableList) > 0) { STableKeyInfo* pKey = taosArrayGet(pTableList, 0); - pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->schemaVersion); + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->endVersion); } int32_t numOfTables = taosArrayGetSize(pTableList); @@ -3450,7 +3315,6 @@ void tsdbReaderClose(STsdbReader* pReader) { } SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; - tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap); taosMemoryFreeClear(pSupInfo->plist); taosMemoryFree(pSupInfo->colIds); @@ -3461,6 +3325,7 @@ void tsdbReaderClose(STsdbReader* pReader) { taosMemoryFreeClear(pSupInfo->buildBuf[i]); } } + taosMemoryFree(pSupInfo->buildBuf); tBlockDataDestroy(&pReader->status.fileBlockData, true); @@ -3474,12 +3339,13 @@ void tsdbReaderClose(STsdbReader* pReader) { tsdbDataFReaderClose(&pReader->pFileReader); } + tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap); + taosMemoryFree(pReader->status.uidCheckInfo.tableUidList); SFilesetIter* pFilesetIter = &pReader->status.fileIter; if (pFilesetIter->pLastBlockReader != NULL) { - tBlockDataDestroy(&pFilesetIter->pLastBlockReader->lastBlockData, true); - taosArrayDestroy(pFilesetIter->pLastBlockReader->pBlockL); + tMergeTreeClose(&pFilesetIter->pLastBlockReader->mergeTree); taosMemoryFree(pFilesetIter->pLastBlockReader); } @@ -3603,12 +3469,12 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); - SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter); - int64_t stime = taosGetTimestampUs(); + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); + int64_t stime = taosGetTimestampUs(); SBlockLoadSuppInfo* pSup = &pReader->suppInfo; - if (tBlockHasSma(pBlock)) { + if (tDataBlkHasSma(pBlock)) { code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg); if (code != TSDB_CODE_SUCCESS) { tsdbDebug("vgId:%d, failed to load block SMA for uid %" PRIu64 ", code:%s, %s", 0, pFBlock->uid, tstrerror(code), @@ -3785,7 +3651,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa while (true) { if (hasNext) { - SBlock* pBlock = getCurrentBlock(pBlockIter); + SDataBlk* pBlock = getCurrentBlock(pBlockIter); int32_t numOfRows = pBlock->nRow; pTableBlockInfo->totalRows += numOfRows; @@ -3953,4 +3819,4 @@ void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap) { } tsdbTrace("vgId:%d, untake read snapshot", TD_VID(pTsdb->pVnode)); -} +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index c8f3862071b3628fdefd26df58ea3cb01e80d302..dbaf9b234c5a7bca7b41c2f5ca943234c05e129f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -394,17 +394,6 @@ _err: } // SDataFReader ==================================================== -struct SDataFReader { - STsdb *pTsdb; - SDFileSet *pSet; - TdFilePtr pHeadFD; - TdFilePtr pDataFD; - TdFilePtr pLastFD; - TdFilePtr pSmaFD; - - uint8_t *aBuf[3]; -}; - int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet) { int32_t code = 0; SDataFReader *pReader; @@ -436,14 +425,6 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS goto _err; } - // last - tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname); - pReader->pLastFD = taosOpenFile(fname, TD_FILE_READ); - if (pReader->pLastFD == NULL) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - // sma tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname); pReader->pSmaFD = taosOpenFile(fname, TD_FILE_READ); @@ -452,6 +433,16 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS goto _err; } + // sst + for (int32_t iSst = 0; iSst < pSet->nSstF; iSst++) { + tsdbSstFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSstF[iSst], fname); + pReader->aLastFD[iSst] = taosOpenFile(fname, TD_FILE_READ); + if (pReader->aLastFD[iSst] == NULL) { + code = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + } + *ppReader = pReader; return code; @@ -465,30 +456,35 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) { int32_t code = 0; if (*ppReader == NULL) goto _exit; + // head if (taosCloseFile(&(*ppReader)->pHeadFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } + // data if (taosCloseFile(&(*ppReader)->pDataFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - if (taosCloseFile(&(*ppReader)->pLastFD) < 0) { + // sma + if (taosCloseFile(&(*ppReader)->pSmaFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - if (taosCloseFile(&(*ppReader)->pSmaFD) < 0) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; + // sst + for (int32_t iSst = 0; iSst < (*ppReader)->pSet->nSstF; iSst++) { + if (taosCloseFile(&(*ppReader)->aLastFD[iSst]) < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _err; + } } for (int32_t iBuf = 0; iBuf < sizeof((*ppReader)->aBuf) / sizeof(uint8_t *); iBuf++) { tFree((*ppReader)->aBuf[iBuf]); } - taosMemoryFree(*ppReader); _exit: @@ -563,14 +559,14 @@ _err: return code; } -int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) { +int32_t tsdbReadSstBlk(SDataFReader *pReader, int32_t iSst, SArray *aSstBlk) { int32_t code = 0; - int64_t offset = pReader->pSet->pLastF->offset; - int64_t size = pReader->pSet->pLastF->size - offset; + int64_t offset = pReader->pSet->aSstF[iSst]->offset; + int64_t size = pReader->pSet->aSstF[iSst]->size - offset; int64_t n; uint32_t delimiter; - taosArrayClear(aBlockL); + taosArrayClear(aSstBlk); if (size == 0) { goto _exit; } @@ -580,13 +576,13 @@ int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) { if (code) goto _err; // seek - if (taosLSeekFile(pReader->pLastFD, offset, SEEK_SET) < 0) { + if (taosLSeekFile(pReader->aLastFD[iSst], offset, SEEK_SET) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } // read - n = taosReadFile(pReader->pLastFD, pReader->aBuf[0], size); + n = taosReadFile(pReader->aLastFD[iSst], pReader->aBuf[0], size); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -607,10 +603,10 @@ int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) { ASSERT(delimiter == TSDB_FILE_DLMT); while (n < size - sizeof(TSCKSUM)) { - SBlockL blockl; - n += tGetBlockL(pReader->aBuf[0] + n, &blockl); + SSstBlk blockl; + n += tGetSstBlk(pReader->aBuf[0] + n, &blockl); - if (taosArrayPush(aBlockL, &blockl) == NULL) { + if (taosArrayPush(aSstBlk, &blockl) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -681,9 +677,9 @@ _err: return code; } -int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnDataAgg) { +int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pDataBlk, SArray *aColumnDataAgg) { int32_t code = 0; - SSmaInfo *pSmaInfo = &pBlock->smaInfo; + SSmaInfo *pSmaInfo = &pDataBlk->smaInfo; ASSERT(pSmaInfo->size > 0); @@ -745,7 +741,7 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo tBlockDataClear(pBlockData); - TdFilePtr pFD = fromLast ? pReader->pLastFD : pReader->pDataFD; + TdFilePtr pFD = fromLast ? pReader->aLastFD[0] : pReader->pDataFD; // (todo) // uid + version + tskey code = tsdbReadAndCheck(pFD, pBlkInfo->offset, &pReader->aBuf[0], pBlkInfo->szKey, 1); @@ -847,13 +843,13 @@ _err: return code; } -int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBlockData) { +int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) { int32_t code = 0; - code = tsdbReadBlockDataImpl(pReader, &pBlock->aSubBlock[0], 0, pBlockData); + code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[0], 0, pBlockData); if (code) goto _err; - if (pBlock->nSubBlock > 1) { + if (pDataBlk->nSubBlock > 1) { SBlockData bData1; SBlockData bData2; @@ -867,8 +863,8 @@ int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBl tBlockDataInitEx(&bData1, pBlockData); tBlockDataInitEx(&bData2, pBlockData); - for (int32_t iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) { - code = tsdbReadBlockDataImpl(pReader, &pBlock->aSubBlock[iSubBlock], 0, &bData1); + for (int32_t iSubBlock = 1; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) { + code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[iSubBlock], 0, &bData1); if (code) { tBlockDataDestroy(&bData1, 1); tBlockDataDestroy(&bData2, 1); @@ -901,10 +897,10 @@ _err: return code; } -int32_t tsdbReadLastBlock(SDataFReader *pReader, SBlockL *pBlockL, SBlockData *pBlockData) { +int32_t tsdbReadSstBlock(SDataFReader *pReader, int32_t iSst, SSstBlk *pSstBlk, SBlockData *pBlockData) { int32_t code = 0; - code = tsdbReadBlockDataImpl(pReader, &pBlockL->bInfo, 1, pBlockData); + code = tsdbReadBlockDataImpl(pReader, &pSstBlk->bInfo, 1, pBlockData); if (code) goto _err; return code; @@ -914,6 +910,21 @@ _err: return code; } +int32_t tsdbReadSstBlockEx(SDataFReader *pReader, int32_t iSst, SSstBlk *pSstBlk, SBlockData *pBlockData) { + int32_t code = 0; + + // read + code = tsdbReadAndCheck(pReader->aLastFD[iSst], pSstBlk->bInfo.offset, &pReader->aBuf[0], pSstBlk->bInfo.szBlock, 0); + if (code) goto _exit; + + // decmpr + code = tDecmprBlockData(pReader->aBuf[0], pSstBlk->bInfo.szBlock, pBlockData, &pReader->aBuf[1]); + if (code) goto _exit; + +_exit: + return code; +} + // SDataFWriter ==================================================== int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet) { int32_t code = 0; @@ -929,18 +940,22 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - if (code) goto _err; pWriter->pTsdb = pTsdb; - pWriter->wSet = (SDFileSet){.diskId = pSet->diskId, - .fid = pSet->fid, - .pHeadF = &pWriter->fHead, - .pDataF = &pWriter->fData, - .pLastF = &pWriter->fLast, - .pSmaF = &pWriter->fSma}; + pWriter->wSet = (SDFileSet){ + .diskId = pSet->diskId, + .fid = pSet->fid, + .pHeadF = &pWriter->fHead, + .pDataF = &pWriter->fData, + .pSmaF = &pWriter->fSma, + .nSstF = pSet->nSstF // + }; pWriter->fHead = *pSet->pHeadF; pWriter->fData = *pSet->pDataF; - pWriter->fLast = *pSet->pLastF; pWriter->fSma = *pSet->pSmaF; + for (int8_t iSst = 0; iSst < pSet->nSstF; iSst++) { + pWriter->wSet.aSstF[iSst] = &pWriter->fSst[iSst]; + pWriter->fSst[iSst] = *pSet->aSstF[iSst]; + } // head flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; @@ -991,36 +1006,6 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS ASSERT(n == pWriter->fData.size); } - // last - if (pWriter->fLast.size == 0) { - flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; - } else { - flag = TD_FILE_WRITE; - } - tsdbLastFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fLast, fname); - pWriter->pLastFD = taosOpenFile(fname, flag); - if (pWriter->pLastFD == NULL) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - if (pWriter->fLast.size == 0) { - n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE); - if (n < 0) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - - pWriter->fLast.size += TSDB_FHDR_SIZE; - } else { - n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_END); - if (n < 0) { - code = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - - ASSERT(n == pWriter->fLast.size); - } - // sma if (pWriter->fSma.size == 0) { flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; @@ -1051,6 +1036,22 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS ASSERT(n == pWriter->fSma.size); } + // sst + ASSERT(pWriter->fSst[pSet->nSstF - 1].size == 0); + flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; + tsdbSstFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fSst[pSet->nSstF - 1], fname); + pWriter->pLastFD = taosOpenFile(fname, flag); + if (pWriter->pLastFD == NULL) { + code = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE); + if (n < 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + pWriter->fSst[pWriter->wSet.nSstF - 1].size += TSDB_FHDR_SIZE; + *ppWriter = pWriter; return code; @@ -1078,12 +1079,12 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) { goto _err; } - if (taosFsyncFile((*ppWriter)->pLastFD) < 0) { + if (taosFsyncFile((*ppWriter)->pSmaFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - if (taosFsyncFile((*ppWriter)->pSmaFD) < 0) { + if (taosFsyncFile((*ppWriter)->pLastFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -1099,12 +1100,12 @@ int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) { goto _err; } - if (taosCloseFile(&(*ppWriter)->pLastFD) < 0) { + if (taosCloseFile(&(*ppWriter)->pSmaFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - if (taosCloseFile(&(*ppWriter)->pSmaFD) < 0) { + if (taosCloseFile(&(*ppWriter)->pLastFD) < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -1161,35 +1162,35 @@ int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) { goto _err; } - // last ============== + // sma ============== memset(hdr, 0, TSDB_FHDR_SIZE); - tPutLastFile(hdr, &pWriter->fLast); + tPutSmaFile(hdr, &pWriter->fSma); taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE); - n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_SET); + n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_SET); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE); + n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - // sma ============== + // sst ============== memset(hdr, 0, TSDB_FHDR_SIZE); - tPutSmaFile(hdr, &pWriter->fSma); + tPutSstFile(hdr, &pWriter->fSst[pWriter->wSet.nSstF - 1]); taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE); - n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_SET); + n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_SET); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE); + n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -1300,22 +1301,22 @@ _err: return code; } -int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) { - int32_t code = 0; - SLastFile *pLastFile = &pWriter->fLast; - int64_t size; - int64_t n; +int32_t tsdbWriteSstBlk(SDataFWriter *pWriter, SArray *aSstBlk) { + int32_t code = 0; + SSstFile *pSstFile = &pWriter->fSst[pWriter->wSet.nSstF - 1]; + int64_t size; + int64_t n; // check - if (taosArrayGetSize(aBlockL) == 0) { - pLastFile->offset = pLastFile->size; + if (taosArrayGetSize(aSstBlk) == 0) { + pSstFile->offset = pSstFile->size; goto _exit; } // size size = sizeof(uint32_t); // TSDB_FILE_DLMT - for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aBlockL); iBlockL++) { - size += tPutBlockL(NULL, taosArrayGet(aBlockL, iBlockL)); + for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aSstBlk); iBlockL++) { + size += tPutSstBlk(NULL, taosArrayGet(aSstBlk, iBlockL)); } size += sizeof(TSCKSUM); @@ -1326,8 +1327,8 @@ int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) { // encode n = 0; n += tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT); - for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aBlockL); iBlockL++) { - n += tPutBlockL(pWriter->aBuf[0] + n, taosArrayGet(aBlockL, iBlockL)); + for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aSstBlk); iBlockL++) { + n += tPutSstBlk(pWriter->aBuf[0] + n, taosArrayGet(aSstBlk, iBlockL)); } taosCalcChecksumAppend(0, pWriter->aBuf[0], size); @@ -1341,12 +1342,12 @@ int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) { } // update - pLastFile->offset = pLastFile->size; - pLastFile->size += size; + pSstFile->offset = pSstFile->size; + pSstFile->size += size; _exit: tsdbTrace("vgId:%d tsdb write blockl, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), - pLastFile->offset, size); + pSstFile->offset, size); return code; _err: @@ -1354,28 +1355,28 @@ _err: return code; } -static void tsdbUpdateBlockInfo(SBlockData *pBlockData, SBlock *pBlock) { +static void tsdbUpdateBlockInfo(SBlockData *pBlockData, SDataBlk *pDataBlk) { for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) { TSDBKEY key = {.ts = pBlockData->aTSKEY[iRow], .version = pBlockData->aVersion[iRow]}; if (iRow == 0) { - if (tsdbKeyCmprFn(&pBlock->minKey, &key) > 0) { - pBlock->minKey = key; + if (tsdbKeyCmprFn(&pDataBlk->minKey, &key) > 0) { + pDataBlk->minKey = key; } } else { if (pBlockData->aTSKEY[iRow] == pBlockData->aTSKEY[iRow - 1]) { - pBlock->hasDup = 1; + pDataBlk->hasDup = 1; } } - if (iRow == pBlockData->nRow - 1 && tsdbKeyCmprFn(&pBlock->maxKey, &key) < 0) { - pBlock->maxKey = key; + if (iRow == pBlockData->nRow - 1 && tsdbKeyCmprFn(&pDataBlk->maxKey, &key) < 0) { + pDataBlk->maxKey = key; } - pBlock->minVer = TMIN(pBlock->minVer, key.version); - pBlock->maxVer = TMAX(pBlock->maxVer, key.version); + pDataBlk->minVer = TMIN(pDataBlk->minVer, key.version); + pDataBlk->maxVer = TMAX(pDataBlk->maxVer, key.version); } - pBlock->nRow += pBlockData->nRow; + pDataBlk->nRow += pBlockData->nRow; } static int32_t tsdbWriteBlockSma(SDataFWriter *pWriter, SBlockData *pBlockData, SSmaInfo *pSmaInfo) { @@ -1430,7 +1431,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock ASSERT(pBlockData->nRow > 0); - pBlkInfo->offset = toLast ? pWriter->fLast.size : pWriter->fData.size; + pBlkInfo->offset = toLast ? pWriter->fSst[pWriter->wSet.nSstF - 1].size : pWriter->fData.size; pBlkInfo->szBlock = 0; pBlkInfo->szKey = 0; @@ -1474,7 +1475,7 @@ int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlock // update info if (toLast) { - pWriter->fLast.size += pBlkInfo->szBlock; + pWriter->fSst[pWriter->wSet.nSstF - 1].size += pBlkInfo->szBlock; } else { pWriter->fData.size += pBlkInfo->szBlock; } @@ -1553,9 +1554,9 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { taosCloseFile(&pOutFD); taosCloseFile(&PInFD); - // last - tsdbLastFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pLastF, fNameFrom); - tsdbLastFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pLastF, fNameTo); + // sst + tsdbSstFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSstF[0], fNameFrom); + tsdbSstFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSstF[0], fNameTo); pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); if (pOutFD == NULL) { @@ -1569,7 +1570,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { goto _err; } - n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pLastF->size); + n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->aSstF[0]->size); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index a30b9154ab07084adc31c65089d223ac728445ae..ee29538a8112c972f9e6b4d92beccb9cc2bbdfab 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -60,7 +60,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) { if (expLevel < 0) { taosMemoryFree(pSet->pHeadF); taosMemoryFree(pSet->pDataF); - taosMemoryFree(pSet->pLastF); + taosMemoryFree(pSet->aSstF[0]); taosMemoryFree(pSet->pSmaF); taosArrayRemove(fs.aDFileSet, iSet); iSet--; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index ab2b2b617a3d36dbc2c86c2a2207cffac8f087f6..8d19a2ffb822ba6cf72be5b911aad978aed0bc57 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -27,13 +27,13 @@ struct STsdbSnapReader { int32_t fid; SDataFReader* pDataFReader; SArray* aBlockIdx; // SArray - SArray* aBlockL; // SArray + SArray* aSstBlk; // SArray SBlockIdx* pBlockIdx; - SBlockL* pBlockL; + SSstBlk* pSstBlk; int32_t iBlockIdx; int32_t iBlockL; - SMapData mBlock; // SMapData + SMapData mBlock; // SMapData int32_t iBlock; SBlockData oBlockData; SBlockData nBlockData; @@ -64,7 +64,7 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { code = tsdbReadBlockIdx(pReader->pDataFReader, pReader->aBlockIdx); if (code) goto _err; - code = tsdbReadBlockL(pReader->pDataFReader, pReader->aBlockL); + code = tsdbReadSstBlk(pReader->pDataFReader, 0, pReader->aSstBlk); if (code) goto _err; // init @@ -82,13 +82,13 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { pReader->iBlockL = 0; while (true) { - if (pReader->iBlockL >= taosArrayGetSize(pReader->aBlockL)) { - pReader->pBlockL = NULL; + if (pReader->iBlockL >= taosArrayGetSize(pReader->aSstBlk)) { + pReader->pSstBlk = NULL; break; } - pReader->pBlockL = (SBlockL*)taosArrayGet(pReader->aBlockL, pReader->iBlockL); - if (pReader->pBlockL->minVer <= pReader->ever && pReader->pBlockL->maxVer >= pReader->sver) { + pReader->pSstBlk = (SSstBlk*)taosArrayGet(pReader->aSstBlk, pReader->iBlockL); + if (pReader->pSstBlk->minVer <= pReader->ever && pReader->pSstBlk->maxVer >= pReader->sver) { // TODO break; } @@ -101,8 +101,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { } while (true) { - if (pReader->pBlockIdx && pReader->pBlockL) { - TABLEID id = {.suid = pReader->pBlockL->suid, .uid = pReader->pBlockL->minUid}; + if (pReader->pBlockIdx && pReader->pSstBlk) { + TABLEID id = {.suid = pReader->pSstBlk->suid, .uid = pReader->pSstBlk->minUid}; ASSERT(0); @@ -115,8 +115,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { // } } else if (pReader->pBlockIdx) { while (pReader->iBlock < pReader->mBlock.nItem) { - SBlock block; - tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, &block, tGetBlock); + SDataBlk block; + tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, &block, tGetDataBlk); if (block.minVer <= pReader->ever && block.maxVer >= pReader->sver) { // load data (todo) @@ -142,18 +142,18 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { } if (*ppData) goto _exit; - } else if (pReader->pBlockL) { - while (pReader->pBlockL) { - if (pReader->pBlockL->minVer <= pReader->ever && pReader->pBlockL->maxVer >= pReader->sver) { + } else if (pReader->pSstBlk) { + while (pReader->pSstBlk) { + if (pReader->pSstBlk->minVer <= pReader->ever && pReader->pSstBlk->maxVer >= pReader->sver) { // load data (todo) } // next pReader->iBlockL++; - if (pReader->iBlockL < taosArrayGetSize(pReader->aBlockL)) { - pReader->pBlockL = (SBlockL*)taosArrayGetSize(pReader->aBlockL); + if (pReader->iBlockL < taosArrayGetSize(pReader->aSstBlk)) { + pReader->pSstBlk = (SSstBlk*)taosArrayGetSize(pReader->aSstBlk); } else { - pReader->pBlockL = NULL; + pReader->pSstBlk = NULL; } if (*ppData) goto _exit; @@ -298,8 +298,8 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - pReader->aBlockL = taosArrayInit(0, sizeof(SBlockL)); - if (pReader->aBlockL == NULL) { + pReader->aSstBlk = taosArrayInit(0, sizeof(SSstBlk)); + if (pReader->aSstBlk == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -338,7 +338,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) { if (pReader->pDataFReader) { tsdbDataFReaderClose(&pReader->pDataFReader); } - taosArrayDestroy(pReader->aBlockL); + taosArrayDestroy(pReader->aSstBlk); taosArrayDestroy(pReader->aBlockIdx); tMapDataClear(&pReader->mBlock); tBlockDataDestroy(&pReader->oBlockData, 1); @@ -426,24 +426,24 @@ struct STsdbSnapWriter { SArray* aBlockIdx; // SArray int32_t iBlockIdx; SBlockIdx* pBlockIdx; - SMapData mBlock; // SMapData + SMapData mBlock; // SMapData int32_t iBlock; SBlockData* pBlockData; int32_t iRow; SBlockData bDataR; - SArray* aBlockL; // SArray + SArray* aSstBlk; // SArray int32_t iBlockL; SBlockData lDataR; SDataFWriter* pDataFWriter; SBlockIdx* pBlockIdxW; // NULL when no committing table - SBlock blockW; + SDataBlk blockW; SBlockData bDataW; SBlockIdx blockIdxW; - SMapData mBlockW; // SMapData + SMapData mBlockW; // SMapData SArray* aBlockIdxW; // SArray - SArray* aBlockLW; // SArray + SArray* aBlockLW; // SArray // for del file SDelFReader* pDelFReader; @@ -475,10 +475,10 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) { // &pWriter->blockW, pWriter->cmprAlg); if (code) goto _err; - code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutDataBlk); if (code) goto _err; - tBlockReset(&pWriter->blockW); + tDataBlkReset(&pWriter->blockW); tBlockDataClear(&pWriter->bDataW); } @@ -499,15 +499,15 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) { // &pWriter->blockW, pWriter->cmprAlg); // if (code) goto _err; - code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutDataBlk); if (code) goto _err; } while (true) { if (pWriter->iBlock >= pWriter->mBlock.nItem) break; - SBlock block; - tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetBlock); + SDataBlk block; + tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetDataBlk); // if (block.last) { // code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, &pWriter->bDataR, NULL, NULL); @@ -520,13 +520,13 @@ static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) { // if (code) goto _err; // } - code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutDataBlk); if (code) goto _err; pWriter->iBlock++; } - // SBlock + // SDataBlk // code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, NULL, pWriter->pBlockIdxW); // if (code) goto _err; @@ -553,10 +553,10 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p if (code) goto _err; // SBlockData - SBlock block; + SDataBlk block; tMapDataReset(&pWriter->mBlockW); for (int32_t iBlock = 0; iBlock < pWriter->mBlock.nItem; iBlock++) { - tMapDataGetItemByIdx(&pWriter->mBlock, iBlock, &block, tGetBlock); + tMapDataGetItemByIdx(&pWriter->mBlock, iBlock, &block, tGetDataBlk); // if (block.last) { // code = tsdbReadBlockData(pWriter->pDataFReader, pBlockIdx, &block, &pWriter->bDataR, NULL, NULL); @@ -570,11 +570,11 @@ static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* p // if (code) goto _err; // } - code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutDataBlk); if (code) goto _err; } - // SBlock + // SDataBlk SBlockIdx blockIdx = {.suid = pBlockIdx->suid, .uid = pBlockIdx->uid}; code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, &blockIdx); if (code) goto _err; @@ -642,10 +642,10 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { while (true) { if (pWriter->iBlock >= pWriter->mBlock.nItem) break; - SBlock block; - int32_t c; + SDataBlk block; + int32_t c; - tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetBlock); + tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetDataBlk); // if (block.last) { // pWriter->pBlockData = &pWriter->bDataR; @@ -668,14 +668,14 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { // &pWriter->blockW, pWriter->cmprAlg); // if (code) goto _err; - code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutDataBlk); if (code) goto _err; - tBlockReset(&pWriter->blockW); + tDataBlkReset(&pWriter->blockW); tBlockDataClear(&pWriter->bDataW); } - code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutDataBlk); if (code) goto _err; pWriter->iBlock++; @@ -719,10 +719,10 @@ static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) { // &pWriter->blockW, pWriter->cmprAlg); // if (code) goto _err; - code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock); + code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutDataBlk); if (code) goto _err; - tBlockReset(&pWriter->blockW); + tDataBlkReset(&pWriter->blockW); tBlockDataClear(&pWriter->bDataW); } @@ -803,7 +803,7 @@ static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) { pWriter->pBlockIdxW->suid = id.suid; pWriter->pBlockIdxW->uid = id.uid; - tBlockReset(&pWriter->blockW); + tDataBlkReset(&pWriter->blockW); tBlockDataReset(&pWriter->bDataW); tMapDataReset(&pWriter->mBlockW); } @@ -845,7 +845,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) { // write remain stuff if (taosArrayGetSize(pWriter->aBlockLW) > 0) { - code = tsdbWriteBlockL(pWriter->pDataFWriter, pWriter->aBlockIdxW); + code = tsdbWriteSstBlk(pWriter->pDataFWriter, pWriter->aBlockIdxW); if (code) goto _err; } @@ -911,12 +911,12 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx); if (code) goto _err; - code = tsdbReadBlockL(pWriter->pDataFReader, pWriter->aBlockL); + code = tsdbReadSstBlk(pWriter->pDataFReader, 0, pWriter->aSstBlk); if (code) goto _err; } else { ASSERT(pWriter->pDataFReader == NULL); taosArrayClear(pWriter->aBlockIdx); - taosArrayClear(pWriter->aBlockL); + taosArrayClear(pWriter->aSstBlk); } pWriter->iBlockIdx = 0; pWriter->pBlockIdx = NULL; @@ -931,23 +931,25 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3 // write SHeadFile fHead; SDataFile fData; - SLastFile fLast; + SSstFile fLast; SSmaFile fSma; - SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma}; + SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .aSstF[0] = &fLast, .pSmaF = &fSma}; if (pSet) { wSet.diskId = pSet->diskId; wSet.fid = fid; + wSet.nSstF = 1; fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0}; fData = *pSet->pDataF; - fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0}; + fLast = (SSstFile){.commitID = pWriter->commitID, .size = 0}; fSma = *pSet->pSmaF; } else { wSet.diskId = (SDiskID){.level = 0, .id = 0}; wSet.fid = fid; + wSet.nSstF = 1; fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0}; fData = (SDataFile){.commitID = pWriter->commitID, .size = 0}; - fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0, .offset = 0}; + fLast = (SSstFile){.commitID = pWriter->commitID, .size = 0, .offset = 0}; fSma = (SSmaFile){.commitID = pWriter->commitID, .size = 0}; } @@ -1145,8 +1147,8 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr code = tBlockDataCreate(&pWriter->bDataR); if (code) goto _err; - pWriter->aBlockL = taosArrayInit(0, sizeof(SBlockL)); - if (pWriter->aBlockL == NULL) { + pWriter->aSstBlk = taosArrayInit(0, sizeof(SSstBlk)); + if (pWriter->aSstBlk == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -1159,7 +1161,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr code = tBlockDataCreate(&pWriter->bDataW); if (code) goto _err; - pWriter->aBlockLW = taosArrayInit(0, sizeof(SBlockL)); + pWriter->aBlockLW = taosArrayInit(0, sizeof(SSstBlk)); if (pWriter->aBlockLW == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 6db9d5e6f40c5d35e52d90dd86b28f4cb7a94676..6937a27fe4bffaf4e7ecd29c4fc29320d8e46d40 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -51,6 +51,22 @@ _exit: return code; } +int32_t tMapDataCopy(SMapData *pFrom, SMapData *pTo) { + int32_t code = 0; + + pTo->nItem = pFrom->nItem; + pTo->nData = pFrom->nData; + code = tRealloc((uint8_t **)&pTo->aOffset, sizeof(int32_t) * pFrom->nItem); + if (code) goto _exit; + code = tRealloc(&pTo->pData, pFrom->nData); + if (code) goto _exit; + memcpy(pTo->aOffset, pFrom->aOffset, sizeof(int32_t) * pFrom->nItem); + memcpy(pTo->pData, pFrom->pData, pFrom->nData); + +_exit: + return code; +} + int32_t tMapDataSearch(SMapData *pMapData, void *pSearchItem, int32_t (*tGetItemFn)(uint8_t *, void *), int32_t (*tItemCmprFn)(const void *, const void *), void *pItem) { int32_t code = 0; @@ -198,7 +214,7 @@ int32_t tCmprBlockIdx(void const *lhs, void const *rhs) { int32_t tCmprBlockL(void const *lhs, void const *rhs) { SBlockIdx *lBlockIdx = (SBlockIdx *)lhs; - SBlockL *rBlockL = (SBlockL *)rhs; + SSstBlk *rBlockL = (SSstBlk *)rhs; if (lBlockIdx->suid < rBlockL->suid) { return -1; @@ -215,69 +231,69 @@ int32_t tCmprBlockL(void const *lhs, void const *rhs) { return 0; } -// SBlock ====================================================== -void tBlockReset(SBlock *pBlock) { - *pBlock = (SBlock){.minKey = TSDBKEY_MAX, .maxKey = TSDBKEY_MIN, .minVer = VERSION_MAX, .maxVer = VERSION_MIN}; +// SDataBlk ====================================================== +void tDataBlkReset(SDataBlk *pDataBlk) { + *pDataBlk = (SDataBlk){.minKey = TSDBKEY_MAX, .maxKey = TSDBKEY_MIN, .minVer = VERSION_MAX, .maxVer = VERSION_MIN}; } -int32_t tPutBlock(uint8_t *p, void *ph) { - int32_t n = 0; - SBlock *pBlock = (SBlock *)ph; - - n += tPutI64v(p ? p + n : p, pBlock->minKey.version); - n += tPutI64v(p ? p + n : p, pBlock->minKey.ts); - n += tPutI64v(p ? p + n : p, pBlock->maxKey.version); - n += tPutI64v(p ? p + n : p, pBlock->maxKey.ts); - n += tPutI64v(p ? p + n : p, pBlock->minVer); - n += tPutI64v(p ? p + n : p, pBlock->maxVer); - n += tPutI32v(p ? p + n : p, pBlock->nRow); - n += tPutI8(p ? p + n : p, pBlock->hasDup); - n += tPutI8(p ? p + n : p, pBlock->nSubBlock); - for (int8_t iSubBlock = 0; iSubBlock < pBlock->nSubBlock; iSubBlock++) { - n += tPutI64v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].offset); - n += tPutI32v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].szBlock); - n += tPutI32v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].szKey); - } - if (pBlock->nSubBlock == 1 && !pBlock->hasDup) { - n += tPutI64v(p ? p + n : p, pBlock->smaInfo.offset); - n += tPutI32v(p ? p + n : p, pBlock->smaInfo.size); +int32_t tPutDataBlk(uint8_t *p, void *ph) { + int32_t n = 0; + SDataBlk *pDataBlk = (SDataBlk *)ph; + + n += tPutI64v(p ? p + n : p, pDataBlk->minKey.version); + n += tPutI64v(p ? p + n : p, pDataBlk->minKey.ts); + n += tPutI64v(p ? p + n : p, pDataBlk->maxKey.version); + n += tPutI64v(p ? p + n : p, pDataBlk->maxKey.ts); + n += tPutI64v(p ? p + n : p, pDataBlk->minVer); + n += tPutI64v(p ? p + n : p, pDataBlk->maxVer); + n += tPutI32v(p ? p + n : p, pDataBlk->nRow); + n += tPutI8(p ? p + n : p, pDataBlk->hasDup); + n += tPutI8(p ? p + n : p, pDataBlk->nSubBlock); + for (int8_t iSubBlock = 0; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) { + n += tPutI64v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].offset); + n += tPutI32v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].szBlock); + n += tPutI32v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].szKey); + } + if (pDataBlk->nSubBlock == 1 && !pDataBlk->hasDup) { + n += tPutI64v(p ? p + n : p, pDataBlk->smaInfo.offset); + n += tPutI32v(p ? p + n : p, pDataBlk->smaInfo.size); } return n; } -int32_t tGetBlock(uint8_t *p, void *ph) { - int32_t n = 0; - SBlock *pBlock = (SBlock *)ph; - - n += tGetI64v(p + n, &pBlock->minKey.version); - n += tGetI64v(p + n, &pBlock->minKey.ts); - n += tGetI64v(p + n, &pBlock->maxKey.version); - n += tGetI64v(p + n, &pBlock->maxKey.ts); - n += tGetI64v(p + n, &pBlock->minVer); - n += tGetI64v(p + n, &pBlock->maxVer); - n += tGetI32v(p + n, &pBlock->nRow); - n += tGetI8(p + n, &pBlock->hasDup); - n += tGetI8(p + n, &pBlock->nSubBlock); - for (int8_t iSubBlock = 0; iSubBlock < pBlock->nSubBlock; iSubBlock++) { - n += tGetI64v(p + n, &pBlock->aSubBlock[iSubBlock].offset); - n += tGetI32v(p + n, &pBlock->aSubBlock[iSubBlock].szBlock); - n += tGetI32v(p + n, &pBlock->aSubBlock[iSubBlock].szKey); - } - if (pBlock->nSubBlock == 1 && !pBlock->hasDup) { - n += tGetI64v(p + n, &pBlock->smaInfo.offset); - n += tGetI32v(p + n, &pBlock->smaInfo.size); +int32_t tGetDataBlk(uint8_t *p, void *ph) { + int32_t n = 0; + SDataBlk *pDataBlk = (SDataBlk *)ph; + + n += tGetI64v(p + n, &pDataBlk->minKey.version); + n += tGetI64v(p + n, &pDataBlk->minKey.ts); + n += tGetI64v(p + n, &pDataBlk->maxKey.version); + n += tGetI64v(p + n, &pDataBlk->maxKey.ts); + n += tGetI64v(p + n, &pDataBlk->minVer); + n += tGetI64v(p + n, &pDataBlk->maxVer); + n += tGetI32v(p + n, &pDataBlk->nRow); + n += tGetI8(p + n, &pDataBlk->hasDup); + n += tGetI8(p + n, &pDataBlk->nSubBlock); + for (int8_t iSubBlock = 0; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) { + n += tGetI64v(p + n, &pDataBlk->aSubBlock[iSubBlock].offset); + n += tGetI32v(p + n, &pDataBlk->aSubBlock[iSubBlock].szBlock); + n += tGetI32v(p + n, &pDataBlk->aSubBlock[iSubBlock].szKey); + } + if (pDataBlk->nSubBlock == 1 && !pDataBlk->hasDup) { + n += tGetI64v(p + n, &pDataBlk->smaInfo.offset); + n += tGetI32v(p + n, &pDataBlk->smaInfo.size); } else { - pBlock->smaInfo.offset = 0; - pBlock->smaInfo.size = 0; + pDataBlk->smaInfo.offset = 0; + pDataBlk->smaInfo.size = 0; } return n; } -int32_t tBlockCmprFn(const void *p1, const void *p2) { - SBlock *pBlock1 = (SBlock *)p1; - SBlock *pBlock2 = (SBlock *)p2; +int32_t tDataBlkCmprFn(const void *p1, const void *p2) { + SDataBlk *pBlock1 = (SDataBlk *)p1; + SDataBlk *pBlock2 = (SDataBlk *)p2; if (tsdbKeyCmprFn(&pBlock1->maxKey, &pBlock2->minKey) < 0) { return -1; @@ -288,48 +304,48 @@ int32_t tBlockCmprFn(const void *p1, const void *p2) { return 0; } -bool tBlockHasSma(SBlock *pBlock) { - if (pBlock->nSubBlock > 1) return false; - if (pBlock->hasDup) return false; +bool tDataBlkHasSma(SDataBlk *pDataBlk) { + if (pDataBlk->nSubBlock > 1) return false; + if (pDataBlk->hasDup) return false; - return pBlock->smaInfo.size > 0; + return pDataBlk->smaInfo.size > 0; } -// SBlockL ====================================================== -int32_t tPutBlockL(uint8_t *p, void *ph) { +// SSstBlk ====================================================== +int32_t tPutSstBlk(uint8_t *p, void *ph) { int32_t n = 0; - SBlockL *pBlockL = (SBlockL *)ph; - - n += tPutI64(p ? p + n : p, pBlockL->suid); - n += tPutI64(p ? p + n : p, pBlockL->minUid); - n += tPutI64(p ? p + n : p, pBlockL->maxUid); - n += tPutI64v(p ? p + n : p, pBlockL->minKey); - n += tPutI64v(p ? p + n : p, pBlockL->maxKey); - n += tPutI64v(p ? p + n : p, pBlockL->minVer); - n += tPutI64v(p ? p + n : p, pBlockL->maxVer); - n += tPutI32v(p ? p + n : p, pBlockL->nRow); - n += tPutI64v(p ? p + n : p, pBlockL->bInfo.offset); - n += tPutI32v(p ? p + n : p, pBlockL->bInfo.szBlock); - n += tPutI32v(p ? p + n : p, pBlockL->bInfo.szKey); + SSstBlk *pSstBlk = (SSstBlk *)ph; + + n += tPutI64(p ? p + n : p, pSstBlk->suid); + n += tPutI64(p ? p + n : p, pSstBlk->minUid); + n += tPutI64(p ? p + n : p, pSstBlk->maxUid); + n += tPutI64v(p ? p + n : p, pSstBlk->minKey); + n += tPutI64v(p ? p + n : p, pSstBlk->maxKey); + n += tPutI64v(p ? p + n : p, pSstBlk->minVer); + n += tPutI64v(p ? p + n : p, pSstBlk->maxVer); + n += tPutI32v(p ? p + n : p, pSstBlk->nRow); + n += tPutI64v(p ? p + n : p, pSstBlk->bInfo.offset); + n += tPutI32v(p ? p + n : p, pSstBlk->bInfo.szBlock); + n += tPutI32v(p ? p + n : p, pSstBlk->bInfo.szKey); return n; } -int32_t tGetBlockL(uint8_t *p, void *ph) { +int32_t tGetSstBlk(uint8_t *p, void *ph) { int32_t n = 0; - SBlockL *pBlockL = (SBlockL *)ph; - - n += tGetI64(p + n, &pBlockL->suid); - n += tGetI64(p + n, &pBlockL->minUid); - n += tGetI64(p + n, &pBlockL->maxUid); - n += tGetI64v(p + n, &pBlockL->minKey); - n += tGetI64v(p + n, &pBlockL->maxKey); - n += tGetI64v(p + n, &pBlockL->minVer); - n += tGetI64v(p + n, &pBlockL->maxVer); - n += tGetI32v(p + n, &pBlockL->nRow); - n += tGetI64v(p + n, &pBlockL->bInfo.offset); - n += tGetI32v(p + n, &pBlockL->bInfo.szBlock); - n += tGetI32v(p + n, &pBlockL->bInfo.szKey); + SSstBlk *pSstBlk = (SSstBlk *)ph; + + n += tGetI64(p + n, &pSstBlk->suid); + n += tGetI64(p + n, &pSstBlk->minUid); + n += tGetI64(p + n, &pSstBlk->maxUid); + n += tGetI64v(p + n, &pSstBlk->minKey); + n += tGetI64v(p + n, &pSstBlk->maxKey); + n += tGetI64v(p + n, &pSstBlk->minVer); + n += tGetI64v(p + n, &pSstBlk->maxVer); + n += tGetI32v(p + n, &pSstBlk->nRow); + n += tGetI64v(p + n, &pSstBlk->bInfo.offset); + n += tGetI32v(p + n, &pSstBlk->bInfo.szBlock); + n += tGetI32v(p + n, &pSstBlk->bInfo.szKey); return n; } @@ -1603,7 +1619,7 @@ _exit: int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uint8_t *aBuf[]) { int32_t code = 0; - tBlockDataClear(pBlockData); + tBlockDataReset(pBlockData); int32_t n = 0; SDiskDataHdr hdr = {0}; @@ -2039,7 +2055,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol size += pBlockCol->szOffset; // value - if (pColData->flag != (HAS_NULL | HAS_NONE)) { + if ((pColData->flag != (HAS_NULL | HAS_NONE)) && pColData->nData) { code = tsdbCmprData((uint8_t *)pColData->pData, pColData->nData, pColData->type, cmprAlg, ppOut, nOut + size, &pBlockCol->szValue, ppBuf); if (code) goto _exit; diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 580ab8bc93cac3a5057821f238cf85fc1011fa38..f379d9f71afdf62089fb3f864ff2d0ac376d6997 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -14,6 +14,7 @@ */ #include "vnd.h" +#include "tutil.h" const SVnodeCfg vnodeCfgDefault = {.vgId = -1, .dbname = "", @@ -106,9 +107,12 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "sstTrigger", pCfg->sstTrigger) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "hashPrefix", pCfg->hashPrefix) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "hashSuffix", pCfg->hashSuffix) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "syncCfg.myIndex", pCfg->syncCfg.myIndex) < 0) return -1; @@ -205,12 +209,18 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (code < 0) return -1; tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level, code); if (code < 0) return -1; + tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sstTrigger, code); + if (code < 0) return -1; tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin, code); if (code < 0) return -1; tjsonGetNumberValue(pJson, "hashEnd", pCfg->hashEnd, code); if (code < 0) return -1; tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod, code); if (code < 0) return -1; + tjsonGetNumberValue(pJson, "hashPrefix", pCfg->hashPrefix, code); + if (code < 0) return -1; + tjsonGetNumberValue(pJson, "hashSuffix", pCfg->hashSuffix, code); + if (code < 0) return -1; tjsonGetNumberValue(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum, code); if (code < 0) return -1; @@ -247,7 +257,8 @@ int vnodeValidateTableHash(SVnode *pVnode, char *tableFName) { switch (pVnode->config.hashMethod) { default: - hashValue = MurmurHash3_32(tableFName, strlen(tableFName)); + hashValue = taosGetTbHashVal(tableFName, strlen(tableFName), pVnode->config.hashMethod, pVnode->config.hashPrefix, + pVnode->config.hashSuffix); break; } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 8d799e919d1e4c06cfec6438d7a4a34fc336993d..8cfe1d8adfddb675856238501977fb9d9d8aee6e 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -368,6 +368,7 @@ _exit: int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->vgId = TD_VID(pVnode); pLoad->syncState = syncGetMyRole(pVnode->sync); + pLoad->cacheUsage = tsdbCacheGetUsage(pVnode); pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta); pLoad->totalStorage = (int64_t)3 * 1073741824; @@ -424,8 +425,8 @@ int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) { return TSDB_CODE_SUCCESS; } -int32_t vnodeGetStbIdList(SVnode* pVnode, int64_t suid, SArray* list) { - SMStbCursor* pCur = metaOpenStbCursor(pVnode->pMeta, suid); +int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) { + SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid); if (!pCur) { return TSDB_CODE_FAILED; } @@ -467,9 +468,13 @@ static int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) { STSchema *pTSchema = metaGetTbTSchema(pVnode->pMeta, suid, -1); // metaGetTbTSchemaEx(pVnode->pMeta, suid, suid, -1, &pTSchema); - *num = pTSchema->numOfCols; + if (pTSchema) { + *num = pTSchema->numOfCols; - taosMemoryFree(pTSchema); + taosMemoryFree(pTSchema); + } else { + *num = 2; + } return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 5a81f9191920ffac0ae055e140e7e59448dfd406..03ab5e828582c6598df81611a002fd0927e85ba6 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -39,7 +39,7 @@ struct SVSnapReader { SStreamStateReader *pStreamStateReader; // rsma int8_t rsmaDone; - SRsmaSnapReader *pRsmaReader; + SRSmaSnapReader *pRsmaReader; }; int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) { @@ -241,7 +241,7 @@ struct SVSnapWriter { SStreamTaskWriter *pStreamTaskWriter; SStreamStateWriter *pStreamStateWriter; // rsma - SRsmaSnapWriter *pRsmaSnapWriter; + SRSmaSnapWriter *pRsmaSnapWriter; }; int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 85feecff1a0247790eec14b503b7dda6247a6c87..2724d4cbfdbf2347def3ffae9ffc5295d6bb95d7 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -371,7 +371,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) { if (NULL == pMetaRsp) { return; } - + strcpy(pMetaRsp->dbFName, pVnode->config.dbname); pMetaRsp->dbId = pVnode->config.dbId; pMetaRsp->vgId = TD_VID(pVnode); @@ -496,6 +496,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; + memset(&cRsp, 0, sizeof(cRsp)); if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) { rcode = -1; @@ -526,7 +527,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR cRsp.code = TSDB_CODE_SUCCESS; tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); taosArrayPush(tbUids, &pCreateReq->uid); - vnodeUpdateMetaRsp(pVnode, cRsp.pMeta); + vnodeUpdateMetaRsp(pVnode, cRsp.pMeta); } taosArrayPush(rsp.pArray, &cRsp); @@ -1106,6 +1107,7 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq tDecoderInit(pCoder, pReq, len); tDecodeDeleteRes(pCoder, pRes); + ASSERT(taosArrayGetSize(pRes->uidList) == 0 || (pRes->skey != 0 && pRes->ekey != 0)); for (int32_t iUid = 0; iUid < taosArrayGetSize(pRes->uidList); iUid++) { code = tsdbDeleteTableData(pVnode->pTsdb, version, pRes->suid, *(uint64_t *)taosArrayGet(pRes->uidList, iUid), diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 7d259fe06c26bfdd82b595ba49d3fefb7a181598..18d839e1091e3fc5f1be2939a22345efe8ea8579 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -471,6 +471,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName); appendColumnFields(buf2, &len, pCfg); len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")"); + appendTableOptions(buf2, &len, pDbCfg, pCfg); } varDataLen(buf2) = len; diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 9e7fcc222788e16f60252727ba7ca7c911366e9b..0722c2b30653020af9972d3a8c4110a1941f240b 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -87,9 +87,7 @@ struct SqlFunctionCtx; size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); void initResultRowInfo(SResultRowInfo* pResultRowInfo); - -void initResultRow(SResultRow* pResultRow); -void closeResultRow(SResultRow* pResultRow); +void closeResultRow(SResultRow* pResultRow); struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 8878bdcc99361a15d77294274c177fb8ac4acd0e..93bb5b0b49b6e7b1f9df5aa9e483c80ef41cb139 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -38,11 +38,11 @@ extern "C" { #include "tlockfree.h" #include "tmsg.h" #include "tpagedbuf.h" -#include "tstreamUpdate.h" #include "tstream.h" +#include "tstreamUpdate.h" -#include "vnode.h" #include "executorInt.h" +#include "vnode.h" typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); @@ -139,20 +139,23 @@ enum { }; typedef struct { - //TODO remove prepareStatus - STqOffsetVal prepareStatus; // for tmq - STqOffsetVal lastStatus; // for tmq - SMqMetaRsp metaRsp; // for tmq fetching meta - SSchemaWrapper *schema; - char tbName[TSDB_TABLE_NAME_LEN]; - SSDataBlock* pullOverBlk; // for streaming - SWalFilterCond cond; - int64_t lastScanUid; - int8_t recoverStep; + // TODO remove prepareStatus + STqOffsetVal prepareStatus; // for tmq + STqOffsetVal lastStatus; // for tmq + SMqMetaRsp metaRsp; // for tmq fetching meta + int8_t returned; + int64_t snapshotVer; + + SSchemaWrapper* schema; + char tbName[TSDB_TABLE_NAME_LEN]; + SSDataBlock* pullOverBlk; // for streaming + SWalFilterCond cond; + int64_t lastScanUid; + int8_t recoverStep; SQueryTableDataCond tableCond; - int64_t recoverStartVer; - int64_t recoverEndVer; - SStreamState* pState; + int64_t recoverStartVer; + int64_t recoverEndVer; + SStreamState* pState; } SStreamTaskInfo; typedef struct { @@ -164,29 +167,29 @@ typedef struct { } SSchemaInfo; typedef struct SExecTaskInfo { - STaskIdInfo id; - uint32_t status; - STimeWindow window; - STaskCostInfo cost; - int64_t owner; // if it is in execution - int32_t code; - - int64_t version; // used for stream to record wal version - SStreamTaskInfo streamInfo; - SSchemaInfo schemaInfo; - STableListInfo tableqinfoList; // this is a table list - const char* sql; // query sql string - jmp_buf env; // jump to this position when error happens. - EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] - SSubplan* pSubplan; + STaskIdInfo id; + uint32_t status; + STimeWindow window; + STaskCostInfo cost; + int64_t owner; // if it is in execution + int32_t code; + + int64_t version; // used for stream to record wal version + SStreamTaskInfo streamInfo; + SSchemaInfo schemaInfo; + STableListInfo tableqinfoList; // this is a table list + const char* sql; // query sql string + jmp_buf env; // jump to this position when error happens. + EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] + SSubplan* pSubplan; struct SOperatorInfo* pRoot; } SExecTaskInfo; enum { - OP_NOT_OPENED = 0x0, - OP_OPENED = 0x1, + OP_NOT_OPENED = 0x0, + OP_OPENED = 0x1, OP_RES_TO_RETURN = 0x5, - OP_EXEC_DONE = 0x9, + OP_EXEC_DONE = 0x9, }; typedef struct SOperatorFpSet { @@ -225,7 +228,7 @@ typedef struct SOperatorInfo { typedef enum { EX_SOURCE_DATA_NOT_READY = 0x1, - EX_SOURCE_DATA_READY = 0x2, + EX_SOURCE_DATA_READY = 0x2, EX_SOURCE_DATA_EXHAUSTED = 0x3, } EX_SOURCE_STATUS; @@ -248,26 +251,26 @@ typedef struct SLoadRemoteDataInfo { } SLoadRemoteDataInfo; typedef struct SLimitInfo { - SLimit limit; - SLimit slimit; - uint64_t currentGroupId; - int64_t remainGroupOffset; - int64_t numOfOutputGroups; - int64_t remainOffset; - int64_t numOfOutputRows; + SLimit limit; + SLimit slimit; + uint64_t currentGroupId; + int64_t remainGroupOffset; + int64_t numOfOutputGroups; + int64_t remainOffset; + int64_t numOfOutputRows; } SLimitInfo; typedef struct SExchangeInfo { - SArray* pSources; - SArray* pSourceDataInfo; - tsem_t ready; - void* pTransporter; + SArray* pSources; + SArray* pSourceDataInfo; + tsem_t ready; + void* pTransporter; // SArray, result block list, used to keep the multi-block that // passed by downstream operator SArray* pResultBlockList; - int32_t rspBlockIndex; // indicate the return block index in pResultBlockList - SSDataBlock* pDummyBlock; // dummy block, not keep data - bool seqLoadData; // sequential load data or not, false by default + int32_t rspBlockIndex; // indicate the return block index in pResultBlockList + SSDataBlock* pDummyBlock; // dummy block, not keep data + bool seqLoadData; // sequential load data or not, false by default int32_t current; SLoadRemoteDataInfo loadInfo; uint64_t self; @@ -275,22 +278,22 @@ typedef struct SExchangeInfo { } SExchangeInfo; typedef struct SColMatchInfo { - int32_t srcSlotId; // source slot id + int32_t srcSlotId; // source slot id int32_t colId; int32_t targetSlotId; - bool output; // todo remove this? + bool output; // todo remove this? bool reserved; - int32_t matchType; // determinate the source according to col id or slot id + int32_t matchType; // determinate the source according to col id or slot id } SColMatchInfo; typedef struct SScanInfo { - int32_t numOfAsc; - int32_t numOfDesc; + int32_t numOfAsc; + int32_t numOfDesc; } SScanInfo; typedef struct SSampleExecInfo { - double sampleRatio; // data block sample ratio, 1 by default - uint32_t seed; // random seed value + double sampleRatio; // data block sample ratio, 1 by default + uint32_t seed; // random seed value } SSampleExecInfo; enum { @@ -302,39 +305,40 @@ typedef struct SAggSupporter { SSHashObj* pResultRowHashTable; // quick locate the window object for each result char* keyBuf; // window key buffer SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file - int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row - int32_t currentPageId; // current write page id + int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row + int32_t currentPageId; // current write page id } SAggSupporter; typedef struct { - // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded. - SInterval interval; - SAggSupporter *pAggSup; - SExprSupp *pExprSup; // expr supporter of aggregate operator + // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if + // current data block needs to be loaded. + SInterval interval; + SAggSupporter* pAggSup; + SExprSupp* pExprSup; // expr supporter of aggregate operator } SAggOptrPushDownInfo; typedef struct STableScanInfo { - STsdbReader* dataReader; - SReadHandle readHandle; + STsdbReader* dataReader; + SReadHandle readHandle; SFileBlockLoadRecorder readRecorder; - SScanInfo scanInfo; - int32_t scanTimes; - SNode* pFilterNode; // filter info, which is push down by optimizer + SScanInfo scanInfo; + int32_t scanTimes; + SNode* pFilterNode; // filter info, which is push down by optimizer - SSDataBlock* pResBlock; - SArray* pColMatchInfo; - SExprSupp pseudoSup; - SQueryTableDataCond cond; - int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan - int32_t dataBlockLoadFlag; - SSampleExecInfo sample; // sample execution info - int32_t currentGroupId; - int32_t currentTable; - int8_t scanMode; - int8_t noTable; + SSDataBlock* pResBlock; + SArray* pColMatchInfo; + SExprSupp pseudoSup; + SQueryTableDataCond cond; + int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan + int32_t dataBlockLoadFlag; + SSampleExecInfo sample; // sample execution info + int32_t currentGroupId; + int32_t currentTable; + int8_t scanMode; + int8_t noTable; SAggOptrPushDownInfo pdInfo; - int8_t assignBlockUid; + int8_t assignBlockUid; } STableScanInfo; typedef struct STableMergeScanInfo { @@ -367,7 +371,7 @@ typedef struct STableMergeScanInfo { SArray* pColMatchInfo; int32_t numOfOutput; - SExprSupp pseudoSup; + SExprSupp pseudoSup; SQueryTableDataCond cond; int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan @@ -381,32 +385,33 @@ typedef struct STableMergeScanInfo { } STableMergeScanInfo; typedef struct STagScanInfo { - SColumnInfo *pCols; - SSDataBlock *pRes; - SArray *pColMatchInfo; - int32_t curPos; - SReadHandle readHandle; - STableListInfo *pTableList; + SColumnInfo* pCols; + SSDataBlock* pRes; + SArray* pColMatchInfo; + int32_t curPos; + SReadHandle readHandle; + STableListInfo* pTableList; } STagScanInfo; typedef struct SLastrowScanInfo { - SSDataBlock *pRes; - SReadHandle readHandle; - void *pLastrowReader; - SArray *pColMatchInfo; - int32_t *pSlotIds; - SExprSupp pseudoExprSup; - int32_t retrieveType; - int32_t currentGroupIndex; - SSDataBlock *pBufferredRes; - SArray *pUidList; - int32_t indexOfBufferedRes; + SSDataBlock* pRes; + SReadHandle readHandle; + void* pLastrowReader; + SArray* pColMatchInfo; + int32_t* pSlotIds; + SExprSupp pseudoExprSup; + int32_t retrieveType; + int32_t currentGroupIndex; + SSDataBlock* pBufferredRes; + SArray* pUidList; + int32_t indexOfBufferedRes; } SLastrowScanInfo; typedef enum EStreamScanMode { STREAM_SCAN_FROM_READERHANDLE = 1, STREAM_SCAN_FROM_RES, STREAM_SCAN_FROM_UPDATERES, + STREAM_SCAN_FROM_DELETERES, STREAM_SCAN_FROM_DATAREADER_RETRIEVE, STREAM_SCAN_FROM_DATAREADER_RANGE, } EStreamScanMode; @@ -428,25 +433,37 @@ typedef struct SStreamAggSupporter { SArray* pCurWins; int32_t valueSize; int32_t keySize; - char* pKeyBuf; // window key buffer - SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file - int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row - int32_t currentPageId; // buffer page that is active + char* pKeyBuf; // window key buffer + SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file + int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row + int32_t currentPageId; // buffer page that is active SSDataBlock* pScanBlock; } SStreamAggSupporter; -typedef struct SessionWindowSupporter { +typedef struct SWindowSupporter { SStreamAggSupporter* pStreamAggSup; int64_t gap; uint16_t parentType; SAggSupporter* pIntervalAggSup; -} SessionWindowSupporter; +} SWindowSupporter; + +typedef struct SPartitionBySupporter { + SArray* pGroupCols; // group by columns, SArray + SArray* pGroupColVals; // current group column values, SArray + char* keyBuf; // group by keys for hash + bool needCalc; // partition by column +} SPartitionBySupporter; + +typedef struct SPartitionDataInfo { + uint64_t groupId; + SArray* rowIds; +} SPartitionDataInfo; typedef struct STimeWindowSupp { - int8_t calTrigger; - int64_t waterMark; - TSKEY maxTs; - SColumnInfoData timeWindowData; // query time window info for scalar function execution. + int8_t calTrigger; + int64_t waterMark; + TSKEY maxTs; + SColumnInfoData timeWindowData; // query time window info for scalar function execution. } STimeWindowAggSupp; typedef struct SStreamScanInfo { @@ -471,39 +488,40 @@ typedef struct SStreamScanInfo { uint64_t groupId; SUpdateInfo* pUpdateInfo; - EStreamScanMode scanMode; - SOperatorInfo* pStreamScanOp; - SOperatorInfo* pTableScanOp; - SArray* childIds; - SessionWindowSupporter sessionSup; - bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA. - int32_t scanWinIndex; // for state operator - int32_t pullDataResIndex; - SSDataBlock* pPullDataRes; // pull data SSDataBlock - SSDataBlock* pDeleteDataRes; // delete data SSDataBlock - int32_t deleteDataIndex; - STimeWindow updateWin; - STimeWindowAggSupp twAggSup; - SSDataBlock* pUpdateDataRes; + EStreamScanMode scanMode; + SOperatorInfo* pStreamScanOp; + SOperatorInfo* pTableScanOp; + SArray* childIds; + SWindowSupporter windowSup; + SPartitionBySupporter partitionSup; + SExprSupp* pPartScalarSup; + bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA. + int32_t scanWinIndex; // for state operator + int32_t pullDataResIndex; + SSDataBlock* pPullDataRes; // pull data SSDataBlock + SSDataBlock* pDeleteDataRes; // delete data SSDataBlock + int32_t deleteDataIndex; + STimeWindow updateWin; + STimeWindowAggSupp twAggSup; + SSDataBlock* pUpdateDataRes; // status for tmq - // SSchemaWrapper schema; - SNodeList* pGroupTags; - SNode* pTagCond; - SNode* pTagIndexCond; + SNodeList* pGroupTags; + SNode* pTagCond; + SNode* pTagIndexCond; } SStreamScanInfo; -typedef struct SStreamRawScanInfo{ -// int8_t subType; -// bool withMeta; -// int64_t suid; -// int64_t snapVersion; -// void *metaInfo; -// void *dataInfo; - SVnode* vnode; - SSDataBlock pRes; // result SSDataBlock - STsdbReader* dataReader; - SSnapContext* sContext; -}SStreamRawScanInfo; +typedef struct { + // int8_t subType; + // bool withMeta; + // int64_t suid; + // int64_t snapVersion; + // void *metaInfo; + // void *dataInfo; + SVnode* vnode; + SSDataBlock pRes; // result SSDataBlock + STsdbReader* dataReader; + SSnapContext* sContext; +} SStreamRawScanInfo; typedef struct SSysTableScanInfo { SRetrieveMetaTableRsp* pRsp; @@ -528,14 +546,14 @@ typedef struct SBlockDistInfo { SSDataBlock* pResBlock; void* pHandle; SReadHandle readHandle; - uint64_t uid; // table uid + uint64_t uid; // table uid } SBlockDistInfo; // todo remove this typedef struct SOptrBasicInfo { - SResultRowInfo resultRowInfo; - SSDataBlock* pRes; - bool mergeResultBlock; + SResultRowInfo resultRowInfo; + SSDataBlock* pRes; + bool mergeResultBlock; } SOptrBasicInfo; typedef struct SIntervalAggOperatorInfo { @@ -554,17 +572,17 @@ typedef struct SIntervalAggOperatorInfo { EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] STimeWindowAggSupp twAggSup; bool invertible; - SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation. + SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation. bool ignoreExpiredData; SArray* pRecycledPages; - SArray* pDelWins; // SWinRes + SArray* pDelWins; // SWinRes int32_t delIndex; SSDataBlock* pDelRes; SNode* pCondition; } SIntervalAggOperatorInfo; typedef struct SMergeAlignedIntervalAggOperatorInfo { - SIntervalAggOperatorInfo *intervalAggOperatorInfo; + SIntervalAggOperatorInfo* intervalAggOperatorInfo; bool hasGroupId; uint64_t groupId; // current groupId @@ -575,63 +593,63 @@ typedef struct SMergeAlignedIntervalAggOperatorInfo { typedef struct SStreamFinalIntervalOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; // basic info - SAggSupporter aggSup; // aggregate supporter - SExprSupp scalarSupp; // supporter for perform scalar function - SGroupResInfo groupResInfo; // multiple results build supporter - SInterval interval; // interval info - int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. - int32_t order; // current SSDataBlock scan order + SOptrBasicInfo binfo; // basic info + SAggSupporter aggSup; // aggregate supporter + SExprSupp scalarSupp; // supporter for perform scalar function + SGroupResInfo groupResInfo; // multiple results build supporter + SInterval interval; // interval info + int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. + int32_t order; // current SSDataBlock scan order STimeWindowAggSupp twAggSup; SArray* pChildren; SSDataBlock* pUpdateRes; bool returnUpdate; - SPhysiNode* pPhyNode; // create new child + SPhysiNode* pPhyNode; // create new child bool isFinal; SHashObj* pPullDataMap; - SArray* pPullWins; // SPullWindowInfo + SArray* pPullWins; // SPullWindowInfo int32_t pullIndex; SSDataBlock* pPullDataRes; bool ignoreExpiredData; SArray* pRecycledPages; - SArray* pDelWins; // SWinRes + SArray* pDelWins; // SWinRes int32_t delIndex; SSDataBlock* pDelRes; } SStreamFinalIntervalOperatorInfo; typedef struct SAggOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; + SOptrBasicInfo binfo; + SAggSupporter aggSup; - STableQueryInfo *current; - uint64_t groupId; - SGroupResInfo groupResInfo; - SExprSupp scalarExprSup; - SNode *pCondition; + STableQueryInfo* current; + uint64_t groupId; + SGroupResInfo groupResInfo; + SExprSupp scalarExprSup; + SNode* pCondition; } SAggOperatorInfo; typedef struct SProjectOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; - SNode* pFilterNode; // filter info, which is push down by optimizer - SArray* pPseudoColInfo; - SLimitInfo limitInfo; - bool mergeDataBlocks; - SSDataBlock* pFinalRes; - SNode* pCondition; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + SNode* pFilterNode; // filter info, which is push down by optimizer + SArray* pPseudoColInfo; + SLimitInfo limitInfo; + bool mergeDataBlocks; + SSDataBlock* pFinalRes; + SNode* pCondition; } SProjectOperatorInfo; typedef struct SIndefOperatorInfo { - SOptrBasicInfo binfo; - SAggSupporter aggSup; - SArray* pPseudoColInfo; - SExprSupp scalarSup; - SNode* pCondition; - uint64_t groupId; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + SArray* pPseudoColInfo; + SExprSupp scalarSup; + SNode* pCondition; + uint64_t groupId; - SSDataBlock* pNextGroupRes; + SSDataBlock* pNextGroupRes; } SIndefOperatorInfo; typedef struct SFillOperatorInfo { @@ -646,7 +664,7 @@ typedef struct SFillOperatorInfo { SArray* pColMatchColInfo; int32_t primaryTsCol; int32_t primarySrcSlotId; - uint64_t curGroupId; // current handled group id + uint64_t curGroupId; // current handled group id SExprInfo* pExprInfo; int32_t numOfExpr; SExprInfo* pNotFillExprInfo; @@ -655,23 +673,23 @@ typedef struct SFillOperatorInfo { typedef struct SGroupbyOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; - - SArray* pGroupCols; // group by columns, SArray - SArray* pGroupColVals; // current group column values, SArray - SNode* pCondition; - bool isInit; // denote if current val is initialized or not - char* keyBuf; // group by keys for hash - int32_t groupKeyLen; // total group by column width - SGroupResInfo groupResInfo; - SExprSupp scalarSup; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + + SArray* pGroupCols; // group by columns, SArray + SArray* pGroupColVals; // current group column values, SArray + SNode* pCondition; + bool isInit; // denote if current val is initialized or not + char* keyBuf; // group by keys for hash + int32_t groupKeyLen; // total group by column width + SGroupResInfo groupResInfo; + SExprSupp scalarSup; } SGroupbyOperatorInfo; typedef struct SDataGroupInfo { - uint64_t groupId; - int64_t numOfRows; - SArray* pPageList; + uint64_t groupId; + int64_t numOfRows; + SArray* pPageList; } SDataGroupInfo; // The sort in partition may be needed later. @@ -683,13 +701,12 @@ typedef struct SPartitionOperatorInfo { int32_t groupKeyLen; // total group by column width SHashObj* pGroupSet; // quick locate the window object for each result - SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file - int32_t rowCapacity; // maximum number of rows for each buffer page - int32_t* columnOffset; // start position for each column data - SArray* sortedGroupArray; // SDataGroupInfo sorted by group id - int32_t groupIndex; // group index - int32_t pageIndex; // page index of current group - SSDataBlock* pUpdateRes; + SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file + int32_t rowCapacity; // maximum number of rows for each buffer page + int32_t* columnOffset; // start position for each column data + SArray* sortedGroupArray; // SDataGroupInfo sorted by group id + int32_t groupIndex; // group index + int32_t pageIndex; // page index of current group SExprSupp scalarSup; } SPartitionOperatorInfo; @@ -703,75 +720,85 @@ typedef struct SWindowRowsSup { typedef struct SSessionAggOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; + SOptrBasicInfo binfo; + SAggSupporter aggSup; SGroupResInfo groupResInfo; SWindowRowsSup winSup; - bool reptScan; // next round scan - int64_t gap; // session window gap - int32_t tsSlotId; // primary timestamp slot id + bool reptScan; // next round scan + int64_t gap; // session window gap + int32_t tsSlotId; // primary timestamp slot id STimeWindowAggSupp twAggSup; - const SNode* pCondition; + const SNode* pCondition; } SSessionAggOperatorInfo; typedef struct SResultWindowInfo { SResultRowPosition pos; - STimeWindow win; - uint64_t groupId; - bool isOutput; - bool isClosed; + STimeWindow win; + uint64_t groupId; + bool isOutput; + bool isClosed; } SResultWindowInfo; typedef struct SStateWindowInfo { SResultWindowInfo winInfo; - SStateKeys stateKey; + SStateKeys stateKey; } SStateWindowInfo; typedef struct SStreamSessionAggOperatorInfo { - SOptrBasicInfo binfo; - SStreamAggSupporter streamAggSup; - SExprSupp scalarSupp; // supporter for perform scalar function - SGroupResInfo groupResInfo; - int64_t gap; // session window gap - int32_t primaryTsIndex; // primary timestamp slot id - int32_t endTsIndex; // window end timestamp slot id - int32_t order; // current SSDataBlock scan order - STimeWindowAggSupp twAggSup; - SSDataBlock* pWinBlock; // window result - SqlFunctionCtx* pDummyCtx; // for combine - SSDataBlock* pDelRes; // delete result - bool returnDelete; - SSDataBlock* pUpdateRes; // update window - SHashObj* pStDeleted; - void* pDelIterator; - SArray* pChildren; // cache for children's result; final stream operator - SPhysiNode* pPhyNode; // create new child - bool isFinal; - bool ignoreExpiredData; + SOptrBasicInfo binfo; + SStreamAggSupporter streamAggSup; + SExprSupp scalarSupp; // supporter for perform scalar function + SGroupResInfo groupResInfo; + int64_t gap; // session window gap + int32_t primaryTsIndex; // primary timestamp slot id + int32_t endTsIndex; // window end timestamp slot id + int32_t order; // current SSDataBlock scan order + STimeWindowAggSupp twAggSup; + SSDataBlock* pWinBlock; // window result + SqlFunctionCtx* pDummyCtx; // for combine + SSDataBlock* pDelRes; // delete result + SSDataBlock* pUpdateRes; // update window + bool returnUpdate; + SHashObj* pStDeleted; + void* pDelIterator; + SArray* pChildren; // cache for children's result; final stream operator + SPhysiNode* pPhyNode; // create new child + bool isFinal; + bool ignoreExpiredData; } SStreamSessionAggOperatorInfo; +typedef struct SStreamPartitionOperatorInfo { + SOptrBasicInfo binfo; + SPartitionBySupporter partitionSup; + SExprSupp scalarSup; + SHashObj* pPartitions; + void* parIte; + SSDataBlock* pInputDataBlock; + int32_t tsColIndex; +} SStreamPartitionOperatorInfo; + typedef struct STimeSliceOperatorInfo { - SSDataBlock* pRes; - STimeWindow win; - SInterval interval; - int64_t current; - SArray* pPrevRow; // SArray - SArray* pNextRow; // SArray - SArray* pLinearInfo; // SArray - bool fillLastPoint; - bool isPrevRowSet; - bool isNextRowSet; - int32_t fillType; // fill type - SColumn tsCol; // primary timestamp column - SExprSupp scalarSup; // scalar calculation - struct SFillColInfo* pFillColInfo; // fill column info + SSDataBlock* pRes; + STimeWindow win; + SInterval interval; + int64_t current; + SArray* pPrevRow; // SArray + SArray* pNextRow; // SArray + SArray* pLinearInfo; // SArray + bool fillLastPoint; + bool isPrevRowSet; + bool isNextRowSet; + int32_t fillType; // fill type + SColumn tsCol; // primary timestamp column + SExprSupp scalarSup; // scalar calculation + struct SFillColInfo* pFillColInfo; // fill column info } STimeSliceOperatorInfo; typedef struct SStateWindowOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; + SOptrBasicInfo binfo; + SAggSupporter aggSup; SGroupResInfo groupResInfo; SWindowRowsSup winSup; @@ -785,52 +812,52 @@ typedef struct SStateWindowOperatorInfo { } SStateWindowOperatorInfo; typedef struct SStreamStateAggOperatorInfo { - SOptrBasicInfo binfo; - SStreamAggSupporter streamAggSup; - SExprSupp scalarSupp; // supporter for perform scalar function - SGroupResInfo groupResInfo; - int32_t primaryTsIndex; // primary timestamp slot id - int32_t order; // current SSDataBlock scan order - STimeWindowAggSupp twAggSup; - SColumn stateCol; - SqlFunctionCtx* pDummyCtx; // for combine - SSDataBlock* pDelRes; - SHashObj* pSeDeleted; - void* pDelIterator; - SArray* pChildren; // cache for children's result; - bool ignoreExpiredData; + SOptrBasicInfo binfo; + SStreamAggSupporter streamAggSup; + SExprSupp scalarSupp; // supporter for perform scalar function + SGroupResInfo groupResInfo; + int32_t primaryTsIndex; // primary timestamp slot id + int32_t order; // current SSDataBlock scan order + STimeWindowAggSupp twAggSup; + SColumn stateCol; + SqlFunctionCtx* pDummyCtx; // for combine + SSDataBlock* pDelRes; + SHashObj* pSeDeleted; + void* pDelIterator; + SArray* pChildren; // cache for children's result; + bool ignoreExpiredData; } SStreamStateAggOperatorInfo; typedef struct SSortedMergeOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode - SOptrBasicInfo binfo; - SAggSupporter aggSup; - - SArray* pSortInfo; - int32_t numOfSources; - SSortHandle *pSortHandle; - int32_t bufPageSize; - uint32_t sortBufSize; // max buffer size for in-memory sort - int32_t resultRowFactor; - bool hasGroupVal; - SDiskbasedBuf *pTupleStore; // keep the final results - int32_t numOfResPerPage; - char** groupVal; - SArray *groupInfo; + SOptrBasicInfo binfo; + SAggSupporter aggSup; + + SArray* pSortInfo; + int32_t numOfSources; + SSortHandle* pSortHandle; + int32_t bufPageSize; + uint32_t sortBufSize; // max buffer size for in-memory sort + int32_t resultRowFactor; + bool hasGroupVal; + SDiskbasedBuf* pTupleStore; // keep the final results + int32_t numOfResPerPage; + char** groupVal; + SArray* groupInfo; } SSortedMergeOperatorInfo; typedef struct SSortOperatorInfo { SOptrBasicInfo binfo; - uint32_t sortBufSize; // max buffer size for in-memory sort - SArray* pSortInfo; - SSortHandle* pSortHandle; - SArray* pColMatchInfo; // for index map from table scan output - int32_t bufPageSize; - - int64_t startTs; // sort start time - uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. - SLimitInfo limitInfo; - SNode* pCondition; + uint32_t sortBufSize; // max buffer size for in-memory sort + SArray* pSortInfo; + SSortHandle* pSortHandle; + SArray* pColMatchInfo; // for index map from table scan output + int32_t bufPageSize; + + int64_t startTs; // sort start time + uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. + SLimitInfo limitInfo; + SNode* pCondition; } SSortOperatorInfo; typedef struct STagFilterOperatorInfo { @@ -838,18 +865,18 @@ typedef struct STagFilterOperatorInfo { } STagFilterOperatorInfo; typedef struct SJoinOperatorInfo { - SSDataBlock *pRes; - int32_t joinType; - int32_t inputOrder; - - SSDataBlock *pLeft; - int32_t leftPos; - SColumnInfo leftCol; - - SSDataBlock *pRight; - int32_t rightPos; - SColumnInfo rightCol; - SNode *pCondAfterMerge; + SSDataBlock* pRes; + int32_t joinType; + int32_t inputOrder; + + SSDataBlock* pLeft; + int32_t leftPos; + SColumnInfo leftCol; + + SSDataBlock* pRight; + int32_t rightPos; + SColumnInfo rightCol; + SNode* pCondAfterMerge; } SJoinOperatorInfo; #define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED) @@ -858,8 +885,8 @@ typedef struct SJoinOperatorInfo { void doDestroyExchangeOperatorInfo(void* param); SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn, - __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode, - __optr_decode_fn_t decode, __optr_explain_fn_t explain); + __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode, + __optr_decode_fn_t decode, __optr_explain_fn_t explain); int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); void operatorDummyCloseFn(void* param, int32_t numOfCols); @@ -870,24 +897,25 @@ void cleanupBasicInfo(SOptrBasicInfo* pInfo); int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr); void cleanupExprSupp(SExprSupp* pSup); void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs); -int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, +int32_t initAggInfo(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, const char* pkey); -void initResultSizeInfo(SResultInfo * pResultInfo, int32_t numOfRows); -void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf); -int32_t handleLimitOffset(SOperatorInfo *pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf); +void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows); +void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, + SDiskbasedBuf* pBuf); +int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf); bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo); void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo); -void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, int32_t offset, - int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput); +void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, int32_t offset, + int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput); int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart); -void updateLoadRemoteInfo(SLoadRemoteDataInfo *pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs, - SOperatorInfo* pOperator); +void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs, + SOperatorInfo* pOperator); STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); -int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag); +int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag); int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); void doSetOperatorCompleted(SOperatorInfo* pOperator); @@ -895,10 +923,10 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pC int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock, const char* idStr); -void cleanupAggSup(SAggSupporter* pAggSup); -void destroyBasicOperatorInfo(void* param, int32_t numOfOutput); -void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle); -void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId); +void cleanupAggSup(SAggSupporter* pAggSup); +void destroyBasicOperatorInfo(void* param, int32_t numOfOutput); +void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle); +void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId); int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts); int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts); @@ -907,29 +935,37 @@ SSDataBlock* loadNextDataBlock(void* param); void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset); -SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, - char* pData, int16_t bytes, bool masterscan, uint64_t groupId, - SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup); +SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData, + int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, + bool isIntervalQuery, SAggSupporter* pSup); SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, + SExecTaskInfo* pTaskInfo); SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, + const char* pUser, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo, +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, bool mergeResult, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, + SExecTaskInfo* pTaskInfo); +SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, + SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, + SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, + SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, - STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, bool isStream); + STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo, bool isStream); SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMergeIntervalPhysiNode* pIntervalPhyNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SMergeAlignedIntervalPhysiNode* pNode, @@ -949,30 +985,39 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWinodwPhysiNode* pStateNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SSortMergeJoinPhysiNode* pJoinNode, +SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, + SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWinodwPhysiNode* pStateNode, + SExecTaskInfo* pTaskInfo); +SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, - SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, - SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild); +SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, + SExecTaskInfo* pTaskInfo); + +SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, + SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo); + +SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo, int32_t numOfChild); -SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo); int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, - int32_t numOfOutput, SArray* pPseudoList); + int32_t numOfOutput, SArray* pPseudoList); -void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol); +void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, + int32_t scanFlag, bool createDummyCol); bool isTaskKilled(SExecTaskInfo* pTaskInfo); int32_t checkForQueryBuf(size_t numOfTables); -void setTaskKilled(SExecTaskInfo* pTaskInfo); -void queryCostStatis(SExecTaskInfo* pTaskInfo); +void setTaskKilled(SExecTaskInfo* pTaskInfo); +void queryCostStatis(SExecTaskInfo* pTaskInfo); void doDestroyTask(SExecTaskInfo* pTaskInfo); int32_t getMaximumIdleDurationSec(); @@ -984,7 +1029,7 @@ int32_t getMaximumIdleDurationSec(); * nOptrWithVal: *nOptrWithVal save the number of optr with value * return: result code, 0 means success */ -int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length, int32_t *nOptrWithVal); +int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t* length, int32_t* nOptrWithVal); /* * ops: root operator, created by caller @@ -997,7 +1042,7 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, char* sql, EOPTR_EXEC_MODEL model); -int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList); int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result); @@ -1006,41 +1051,43 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, int32_t order); int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, - __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order); + __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order); int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput, - int32_t size); -SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize); -SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, - TSKEY endTs, uint64_t groupId, int64_t gap, int32_t* pIndex); -SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, - TSKEY endTs, uint64_t groupId, int64_t gap, int32_t* pIndex); -bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap); -bool functionNeedToExecute(SqlFunctionCtx* pCtx); -bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); -bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); -bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); -void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, int32_t uidCol, uint64_t* pID); -void printDataBlock(SSDataBlock* pBlock, const char* flag); + int32_t size); +SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize); +SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, + int64_t gap, int32_t* pIndex); +SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, + int64_t gap, int32_t* pIndex); +bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap); +bool functionNeedToExecute(SqlFunctionCtx* pCtx); +bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); +bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); +bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); +void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp); +void printDataBlock(SSDataBlock* pBlock, const char* flag); +uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId); int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, - SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset, - SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); + SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, + const int32_t* rowCellOffset, SSDataBlock* pBlock, + SExecTaskInfo* pTaskInfo); -int32_t createScanTableListInfo(SScanPhysiNode *pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle, - STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, const char* idstr); +int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle, + STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, + const char* idstr); SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, STableListInfo *pTableListInfo, +SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, STableListInfo* pTableListInfo, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex); -bool groupbyTbname(SNodeList* pGroupList); +bool groupbyTbname(SNodeList* pGroupList); int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey); -SSDataBlock* createSpecialDataBlock(EStreamType type); -void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput); +void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput); #ifdef __cplusplus } diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 06b7c13fa2cb52b8255098c5efb652d56ec57974..40198615eab8a00a09479693193306026b4ba938 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -168,7 +168,9 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf)); taosFreeQitem(pBuf); - *pLen = ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->dataLen; + + SDataCacheEntry* pEntry = (SDataCacheEntry*)pDeleter->nextOutput.pData; + *pLen = pEntry->dataLen; *pQueryEnd = pDeleter->queryEnd; qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows); } diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 20396046ba5daa34c3caaf76796c2b8a3b06527c..1697ed63fb196aa2a571aa26f8ffe29ee1d6c5d5 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -93,6 +93,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn pBuf->useSize = sizeof(SDataCacheEntry); blockEncode(pInput->pData, pEntry->data, &pEntry->dataLen, numOfCols, pEntry->compressed); + ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data+8)); + ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data+8+4)); pBuf->useSize += pEntry->dataLen; @@ -170,7 +172,13 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf); memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf)); taosFreeQitem(pBuf); - *pLen = ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->dataLen; + + 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)); + *pQueryEnd = pDispatcher->queryEnd; qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->numOfRows); } @@ -191,6 +199,9 @@ 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)); + atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen); atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index e9dbb67472a9d51c63cad557385d714e94e1ce69..3965b7e5b24d981257a53d6afe5ea7edf9168c89 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1192,7 +1192,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); } else { char* udfName = pExpr->pExpr->_function.pFunctNode->functionName; - strncpy(pCtx->udfName, udfName, strlen(udfName)); + strncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN); fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet); } pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); @@ -1302,7 +1302,6 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = -1; - pCond->schemaVersion = -1; // pCond->type = pTableScanNode->scanFlag; int32_t j = 0; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 124f4b44b0b454e738b928f1c607ab6e5bd09c89..5da0f5c51a58cbd87f7fee19752e1e87e97c5932 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -52,7 +52,11 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu // TODO: if a block was set but not consumed, // prevent setting a different type of block pInfo->validBlockIndex = 0; - taosArrayClear(pInfo->pBlockLists); + if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) { + taosArrayClearP(pInfo->pBlockLists, taosMemoryFree); + } else { + taosArrayClear(pInfo->pBlockLists); + } if (type == STREAM_INPUT__MERGED_SUBMIT) { // ASSERT(numOfBlocks > 1); @@ -139,7 +143,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema) { if (msg == NULL) { - // TODO create raw scan + // create raw scan SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); if (NULL == pTaskInfo) { @@ -151,7 +155,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n pTaskInfo->cost.created = taosGetTimestampMs(); pTaskInfo->execModel = OPTR_EXEC_MODEL_QUEUE; pTaskInfo->pRoot = createRawScanOperatorInfo(readers, pTaskInfo); - if(NULL == pTaskInfo->pRoot){ + if (NULL == pTaskInfo->pRoot) { terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pTaskInfo); return NULL; @@ -729,7 +733,6 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = sContext->snapVersion; - pCond->schemaVersion = sContext->snapVersion; for (int32_t i = 0; i < pCond->numOfCols; ++i) { pCond->colList[i].type = mtInfo.schema->pSchema[i].type; @@ -745,6 +748,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT SOperatorInfo* pOperator = pTaskInfo->pRoot; ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); pTaskInfo->streamInfo.prepareStatus = *pOffset; + pTaskInfo->streamInfo.returned = 0; if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.lastStatus)) { return 0; } @@ -810,7 +814,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT } } - // TODO after dropping table, table may be not found + // TODO after dropping table, table may not found ASSERT(found); if (pTableScanInfo->dataReader == NULL) { @@ -834,11 +838,11 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT } else { ASSERT(0); } - }else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA){ + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if(setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setDataForSnapShot error. uid:%"PRIi64, pOffset->uid); + SSnapContext* sContext = pInfo->sContext; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setDataForSnapShot error. uid:%" PRIi64, pOffset->uid); return -1; } @@ -847,27 +851,29 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT pInfo->dataReader = NULL; cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); taosArrayDestroy(pTaskInfo->tableqinfoList.pTableList); - if(mtInfo.uid == 0) return 0; // no data + if (mtInfo.uid == 0) return 0; // no data initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, mtInfo); pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts; pTaskInfo->tableqinfoList.pTableList = taosArrayInit(1, sizeof(STableKeyInfo)); taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &(STableKeyInfo){.uid = mtInfo.uid, .groupId = 0}); - tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pTaskInfo->tableqinfoList.pTableList, &pInfo->dataReader, NULL); + tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pTaskInfo->tableqinfoList.pTableList, + &pInfo->dataReader, NULL); strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); pTaskInfo->streamInfo.schema = mtInfo.schema; + qDebug("tmqsnap qStreamPrepareScan snapshot data uid %ld ts %ld", mtInfo.uid, pOffset->ts); - }else if(pOffset->type == TMQ_OFFSET__SNAPSHOT_META){ + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if(setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setForSnapShot error. uid:%"PRIi64" ,version:%"PRIi64, pOffset->uid); + SSnapContext* sContext = pInfo->sContext; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setForSnapShot error. uid:%" PRIi64 " ,version:%" PRIi64, pOffset->uid); return -1; } qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %ld", pOffset->uid); - }else if (pOffset->type == TMQ_OFFSET__LOG) { + } else if (pOffset->type == TMQ_OFFSET__LOG) { SStreamRawScanInfo* pInfo = pOperator->info; tsdbReaderClose(pInfo->dataReader); pInfo->dataReader = NULL; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ec766913a9edb431f108cc3efa39b863032fb46a..0240102437cebdd2f977e6f5565ebe817e18282d 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -266,7 +266,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, - sizeof(SResultRowPosition)); + sizeof(SResultRowPosition)); } // 2. set the new time window to be the new active time window @@ -2637,92 +2637,6 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } } -#if 0 -int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts) { - uint8_t type = pOperator->operatorType; - - pOperator->status = OP_OPENED; - - if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - SStreamScanInfo* pScanInfo = pOperator->info; - pScanInfo->blockType = STREAM_INPUT__TABLE_SCAN; - - pScanInfo->pTableScanOp->status = OP_OPENED; - - STableScanInfo* pInfo = pScanInfo->pTableScanOp->info; - ASSERT(pInfo->scanMode == TABLE_SCAN__TABLE_ORDER); - - if (uid == 0) { - pInfo->noTable = 1; - return TSDB_CODE_SUCCESS; - } - - /*if (pSnapShotScanInfo->dataReader == NULL) {*/ - /*pSnapShotScanInfo->dataReader = tsdbReaderOpen(pHandle->vnode, &pSTInfo->cond, tableList, 0, 0);*/ - /*pSnapShotScanInfo->scanMode = TABLE_SCAN__TABLE_ORDER;*/ - /*}*/ - - pInfo->noTable = 0; - - if (pInfo->lastStatus.uid != uid || pInfo->lastStatus.ts != ts) { - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - - int32_t tableSz = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList); - bool found = false; - for (int32_t i = 0; i < tableSz; i++) { - STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i); - if (pTableInfo->uid == uid) { - found = true; - pInfo->currentTable = i; - } - } - // TODO after processing drop, found can be false - ASSERT(found); - - tsdbSetTableId(pInfo->dataReader, uid); - int64_t oldSkey = pInfo->cond.twindows.skey; - pInfo->cond.twindows.skey = ts + 1; - tsdbReaderReset(pInfo->dataReader, &pInfo->cond); - pInfo->cond.twindows.skey = oldSkey; - pInfo->scanTimes = 0; - - qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, ts, - pInfo->currentTable, tableSz); - } - - return TSDB_CODE_SUCCESS; - - } else { - if (pOperator->numOfDownstream == 1) { - return doPrepareScan(pOperator->pDownstream[0], uid, ts); - } else if (pOperator->numOfDownstream == 0) { - qError("failed to find stream scan operator to set the input data block"); - return TSDB_CODE_QRY_APP_ERROR; - } else { - qError("join not supported for stream block scan"); - return TSDB_CODE_QRY_APP_ERROR; - } - } -} - -int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts) { - int32_t type = pOperator->operatorType; - if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - SStreamScanInfo* pScanInfo = pOperator->info; - STableScanInfo* pSnapShotScanInfo = pScanInfo->pTableScanOp->info; - *uid = pSnapShotScanInfo->lastStatus.uid; - *ts = pSnapShotScanInfo->lastStatus.ts; - } else { - if (pOperator->pDownstream[0] == NULL) { - return TSDB_CODE_INVALID_PARA; - } else { - doGetScanStatus(pOperator->pDownstream[0], uid, ts); - } - } - - return TSDB_CODE_SUCCESS; -} -#endif // this is a blocking operator static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { @@ -2846,7 +2760,7 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); setBufPageDirty(pPage, true); releaseBufPage(pSup->pResultBuf, pPage); - + int32_t iter = 0; void* pIter = NULL; while ((pIter = tSimpleHashIterate(pSup->pResultRowHashTable, pIter, &iter))) { @@ -3255,7 +3169,7 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey) { - int32_t code = 0; + int32_t code = 0; _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pAggSup->currentPageId = -1; @@ -3815,7 +3729,6 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = -1; - pCond->schemaVersion = -1; return TSDB_CODE_SUCCESS; } @@ -3889,8 +3802,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i); qDebug("creating stream task: add table %" PRId64, pKeyInfo->uid); } - } #endif + } pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); @@ -4057,6 +3970,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createStreamFinalSessionAggOperatorInfo(ops[0], pPhyNode, pTaskInfo, children); } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { pOptr = createPartitionOperatorInfo(ops[0], (SPartitionPhysiNode*)pPhyNode, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION == type) { + pOptr = createStreamPartitionOperatorInfo(ops[0], (SPartitionPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE == type) { SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*)pPhyNode; pOptr = createStatewindowOperatorInfo(ops[0], pStateNode, pTaskInfo); @@ -4115,42 +4030,6 @@ SArray* extractColumnInfo(SNodeList* pNodeList) { return pList; } -#if 0 -STsdbReader* doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, - STableListInfo* pTableListInfo, const char* idstr) { - int32_t code = getTableList(pHandle->meta, pHandle->vnode, &pTableScanNode->scan, pTableListInfo); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - if (taosArrayGetSize(pTableListInfo->pTableList) == 0) { - code = 0; - qDebug("no table qualified for query, %s", idstr); - goto _error; - } - - SQueryTableDataCond cond = {0}; - code = initQueryTableDataCond(&cond, pTableScanNode); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - STsdbReader* pReader; - code = tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, &pReader, idstr); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - cleanupQueryTableDataCond(&cond); - - return pReader; - -_error: - terrno = code; - return NULL; -} -#endif - static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanInfo** ppInfo) { if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { @@ -4392,7 +4271,7 @@ _complete: return code; } -static void doDestroyTableList(STableListInfo* pTableqinfoList) { +void doDestroyTableList(STableListInfo* pTableqinfoList) { taosArrayDestroy(pTableqinfoList->pTableList); taosHashCleanup(pTableqinfoList->map); if (pTableqinfoList->needSortTableByGroupId) { diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 5d123f723e01d98faa791e612f95235ffef5a04d..599edb07222840d6e3bc74889ad0bd52bba50907 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -830,3 +830,205 @@ int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, setResultRowInitCtx(pResultRow, pCtx, numOfCols, pOperator->exprSupp.rowEntryInfoOffset); return TSDB_CODE_SUCCESS; } + +uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId) { + if (pExprSup->pExprInfo != NULL) { + int32_t code = projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); + if (code != TSDB_CODE_SUCCESS) { + qError("calaculate group id error, code:%d", code); + } + } + recordNewGroupKeys(pParSup->pGroupCols, pParSup->pGroupColVals, pBlock, rowId); + int32_t len = buildGroupKeys(pParSup->keyBuf, pParSup->pGroupColVals); + uint64_t groupId = calcGroupId(pParSup->keyBuf, len); + return groupId; +} + +static bool hasRemainPartion(SStreamPartitionOperatorInfo* pInfo) { + return pInfo->parIte != NULL; +} + +static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) { + SStreamPartitionOperatorInfo* pInfo = pOperator->info; + SSDataBlock* pDest = pInfo->binfo.pRes; + ASSERT(hasRemainPartion(pInfo)); + SPartitionDataInfo* pParInfo = (SPartitionDataInfo*)pInfo->parIte; + blockDataCleanup(pDest); + int32_t rows = taosArrayGetSize(pParInfo->rowIds); + SSDataBlock* pSrc = pInfo->pInputDataBlock; + for (int32_t i = 0; i < rows; i++) { + int32_t rowIndex = *(int32_t*)taosArrayGet(pParInfo->rowIds, i); + for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; j++) { + int32_t slotId = pOperator->exprSupp.pExprInfo[j].base.pParam[0].pCol->slotId; + SColumnInfoData* pSrcCol = taosArrayGet(pSrc->pDataBlock, slotId); + SColumnInfoData* pDestCol = taosArrayGet(pDest->pDataBlock, j); + bool isNull = colDataIsNull(pSrcCol, pSrc->info.rows, rowIndex, NULL); + char* pSrcData = colDataGetData(pSrcCol, rowIndex); + colDataAppend(pDestCol, pDest->info.rows, pSrcData, isNull); + } + pDest->info.rows++; + } + blockDataUpdateTsWindow(pDest, pInfo->tsColIndex); + pDest->info.groupId = pParInfo->groupId; + pOperator->resultInfo.totalRows += pDest->info.rows; + pInfo->parIte = taosHashIterate(pInfo->pPartitions, pInfo->parIte); + ASSERT(pDest->info.rows > 0); + printDataBlock(pDest, "stream partitionby"); + return pDest; +} + +static void doStreamHashPartitionImpl(SStreamPartitionOperatorInfo* pInfo, SSDataBlock* pBlock) { + pInfo->pInputDataBlock = pBlock; + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + recordNewGroupKeys(pInfo->partitionSup.pGroupCols, pInfo->partitionSup.pGroupColVals, pBlock, i); + int32_t keyLen = buildGroupKeys(pInfo->partitionSup.keyBuf, pInfo->partitionSup.pGroupColVals); + SPartitionDataInfo* pParData = + (SPartitionDataInfo*) taosHashGet(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen); + if (pParData) { + taosArrayPush(pParData->rowIds, &i); + } else { + SPartitionDataInfo newParData = {0}; + newParData.groupId = calcGroupId(pInfo->partitionSup.keyBuf, keyLen); + newParData.rowIds = taosArrayInit(64, sizeof(int32_t)); + taosArrayPush(newParData.rowIds, &i); + taosHashPut(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen, &newParData, + sizeof(SPartitionDataInfo)); + } + } +} + +static SSDataBlock* doStreamHashPartition(SOperatorInfo* pOperator) { + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStreamPartitionOperatorInfo* pInfo = pOperator->info; + if (hasRemainPartion(pInfo)) { + return buildStreamPartitionResult(pOperator); + } + + int64_t st = taosGetTimestampUs(); + SOperatorInfo* downstream = pOperator->pDownstream[0]; + { + pInfo->pInputDataBlock = NULL; + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + doSetOperatorCompleted(pOperator); + return NULL; + } + printDataBlock(pBlock, "stream partitionby recv"); + switch (pBlock->info.type) { + case STREAM_NORMAL: + case STREAM_PULL_DATA: + case STREAM_INVALID: + pInfo->binfo.pRes->info.type = pBlock->info.type; + break; + default: + return pBlock; + } + + // there is an scalar expression that needs to be calculated right before apply the group aggregation. + if (pInfo->scalarSup.pExprInfo != NULL) { + pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, + pInfo->scalarSup.pCtx, pInfo->scalarSup.numOfExprs, NULL); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, pTaskInfo->code); + } + } + taosHashClear(pInfo->pPartitions); + doStreamHashPartitionImpl(pInfo, pBlock); + } + pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; + + pInfo->parIte = taosHashIterate(pInfo->pPartitions, NULL); + return buildStreamPartitionResult(pOperator); +} + +static void destroyStreamPartitionOperatorInfo(void* param) { + SStreamPartitionOperatorInfo* pInfo = (SStreamPartitionOperatorInfo*)param; + cleanupBasicInfo(&pInfo->binfo); + taosArrayDestroy(pInfo->partitionSup.pGroupCols); + + for(int i = 0; i < taosArrayGetSize(pInfo->partitionSup.pGroupColVals); i++){ + SGroupKeys key = *(SGroupKeys*)taosArrayGet(pInfo->partitionSup.pGroupColVals, i); + taosMemoryFree(key.pData); + } + taosArrayDestroy(pInfo->partitionSup.pGroupColVals); + + taosMemoryFree(pInfo->partitionSup.keyBuf); + cleanupExprSupp(&pInfo->scalarSup); + taosMemoryFreeClear(param); +} + +void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup, SExprSupp* pExpr) { + if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + return; + } + SStreamScanInfo* pScanInfo = downstream->info; + pScanInfo->partitionSup = *pParSup; + pScanInfo->pPartScalarSup = pExpr; +} + +SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStreamPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo) { + SStreamPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamPartitionOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + int32_t code = TSDB_CODE_SUCCESS; + pInfo->partitionSup.pGroupCols = extractPartitionColInfo(pPartNode->pPartitionKeys); + + if (pPartNode->pExprs != NULL) { + int32_t num = 0; + SExprInfo* pCalExprInfo = createExprInfo(pPartNode->pExprs, NULL, &num); + code = initExprSupp(&pInfo->scalarSup, pCalExprInfo, num); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + } + + int32_t keyLen = 0; + code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf, pInfo->partitionSup.pGroupCols); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + pInfo->partitionSup.needCalc = true; + + SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc); + if (!pResBlock) { + goto _error; + } + blockDataEnsureCapacity(pResBlock, 4096); + pInfo->binfo.pRes = pResBlock; + pInfo->parIte = NULL; + pInfo->pInputDataBlock = NULL; + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pInfo->pPartitions = taosHashInit(1024, hashFn, false, HASH_NO_LOCK); + pInfo->tsColIndex = 0; + + int32_t numOfCols = 0; + SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols); + + pOperator->name = "StreamPartitionOperator"; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION; + pOperator->exprSupp.numOfExprs = numOfCols; + pOperator->exprSupp.pExprInfo = pExprInfo; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, NULL, destroyStreamPartitionOperatorInfo, + NULL, NULL, NULL); + + initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup); + code = appendDownstream(pOperator, &downstream, 1); + return pOperator; + + _error: + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFreeClear(pInfo); + taosMemoryFreeClear(pOperator); + return NULL; +} + diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index e23a591904859579617c7c27753832f73e00ab45..c099c1c24c31da8a41087156cbef98c6c4fd4846 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -695,6 +695,7 @@ static void destroyTableScanOperatorInfo(void* param) { cleanupQueryTableDataCond(&pTableScanInfo->cond); tsdbReaderClose(pTableScanInfo->dataReader); + pTableScanInfo->dataReader = NULL; if (pTableScanInfo->pColMatchInfo != NULL) { taosArrayDestroy(pTableScanInfo->pColMatchInfo); @@ -920,49 +921,28 @@ static void doClearBufferedBlocks(SStreamScanInfo* pInfo) { } static bool isSessionWindow(SStreamScanInfo* pInfo) { - return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || - pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION; + return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || + pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION; } static bool isStateWindow(SStreamScanInfo* pInfo) { - return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE; + return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE; } static bool isIntervalWindow(SStreamScanInfo* pInfo) { - return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || - pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || - pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; + return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || + pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || + pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; } static bool isSignleIntervalWindow(SStreamScanInfo* pInfo) { - return pInfo->sessionSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL; + return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL; } static bool isSlidingWindow(SStreamScanInfo* pInfo) { return isIntervalWindow(pInfo) && pInfo->interval.interval != pInfo->interval.sliding; } -static uint64_t getGroupId(SOperatorInfo* pOperator, uint64_t uid) { - uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &uid, sizeof(int64_t)); - if (groupId) { - return *groupId; - } - return 0; - /* Todo(liuyao) for partition by column - recordNewGroupKeys(pTableScanInfo->pGroupCols, pTableScanInfo->pGroupColVals, pBlock, rowId); - int32_t len = buildGroupKeys(pTableScanInfo->keyBuf, pTableScanInfo->pGroupColVals); - uint64_t resId = 0; - uint64_t* groupId = taosHashGet(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len); - if (groupId) { - return *groupId; - } else if (len != 0) { - resId = calcGroupId(pTableScanInfo->keyBuf, len); - taosHashPut(pTableScanInfo->pGroupSet, pTableScanInfo->keyBuf, len, &resId, sizeof(uint64_t)); - } - return resId; - */ -} - static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t groupColIndex, int32_t rowIndex) { SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, groupColIndex); uint64_t* groupCol = (uint64_t*)pColInfo->pData; @@ -976,6 +956,61 @@ void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) { pTableScanInfo->currentGroupId = -1; } +static void freeArray(void* array) { taosArrayDestroy(array); } + +static void resetTableScanOperator(SOperatorInfo* pTableScanOp) { + STableScanInfo* pTableScanInfo = pTableScanOp->info; + pTableScanInfo->cond.startVersion = -1; + pTableScanInfo->cond.endVersion = -1; + SArray* gpTbls = pTableScanOp->pTaskInfo->tableqinfoList.pGroupList; + SArray* allTbls = pTableScanOp->pTaskInfo->tableqinfoList.pTableList; + taosArrayClearP(gpTbls, freeArray); + taosArrayPush(gpTbls, &allTbls); + STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX}; + resetTableScanInfo(pTableScanOp->info, &win); +} + +static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbUid, TSKEY startTs, TSKEY endTs, + int64_t maxVersion) { + SArray* gpTbls = pTableScanOp->pTaskInfo->tableqinfoList.pGroupList; + taosArrayClear(gpTbls); + STableKeyInfo tblInfo = {.uid = tbUid, .groupId = 0}; + SArray* tbls = taosArrayInit(1, sizeof(STableKeyInfo)); + taosArrayPush(tbls, &tblInfo); + taosArrayPush(gpTbls, &tbls); + + STimeWindow win = {.skey = startTs, .ekey = endTs}; + STableScanInfo* pTableScanInfo = pTableScanOp->info; + pTableScanInfo->cond.startVersion = -1; + pTableScanInfo->cond.endVersion = maxVersion; + resetTableScanInfo(pTableScanOp->info, &win); + SSDataBlock* pRes = doTableScan(pTableScanOp); + resetTableScanOperator(pTableScanOp); + return pRes; +} + +static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { + SSDataBlock* pPreRes = readPreVersionData(pInfo->pTableScanOp, uid, ts, ts, maxVersion); + if (!pPreRes || pPreRes->info.rows == 0) { + return 0; + } + ASSERT(pPreRes->info.rows == 1); + return calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pPreRes, 0); +} + +static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { + if (pInfo->partitionSup.needCalc) { + return getGroupIdByCol(pInfo, uid, ts, maxVersion); + } + + SHashObj* map = pInfo->pTableScanOp->pTaskInfo->tableqinfoList.map; + uint64_t* groupId = taosHashGet(map, &uid, sizeof(int64_t)); + if (groupId) { + return *groupId; + } + return 0; +} + static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t* pRowIndex) { if ((*pRowIndex) == pBlock->info.rows) { return false; @@ -987,6 +1022,9 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); TSKEY* endData = (TSKEY*)pEndTsCol->pData; STimeWindow win = {.skey = startData[*pRowIndex], .ekey = endData[*pRowIndex]}; + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* gpData = (uint64_t*)pGpCol->pData; + uint64_t groupId = gpData[*pRowIndex]; SColumnInfoData* pCalStartTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); TSKEY* calStartData = (TSKEY*)pCalStartTsCol->pData; @@ -1001,11 +1039,11 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ (*pRowIndex)++; for (; *pRowIndex < pBlock->info.rows; (*pRowIndex)++) { - if (win.skey == startData[*pRowIndex]) { + if (win.skey == startData[*pRowIndex] && groupId == gpData[*pRowIndex]) { win.ekey = TMAX(win.ekey, endData[*pRowIndex]); continue; } - if (win.skey == endData[*pRowIndex]) { + if (win.skey == endData[*pRowIndex] && groupId == gpData[*pRowIndex]) { win.skey = TMIN(win.skey, startData[*pRowIndex]); continue; } @@ -1020,15 +1058,19 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ } static STimeWindow getSlidingWindow(TSKEY* tsCol, SInterval* pInterval, SDataBlockInfo* pDataBlockInfo, - int32_t* pRowIndex) { + int32_t* pRowIndex, bool hasGroup) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC); STimeWindow endWin = win; STimeWindow preWin = win; while (1) { - (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, tsCol, *pRowIndex, endWin.ekey, binarySearchForKey, NULL, - TSDB_ORDER_ASC); + if (hasGroup) { + (*pRowIndex) += 1; + } else { + (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, tsCol, *pRowIndex, endWin.ekey, binarySearchForKey, NULL, + TSDB_ORDER_ASC); + } do { preWin = endWin; getNextTimeWindow(pInterval, &endWin, TSDB_ORDER_ASC); @@ -1060,7 +1102,26 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32 return NULL; } - if (pResult->info.groupId == pInfo->groupId) { + if (pInfo->partitionSup.needCalc) { + SSDataBlock* tmpBlock = createOneDataBlock(pResult, true); + blockDataCleanup(pResult); + for (int32_t i = 0; i < tmpBlock->info.rows; i++) { + if (calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, tmpBlock, i) == pInfo->groupId) { + for (int32_t j = 0; j < pInfo->pTableScanOp->exprSupp.numOfExprs; j++) { + SColumnInfoData* pSrcCol = taosArrayGet(tmpBlock->pDataBlock, j); + SColumnInfoData* pDestCol = taosArrayGet(pResult->pDataBlock, j); + bool isNull = colDataIsNull(pSrcCol, tmpBlock->info.rows, i, NULL); + char* pSrcData = colDataGetData(pSrcCol, i); + colDataAppend(pDestCol, pResult->info.rows, pSrcData, isNull); + } + pResult->info.rows++; + } + } + if (pResult->info.rows > 0) { + pResult->info.calWin = pInfo->updateWin; + return pResult; + } + } else if (pResult->info.groupId == pInfo->groupId) { pResult->info.calWin = pInfo->updateWin; return pResult; } @@ -1091,17 +1152,18 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); int32_t dummy = 0; + int64_t version = pSrcBlock->info.version - 1; for (int32_t i = 0; i < pSrcBlock->info.rows; i++) { - uint64_t groupId = getGroupId(pInfo->pTableScanOp, uidCol[i]); + uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], version); // gap must be 0. SResultWindowInfo* pStartWin = - getCurSessionWindow(pInfo->sessionSup.pStreamAggSup, startData[i], endData[i], groupId, 0, &dummy); + getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], endData[i], groupId, 0, &dummy); if (!pStartWin) { // window has been closed. continue; } SResultWindowInfo* pEndWin = - getCurSessionWindow(pInfo->sessionSup.pStreamAggSup, endData[i], endData[i], groupId, 0, &dummy); + getCurSessionWindow(pInfo->windowSup.pStreamAggSup, endData[i], endData[i], groupId, 0, &dummy); ASSERT(pEndWin); TSKEY ts = INT64_MIN; colDataAppend(pDestStartCol, i, (const char*)&pStartWin->win.skey, false); @@ -1121,34 +1183,49 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS if (rows == 0) { return TSDB_CODE_SUCCESS; } - int32_t code = blockDataEnsureCapacity(pDestBlock, rows); + int32_t code = blockDataEnsureCapacity(pDestBlock, rows * 2); if (code != TSDB_CODE_SUCCESS) { return code; } - SColumnInfoData* pTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX); - SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX); - uint64_t* uidCol = (uint64_t*)pUidCol->pData; - ASSERT(pTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); - TSKEY* tsCol = (TSKEY*)pTsCol->pData; + SColumnInfoData* pSrcTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX); + SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX); + uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData; + SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData; + ASSERT(pSrcTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); + TSKEY* tsCol = (TSKEY*)pSrcTsCol->pData; SColumnInfoData* pStartTsCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pEndTsCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX); + SColumnInfoData* pDeUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX); SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX); SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); - uint64_t groupId = getGroupId(pInfo->pTableScanOp, uidCol[0]); + int64_t version = pSrcBlock->info.version - 1; for (int32_t i = 0; i < rows;) { - colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(tsCol + i), false); - STimeWindow win = getSlidingWindow(tsCol, &pInfo->interval, &pSrcBlock->info, &i); - colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(tsCol + i - 1), false); - + uint64_t srcUid = srcUidData[i]; + uint64_t groupId = getGroupIdByData(pInfo, srcUid, tsCol[i], version); + uint64_t srcGpId = srcGp[i]; + TSKEY calStartTs = tsCol[i]; + colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false); + STimeWindow win = getSlidingWindow(tsCol, &pInfo->interval, &pSrcBlock->info, &i, pInfo->partitionSup.needCalc); + TSKEY calEndTs = tsCol[i - 1]; + colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(&calEndTs), false); + colDataAppend(pDeUidCol, pDestBlock->info.rows, (const char*)(&srcUid), false); colDataAppend(pStartTsCol, pDestBlock->info.rows, (const char*)(&win.skey), false); colDataAppend(pEndTsCol, pDestBlock->info.rows, (const char*)(&win.ekey), false); colDataAppend(pGpCol, pDestBlock->info.rows, (const char*)(&groupId), false); pDestBlock->info.rows++; + if (pInfo->partitionSup.needCalc && srcGpId != 0 && groupId != srcGpId) { + colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false); + colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(&calEndTs), false); + colDataAppend(pDeUidCol, pDestBlock->info.rows, (const char*)(&srcUid), false); + colDataAppend(pStartTsCol, pDestBlock->info.rows, (const char*)(&win.skey), false); + colDataAppend(pEndTsCol, pDestBlock->info.rows, (const char*)(&win.ekey), false); + colDataAppend(pGpCol, pDestBlock->info.rows, (const char*)(&srcGpId), false); + pDestBlock->info.rows++; + } } - // all rows have same group id - pDestBlock->info.groupId = groupId; return TSDB_CODE_SUCCESS; } @@ -1160,17 +1237,20 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock); } pDestBlock->info.type = STREAM_CLEAR; + pDestBlock->info.version = pSrcBlock->info.version; blockDataUpdateTsWindow(pDestBlock, 0); return code; } -void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, int32_t uidCol, uint64_t* pID) { +void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp) { SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); - SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, uidCol); + SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); colDataAppend(pStartTsCol, pBlock->info.rows, (const char*)pStartTs, false); colDataAppend(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false); - colDataAppend(pUidCol, pBlock->info.rows, (const char*)pID, false); + colDataAppend(pUidCol, pBlock->info.rows, (const char*)pUid, false); + colDataAppend(pGpCol, pBlock->info.rows, (const char*)pGp, false); pBlock->info.rows++; } @@ -1195,31 +1275,25 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock // must check update info first. bool update = updateInfoIsUpdated(pInfo->pUpdateInfo, pBlock->info.uid, tsCol[rowId]); bool closedWin = isClosed && isSignleIntervalWindow(pInfo) && - isDeletedWindow(&win, pBlock->info.groupId, pInfo->sessionSup.pIntervalAggSup); + isDeletedWindow(&win, pBlock->info.groupId, pInfo->windowSup.pIntervalAggSup); if ((update || closedWin) && out) { - appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, UID_COLUMN_INDEX, &pBlock->info.uid); + uint64_t gpId = closedWin && pInfo->partitionSup.needCalc + ? calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId) + : 0; + appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid, &gpId); } } - if (out) { + if (out && pInfo->pUpdateDataRes->info.rows > 0) { + pInfo->pUpdateDataRes->info.version = pBlock->info.version; blockDataUpdateTsWindow(pInfo->pUpdateDataRes, 0); - pInfo->pUpdateDataRes->info.type = STREAM_CLEAR; - } -} - -static void setBlockGroupId(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t uidColIndex) { - ASSERT(taosArrayGetSize(pBlock->pDataBlock) >= 3); - SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, uidColIndex); - uint64_t* uidCol = (uint64_t*)pColDataInfo->pData; - ASSERT(pBlock->info.rows > 0); - for (int32_t i = 0; i < pBlock->info.rows; i++) { - uidCol[i] = getGroupId(pOperator, uidCol[i]); + pInfo->pUpdateDataRes->info.type = pInfo->partitionSup.needCalc ? STREAM_DELETE_DATA : STREAM_CLEAR; } } static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock) { SDataBlockInfo* pBlockInfo = &pInfo->pRes->info; SOperatorInfo* pOperator = pInfo->pStreamScanOp; - SExecTaskInfo* pTaskInfo = pInfo->pStreamScanOp->pTaskInfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; blockDataEnsureCapacity(pInfo->pRes, pBlock->info.rows); @@ -1228,7 +1302,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock pInfo->pRes->info.type = STREAM_NORMAL; pInfo->pRes->info.version = pBlock->info.version; - uint64_t* groupIdPre = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t)); + uint64_t* groupIdPre = taosHashGet(pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t)); if (groupIdPre) { pInfo->pRes->info.groupId = *groupIdPre; } else { @@ -1276,48 +1350,34 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock return 0; } -static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { - // NOTE: this operator does never check if current status is done or not +static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamScanInfo* pInfo = pOperator->info; -#if 0 - SStreamState* pState = pTaskInfo->streamInfo.pState; - if (pState) { - printf(">>>>>>>> stream write backend\n"); - SWinKey key = { - .ts = 1, - .groupId = 2, - }; - char tmp[100] = "abcdefg1"; - if (streamStatePut(pState, &key, &tmp, strlen(tmp) + 1) < 0) { - ASSERT(0); - } - - key.ts = 2; - char tmp2[100] = "abcdefg2"; - if (streamStatePut(pState, &key, &tmp2, strlen(tmp2) + 1) < 0) { - ASSERT(0); - } - - key.groupId = 5; - key.ts = 1; - char tmp3[100] = "abcdefg3"; - if (streamStatePut(pState, &key, &tmp3, strlen(tmp3) + 1) < 0) { - ASSERT(0); - } - - char* val2 = NULL; - int32_t sz; - if (streamStateGet(pState, &key, (void**)&val2, &sz) < 0) { - ASSERT(0); + qDebug("queue scan called"); + if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { + SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); + if (pResult && pResult->info.rows > 0) { + qDebug("queue scan tsdb return %d rows", pResult->info.rows); + pTaskInfo->streamInfo.returned = 1; + return pResult; + } else { + if (!pTaskInfo->streamInfo.returned) { + STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; + tsdbReaderClose(pTSInfo->dataReader); + pTSInfo->dataReader = NULL; + tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer); + qDebug("queue scan tsdb over, switch to wal ver %d", pTaskInfo->streamInfo.snapshotVer + 1); + if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) { + return NULL; + } + ASSERT(pInfo->tqReader->pWalReader->curVersion == pTaskInfo->streamInfo.snapshotVer + 1); + } else { + return NULL; + } } - printf("stream read %s %d\n", val2, sz); - streamFreeVal(val2); } -#endif - qDebug("stream scan called"); if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { while (1) { SFetchRet ret = {0}; @@ -1329,21 +1389,21 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } // TODO clean data block if (pInfo->pRes->info.rows > 0) { - qDebug("stream scan log return %d rows", pInfo->pRes->info.rows); + qDebug("queue scan log return %d rows", pInfo->pRes->info.rows); return pInfo->pRes; } } else if (ret.fetchType == FETCH_TYPE__META) { ASSERT(0); -// pTaskInfo->streamInfo.lastStatus = ret.offset; -// pTaskInfo->streamInfo.metaBlk = ret.meta; -// return NULL; + // pTaskInfo->streamInfo.lastStatus = ret.offset; + // pTaskInfo->streamInfo.metaBlk = ret.meta; + // return NULL; } else if (ret.fetchType == FETCH_TYPE__NONE) { pTaskInfo->streamInfo.lastStatus = ret.offset; ASSERT(pTaskInfo->streamInfo.lastStatus.version >= pTaskInfo->streamInfo.prepareStatus.version); ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 == pInfo->tqReader->pWalReader->curVersion); char formatBuf[80]; tFormatOffset(formatBuf, 80, &ret.offset); - qDebug("stream scan log return null, offset %s", formatBuf); + qDebug("queue scan log return null, offset %s", formatBuf); return NULL; } else { ASSERT(0); @@ -1357,7 +1417,53 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } qDebug("stream scan tsdb return null"); return NULL; + } else { + ASSERT(0); + return NULL; } +} + +static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { + // NOTE: this operator does never check if current status is done or not + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStreamScanInfo* pInfo = pOperator->info; + + qDebug("stream scan called"); +#if 0 + SStreamState* pState = pTaskInfo->streamInfo.pState; + if (pState) { + printf(">>>>>>>> stream write backend\n"); + SWinKey key = { + .ts = 1, + .groupId = 2, + }; + char tmp[100] = "abcdefg1"; + if (streamStatePut(pState, &key, &tmp, strlen(tmp) + 1) < 0) { + ASSERT(0); + } + + key.ts = 2; + char tmp2[100] = "abcdefg2"; + if (streamStatePut(pState, &key, &tmp2, strlen(tmp2) + 1) < 0) { + ASSERT(0); + } + + key.groupId = 5; + key.ts = 1; + char tmp3[100] = "abcdefg3"; + if (streamStatePut(pState, &key, &tmp3, strlen(tmp3) + 1) < 0) { + ASSERT(0); + } + + char* val2 = NULL; + int32_t sz; + if (streamStateGet(pState, &key, (void**)&val2, &sz) < 0) { + ASSERT(0); + } + printf("stream read %s %d\n", val2, sz); + streamFreeVal(val2); + } +#endif if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE) { STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; @@ -1409,12 +1515,14 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { generateScanRange(pInfo, pBlock, pInfo->pUpdateRes); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); + pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; return pInfo->pDeleteDataRes; } break; default: break; } + // printDataBlock(pBlock, "stream scan recv"); return pBlock; } else if (pInfo->blockType == STREAM_INPUT__DATA_SUBMIT) { qDebug("scan mode %d", pInfo->scanMode); @@ -1424,6 +1532,14 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; return pInfo->pRes; } break; + case STREAM_SCAN_FROM_DELETERES: { + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); + prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); + pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; + copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); + pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; + return pInfo->pDeleteDataRes; + } break; case STREAM_SCAN_FROM_UPDATERES: { generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); @@ -1439,6 +1555,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { updateInfoSetScanRange(pInfo->pUpdateInfo, &pTableScanInfo->cond.twindows, pInfo->groupId, version); pSDB->info.type = pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER_RANGE ? STREAM_NORMAL : STREAM_PULL_DATA; checkUpdateData(pInfo, true, pSDB, false); + // printDataBlock(pSDB, "stream scan update"); return pSDB; } pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; @@ -1447,7 +1564,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { break; } - SStreamAggSupporter* pSup = pInfo->sessionSup.pStreamAggSup; + SStreamAggSupporter* pSup = pInfo->windowSup.pStreamAggSup; if (isStateWindow(pInfo) && pSup->pScanBlock->info.rows > 0) { pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; pInfo->updateResIndex = 0; @@ -1513,7 +1630,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // record the scan action. pInfo->numOfExec++; pOperator->resultInfo.totalRows += pBlockInfo->rows; - printDataBlock(pInfo->pRes, "stream scan"); + // printDataBlock(pInfo->pRes, "stream scan"); if (pBlockInfo->rows == 0) { updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo); @@ -1522,19 +1639,20 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { checkUpdateData(pInfo, true, pInfo->pRes, true); pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlockInfo->window.ekey); if (pInfo->pUpdateDataRes->info.rows > 0) { + pInfo->updateResIndex = 0; if (pInfo->pUpdateDataRes->info.type == STREAM_CLEAR) { - pInfo->updateResIndex = 0; pInfo->scanMode = STREAM_SCAN_FROM_UPDATERES; } else if (pInfo->pUpdateDataRes->info.type == STREAM_INVERT) { pInfo->scanMode = STREAM_SCAN_FROM_RES; return pInfo->pUpdateDataRes; + } else if (pInfo->pUpdateDataRes->info.type == STREAM_DELETE_DATA) { + pInfo->scanMode = STREAM_SCAN_FROM_DELETERES; } } } qDebug("scan rows: %d", pBlockInfo->rows); return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; - } else { ASSERT(0); return NULL; @@ -1554,14 +1672,14 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) { } static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { -// NOTE: this operator does never check if current status is done or not - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + // NOTE: this operator does never check if current status is done or not + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamRawScanInfo* pInfo = pOperator->info; - pTaskInfo->streamInfo.metaRsp.metaRspLen = 0; // use metaRspLen !=0 to judge if data is meta + pTaskInfo->streamInfo.metaRsp.metaRspLen = 0; // use metaRspLen !=0 to judge if data is meta pTaskInfo->streamInfo.metaRsp.metaRsp = NULL; qDebug("tmqsnap doRawScan called"); - if(pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA){ + if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { SSDataBlock* pBlock = &pInfo->pRes; if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) { @@ -1585,42 +1703,38 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { } SMetaTableInfo mtInfo = getUidfromSnapShot(pInfo->sContext); - if (mtInfo.uid == 0){ //read snapshot done, change to get data from wal + if (mtInfo.uid == 0) { // read snapshot done, change to get data from wal qDebug("tmqsnap read snapshot done, change to get data from wal"); pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid; pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; pTaskInfo->streamInfo.lastStatus.version = pInfo->sContext->snapVersion; - tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); - }else{ + } else { pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid; pTaskInfo->streamInfo.prepareStatus.ts = INT64_MIN; qDebug("tmqsnap change get data uid:%ld", mtInfo.uid); qStreamPrepareScan(pTaskInfo, &pTaskInfo->streamInfo.prepareStatus, pInfo->sContext->subType); - strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); - tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); - pTaskInfo->streamInfo.schema = mtInfo.schema; } qDebug("tmqsnap stream scan tsdb return null"); return NULL; - }else if(pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_META){ - SSnapContext *sContext = pInfo->sContext; - void* data = NULL; - int32_t dataLen = 0; - int16_t type = 0; - int64_t uid = 0; - if(getMetafromSnapShot(sContext, &data, &dataLen, &type, &uid) < 0){ + } else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_META) { + SSnapContext* sContext = pInfo->sContext; + void* data = NULL; + int32_t dataLen = 0; + int16_t type = 0; + int64_t uid = 0; + if (getMetafromSnapShot(sContext, &data, &dataLen, &type, &uid) < 0) { qError("tmqsnap getMetafromSnapShot error"); taosMemoryFreeClear(data); return NULL; } - if(!sContext->queryMetaOrData){ // change to get data next poll request + if (!sContext->queryMetaOrData) { // change to get data next poll request pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_META; pTaskInfo->streamInfo.lastStatus.uid = uid; pTaskInfo->streamInfo.metaRsp.rspOffset.type = TMQ_OFFSET__SNAPSHOT_DATA; pTaskInfo->streamInfo.metaRsp.rspOffset.uid = 0; pTaskInfo->streamInfo.metaRsp.rspOffset.ts = INT64_MIN; - }else{ + } else { pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_META; pTaskInfo->streamInfo.lastStatus.uid = uid; pTaskInfo->streamInfo.metaRsp.rspOffset = pTaskInfo->streamInfo.lastStatus; @@ -1631,44 +1745,44 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { return NULL; } -// else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { -// int64_t fetchVer = pTaskInfo->streamInfo.prepareStatus.version + 1; -// -// while(1){ -// if (tqFetchLog(pInfo->tqReader->pWalReader, pInfo->sContext->withMeta, &fetchVer, &pInfo->pCkHead) < 0) { -// qDebug("tmqsnap tmq poll: consumer log end. offset %" PRId64, fetchVer); -// pTaskInfo->streamInfo.lastStatus.version = fetchVer; -// pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; -// return NULL; -// } -// SWalCont* pHead = &pInfo->pCkHead->head; -// qDebug("tmqsnap tmq poll: consumer log offset %" PRId64 " msgType %d", fetchVer, pHead->msgType); -// -// if (pHead->msgType == TDMT_VND_SUBMIT) { -// SSubmitReq* pCont = (SSubmitReq*)&pHead->body; -// tqReaderSetDataMsg(pInfo->tqReader, pCont, 0); -// SSDataBlock* block = tqLogScanExec(pInfo->sContext->subType, pInfo->tqReader, pInfo->pFilterOutTbUid, &pInfo->pRes); -// if(block){ -// pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; -// pTaskInfo->streamInfo.lastStatus.version = fetchVer; -// qDebug("tmqsnap fetch data msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); -// return block; -// }else{ -// fetchVer++; -// } -// } else{ -// ASSERT(pInfo->sContext->withMeta); -// ASSERT(IS_META_MSG(pHead->msgType)); -// qDebug("tmqsnap fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); -// pTaskInfo->streamInfo.metaRsp.rspOffset.version = fetchVer; -// pTaskInfo->streamInfo.metaRsp.rspOffset.type = TMQ_OFFSET__LOG; -// pTaskInfo->streamInfo.metaRsp.resMsgType = pHead->msgType; -// pTaskInfo->streamInfo.metaRsp.metaRspLen = pHead->bodyLen; -// pTaskInfo->streamInfo.metaRsp.metaRsp = taosMemoryMalloc(pHead->bodyLen); -// memcpy(pTaskInfo->streamInfo.metaRsp.metaRsp, pHead->body, pHead->bodyLen); -// return NULL; -// } -// } + // else if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { + // int64_t fetchVer = pTaskInfo->streamInfo.prepareStatus.version + 1; + // + // while(1){ + // if (tqFetchLog(pInfo->tqReader->pWalReader, pInfo->sContext->withMeta, &fetchVer, &pInfo->pCkHead) < 0) { + // qDebug("tmqsnap tmq poll: consumer log end. offset %" PRId64, fetchVer); + // pTaskInfo->streamInfo.lastStatus.version = fetchVer; + // pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; + // return NULL; + // } + // SWalCont* pHead = &pInfo->pCkHead->head; + // qDebug("tmqsnap tmq poll: consumer log offset %" PRId64 " msgType %d", fetchVer, pHead->msgType); + // + // if (pHead->msgType == TDMT_VND_SUBMIT) { + // SSubmitReq* pCont = (SSubmitReq*)&pHead->body; + // tqReaderSetDataMsg(pInfo->tqReader, pCont, 0); + // SSDataBlock* block = tqLogScanExec(pInfo->sContext->subType, pInfo->tqReader, pInfo->pFilterOutTbUid, + // &pInfo->pRes); if(block){ + // pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__LOG; + // pTaskInfo->streamInfo.lastStatus.version = fetchVer; + // qDebug("tmqsnap fetch data msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); + // return block; + // }else{ + // fetchVer++; + // } + // } else{ + // ASSERT(pInfo->sContext->withMeta); + // ASSERT(IS_META_MSG(pHead->msgType)); + // qDebug("tmqsnap fetch meta msg, ver:%" PRId64 ", type:%d", pHead->version, pHead->msgType); + // pTaskInfo->streamInfo.metaRsp.rspOffset.version = fetchVer; + // pTaskInfo->streamInfo.metaRsp.rspOffset.type = TMQ_OFFSET__LOG; + // pTaskInfo->streamInfo.metaRsp.resMsgType = pHead->msgType; + // pTaskInfo->streamInfo.metaRsp.metaRspLen = pHead->bodyLen; + // pTaskInfo->streamInfo.metaRsp.metaRsp = taosMemoryMalloc(pHead->bodyLen); + // memcpy(pTaskInfo->streamInfo.metaRsp.metaRsp, pHead->body, pHead->bodyLen); + // return NULL; + // } + // } return NULL; } @@ -1689,7 +1803,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT // create tq reader SStreamRawScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamRawScanInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return NULL; @@ -1699,13 +1813,12 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT pInfo->sContext = pHandle->sContext; pOperator->name = "RawStreamScanOperator"; -// pOperator->blocking = false; -// pOperator->status = OP_NOT_OPENED; + // pOperator->blocking = false; + // pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, - NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL, NULL, NULL); return pOperator; } @@ -1724,7 +1837,7 @@ static void destroyStreamScanOperatorInfo(void* param) { } if (pStreamScan->pPseudoExpr) { destroyExprInfo(pStreamScan->pPseudoExpr, pStreamScan->numOfPseudoExpr); - taosMemoryFreeClear(pStreamScan->pPseudoExpr); + taosMemoryFree(pStreamScan->pPseudoExpr); } updateInfoDestroy(pStreamScan->pUpdateInfo); @@ -1804,17 +1917,13 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->tqReader = pHandle->tqReader; } - if (pTSInfo->pdInfo.interval.interval > 0) { - pInfo->pUpdateInfo = updateInfoInitP(&pTSInfo->pdInfo.interval, pInfo->twAggSup.waterMark); - } else { - pInfo->pUpdateInfo = NULL; - } - + pInfo->pUpdateInfo = NULL; pInfo->pTableScanOp = pTableScanOp; pInfo->interval = pTSInfo->pdInfo.interval; pInfo->readHandle = *pHandle; pInfo->tableUid = pScanPhyNode->uid; + pTaskInfo->streamInfo.snapshotVer = pHandle->version; // set the extract column id to streamHandle tqReaderSetColIdList(pInfo->tqReader, pColIds); @@ -1839,8 +1948,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR); pInfo->pCondition = pScanPhyNode->node.pConditions; pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; - pInfo->sessionSup = - (SessionWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN}; + pInfo->windowSup = (SWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN}; pInfo->groupId = 0; pInfo->pPullDataRes = createSpecialDataBlock(STREAM_RETRIEVE); pInfo->pStreamScanOp = pOperator; @@ -1849,6 +1957,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR); pInfo->assignBlockUid = pTableScanNode->assignBlockUid; + pInfo->partitionSup.needCalc = false; pOperator->name = "StreamScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN; @@ -1858,8 +1967,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamScan, NULL, NULL, destroyStreamScanOperatorInfo, - NULL, NULL, NULL); + __optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan; + pOperator->fpSet = + createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, NULL, destroyStreamScanOperatorInfo, NULL, NULL, NULL); return pOperator; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 90d262e59acf6e28b7fd31764e8285db9dc2bdb9..b7a0673d885406eab528f5541ce470d16eac08cb 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -35,14 +35,15 @@ typedef struct SPullWindowInfo { typedef struct SOpenWindowInfo { SResultRowPosition pos; - uint64_t groupId; + uint64_t groupId; } SOpenWindowInfo; static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator); static int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo); -static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult, uint64_t groupId); +static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult, + uint64_t groupId); static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOperatorInfo* pInfo, SResultRow* pResult); ///* @@ -601,15 +602,15 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info; SExprSupp* pSup = &pOperatorInfo->exprSupp; - int32_t startPos = 0; - int32_t numOfOutput = pSup->numOfExprs; + int32_t startPos = 0; + int32_t numOfOutput = pSup->numOfExprs; SResultRow* pResult = NULL; while (1) { - SListNode* pn = tdListGetHead(pResultRowInfo->openWindow); - SOpenWindowInfo* pOpenWin = (SOpenWindowInfo *)pn->data; - uint64_t groupId = pOpenWin->groupId; + SListNode* pn = tdListGetHead(pResultRowInfo->openWindow); + SOpenWindowInfo* pOpenWin = (SOpenWindowInfo*)pn->data; + uint64_t groupId = pOpenWin->groupId; SResultRowPosition* p1 = &pOpenWin->pos; if (p->pageId == p1->pageId && p->offset == p1->offset) { break; @@ -621,7 +622,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num if (pr->closed) { ASSERT(isResultRowInterpolated(pr, RESULT_ROW_START_INTERP) && isResultRowInterpolated(pr, RESULT_ROW_END_INTERP)); - tdListPopHead(pResultRowInfo->openWindow); + SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow); + taosMemoryFree(pNode); continue; } @@ -650,7 +652,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) { closeResultRow(pr); - tdListPopHead(pResultRowInfo->openWindow); + SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow); + taosMemoryFree(pNode); } else { // the remains are can not be closed yet. break; } @@ -897,7 +900,7 @@ int64_t getWinReskey(void* data, int32_t index) { int32_t compareWinRes(void* pKey, void* data, int32_t index) { SArray* res = (SArray*)data; - SWinKey* pos = taosArrayGetP(res, index); + SWinKey* pos = taosArrayGet(res, index); SResKeyPos* pData = (SResKeyPos*)pKey; if (*(int64_t*)pData->key == pos->ts) { if (pData->groupId > pos->groupId) { @@ -919,10 +922,11 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) { } void* pIte = NULL; while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) { - SResKeyPos* pResKey = (SResKeyPos*)pIte; + SResKeyPos* pResKey = *(SResKeyPos**)pIte; int32_t index = binarySearchCom(pDelWins, delSize, pResKey, TSDB_ORDER_DESC, compareWinRes); if (index >= 0 && 0 == compareWinRes(pResKey, pDelWins, index)) { taosArrayRemove(pDelWins, index); + delSize = taosArrayGetSize(pDelWins); } } } @@ -1027,7 +1031,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); // window start(end) key interpolation doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup); - //TODO: add to open window? how to close the open windows after input blocks exhausted? + // TODO: add to open window? how to close the open windows after input blocks exhausted? #if 0 if ((ascScan && ekey <= pBlock->info.window.ekey) || (!ascScan && ekey >= pBlock->info.window.skey)) { @@ -1061,13 +1065,13 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe openWin.pos.pageId = pResult->pageId; openWin.pos.offset = pResult->offset; openWin.groupId = groupId; - SListNode* pn = tdListGetTail(pResultRowInfo->openWindow); + SListNode* pn = tdListGetTail(pResultRowInfo->openWindow); if (pn == NULL) { tdListAppend(pResultRowInfo->openWindow, &openWin); return openWin.pos; } - SOpenWindowInfo * px = (SOpenWindowInfo *)pn->data; + SOpenWindowInfo* px = (SOpenWindowInfo*)pn->data; if (px->pos.pageId != openWin.pos.pageId || px->pos.offset != openWin.pos.offset || px->groupId != openWin.groupId) { tdListAppend(pResultRowInfo->openWindow, &openWin); } @@ -1423,7 +1427,8 @@ bool doDeleteIntervalWindow(SAggSupporter* pAggSup, TSKEY ts, uint64_t groupId) return true; } -void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* pUpWins, SInterval* pInterval) { +void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* pDelWins, SInterval* pInterval, + SHashObj* pUpdatedMap) { SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* tsStarts = (TSKEY*)pStartCol->pData; SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); @@ -1433,9 +1438,12 @@ void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, TSDB_ORDER_ASC); doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]); - if (pUpWins) { - SWinKey winRes = {.ts = win.skey, .groupId = groupIds[i]}; - taosArrayPush(pUpWins, &winRes); + SWinKey winRes = {.ts = win.skey, .groupId = groupIds[i]}; + if (pDelWins) { + taosArrayPush(pDelWins, &winRes); + } + if (pUpdatedMap) { + taosHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey)); } } } @@ -1446,19 +1454,14 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* TSKEY* startTsCols = (TSKEY*)pStartTsCol->pData; SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); TSKEY* endTsCols = (TSKEY*)pEndTsCol->pData; - uint64_t* pGpDatas = NULL; - if (pBlock->info.type == STREAM_RETRIEVE) { - SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); - pGpDatas = (uint64_t*)pGpCol->pData; - } - int32_t step = 0; - int32_t startPos = 0; + SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* pGpDatas = (uint64_t*)pGpCol->pData; for (int32_t i = 0; i < pBlock->info.rows; i++) { SResultRowInfo dumyInfo; dumyInfo.cur.pageId = -1; STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCols[i], pInterval, TSDB_ORDER_ASC); while (win.ekey <= endTsCols[i]) { - uint64_t winGpId = pGpDatas ? pGpDatas[startPos] : pBlock->info.groupId; + uint64_t winGpId = pGpDatas[i]; bool res = doClearWindow(pAggSup, pSup1, (char*)&win.skey, sizeof(TSKEY), winGpId, numOfOutput); if (pUpWins && res) { SWinKey winRes = {.ts = win.skey, .groupId = winGpId}; @@ -1470,7 +1473,6 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval* } static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) { - void* pIte = NULL; size_t keyLen = 0; int32_t iter = 0; @@ -1571,13 +1573,10 @@ static void doBuildDeleteResult(SArray* pWins, int32_t* index, SSDataBlock* pBlo return; } blockDataEnsureCapacity(pBlock, size - *index); - SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); - SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t uid = 0; for (int32_t i = *index; i < size; i++) { SWinKey* pWin = taosArrayGet(pWins, i); - colDataAppend(pTsCol, pBlock->info.rows, (const char*)&pWin->ts, false); - colDataAppend(pGroupCol, pBlock->info.rows, (const char*)&pWin->groupId, false); - pBlock->info.rows++; + appendOneRow(pBlock, &pWin->ts, &pWin->ts, &uid, &pWin->groupId); (*index)++; } } @@ -1596,6 +1595,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, "single interval"); return pInfo->pDelRes; } @@ -1632,7 +1632,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { continue; } if (pBlock->info.type == STREAM_DELETE_DATA) { - doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval); + doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval, pUpdatedMap); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap); @@ -1707,6 +1707,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { taosHashCleanup(pUpdatedMap); doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, "single interval"); return pInfo->pDelRes; } @@ -1732,6 +1733,10 @@ void destroyIntervalOperatorInfo(void* param) { SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)param; cleanupBasicInfo(&pInfo->binfo); cleanupAggSup(&pInfo->aggSup); + cleanupExprSupp(&pInfo->scalarSupp); + + tdListFree(pInfo->binfo.resultRowInfo.openWindow); + pInfo->pRecycledPages = taosArrayDestroy(pInfo->pRecycledPages); pInfo->pInterpCols = taosArrayDestroy(pInfo->pInterpCols); taosArrayDestroyEx(pInfo->pPrevValues, freeItem); @@ -1828,14 +1833,17 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt return needed; } -void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup) { +void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup, SInterval* pInterval, + int64_t waterMark) { if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - // Todo(liuyao) support partition by column + initIntervalDownStream(downstream->pDownstream[0], type, pSup, pInterval, waterMark); return; } SStreamScanInfo* pScanInfo = downstream->info; - pScanInfo->sessionSup.parentType = type; - pScanInfo->sessionSup.pIntervalAggSup = pSup; + pScanInfo->windowSup.parentType = type; + pScanInfo->windowSup.pIntervalAggSup = pSup; + pScanInfo->pUpdateInfo = updateInfoInitP(pInterval, waterMark); + pScanInfo->interval = *pInterval; } void initStreamFunciton(SqlFunctionCtx* pCtx, int32_t numOfExpr) { @@ -1921,7 +1929,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL) { - initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup); + initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup, &pInfo->interval, + pInfo->twAggSup.waterMark); } code = appendDownstream(pOperator, &downstream, 1); @@ -2248,7 +2257,6 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp if (hasInterp) { pResBlock->info.rows += 1; } - } static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock) { @@ -2721,7 +2729,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi goto _error; } - int32_t num = 0; + int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); SSDataBlock* pResBlock = createResDataBlock(pStateNode->window.node.pOutputDataBlockDesc); int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId; @@ -2748,7 +2756,9 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi initBasicInfo(&pInfo->binfo, pResBlock); initResultRowInfo(&pInfo->binfo.resultRowInfo); - pInfo->twAggSup = (STimeWindowAggSupp){.waterMark = pStateNode->window.watermark, .calTrigger = pStateNode->window.triggerType};; + pInfo->twAggSup = + (STimeWindowAggSupp){.waterMark = pStateNode->window.watermark, .calTrigger = pStateNode->window.triggerType}; + ; initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); pInfo->tsSlotId = tsSlotId; @@ -2849,14 +2859,26 @@ _error: } void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int32_t numOfOutput, - SExecTaskInfo* pTaskInfo) { + SExecTaskInfo* pTaskInfo, SColumnInfoData* pTimeWindowData) { for (int32_t k = 0; k < numOfOutput; ++k) { if (fmIsWindowPseudoColumnFunc(pDestCtx[k].functionId)) { - continue; - } - int32_t code = TSDB_CODE_SUCCESS; - if (functionNeedToExecute(&pDestCtx[k]) && pDestCtx[k].fpSet.combine != NULL) { - code = pDestCtx[k].fpSet.combine(&pDestCtx[k], &pSourceCtx[k]); + if (!pTimeWindowData) { + continue; + } + + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pDestCtx[k]); + char* p = GET_ROWCELL_INTERBUF(pEntryInfo); + SColumnInfoData idata = {0}; + idata.info.type = TSDB_DATA_TYPE_BIGINT; + idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + idata.pData = p; + + SScalarParam out = {.columnData = &idata}; + SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData}; + pDestCtx[k].sfp.process(&tw, 1, &out); + pEntryInfo->numOfRes = 1; + } else if (functionNeedToExecute(&pDestCtx[k]) && pDestCtx[k].fpSet.combine != NULL) { + int32_t code = pDestCtx[k].fpSet.combine(&pDestCtx[k], &pSourceCtx[k]); if (code != TSDB_CODE_SUCCESS) { qError("%s apply functions error, code: %s", GET_TASKID(pTaskInfo), tstrerror(code)); pTaskInfo->code = code; @@ -2874,8 +2896,15 @@ bool hasIntervalWindow(SAggSupporter* pSup, TSKEY ts, uint64_t groupId) { return p1 != NULL; } +STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) { + STimeWindow w = {.skey = ts, .ekey = INT64_MAX}; + w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; + return w; +} + static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray, - int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SArray* pUpdated) { + int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, + SHashObj* pUpdatedMap) { int32_t size = taosArrayGetSize(pWinArray); if (!pInfo->pChildren) { return; @@ -2883,11 +2912,14 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr for (int32_t i = 0; i < size; i++) { SWinKey* pWinRes = taosArrayGet(pWinArray, i); SResultRow* pCurResult = NULL; - STimeWindow ParentWin = {.skey = pWinRes->ts, .ekey = pWinRes->ts + 1}; - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &ParentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx, + STimeWindow parentWin = getFinalTimeWindow(pWinRes->ts, &pInfo->interval); + if (isDeletedWindow(&parentWin, pWinRes->groupId, &pInfo->aggSup) && isCloseWindow(&parentWin, &pInfo->twAggSup)) { + continue; + } + setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &parentWin, true, &pCurResult, pWinRes->groupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); - bool find = true; + int32_t num = 0; for (int32_t j = 0; j < numOfChildren; j++) { SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, j); SIntervalAggOperatorInfo* pChInfo = pChildOp->info; @@ -2895,15 +2927,16 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr if (!hasIntervalWindow(&pChInfo->aggSup, pWinRes->ts, pWinRes->groupId)) { continue; } - find = true; + num++; SResultRow* pChResult = NULL; - setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, &ParentWin, true, &pChResult, pWinRes->groupId, + setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, &parentWin, true, &pChResult, pWinRes->groupId, pChildSup->pCtx, pChildSup->numOfExprs, pChildSup->rowEntryInfoOffset, &pChInfo->aggSup, pTaskInfo); - compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo); + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &parentWin, true); + compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData); } - if (find && pUpdated) { - saveResultRow(pCurResult, pWinRes->groupId, pUpdated); + if (num > 1 && pUpdatedMap) { + saveWinResultRow(pCurResult, pWinRes->groupId, pUpdatedMap); setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pInfo->binfo.resultRowInfo.cur); } } @@ -2912,7 +2945,7 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { SET_RES_WINDOW_KEY(pSup->keyBuf, &pWin->skey, sizeof(int64_t), groupId); SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, - GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); + GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); return p1 == NULL; } @@ -2934,12 +2967,6 @@ void addPullWindow(SHashObj* pMap, SWinKey* pWinRes, int32_t size) { static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } -STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) { - STimeWindow w = {.skey = ts, .ekey = INT64_MAX}; - w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1; - return w; -} - static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId, SHashObj* pUpdatedMap) { SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info; @@ -3043,7 +3070,7 @@ static void clearStreamIntervalOperator(SStreamFinalIntervalOperatorInfo* pInfo) tSimpleHashClear(pInfo->aggSup.pResultRowHashTable); clearDiskbasedBuf(pInfo->aggSup.pResultBuf); initResultRowInfo(&pInfo->binfo.resultRowInfo); - pInfo->aggSup.currentPageId = -1; + pInfo->aggSup.currentPageId = -1; } static void clearSpecialDataBlock(SSDataBlock* pBlock) { @@ -3126,6 +3153,31 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) { } } +static void addRetriveWindow(SArray* wins, SStreamFinalIntervalOperatorInfo* pInfo) { + int32_t size = taosArrayGetSize(wins); + for (int32_t i = 0; i < size; i++) { + SWinKey* winKey = taosArrayGet(wins, i); + STimeWindow nextWin = getFinalTimeWindow(winKey->ts, &pInfo->interval); + if (isCloseWindow(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) { + void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey)); + if (!chIds) { + SPullWindowInfo pull = {.window = nextWin, .groupId = winKey->groupId}; + // add pull data request + savePullWindow(&pull, pInfo->pPullWins); + int32_t size = taosArrayGetSize(pInfo->pChildren); + addPullWindow(pInfo->pPullDataMap, winKey, size); + qDebug("===stream===prepare retrive for delete %" PRId64 ", size:%d", winKey->ts, size); + } + } + } +} + +static void clearFunctionContext(SExprSupp* pSup) { + for (int32_t i = 0; i < pSup->numOfExprs; i++) { + pSup->pCtx[i].saveHandle.currentPage = -1; + } +} + static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info; @@ -3150,12 +3202,21 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pPullDataRes; } + doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); + if (pInfo->pDelRes->info.rows != 0) { + // process the rest of the data + printDataBlock(pInfo->pDelRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); + return pInfo->pDelRes; + } + doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); if (pInfo->binfo.pRes->info.rows == 0) { pOperator->status = OP_EXEC_DONE; if (!IS_FINAL_OP(pInfo)) { + clearFunctionContext(&pOperator->exprSupp); // semi interval operator clear disk buffer clearStreamIntervalOperator(pInfo); + qDebug("===stream===clear semi operator"); } else { freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf); } @@ -3219,23 +3280,28 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } removeResults(pUpWins, pUpdatedMap); copyDataBlock(pInfo->pUpdateRes, pBlock); - // copyUpdateDataBlock(pInfo->pUpdateRes, pBlock, pInfo->primaryTsIndex); pInfo->returnUpdate = true; taosArrayDestroy(pUpWins); break; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { - doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval); + SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); + doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, delWins, &pInfo->interval, pUpdatedMap); if (IS_FINAL_OP(pInfo)) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; SExprSupp* pChildSup = &pChildOp->exprSupp; - doDeleteSpecifyIntervalWindow(&pChildInfo->aggSup, pBlock, NULL, &pChildInfo->interval); - rebuildIntervalWindow(pInfo, pSup, pInfo->pDelWins, pInfo->binfo.pRes->info.groupId, - pOperator->exprSupp.numOfExprs, pOperator->pTaskInfo, pUpdated); + doDeleteSpecifyIntervalWindow(&pChildInfo->aggSup, pBlock, NULL, &pChildInfo->interval, NULL); + rebuildIntervalWindow(pInfo, pSup, delWins, pInfo->binfo.pRes->info.groupId, pOperator->exprSupp.numOfExprs, + pOperator->pTaskInfo, pUpdatedMap); + addRetriveWindow(delWins, pInfo); + taosArrayAddAll(pInfo->pDelWins, delWins); + taosArrayDestroy(delWins); continue; } - removeResults(pInfo->pDelWins, pUpdatedMap); + removeResults(delWins, pUpdatedMap); + taosArrayAddAll(pInfo->pDelWins, delWins); + taosArrayDestroy(delWins); break; } else if (pBlock->info.type == STREAM_GET_ALL && IS_FINAL_OP(pInfo)) { getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap); @@ -3309,6 +3375,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return pInfo->pPullDataRes; } + // we should send result first. doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); if (pInfo->binfo.pRes->info.rows != 0) { printDataBlock(pInfo->binfo.pRes, IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); @@ -3332,40 +3399,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return NULL; } -SSDataBlock* createSpecialDataBlock(EStreamType type) { - SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); - pBlock->info.hasVarCol = false; - pBlock->info.groupId = 0; - pBlock->info.rows = 0; - pBlock->info.type = type; - pBlock->info.rowSize = - sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY); - pBlock->info.watermark = INT64_MIN; - - pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData)); - SColumnInfoData infoData = {0}; - infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP; - infoData.info.bytes = sizeof(TSKEY); - // window start ts - taosArrayPush(pBlock->pDataBlock, &infoData); - // window end ts - taosArrayPush(pBlock->pDataBlock, &infoData); - - infoData.info.type = TSDB_DATA_TYPE_UBIGINT; - infoData.info.bytes = sizeof(uint64_t); - // uid - taosArrayPush(pBlock->pDataBlock, &infoData); - // group id - taosArrayPush(pBlock->pDataBlock, &infoData); - - // calculate start ts - taosArrayPush(pBlock->pDataBlock, &infoData); - // calculate end ts - taosArrayPush(pBlock->pDataBlock, &infoData); - - return pBlock; -} - SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; @@ -3470,7 +3503,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { - initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup); + initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, pInfo->twAggSup.waterMark); } code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -3567,10 +3600,18 @@ void initDummyFunction(SqlFunctionCtx* pDummy, SqlFunctionCtx* pCtx, int32_t num } void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, int64_t gap, int64_t waterMark, - uint16_t type) { - ASSERT(downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); + uint16_t type, int32_t tsColIndex) { + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION) { + SStreamPartitionOperatorInfo* pScanInfo = downstream->info; + pScanInfo->tsColIndex = tsColIndex; + } + + if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + initDownStream(downstream->pDownstream[0], pAggSup, gap, waterMark, type, tsColIndex); + return; + } SStreamScanInfo* pScanInfo = downstream->info; - pScanInfo->sessionSup = (SessionWindowSupporter){.pStreamAggSup = pAggSup, .gap = gap, .parentType = type}; + pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = gap, .parentType = type}; pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, waterMark); } @@ -3642,7 +3683,6 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh pInfo->isFinal = false; pInfo->pPhyNode = pPhyNode; pInfo->ignoreExpiredData = pSessionNode->window.igExpired; - pInfo->returnDelete = false; pOperator->name = "StreamSessionWindowAggOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION; @@ -3653,7 +3693,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, NULL, destroyStreamSessionAggOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); if (downstream) { - initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap, pInfo->twAggSup.waterMark, pOperator->operatorType); + initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap, pInfo->twAggSup.waterMark, pOperator->operatorType, + pInfo->primaryTsIndex); code = appendDownstream(pOperator, &downstream, 1); } return pOperator; @@ -3683,13 +3724,15 @@ bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap) { bool isInWindow(SResultWindowInfo* pWinInfo, TSKEY ts, int64_t gap) { return isInTimeWindow(&pWinInfo->win, ts, gap); } -static SResultWindowInfo* insertNewSessionWindow(SArray* pWinInfos, TSKEY ts, int32_t index) { - SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = ts, .win.ekey = ts, .isOutput = false}; +static SResultWindowInfo* insertNewSessionWindow(SArray* pWinInfos, TSKEY startTs, TSKEY endTs, int32_t index) { + SResultWindowInfo win = { + .pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false}; return taosArrayInsert(pWinInfos, index, &win); } -static SResultWindowInfo* addNewSessionWindow(SArray* pWinInfos, TSKEY ts) { - SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = ts, .win.ekey = ts, .isOutput = false}; +static SResultWindowInfo* addNewSessionWindow(SArray* pWinInfos, TSKEY startTs, TSKEY endTs) { + SResultWindowInfo win = { + .pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false}; return taosArrayPush(pWinInfos, &win); } @@ -3748,7 +3791,7 @@ SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY star int32_t size = taosArrayGetSize(pWinInfos); if (size == 0) { *pIndex = 0; - return addNewSessionWindow(pWinInfos, startTs); + return addNewSessionWindow(pWinInfos, startTs, endTs); } // find the first position which is smaller than the key int32_t index = binarySearch(pWinInfos, size, startTs, TSDB_ORDER_DESC, getSessionWindowEndkey); @@ -3774,10 +3817,10 @@ SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY star if (index == size - 1) { *pIndex = taosArrayGetSize(pWinInfos); - return addNewSessionWindow(pWinInfos, startTs); + return addNewSessionWindow(pWinInfos, startTs, endTs); } *pIndex = index + 1; - return insertNewSessionWindow(pWinInfos, startTs, index + 1); + return insertNewSessionWindow(pWinInfos, startTs, endTs, index + 1); } int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t groupId, @@ -3789,7 +3832,7 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, TS if (pWinInfo->win.skey > pStartTs[i]) { if (pStDeleted && pWinInfo->isOutput) { SWinKey res = {.ts = pWinInfo->win.skey, .groupId = groupId}; - taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey)); + taosHashPut(pStDeleted, &res, sizeof(SWinKey), &res, sizeof(SWinKey)); pWinInfo->isOutput = false; } pWinInfo->win.skey = pStartTs[i]; @@ -3903,11 +3946,12 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex, setWindowOutputBuf(pWinInfo, &pWinResult, pInfo->pDummyCtx, groupId, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->streamAggSup, pTaskInfo); pCurWin->win.ekey = TMAX(pCurWin->win.ekey, pWinInfo->win.ekey); - compactFunctions(pSup->pCtx, pInfo->pDummyCtx, numOfOutput, pTaskInfo); + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pCurWin->win, true); + compactFunctions(pSup->pCtx, pInfo->pDummyCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData); taosHashRemove(pStUpdated, &pWinInfo->pos, sizeof(SResultRowPosition)); if (pWinInfo->isOutput) { SWinKey res = {.ts = pWinInfo->win.skey, .groupId = groupId}; - taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey)); + taosHashPut(pStDeleted, &res, sizeof(SWinKey), &res, sizeof(SWinKey)); pWinInfo->isOutput = false; } taosArrayRemove(pInfo->streamAggSup.pCurWins, i); @@ -4004,10 +4048,11 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc if (!pCurWin) { break; } + SResultWindowInfo delWin = *pCurWin; deleteWindow(pAggSup->pCurWins, winIndex, fp); if (result) { - pCurWin->groupId = gpDatas[i]; - taosArrayPush(result, pCurWin); + delWin.groupId = gpDatas[i]; + taosArrayPush(result, &delWin); } } } @@ -4032,6 +4077,7 @@ static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup, ASSERT(isInWindow(pCurWin, tsCols[i], gap)); doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pSup, numOfOutput); if (result) { + pCurWin->groupId = gpCols[i]; taosArrayPush(result, pCurWin); } } @@ -4066,10 +4112,18 @@ void doBuildDeleteDataBlock(SHashObj* pStDeleted, SSDataBlock* pBlock, void** It size_t keyLen = 0; while (((*Ite) = taosHashIterate(pStDeleted, *Ite)) != NULL) { SWinKey* res = *Ite; - SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); - colDataAppend(pTsCol, pBlock->info.rows, (const char*)&res->ts, false); + SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + colDataAppend(pStartTsCol, pBlock->info.rows, (const char*)&res->ts, false); + SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + colDataAppend(pEndTsCol, pBlock->info.rows, (const char*)&res->ts, false); + SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); + colDataAppendNULL(pUidCol, pBlock->info.rows); SColumnInfoData* pGpCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); colDataAppend(pGpCol, pBlock->info.rows, (const char*)&res->groupId, false); + SColumnInfoData* pCalStCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + colDataAppendNULL(pCalStCol, pBlock->info.rows); + SColumnInfoData* pCalEdCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + colDataAppendNULL(pCalEdCol, pBlock->info.rows); pBlock->info.rows += 1; if (pBlock->info.rows + 1 >= pBlock->info.capacity) { break; @@ -4080,8 +4134,8 @@ void doBuildDeleteDataBlock(SHashObj* pStDeleted, SSDataBlock* pBlock, void** It } } -static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWinArray, int32_t groupId, - int32_t numOfOutput, SOperatorInfo* pOperator) { +static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWinArray, int32_t numOfOutput, + SOperatorInfo* pOperator, SHashObj* pStUpdated, bool needCreate) { SExprSupp* pSup = &pOperator->exprSupp; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -4091,9 +4145,16 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin for (int32_t i = 0; i < size; i++) { SResultWindowInfo* pParentWin = taosArrayGet(pWinArray, i); SResultRow* pCurResult = NULL; + uint64_t groupId = pParentWin->groupId; + int32_t winIndex = 0; + if (needCreate) { + pParentWin = + getSessionTimeWindow(&pInfo->streamAggSup, pParentWin->win.skey, pParentWin->win.ekey, groupId, 0, &winIndex); + } setWindowOutputBuf(pParentWin, &pCurResult, pSup->pCtx, groupId, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->streamAggSup, pTaskInfo); int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); + int32_t num = 0; for (int32_t j = 0; j < numOfChildren; j++) { SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j); SStreamSessionAggOperatorInfo* pChInfo = pChild->info; @@ -4109,15 +4170,24 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin SResultRow* pChResult = NULL; setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput, pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo); - compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo); + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pChWin->win, true); + compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData); SFilePage* bufPage = getBufPage(pChInfo->streamAggSup.pResultBuf, pChWin->pos.pageId); releaseBufPage(pChInfo->streamAggSup.pResultBuf, bufPage); + num++; continue; } else if (!pChWin->isClosed) { break; } } } + if (num == 0 && needCreate) { + deleteWindow(pInfo->streamAggSup.pCurWins, winIndex, NULL); + } + if (pStUpdated && num > 0) { + SWinKey value = {.ts = pParentWin->win.skey, .groupId = groupId}; + taosHashPut(pStUpdated, &pParentWin->pos, sizeof(SResultRowPosition), &value, sizeof(SWinKey)); + } SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId); ASSERT(size > 0); setBufPageDirty(bufPage, true); @@ -4197,7 +4267,46 @@ static void copyDeleteWindowInfo(SArray* pResWins, SHashObj* pStDeleted) { for (int32_t i = 0; i < size; i++) { SResultWindowInfo* pWinInfo = taosArrayGet(pResWins, i); SWinKey res = {.ts = pWinInfo->win.skey, .groupId = pWinInfo->groupId}; - taosHashPut(pStDeleted, &pWinInfo->pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey)); + taosHashPut(pStDeleted, &res, sizeof(SWinKey), &res, sizeof(SWinKey)); + } +} + +static void removeSessionResults(SHashObj* pHashMap, SArray* pWins) { + int32_t size = taosArrayGetSize(pWins); + for (int32_t i = 0; i < size; i++) { + SResultWindowInfo* pWin = taosArrayGet(pWins, i); + taosHashRemove(pHashMap, &pWin->pos, sizeof(SResultRowPosition)); + } +} + +int32_t compareWinKey(void* pKey, void* data, int32_t index) { + SArray* res = (SArray*)data; + SResKeyPos* pos = taosArrayGetP(res, index); + SWinKey* pData = (SWinKey*)pKey; + if (pData->ts == *(int64_t*)pos->key) { + if (pData->groupId > pos->groupId) { + return 1; + } else if (pData->groupId < pos->groupId) { + return -1; + } + return 0; + } else if (pData->ts > *(int64_t*)pos->key) { + return 1; + } + return -1; +} + +static void removeSessionDeleteResults(SArray* update, SHashObj* pStDeleted) { + int32_t size = taosHashGetSize(pStDeleted); + if (size == 0) { + return; + } + + int32_t num = taosArrayGetSize(update); + for (int32_t i = 0; i < num; i++) { + SResKeyPos* pos = taosArrayGetP(update, i); + SWinKey winKey = {.ts = *(int64_t*)pos->key, .groupId = pos->groupId}; + taosHashRemove(pStDeleted, &winKey, sizeof(SWinKey)); } } @@ -4225,7 +4334,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); SHashObj* pStUpdated = taosHashInit(64, hashFn, true, HASH_NO_LOCK); SOperatorInfo* downstream = pOperator->pDownstream[0]; - SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); + SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); // SResKeyPos while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { @@ -4243,7 +4352,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info; doClearSessionWindows(&pChildInfo->streamAggSup, &pChildOp->exprSupp, pBlock, START_TS_COLUMN_INDEX, pChildOp->exprSupp.numOfExprs, 0, NULL); - rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator); + rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, NULL, false); } taosArrayDestroy(pWins); continue; @@ -4257,9 +4366,10 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info; // gap must be 0 doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL, NULL); - rebuildTimeWindow(pInfo, pWins, pBlock->info.groupId, pOperator->exprSupp.numOfExprs, pOperator); + rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, pStUpdated, true); } copyDeleteWindowInfo(pWins, pInfo->pStDeleted); + removeSessionResults(pStUpdated, pWins); taosArrayDestroy(pWins); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { @@ -4302,6 +4412,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { pInfo->ignoreExpiredData, NULL); closeChildSessionWindow(pInfo->pChildren, pInfo->twAggSup.maxTs, pInfo->ignoreExpiredData, NULL); copyUpdateResult(pStUpdated, pUpdated); + removeSessionDeleteResults(pUpdated, pInfo->pStDeleted); taosHashCleanup(pStUpdated); finalizeUpdatedResult(pSup->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); @@ -4332,14 +4443,6 @@ static void clearStreamSessionOperator(SStreamSessionAggOperatorInfo* pInfo) { pInfo->streamAggSup.currentPageId = -1; } -static void removeSessionResults(SHashObj* pHashMap, SArray* pWins) { - int32_t size = taosArrayGetSize(pWins); - for (int32_t i = 0; i < size; i++) { - SResultWindowInfo* pWin = taosArrayGet(pWins, i); - taosHashRemove(pHashMap, &pWin->pos, sizeof(SResultRowPosition)); - } -} - static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { SStreamSessionAggOperatorInfo* pInfo = pOperator->info; SOptrBasicInfo* pBInfo = &pInfo->binfo; @@ -4348,30 +4451,35 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { if (pOperator->status == OP_EXEC_DONE) { return NULL; - } else if (pOperator->status == OP_RES_TO_RETURN) { + } + + { doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows > 0) { printDataBlock(pBInfo->pRes, "semi session"); return pBInfo->pRes; } - // doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); - if (pInfo->pDelRes->info.rows > 0 && !pInfo->returnDelete) { - pInfo->returnDelete = true; + doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); + if (pInfo->pDelRes->info.rows > 0) { printDataBlock(pInfo->pDelRes, "semi session"); return pInfo->pDelRes; } - if (pInfo->pUpdateRes->info.rows > 0) { + if (pInfo->pUpdateRes->info.rows > 0 && pInfo->returnUpdate) { + pInfo->returnUpdate = false; // process the rest of the data - pOperator->status = OP_OPENED; printDataBlock(pInfo->pUpdateRes, "semi session"); return pInfo->pUpdateRes; } - // semi interval operator clear disk buffer - clearStreamSessionOperator(pInfo); - pOperator->status = OP_EXEC_DONE; - return NULL; + + if (pOperator->status == OP_RES_TO_RETURN) { + clearFunctionContext(&pOperator->exprSupp); + // semi interval operator clear disk buffer + clearStreamSessionOperator(pInfo); + pOperator->status = OP_EXEC_DONE; + return NULL; + } } _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); @@ -4382,6 +4490,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { clearSpecialDataBlock(pInfo->pUpdateRes); + pOperator->status = OP_RES_TO_RETURN; break; } printDataBlock(pBlock, "semi session recv"); @@ -4392,12 +4501,15 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { removeSessionResults(pStUpdated, pWins); taosArrayDestroy(pWins); copyDataBlock(pInfo->pUpdateRes, pBlock); + pInfo->returnUpdate = true; break; } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { // gap must be 0 - doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, NULL, NULL); - copyDataBlock(pInfo->pDelRes, pBlock); - pInfo->pDelRes->info.type = STREAM_DELETE_RESULT; + SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); + doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, NULL); + copyDeleteWindowInfo(pWins, pInfo->pStDeleted); + removeSessionResults(pStUpdated, pWins); + taosArrayDestroy(pWins); break; } else if (pBlock->info.type == STREAM_GET_ALL) { getAllSessionWindow(pInfo->streamAggSup.pResultRows, pUpdated, getResWinForSession); @@ -4410,18 +4522,15 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { } // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); - doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, pInfo->pStDeleted, false); + doStreamSessionAggImpl(pOperator, pBlock, pStUpdated, NULL, false); maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); } pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); pBInfo->pRes->info.watermark = pInfo->twAggSup.maxTs; - // restore the value - pOperator->status = OP_RES_TO_RETURN; - // semi operator - // closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, - // getResWinForSession); + copyUpdateResult(pStUpdated, pUpdated); + removeSessionDeleteResults(pUpdated, pInfo->pStDeleted); taosHashCleanup(pStUpdated); finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, @@ -4435,16 +4544,15 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { return pBInfo->pRes; } - // doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); - if (pInfo->pDelRes->info.rows > 0 && !pInfo->returnDelete) { - pInfo->returnDelete = true; + doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); + if (pInfo->pDelRes->info.rows > 0) { printDataBlock(pInfo->pDelRes, "semi session"); return pInfo->pDelRes; } - if (pInfo->pUpdateRes->info.rows > 0) { + if (pInfo->pUpdateRes->info.rows > 0 && pInfo->returnUpdate) { + pInfo->returnUpdate = false; // process the rest of the data - pOperator->status = OP_OPENED; printDataBlock(pInfo->pUpdateRes, "semi session"); return pInfo->pUpdateRes; } @@ -4668,7 +4776,7 @@ int32_t updateStateWindowInfo(SArray* pWinInfos, int32_t winIndex, TSKEY* pTs, u if (pWinInfo->winInfo.win.skey > pTs[i]) { if (pSeDeleted && pWinInfo->winInfo.isOutput) { SWinKey res = {.ts = pWinInfo->winInfo.win.skey, .groupId = groupId}; - taosHashPut(pSeDeleted, &pWinInfo->winInfo.pos, sizeof(SResultRowPosition), &res, sizeof(SWinKey)); + taosHashPut(pSeDeleted, &res, sizeof(SWinKey), &res, sizeof(SWinKey)); pWinInfo->winInfo.isOutput = false; } pWinInfo->winInfo.win.skey = pTs[i]; @@ -4736,8 +4844,8 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, groupId, pKeyColInfo, pSDataBlock->info.rows, i, &allEqual, pStDeleted); if (!allEqual) { - appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, GROUPID_COLUMN_INDEX, - &groupId); + uint64_t uid = 0; + appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, &uid, &groupId); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo); continue; @@ -4766,6 +4874,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { SExprSupp* pSup = &pOperator->exprSupp; SStreamStateAggOperatorInfo* pInfo = pOperator->info; SOptrBasicInfo* pBInfo = &pInfo->binfo; + int64_t maxTs = INT64_MIN; if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { @@ -4798,6 +4907,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, destroyStateWinInfo); copyDeleteWindowInfo(pWins, pInfo->pSeDeleted); + removeSessionResults(pSeUpdated, pWins); taosArrayDestroy(pWins); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { @@ -4812,8 +4922,9 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); doStreamStateAggImpl(pOperator, pBlock, pSeUpdated, pInfo->pSeDeleted); - pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); + maxTs = TMAX(maxTs, pBlock->info.window.ekey); } + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs); // restore the value pOperator->status = OP_RES_TO_RETURN; @@ -4912,7 +5023,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, NULL, destroyStreamStateOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); - initDownStream(downstream, &pInfo->streamAggSup, 0, pInfo->twAggSup.waterMark, pOperator->operatorType); + initDownStream(downstream, &pInfo->streamAggSup, 0, pInfo->twAggSup.waterMark, pOperator->operatorType, + pInfo->primaryTsIndex); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -4941,8 +5053,8 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui SExprSupp* pSup = &pOperatorInfo->exprSupp; SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &wstartTs, TSDB_KEYSIZE, tableGroupId); - SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, - GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet( + iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); ASSERT(p1 != NULL); finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pSup->pCtx, pSup->pExprInfo, pSup->numOfExprs, @@ -5151,11 +5263,11 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprSupp* pSup = &pOperator->exprSupp; miaInfo->pCondition = pNode->window.node.pConditions; - miaInfo->curTs = INT64_MIN; - iaInfo->win = pTaskInfo->window; - iaInfo->inputOrder = TSDB_ORDER_ASC; - iaInfo->interval = interval; - iaInfo->execModel = pTaskInfo->execModel; + miaInfo->curTs = INT64_MIN; + iaInfo->win = pTaskInfo->window; + iaInfo->inputOrder = TSDB_ORDER_ASC; + iaInfo->interval = interval; + iaInfo->execModel = pTaskInfo->execModel; iaInfo->primaryTsIndex = ((SColumnNode*)pNode->window.pTspk)->slotId; iaInfo->binfo.mergeResultBlock = pNode->window.mergeDataBlock; @@ -5178,12 +5290,12 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, initResultRowInfo(&iaInfo->binfo.resultRowInfo); blockDataEnsureCapacity(iaInfo->binfo.pRes, pOperator->resultInfo.capacity); - pOperator->name = "TimeMergeAlignedIntervalAggOperator"; + pOperator->name = "TimeMergeAlignedIntervalAggOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->pTaskInfo = pTaskInfo; - pOperator->info = miaInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->pTaskInfo = pTaskInfo; + pOperator->info = miaInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, NULL, destroyMergeAlignedIntervalOperatorInfo, NULL, NULL, NULL); @@ -5236,8 +5348,8 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table SExprSupp* pExprSup = &pOperatorInfo->exprSupp; SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId); - SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, - GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet( + iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); ASSERT(p1 != NULL); finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); @@ -5462,10 +5574,10 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge pMergeIntervalInfo->groupIntervals = tdListNew(sizeof(SGroupTimeWindow)); SIntervalAggOperatorInfo* pIntervalInfo = &pMergeIntervalInfo->intervalAggOperatorInfo; - pIntervalInfo->win = pTaskInfo->window; + pIntervalInfo->win = pTaskInfo->window; pIntervalInfo->inputOrder = TSDB_ORDER_ASC; - pIntervalInfo->interval = interval; - pIntervalInfo->execModel = pTaskInfo->execModel; + pIntervalInfo->interval = interval; + pIntervalInfo->execModel = pTaskInfo->execModel; pIntervalInfo->binfo.mergeResultBlock = pIntervalPhyNode->window.mergeDataBlock; pIntervalInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; @@ -5482,7 +5594,6 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge initBasicInfo(&pIntervalInfo->binfo, pResBlock); initExecTimeWindowInfo(&pIntervalInfo->twAggSup.timeWindowData, &pIntervalInfo->win); - pIntervalInfo->timeWindowInterpo = timeWindowinterpNeeded(pExprSupp->pCtx, num, pIntervalInfo); if (pIntervalInfo->timeWindowInterpo) { pIntervalInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo)); @@ -5493,12 +5604,12 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo); - pOperator->name = "TimeMergeIntervalAggOperator"; + pOperator->name = "TimeMergeIntervalAggOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->pTaskInfo = pTaskInfo; - pOperator->info = pMergeIntervalInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->pTaskInfo = pTaskInfo; + pOperator->info = pMergeIntervalInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, NULL, destroyMergeIntervalOperatorInfo, NULL, NULL, NULL); diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index 8cd376e0920c2c1e4bfaf89a2d3a087c7cf0ac5a..84b615af7a93aef9fbf86190a2544474b7b2c87b 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -295,11 +295,7 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke } if (*pIter == (void *)GET_SHASH_NODE_DATA(pNode)) { - if (!pPrev) { - *pIter = NULL; - } else { - *pIter = GET_SHASH_NODE_DATA(pPrev); - } + *pIter = pPrev ? GET_SHASH_NODE_DATA(pPrev) : NULL; } FREE_HASH_NODE(pNode); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 168cd21c4478d9c1b50053fadf0e9dcdf518d4f4..63fc9d9e1c553bc210c7f525b014cd3d0b4f852b 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -227,9 +227,9 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int continue; } - SPageInfo* pPgInfo = *(SPageInfo**)taosArrayGet(pSource->pageIdList, pSource->pageIndex); + int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex); - void* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo)); + void* pPage = getBufPage(pHandle->pBuf, *pPgId); code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; @@ -302,9 +302,9 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT pSource->pageIndex = -1; pSource->src.pBlock = blockDataDestroy(pSource->src.pBlock); } else { - SPageInfo* pPgInfo = *(SPageInfo**)taosArrayGet(pSource->pageIdList, pSource->pageIndex); + int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex); - void* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo)); + void* pPage = getBufPage(pHandle->pBuf, *pPgId); int32_t code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index b7cd02befd326eafd7b0a9354a3f5c50147d834b..648ae5a538caed9fdb896bc4f1e6fe7537a7948a 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -311,6 +311,22 @@ static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateMinMax(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_TIMESTAMP_TYPE(paraType) && !IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } else if (IS_NULL_TYPE(paraType)) { + paraType = TSDB_DATA_TYPE_BIGINT; + } + + pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isLtrim) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -698,7 +714,7 @@ static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -713,7 +729,7 @@ static int32_t translateSpreadImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (isPartial) { - if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } pFunc->node.resType = (SDataType){.bytes = getSpreadInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; @@ -788,7 +804,7 @@ static int32_t translateElapsedImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1634,7 +1650,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (!IS_SIGNED_NUMERIC_TYPE(colType) && !IS_FLOAT_TYPE(colType) && TSDB_DATA_TYPE_BOOL != colType && - TSDB_DATA_TYPE_TIMESTAMP != colType) { + !IS_TIMESTAMP_TYPE(colType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1660,7 +1676,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { } uint8_t resType; - if (IS_SIGNED_NUMERIC_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType || TSDB_DATA_TYPE_TIMESTAMP == colType) { + if (IS_SIGNED_NUMERIC_TYPE(colType) || IS_TIMESTAMP_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType) { resType = TSDB_DATA_TYPE_BIGINT; } else { resType = TSDB_DATA_TYPE_DOUBLE; @@ -1825,7 +1841,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l // param0 uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1878,7 +1894,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; - if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || + if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && !IS_TIMESTAMP_TYPE(para1Type)) || !IS_INTEGER_TYPE(para2Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1911,7 +1927,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le for (int32_t i = 0; i < 2; ++i) { uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type; - if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } } @@ -2060,7 +2076,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "min", .type = FUNCTION_TYPE_MIN, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC, - .translateFunc = translateInOutNum, + .translateFunc = translateMinMax, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -2075,7 +2091,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "max", .type = FUNCTION_TYPE_MAX, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC, - .translateFunc = translateInOutNum, + .translateFunc = translateMinMax, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index b71d06231e78c4edd904dd72d546284b51dd89ac..dcf58759b01755f545f5b70f1b811218995fd2c2 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -76,11 +76,11 @@ typedef struct STopBotResItem { } STopBotResItem; typedef struct STopBotRes { - int32_t maxSize; - int16_t type; + int32_t maxSize; + int16_t type; - STuplePos nullTuplePos; - bool nullTupleSaved; + STuplePos nullTuplePos; + bool nullTupleSaved; STopBotResItem* pItems; } STopBotRes; @@ -223,14 +223,14 @@ typedef struct SMavgInfo { } SMavgInfo; typedef struct SSampleInfo { - int32_t samples; - int32_t totalPoints; - int32_t numSampled; - uint8_t colType; - int16_t colBytes; + int32_t samples; + int32_t totalPoints; + int32_t numSampled; + uint8_t colType; + int16_t colBytes; - STuplePos nullTuplePos; - bool nullTupleSaved; + STuplePos nullTuplePos; + bool nullTupleSaved; char* data; STuplePos* tuplePos; @@ -1147,7 +1147,7 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { } static STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock); -static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); +static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos); static const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos); static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, const char* tval) { @@ -1160,6 +1160,7 @@ static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, c } ASSERT(0); + return 0; } int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { @@ -1203,7 +1204,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } else { - if (IS_SIGNED_NUMERIC_TYPE(type)) { + if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type)) { int64_t prev = 0; GET_TYPED_DATA(prev, int64_t, type, &pBuf->v); @@ -1215,7 +1216,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock); } } - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { uint64_t prev = 0; GET_TYPED_DATA(prev, uint64_t, type, &pBuf->v); @@ -1263,7 +1263,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; - if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { + if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) { int8_t* pData = (int8_t*)pCol->pData; int8_t* val = (int8_t*)&pBuf->v; @@ -1357,7 +1357,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { numOfElems += 1; } - } else if (type == TSDB_DATA_TYPE_BIGINT) { + } else if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_TIMESTAMP) { int64_t* pData = (int64_t*)pCol->pData; int64_t* val = (int64_t*)&pBuf->v; @@ -1580,7 +1580,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { } _min_max_over: - if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved ) { + if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) { pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock); pBuf->nullTupleSaved = true; } @@ -1600,7 +1600,8 @@ int32_t maxFunction(SqlFunctionCtx* pCtx) { } static void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex); -static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex); +static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, + int32_t rowIndex); int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx); @@ -1650,7 +1651,7 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple if (pCtx->saveHandle.pBuf != NULL) { if (pTuplePos->pageId != -1) { - int32_t numOfCols = pCtx->subsidiaries.num; + int32_t numOfCols = pCtx->subsidiaries.num; const char* p = loadTupleData(pCtx, pTuplePos); bool* nullList = (bool*)p; @@ -1659,7 +1660,7 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple // todo set the offset value to optimize the performance. for (int32_t j = 0; j < numOfCols; ++j) { SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; - int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); @@ -1700,7 +1701,7 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos) char* pData = colDataGetData(pSrcCol, rowIndex); // append to dest col - int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; SColumnInfoData* pDstCol = taosArrayGet(pCtx->pDstBlock->pDataBlock, dstSlotId); ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes); @@ -1711,7 +1712,6 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos) colDataAppend(pDstCol, pos, pData, false); } } - } void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) { @@ -2589,8 +2589,8 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo* memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); - qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, - pHisto->numOfEntries, pHisto); + qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, pHisto->numOfEntries, + pHisto); } else { pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); qDebug("%s input histogram, elem:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, @@ -2600,8 +2600,8 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo* memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN); pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo)); - qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, - pHisto->numOfEntries, pHisto); + qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, pHisto->numOfEntries, + pHisto); tHistogramDestroy(&pRes); } } @@ -2628,8 +2628,8 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { } if (pInfo->algo != APERCT_ALGO_TDIGEST) { - qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, - pInfo->pHisto); + qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, + pInfo->pHisto->numOfEntries, pInfo->pHisto); } SET_VAL(pResInfo, 1, 1); @@ -2708,7 +2708,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) } EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow) { - SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*) pRes; + SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*)pRes; // not initialized yet, data is required if (pEntry == NULL) { @@ -2751,7 +2751,8 @@ static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowInde return *(TSKEY*)colDataGetData(pTsColInfo, rowIndex); } -static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx, SFirstLastRes* pInfo) { +static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx, + SFirstLastRes* pInfo) { if (pCtx->subsidiaries.num <= 0) { return; } @@ -3175,7 +3176,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) { switch (type) { case TSDB_DATA_TYPE_BOOL: - pDiffInfo->prev.i64 = *(bool*)pv? 1:0; + pDiffInfo->prev.i64 = *(bool*)pv ? 1 : 0; break; case TSDB_DATA_TYPE_TINYINT: pDiffInfo->prev.i64 = *(int8_t*)pv; @@ -3536,7 +3537,8 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData * |(n columns, one bit for each column)| src column #1| src column #2| * +------------------------------------+--------------+--------------+ */ -void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies, char* buf) { +void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies, + char* buf) { char* nullList = buf; char* pStart = (char*)(nullList + sizeof(bool) * pSubsidiaryies->num); @@ -3584,7 +3586,7 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf } } - p = (STuplePos) {.pageId = pHandle->currentPage, .offset = pPage->num}; + p = (STuplePos){.pageId = pHandle->currentPage, .offset = pPage->num}; memcpy(pPage->data + pPage->num, pBuf, length); pPage->num += length; @@ -3620,7 +3622,6 @@ static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf setBufPageDirty(pPage, true); releaseBufPage(pHandle->pBuf, pPage); } else { - } return TSDB_CODE_SUCCESS; @@ -3635,7 +3636,7 @@ static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSD static char* doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPos) { if (pHandle->pBuf != NULL) { SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId); - char* p = pPage->data + pPos->offset; + char* p = pPage->data + pPos->offset; releaseBufPage(pHandle->pBuf, pPage); return p; } else { @@ -3979,8 +3980,8 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) { } if (pCtx->end.key == INT64_MIN) { - pInfo->min = (pInfo->min > ptsList[start + pInput->numOfRows - 1]) ? - ptsList[start + pInput->numOfRows - 1] : pInfo->min; + pInfo->min = + (pInfo->min > ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->min; } else { pInfo->min = pCtx->end.key; } @@ -3992,8 +3993,8 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) { } if (pCtx->end.key == INT64_MIN) { - pInfo->max = (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? - ptsList[start + pInput->numOfRows - 1] : pInfo->max; + pInfo->max = + (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->max; } else { pInfo->max = pCtx->end.key + 1; } diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 152a970c48eb5fb374f8806062d264e53b88f664..26735fa263cfed15ead940493b3c1eadf0e29c70 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -101,6 +101,14 @@ bool fmIsBuiltinFunc(const char* pFunc) { return NULL != taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc)); } +EFunctionType fmGetFuncType(const char* pFunc) { + void* pVal = taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc)); + if (NULL != pVal) { + return funcMgtBuiltins[*(int32_t*)pVal].type; + } + return FUNCTION_TYPE_UDF; +} + EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) { return FUNC_DATA_REQUIRED_DATA_LOAD; diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index d5a3e91eeaa63723029617dfc7be1f72679508bd..5de9c52cc1d0f85c268d86a8e54d184a37c55df3 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -81,7 +81,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { taosDirName(path); #endif } else { - strncpy(path, tsProcPath, strlen(tsProcPath)); + strncpy(path, tsProcPath, PATH_MAX); taosDirName(path); } #ifdef WINDOWS diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 5b27e030b92b03a3450cf2a864a406209c1a9dcd..a45e4585e8655d318a440e3357d50df2d2513e2c 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -453,7 +453,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { goto _return; } taosCloseFile(&file); - strncpy(udf->path, path, strlen(path)); + strncpy(udf->path, path, PATH_MAX); tFreeSFuncInfo(pFuncInfo); taosArrayDestroy(retrieveRsp.pFuncInfos); msgInfo->code = 0; @@ -566,17 +566,17 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { uv_dlsym(&udf->lib, processFuncName, (void **)(&udf->aggProcFunc)); char startFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; char *startSuffix = "_start"; - strncpy(startFuncName, processFuncName, strlen(processFuncName)); + strncpy(startFuncName, processFuncName, sizeof(startFuncName)); strncat(startFuncName, startSuffix, strlen(startSuffix)); uv_dlsym(&udf->lib, startFuncName, (void **)(&udf->aggStartFunc)); char finishFuncName[TSDB_FUNC_NAME_LEN + 7] = {0}; char *finishSuffix = "_finish"; - strncpy(finishFuncName, processFuncName, strlen(processFuncName)); + strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); strncat(finishFuncName, finishSuffix, strlen(finishSuffix)); uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggFinishFunc)); char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; char *mergeSuffix = "_merge"; - strncpy(finishFuncName, processFuncName, strlen(processFuncName)); + strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); strncat(finishFuncName, mergeSuffix, strlen(mergeSuffix)); uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggMergeFunc)); } diff --git a/source/libs/index/inc/indexInt.h b/source/libs/index/inc/indexInt.h index 065f4acb576263d1f7d5cbe8238273dc325ccb09..9605528ad6ae150fd88f512cdf5344b81d486a99 100644 --- a/source/libs/index/inc/indexInt.h +++ b/source/libs/index/inc/indexInt.h @@ -40,26 +40,31 @@ extern "C" { #define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("IDX", DEBUG_TRACE, idxDebugFlag, __VA_ARGS__);} } while (0) // clang-format on +extern void* indexQhandle; + typedef enum { LT, LE, GT, GE, CONTAINS, EQ } RangeType; typedef enum { kTypeValue, kTypeDeletion } STermValueType; typedef enum { kRebuild, kFinished } SIdxStatus; typedef struct SIndexStat { - int32_t totalAdded; // - int32_t totalDeled; // - int32_t totalUpdated; // - int32_t totalTerms; // - int32_t distinctCol; // distinct column + int32_t total; + int32_t add; // + int32_t del; // + int32_t update; // + int32_t terms; // + int32_t distCol; // distinct column } SIndexStat; struct SIndex { + SIndexOpts opts; + int64_t refId; void* cache; void* tindex; SHashObj* colObj; // < field name, field id> - int64_t suid; // current super table id, -1 is normal table - int32_t cVersion; // current version allocated to cache + int64_t suid; // current super table id, -1 is normal table + int32_t version; // current version allocated to cache SLRUCache* lru; char* path; @@ -68,7 +73,6 @@ struct SIndex { TdThreadMutex mtx; tsem_t sem; bool quit; - SIndexOpts opts; }; struct SIndexMultiTermQuery { @@ -111,14 +115,15 @@ typedef struct Iterate { void iterateValueDestroy(IterateValue* iv, bool destroy); -extern void* indexQhandle; - typedef struct TFileCacheKey { uint64_t suid; uint8_t colType; char* colName; int32_t nColName; } ICacheKey; + +int32_t idxSerialCacheKey(ICacheKey* key, char* buf); + int idxFlushCacheToTFile(SIndex* sIdx, void*, bool quit); int64_t idxAddRef(void* p); @@ -126,10 +131,6 @@ int32_t idxRemoveRef(int64_t ref); void idxAcquireRef(int64_t ref); void idxReleaseRef(int64_t ref); -int32_t idxSerialCacheKey(ICacheKey* key, char* buf); -// int32_t indexSerialKey(ICacheKey* key, char* buf); -// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf); - #define IDX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0) #define IDX_TYPE_GET_TYPE(ty) (ty & 0x0F) diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index be64a8b44d28a76a0b04a78b3940bcb0c86101da..d9a6b80f3d9762aa778d1167833a76255eafb932 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -25,10 +25,6 @@ #include "tref.h" #include "tsched.h" -#ifdef USE_LUCENE -#include "lucene++/Lucene_c.h" -#endif - #define INDEX_NUM_OF_THREADS 5 #define INDEX_QUEUE_SIZE 200 @@ -74,7 +70,7 @@ void indexCleanup() { typedef struct SIdxColInfo { int colId; // generated by index internal - int cVersion; + int version; } SIdxColInfo; static TdThreadOnce isInit = PTHREAD_ONCE_INIT; @@ -123,7 +119,7 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { } idx->colObj = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - idx->cVersion = 1; + idx->version = 1; idx->path = tstrdup(path); taosThreadMutexInit(&idx->mtx, NULL); tsem_init(&idx->sem, 0, 0); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index 794b85d244f875b6874855ac6a36a7500114afd5..7e867db755c658abad341e8fa59cd6687ef9b959 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -566,7 +566,6 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { taosThreadMutexUnlock(&pCache->mtx); idxCacheUnRef(pCache); return 0; - // encode end } void idxCacheForceToMerge(void* cache) { IndexCache* pCache = cache; @@ -602,10 +601,10 @@ static int32_t idxQueryMem(MemTable* mem, SIndexTermQuery* query, SIdxTRslt* tr, } } int idxCacheSearch(void* cache, SIndexTermQuery* query, SIdxTRslt* result, STermValueType* s) { - int64_t st = taosGetTimestampUs(); if (cache == NULL) { return 0; } + IndexCache* pCache = cache; MemTable *mem = NULL, *imm = NULL; @@ -616,6 +615,8 @@ int idxCacheSearch(void* cache, SIndexTermQuery* query, SIdxTRslt* result, STerm idxMemRef(imm); taosThreadMutexUnlock(&pCache->mtx); + int64_t st = taosGetTimestampUs(); + int ret = (mem && mem->mem) ? idxQueryMem(mem, query, result, s) : 0; if (ret == 0 && *s != kTypeDeletion) { // continue search in imm diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 4f33d98f9e4f7e5b210922b0dd6da0b5448d4472..691eb6771cfb0de12fe0328129dfa153b3eece8c 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -171,15 +171,16 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d return tDoCompare(func, cmptype, &va, &vb); } assert(0); + return BREAK; #endif } TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) { // optime later int32_t ret = func(a, b); switch (comparType) { - case QUERY_LESS_THAN: { + case QUERY_LESS_THAN: if (ret < 0) return MATCH; - } break; + break; case QUERY_LESS_EQUAL: { if (ret <= 0) return MATCH; break; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 75844ce76f1cb50d6847709309dae1ed3f77bf70..e7f221de3d16ed0186f630ebdfe412f77d440dc3 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -27,6 +27,44 @@ #define SIF_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define SIF_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) // clang-format on + +typedef union { + uint8_t u8; + uint16_t u16; + uint32_t u32; + uint64_t u64; + + int8_t i8; + int16_t i16; + int32_t i32; + int64_t i64; + + double d; + float f; +} SDataTypeBuf; + +#define SIF_DATA_CONVERT(type, val, dst) \ + do { \ + if (type == TSDB_DATA_TYPE_DOUBLE) \ + dst = GET_DOUBLE_VAL(val); \ + else if (type == TSDB_DATA_TYPE_BIGINT) \ + dst = *(int64_t *)val; \ + else if (type == TSDB_DATA_TYPE_INT) \ + dst = *(int32_t *)val; \ + else if (type == TSDB_DATA_TYPE_SMALLINT) \ + dst = *(int16_t *)val; \ + else if (type == TSDB_DATA_TYPE_TINYINT) \ + dst = *(int8_t *)val; \ + else if (type == TSDB_DATA_TYPE_UTINYINT) \ + dst = *(uint8_t *)val; \ + else if (type == TSDB_DATA_TYPE_USMALLINT) \ + dst = *(uint16_t *)val; \ + else if (type == TSDB_DATA_TYPE_UINT) \ + dst = *(uint32_t *)val; \ + else if (type == TSDB_DATA_TYPE_UBIGINT) \ + dst = *(uint64_t *)val; \ + } while (0); + typedef struct SIFParam { SHashObj *pFilter; @@ -48,7 +86,6 @@ typedef struct SIFCtx { SHashObj *pRes; /* element is SIFParam */ bool noExec; // true: just iterate condition tree, and add hint to executor plan SIndexMetaArg arg; - // SIdxFltStatus st; } SIFCtx; static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) { @@ -75,11 +112,6 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) { typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output); static sif_func_t sifNullFunc = NULL; -// typedef struct SIFWalkParm -// construct tag filter operator later -// static void destroyTagFilterOperatorInfo(void *param) { -// STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; -//} static void sifFreeParam(SIFParam *param) { if (param == NULL) return; @@ -365,42 +397,6 @@ static Filter sifGetFilterFunc(EIndexQueryType type, bool *reverse) { } return NULL; } -typedef union { - uint8_t u8; - uint16_t u16; - uint32_t u32; - uint64_t u64; - - int8_t i8; - int16_t i16; - int32_t i32; - int64_t i64; - - double d; - float f; -} SDataTypeBuf; - -#define SIF_DATA_CONVERT(type, val, dst) \ - do { \ - if (type == TSDB_DATA_TYPE_DOUBLE) \ - dst = GET_DOUBLE_VAL(val); \ - else if (type == TSDB_DATA_TYPE_BIGINT) \ - dst = *(int64_t *)val; \ - else if (type == TSDB_DATA_TYPE_INT) \ - dst = *(int32_t *)val; \ - else if (type == TSDB_DATA_TYPE_SMALLINT) \ - dst = *(int16_t *)val; \ - else if (type == TSDB_DATA_TYPE_TINYINT) \ - dst = *(int8_t *)val; \ - else if (type == TSDB_DATA_TYPE_UTINYINT) \ - dst = *(uint8_t *)val; \ - else if (type == TSDB_DATA_TYPE_USMALLINT) \ - dst = *(uint16_t *)val; \ - else if (type == TSDB_DATA_TYPE_UINT) \ - dst = *(uint32_t *)val; \ - else if (type == TSDB_DATA_TYPE_UBIGINT) \ - dst = *(uint64_t *)val; \ - } while (0); static void sifSetFltParam(SIFParam *left, SIFParam *right, SDataTypeBuf *typedata, SMetaFltParam *param) { int8_t ltype = left->colValType, rtype = right->colValType; @@ -693,11 +689,8 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou for (int32_t m = 0; m < node->pParameterList->length; m++) { if (node->condType == LOGIC_COND_TYPE_AND) { taosArrayAddAll(output->result, params[m].result); - // taosArrayDestroy(params[m].result); - // params[m].result = NULL; } else if (node->condType == LOGIC_COND_TYPE_OR) { taosArrayAddAll(output->result, params[m].result); - // params[m].result = NULL; } else if (node->condType == LOGIC_COND_TYPE_NOT) { // taosArrayAddAll(output->result, params[m].result); } diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 4f278c7af6adfa8ed4e890b06944d5d5c9560f43..e6d1edfeda1972821c3c1d1341c65a0ebdd6bee8 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -39,7 +39,8 @@ static void idxGenLRUKey(char* buf, const char* path, int32_t blockId) { } static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) { if (ctx->type == TFILE) { - assert(len == taosWriteFile(ctx->file.pFile, buf, len)); + int nwr = taosWriteFile(ctx->file.pFile, buf, len); + assert(nwr == len); } else { memcpy(ctx->mem.buf + ctx->offset, buf, len); } @@ -210,9 +211,7 @@ IdxFstFile* idxFileCreate(void* wrt) { return cw; } void idxFileDestroy(IdxFstFile* cw) { - // free wrt object: close fd or free mem idxFileFlush(cw); - // idxFileCtxDestroy((IFileCtx *)(cw->wrt)); taosMemoryFree(cw); } @@ -221,10 +220,8 @@ int idxFileWrite(IdxFstFile* write, uint8_t* buf, uint32_t len) { return 0; } // update checksum - // write data to file/socket or mem IFileCtx* ctx = write->wrt; - - int nWrite = ctx->write(ctx, buf, len); + int nWrite = ctx->write(ctx, buf, len); assert(nWrite == len); write->count += len; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 0a47fc0f167a359b35952f0c1e88af03d544c95d..48a0c631cf1af64f9a4676567a827accc4261226 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -183,13 +183,14 @@ TFileReader* tfileReaderCreate(IFileCtx* ctx) { return NULL; } reader->ctx = ctx; + reader->remove = false; if (0 != tfileReaderVerify(reader)) { indexError("invalid tfile, suid:%" PRIu64 ", colName:%s", reader->header.suid, reader->header.colName); tfileReaderDestroy(reader); return NULL; } - // T_REF_INC(reader); + if (0 != tfileReaderLoadHeader(reader)) { indexError("failed to load index header, suid:%" PRIu64 ", colName:%s", reader->header.suid, reader->header.colName); @@ -203,7 +204,6 @@ TFileReader* tfileReaderCreate(IFileCtx* ctx) { tfileReaderDestroy(reader); return NULL; } - reader->remove = false; return reader; } @@ -211,7 +211,6 @@ void tfileReaderDestroy(TFileReader* reader) { if (reader == NULL) { return; } - // T_REF_INC(reader); fstDestroy(reader->fst); if (reader->remove) { indexInfo("%s is removed", reader->ctx->file.buf); @@ -222,6 +221,7 @@ void tfileReaderDestroy(TFileReader* reader) { taosMemoryFree(reader); } + static int32_t tfSearchTerm(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { int ret = 0; char* p = tem->colVal; @@ -494,7 +494,6 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTRslt* tr TFileWriter* tfileWriterOpen(char* path, uint64_t suid, int64_t version, const char* colName, uint8_t colType) { char fullname[256] = {0}; tfileGenFileFullName(fullname, path, suid, colName, version); - // indexInfo("open write file name %s", fullname); IFileCtx* wcx = idxFileCtxCreate(TFILE, fullname, false, 1024 * 1024 * 64); if (wcx == NULL) { return NULL; @@ -503,8 +502,8 @@ TFileWriter* tfileWriterOpen(char* path, uint64_t suid, int64_t version, const c TFileHeader tfh = {0}; tfh.suid = suid; tfh.version = version; - memcpy(tfh.colName, colName, strlen(colName)); tfh.colType = colType; + memcpy(tfh.colName, colName, strlen(colName)); return tfileWriterCreate(wcx, &tfh); } @@ -706,7 +705,6 @@ static bool tfileIteratorNext(Iterate* iiter) { iv->type = ADD_VALUE; // value in tfile always ADD_VALUE iv->colVal = colVal; return true; - // std::string key(ch, sz); } static IterateValue* tifileIterateGetValue(Iterate* iter) { return &iter->val; } diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c index 8fa7e8860509ca473ad41b1c89efbf430f0c2649..bbee8b1166903bfcafb611baf7b2bf8ed8b48699 100644 --- a/source/libs/monitor/src/monMsg.c +++ b/source/libs/monitor/src/monMsg.c @@ -510,6 +510,7 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i); if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1; if (tEncodeI32(&encoder, pLoad->syncState) < 0) return -1; + if (tEncodeI64(&encoder, pLoad->cacheUsage) < 0) return -1; if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1; if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1; if (tEncodeI64(&encoder, pLoad->totalStorage) < 0) return -1; @@ -544,6 +545,7 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf SVnodeLoad load = {0}; if (tDecodeI32(&decoder, &load.vgId) < 0) return -1; if (tDecodeI32(&decoder, &load.syncState) < 0) return -1; + if (tDecodeI64(&decoder, &load.cacheUsage) < 0) return -1; if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1; if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1; if (tDecodeI64(&decoder, &load.totalStorage) < 0) return -1; @@ -594,7 +596,6 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf return 0; } - int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -639,5 +640,3 @@ int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) { tDecoderClear(&decoder); return 0; } - - diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 83bccbffb4b973fe3a4b720219ab0bb91d6f05b6..eb0b604d37459342a403ab5120c22e2bf5dc4b13 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -777,6 +777,7 @@ SNode* nodesCloneNode(const SNode* pNode) { code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); break; default: diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 822bdec365e6f5128d7c36cf6b7d765eeb2488de..8976daadbdada2365dbb2e3bf2af4f807c4ac26f 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -265,6 +265,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiStreamStateWindow"; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: return "PhysiPartition"; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + return "PhysiStreamPartition"; case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return "PhysiIndefRowsFunc"; case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC: @@ -4485,6 +4487,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: return physiStateWindowNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: return physiPartitionNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return physiIndefRowsFuncNodeToJson(pObj, pJson); @@ -4632,6 +4635,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE: return jsonToPhysiStateWindowNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: return jsonToPhysiPartitionNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return jsonToPhysiIndefRowsFuncNode(pJson, pObj); diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 2e23998aad9463fb7a4a9b6834ceab2f7ea51e55..728e173ff85e87d553d118f0baf0022a99c58f5d 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -537,7 +537,8 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk } break; } - case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: { SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)pNode; res = walkPhysiNode((SPhysiNode*)pNode, order, walker, pContext); if (DEAL_RES_ERROR != res && DEAL_RES_END != res) { diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index d13057a93e824c2b94d94a006664b4cbc4c2f870..61b2ad954f3c91ed8d3bc8f7b9fb76c3c49cda9c 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -322,6 +322,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SStreamStateWinodwPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: return makeNode(type, sizeof(SPartitionPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: + return makeNode(type, sizeof(SStreamPartitionPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC: return makeNode(type, sizeof(SIndefRowsFuncPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC: @@ -951,7 +953,8 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pPhyNode->pStateKey); break; } - case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: { SPartitionPhysiNode* pPhyNode = (SPartitionPhysiNode*)pNode; destroyPhysiNode((SPhysiNode*)pPhyNode); nodesDestroyList(pPhyNode->pExprs); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 2a4f4c194d3e46c9ff4d052187431287dce87b3e..0507fe0c66190689c168f1e9910d1828a9f6671e 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -59,7 +59,10 @@ typedef enum EDatabaseOptionType { DB_OPTION_WAL_RETENTION_PERIOD, DB_OPTION_WAL_RETENTION_SIZE, DB_OPTION_WAL_ROLL_PERIOD, - DB_OPTION_WAL_SEGMENT_SIZE + DB_OPTION_WAL_SEGMENT_SIZE, + DB_OPTION_SST_TRIGGER, + DB_OPTION_TABLE_PREFIX, + DB_OPTION_TABLE_SUFFIX } EDatabaseOptionType; typedef enum ETableOptionType { @@ -170,6 +173,7 @@ SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId); +SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint); SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo); SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal); SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 9bff061d02fbfa8d5795dff82c9ec93b7093f96d..fdd0ec548b1699440a0d2d3833f0d998f76fa54b 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -207,6 +207,9 @@ db_options(A) ::= db_options(B) WAL_RETENTION_SIZE NK_MINUS(D) NK_INTEGER(C). } db_options(A) ::= db_options(B) WAL_ROLL_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_ROLL_PERIOD, &C); } db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_SEGMENT_SIZE, &C); } +db_options(A) ::= db_options(B) SST_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SST_TRIGGER, &C); } +db_options(A) ::= db_options(B) TABLE_PREFIX NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, &C); } +db_options(A) ::= db_options(B) TABLE_SUFFIX NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, &C); } alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); } alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); } @@ -223,6 +226,7 @@ alter_db_option(A) ::= KEEP variable_list(B). //alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; } //alter_db_option(A) ::= STRICT NK_STRING(B). { A.type = DB_OPTION_STRICT; A.val = B; } alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } +alter_db_option(A) ::= SST_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_SST_TRIGGER; A.val = B; } %type integer_list { SNodeList* } %destructor integer_list { nodesDestroyList($$); } @@ -410,6 +414,8 @@ cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } cmd ::= SHOW TAGS FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, B, A, OP_TYPE_EQUAL); } +cmd ::= SHOW VNODES NK_INTEGER(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A), NULL); } +cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } @@ -997,4 +1003,4 @@ null_ordering_opt(A) ::= NULLS 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 FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT STRING - TIMES UPDATE VALUES VARIABLE VIEW VNODES WAL. + TIMES UPDATE VALUES VARIABLE VIEW WAL. diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4d0b0bbb2533111fe31d4810c58270bea5b22314..901abf17ee0f3e0a4599d730295a5d8700d13900 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -795,6 +795,20 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* return (SNode*)setOp; } +static void updateWalOptionsDefault(SDatabaseOptions* pOptions) { + if (!pOptions->walRetentionPeriodIsSet) { + pOptions->walRetentionPeriod = + pOptions->replica > 1 ? TSDB_REPS_DEF_DB_WAL_RET_PERIOD : TSDB_REP_DEF_DB_WAL_RET_PERIOD; + } + if (!pOptions->walRetentionSizeIsSet) { + pOptions->walRetentionSize = pOptions->replica > 1 ? TSDB_REPS_DEF_DB_WAL_RET_SIZE : TSDB_REP_DEF_DB_WAL_RET_SIZE; + } + if (!pOptions->walRollPeriodIsSet) { + pOptions->walRollPeriod = + pOptions->replica > 1 ? TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD : TSDB_REP_DEF_DB_WAL_ROLL_PERIOD; + } +} + SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { CHECK_PARSER_STATUS(pCxt); SDatabaseOptions* pOptions = (SDatabaseOptions*)nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); @@ -819,10 +833,11 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB; pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE; pOptions->schemaless = TSDB_DEFAULT_DB_SCHEMALESS; - pOptions->walRetentionPeriod = TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD; - pOptions->walRetentionSize = TSDB_DEFAULT_DB_WAL_RETENTION_SIZE; - pOptions->walRollPeriod = TSDB_DEFAULT_DB_WAL_ROLL_PERIOD; + updateWalOptionsDefault(pOptions); pOptions->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE; + pOptions->sstTrigger = TSDB_DEFAULT_SST_TRIGGER; + pOptions->tablePrefix = TSDB_DEFAULT_HASH_PREFIX; + pOptions->tableSuffix = TSDB_DEFAULT_HASH_SUFFIX; return (SNode*)pOptions; } @@ -854,83 +869,100 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->walRetentionSize = -1; pOptions->walRollPeriod = -1; pOptions->walSegmentSize = -1; + pOptions->sstTrigger = -1; + pOptions->tablePrefix = -1; + pOptions->tableSuffix = -1; return (SNode*)pOptions; } SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) { CHECK_PARSER_STATUS(pCxt); + SDatabaseOptions* pDbOptions = (SDatabaseOptions*)pOptions; switch (type) { case DB_OPTION_BUFFER: - ((SDatabaseOptions*)pOptions)->buffer = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->buffer = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_CACHEMODEL: - COPY_STRING_FORM_STR_TOKEN(((SDatabaseOptions*)pOptions)->cacheModelStr, (SToken*)pVal); + COPY_STRING_FORM_STR_TOKEN(pDbOptions->cacheModelStr, (SToken*)pVal); break; case DB_OPTION_CACHESIZE: - ((SDatabaseOptions*)pOptions)->cacheLastSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->cacheLastSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_COMP: - ((SDatabaseOptions*)pOptions)->compressionLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + pDbOptions->compressionLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_DAYS: { SToken* pToken = pVal; if (TK_NK_INTEGER == pToken->type) { - ((SDatabaseOptions*)pOptions)->daysPerFile = taosStr2Int32(pToken->z, NULL, 10) * 1440; + pDbOptions->daysPerFile = taosStr2Int32(pToken->z, NULL, 10) * 1440; } else { - ((SDatabaseOptions*)pOptions)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken); + pDbOptions->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken); } break; } case DB_OPTION_FSYNC: - ((SDatabaseOptions*)pOptions)->fsyncPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->fsyncPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_MAXROWS: - ((SDatabaseOptions*)pOptions)->maxRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->maxRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_MINROWS: - ((SDatabaseOptions*)pOptions)->minRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->minRowsPerBlock = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_KEEP: - ((SDatabaseOptions*)pOptions)->pKeep = pVal; + pDbOptions->pKeep = pVal; break; case DB_OPTION_PAGES: - ((SDatabaseOptions*)pOptions)->pages = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->pages = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_PAGESIZE: - ((SDatabaseOptions*)pOptions)->pagesize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->pagesize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_PRECISION: - COPY_STRING_FORM_STR_TOKEN(((SDatabaseOptions*)pOptions)->precisionStr, (SToken*)pVal); + COPY_STRING_FORM_STR_TOKEN(pDbOptions->precisionStr, (SToken*)pVal); break; case DB_OPTION_REPLICA: - ((SDatabaseOptions*)pOptions)->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + pDbOptions->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + updateWalOptionsDefault(pDbOptions); break; case DB_OPTION_STRICT: - COPY_STRING_FORM_STR_TOKEN(((SDatabaseOptions*)pOptions)->strictStr, (SToken*)pVal); + COPY_STRING_FORM_STR_TOKEN(pDbOptions->strictStr, (SToken*)pVal); break; case DB_OPTION_WAL: - ((SDatabaseOptions*)pOptions)->walLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walLevel = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_VGROUPS: - ((SDatabaseOptions*)pOptions)->numOfVgroups = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->numOfVgroups = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_SINGLE_STABLE: - ((SDatabaseOptions*)pOptions)->singleStable = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + pDbOptions->singleStable = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_RETENTIONS: - ((SDatabaseOptions*)pOptions)->pRetentions = pVal; + pDbOptions->pRetentions = pVal; break; case DB_OPTION_WAL_RETENTION_PERIOD: - ((SDatabaseOptions*)pOptions)->walRetentionPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRetentionPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRetentionPeriodIsSet = true; break; case DB_OPTION_WAL_RETENTION_SIZE: - ((SDatabaseOptions*)pOptions)->walRetentionSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRetentionSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRetentionSizeIsSet = true; break; case DB_OPTION_WAL_ROLL_PERIOD: - ((SDatabaseOptions*)pOptions)->walRollPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRollPeriod = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walRollPeriodIsSet = true; break; case DB_OPTION_WAL_SEGMENT_SIZE: - ((SDatabaseOptions*)pOptions)->walSegmentSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + pDbOptions->walSegmentSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_SST_TRIGGER: + pDbOptions->sstTrigger = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_TABLE_PREFIX: + pDbOptions->tablePrefix = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); + break; + case DB_OPTION_TABLE_SUFFIX: + pDbOptions->tableSuffix = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; default: break; @@ -1251,7 +1283,8 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { static bool needDbShowStmt(ENodeType type) { return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || - QUERY_NODE_SHOW_VGROUPS_STMT == type; + QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type || + QUERY_NODE_SHOW_TAGS_STMT == type; } SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { @@ -1264,7 +1297,7 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName, EOperatorType tableCondType) { CHECK_PARSER_STATUS(pCxt); - if (needDbShowStmt(type) && NULL == pDbName && NULL == pCxt->pQueryCxt->db) { + if (needDbShowStmt(type) && NULL == pDbName) { snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified"); pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; @@ -1316,6 +1349,15 @@ SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId) { return (SNode*)pStmt; } +SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint) { + CHECK_PARSER_STATUS(pCxt); + SShowVnodesStmt* pStmt = (SShowVnodesStmt*)nodesMakeNode(QUERY_NODE_SHOW_VNODES_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->pDnodeId = pDnodeId; + pStmt->pDnodeEndpoint = pDnodeEndpoint; + return (SNode*)pStmt; +} + SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo) { CHECK_PARSER_STATUS(pCxt); char password[TSDB_USET_PASSWORD_LEN] = {0}; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 82b5842663a824b08553da9ac3b1044a19ad3ef6..ec5f6c4e570206f1a08d537f735605d0d54d53ef 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -97,16 +97,23 @@ typedef struct SCollectMetaKeyCxt { typedef struct SCollectMetaKeyFromExprCxt { SCollectMetaKeyCxt* pComCxt; + bool hasLastRow; int32_t errCode; } SCollectMetaKeyFromExprCxt; static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt); static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) { - if (fmIsBuiltinFunc(pFunc->functionName)) { - return DEAL_RES_CONTINUE; + switch (fmGetFuncType(pFunc->functionName)) { + case FUNCTION_TYPE_LAST_ROW: + pCxt->hasLastRow = true; + break; + case FUNCTION_TYPE_UDF: + pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache); + break; + default: + break; } - pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache); return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR; } @@ -136,9 +143,6 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c if (TSDB_CODE_SUCCESS == code && (0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES))) { code = reserveDnodeRequiredInCache(pCxt->pMetaCache); } - if (TSDB_CODE_SUCCESS == code) { - code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache); - } return code; } @@ -185,9 +189,19 @@ static int32_t collectMetaKeyFromSetOperator(SCollectMetaKeyCxt* pCxt, SSetOpera return code; } +static int32_t reserveDbCfgForLastRow(SCollectMetaKeyCxt* pCxt, SNode* pTable) { + if (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable)) { + return TSDB_CODE_SUCCESS; + } + return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SRealTableNode*)pTable)->table.dbName, pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* pStmt) { - SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .errCode = TSDB_CODE_SUCCESS}; + SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .hasLastRow = false, .errCode = TSDB_CODE_SUCCESS}; nodesWalkSelectStmt(pStmt, SQL_CLAUSE_FROM, collectMetaKeyFromExprImpl, &cxt); + if (TSDB_CODE_SUCCESS == cxt.errCode && cxt.hasLastRow) { + cxt.errCode = reserveDbCfgForLastRow(pCxt, pStmt->pFromTable); + } return cxt.errCode; } @@ -360,12 +374,17 @@ static int32_t collectMetaKeyFromShowIndexes(SCollectMetaKeyCxt* pCxt, SShowStmt } static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STABLES, - pCxt->pMetaCache); + int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STABLES, + pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, + ((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ, pCxt->pMetaCache); + } + return code; } static int32_t collectMetaKeyFromShowStreams(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS, pCxt->pMetaCache); } @@ -373,11 +392,11 @@ static int32_t collectMetaKeyFromShowTables(SCollectMetaKeyCxt* pCxt, SShowStmt* int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, pCxt->pMetaCache); if (TSDB_CODE_SUCCESS == code) { - if (NULL != pStmt->pDbName) { - code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache); - } else { - code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, pCxt->pMetaCache); - } + code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache); + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, + ((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ, pCxt->pMetaCache); } return code; } @@ -386,11 +405,7 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p int32_t code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TAGS, pCxt->pMetaCache); if (TSDB_CODE_SUCCESS == code) { - if (NULL != pStmt->pDbName) { - code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache); - } else { - code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, pCxt->pMetaCache); - } + code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, ((SValueNode*)pStmt->pDbName)->literal, pCxt->pMetaCache); } return code; } @@ -411,7 +426,7 @@ static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt } static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TOPICS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TOPICS, pCxt->pMetaCache); } @@ -449,6 +464,11 @@ static int32_t collectMetaKeyFromShowDnodeVariables(SCollectMetaKeyCxt* pCxt, SS return code; } +static int32_t collectMetaKeyFromShowVnodes(SCollectMetaKeyCxt* pCxt, SShowVnodesStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VNODES, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) { return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); } @@ -506,7 +526,7 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa } static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS, pCxt->pMetaCache); } @@ -589,6 +609,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowVariables(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return collectMetaKeyFromShowDnodeVariables(pCxt, (SShowDnodeVariablesStmt*)pStmt); + case QUERY_NODE_SHOW_VNODES_STMT: + return collectMetaKeyFromShowVnodes(pCxt, (SShowVnodesStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: diff --git a/source/libs/parser/src/parAuthenticator.c b/source/libs/parser/src/parAuthenticator.c index d9a5761d99b7f04d5f2d4d9604ceee3faf76a896..9d73be745468c33f6041f5f6bb2a9cd9bfb51b52 100644 --- a/source/libs/parser/src/parAuthenticator.c +++ b/source/libs/parser/src/parAuthenticator.c @@ -96,6 +96,10 @@ static int32_t authInsert(SAuthCxt* pCxt, SInsertStmt* pInsert) { return code; } +static int32_t authShowTables(SAuthCxt* pCxt, SShowStmt* pStmt) { + return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, AUTH_TYPE_READ); +} + static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) { return checkAuth(pCxt, pStmt->dbName, AUTH_TYPE_READ); } @@ -127,6 +131,9 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { case QUERY_NODE_SHOW_VNODES_STMT: case QUERY_NODE_SHOW_SCORES_STMT: return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS; + case QUERY_NODE_SHOW_TABLES_STMT: + case QUERY_NODE_SHOW_STABLES_STMT: + return authShowTables(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: return authShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt); diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index c9115d90e18a73ff6328e877eaddfeb0e2c72b36..162161b67a185bea356d00b426664efe4ced5ec3 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -502,6 +502,10 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return func(pMsgBuf, NULL, 0, param); } + if (IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) { + return buildSyntaxErrMsg(pMsgBuf, "invalid numeric data", pToken->z); + } + switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { @@ -782,6 +786,7 @@ static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTa if (sname) pTbReq->ctb.name = strdup(sname); pTbReq->ctb.pTag = (uint8_t*)pTag; pTbReq->ctb.tagName = taosArrayDup(tagName); + pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL; pTbReq->commentLen = -1; return; @@ -1117,6 +1122,40 @@ static int32_t ignoreAutoCreateTableClause(SInsertParseContext* pCxt) { return code; } +static int32_t parseTableOptions(SInsertParseContext* pCxt) { + do { + int32_t index = 0; + SToken sToken; + NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); + if (TK_TTL == sToken.type) { + pCxt->pSql += index; + NEXT_TOKEN(pCxt->pSql, sToken); + if (TK_NK_INTEGER != sToken.type) { + return buildSyntaxErrMsg(&pCxt->msg, "Invalid option ttl", sToken.z); + } + pCxt->createTblReq.ttl = taosStr2Int32(sToken.z, NULL, 10); + } else if (TK_COMMENT == sToken.type) { + pCxt->pSql += index; + NEXT_TOKEN(pCxt->pSql, sToken); + if (TK_NK_STRING != sToken.type) { + return buildSyntaxErrMsg(&pCxt->msg, "Invalid option comment", sToken.z); + } + if (sToken.n >= TSDB_TB_COMMENT_LEN) { + return buildSyntaxErrMsg(&pCxt->msg, "comment too long", sToken.z); + } + int32_t len = trimString(sToken.z, sToken.n, pCxt->tmpTokenBuf, TSDB_TB_COMMENT_LEN); + pCxt->createTblReq.comment = strndup(pCxt->tmpTokenBuf, len); + if (NULL == pCxt->createTblReq.comment) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->createTblReq.commentLen = len; + } else { + break; + } + } while (1); + return TSDB_CODE_SUCCESS; +} + // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) static int32_t parseUsingClause(SInsertParseContext* pCxt, int32_t tbNo, SName* name, char* tbFName) { int32_t len = strlen(tbFName); @@ -1168,7 +1207,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, int32_t tbNo, SName* return buildSyntaxErrMsg(&pCxt->msg, ") is expected", sToken.z); } - return TSDB_CODE_SUCCESS; + return parseTableOptions(pCxt); } static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, int16_t timePrec, bool* gotRow, @@ -1665,6 +1704,10 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache pDb = taosHashIterate(context.pDbFNameHashObj, pDb); } } + if (pContext->pStmtCb) { + context.pVgroupsHashObj = NULL; + context.pTableBlockHashObj = NULL; + } destroyInsertParseContext(&context); return code; } @@ -1692,6 +1735,21 @@ static int32_t skipValuesClause(SInsertParseSyntaxCxt* pCxt) { static int32_t skipTagsClause(SInsertParseSyntaxCxt* pCxt) { return skipParentheses(pCxt); } +static int32_t skipTableOptions(SInsertParseSyntaxCxt* pCxt) { + do { + int32_t index = 0; + SToken sToken; + NEXT_TOKEN_KEEP_SQL(pCxt->pSql, sToken, index); + if (TK_TTL == sToken.type || TK_COMMENT == sToken.type) { + pCxt->pSql += index; + NEXT_TOKEN(pCxt->pSql, sToken); + } else { + break; + } + } while (1); + return TSDB_CODE_SUCCESS; +} + // pSql -> [(tag1_name, ...)] TAGS (tag1_value, ...) static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) { SToken sToken; @@ -1710,6 +1768,7 @@ static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) { return buildSyntaxErrMsg(&pCxt->msg, "( is expected", sToken.z); } CHECK_CODE(skipTagsClause(pCxt)); + CHECK_CODE(skipTableOptions(pCxt)); return TSDB_CODE_SUCCESS; } @@ -2253,7 +2312,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS SToken sToken = {.n = kv->keyLen, .z = (char*)kv->key}; col_id_t t = lastColIdx + 1; col_id_t index = ((t == 0 && !isTag) ? 0 : findCol(&sToken, t, nCols, pSchema)); - uDebug("SML, index:%d, t:%d, ncols:%d, kv->name:%s", index, t, nCols, kv->key); + uDebug("SML, index:%d, t:%d, ncols:%d", index, t, nCols); if (index < 0 && t > 0) { index = findCol(&sToken, 0, t, pSchema); isOrdered = false; @@ -2474,9 +2533,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols if (p) kv = *p; } - if (!kv || kv->length == 0) { - MemRowAppend(&pBuf, NULL, 0, ¶m); - } else { + if (kv){ int32_t colLen = kv->length; if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { // uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); @@ -2489,6 +2546,8 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols } else { MemRowAppend(&pBuf, &(kv->value), colLen, ¶m); } + }else{ + pBuilder->hasNone = true; } if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 80ec447f66157dd00e1081ee87e431a58b5998cd..e0f54530dd1231ea324e59d3773219052c1e7cf9 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -187,6 +187,7 @@ static SKeyword keywordTable[] = { {"SNODES", TK_SNODES}, {"SOFFSET", TK_SOFFSET}, {"SPLIT", TK_SPLIT}, + {"SST_TRIGGER", TK_SST_TRIGGER}, {"STABLE", TK_STABLE}, {"STABLES", TK_STABLES}, {"STATE", TK_STATE}, @@ -199,6 +200,8 @@ static SKeyword keywordTable[] = { {"SYSINFO", TK_SYSINFO}, {"TABLE", TK_TABLE}, {"TABLES", TK_TABLES}, + {"TABLE_PREFIX", TK_TABLE_PREFIX}, + {"TABLE_SUFFIX", TK_TABLE_SUFFIX}, {"TAG", TK_TAG}, {"TAGS", TK_TAGS}, {"TBNAME", TK_TBNAME}, @@ -228,6 +231,7 @@ static SKeyword keywordTable[] = { {"VERBOSE", TK_VERBOSE}, {"VGROUP", TK_VGROUP}, {"VGROUPS", TK_VGROUPS}, + {"VNODES", TK_VNODES}, {"WAL_FSYNC_PERIOD", TK_WAL_FSYNC_PERIOD}, {"WAL_LEVEL", TK_WAL_LEVEL}, {"WAL_RETENTION_PERIOD", TK_WAL_RETENTION_PERIOD}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d938325ef2526d137271af93353a5adec9cf1d2c..240aa0d6c084964c84cc1da804bcef997ae8baab 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -142,8 +142,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_STREAMS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_STREAMS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_STREAMS, .numOfShowCols = 1, .pShowCols = {"stream_name"} }, @@ -184,8 +184,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_TOPICS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_TOPICS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_TOPICS, .numOfShowCols = 1, .pShowCols = {"topic_name"} }, @@ -240,8 +240,14 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { }, { .showType = QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, - .pDbName = TSDB_PERFORMANCE_SCHEMA_DB, - .pTableName = TSDB_PERFS_TABLE_SUBSCRIPTIONS, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_SUBSCRIPTIONS, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, + { .showType = QUERY_NODE_SHOW_VNODES_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_VNODES, .numOfShowCols = 1, .pShowCols = {"*"} }, @@ -2160,15 +2166,16 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo return TSDB_CODE_SUCCESS; } -static int32_t setTableCacheLastMode(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { - if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) { +static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (!pSelect->hasLastRowFunc || QUERY_NODE_REAL_TABLE != nodeType(pSelect->pFromTable)) { return TSDB_CODE_SUCCESS; } - SDbCfgInfo dbCfg = {0}; - int32_t code = getDBCfg(pCxt, pRealTable->table.dbName, &dbCfg); + SRealTableNode* pTable = (SRealTableNode*)pSelect->pFromTable; + SDbCfgInfo dbCfg = {0}; + int32_t code = getDBCfg(pCxt, pTable->table.dbName, &dbCfg); if (TSDB_CODE_SUCCESS == code) { - pRealTable->cacheLastMode = dbCfg.cacheLast; + pTable->cacheLastMode = dbCfg.cacheLast; } return code; } @@ -2192,9 +2199,6 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { if (TSDB_CODE_SUCCESS == code) { code = setTableIndex(pCxt, &name, pRealTable); } - if (TSDB_CODE_SUCCESS == code) { - code = setTableCacheLastMode(pCxt, &name, pRealTable); - } } if (TSDB_CODE_SUCCESS == code) { pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision; @@ -2273,10 +2277,14 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { 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)); + len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName); + strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1)); } else { len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pExpr->aliasName); + strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); + strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1)); } - strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); return (SNode*)pFunc; } @@ -2475,13 +2483,65 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } +static EDealRes needFillImpl(SNode* pNode, void* pContext) { + if (isAggFunc(pNode) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType) { + *(bool*)pContext = true; + return DEAL_RES_END; + } + return DEAL_RES_CONTINUE; +} + +static bool needFill(SNode* pNode) { + bool hasFillFunc = false; + nodesWalkExpr(pNode, needFillImpl, &hasFillFunc); + return hasFillFunc; +} + +static bool mismatchFillDataType(SDataType origDt, SDataType fillDt) { + if (TSDB_DATA_TYPE_NULL == fillDt.type) { + return false; + } + if (IS_NUMERIC_TYPE(origDt.type) && !IS_NUMERIC_TYPE(fillDt.type)) { + return true; + } + if (IS_VAR_DATA_TYPE(origDt.type) && !IS_VAR_DATA_TYPE(fillDt.type)) { + return true; + } + return false; +} + +static int32_t checkFillValues(STranslateContext* pCxt, SFillNode* pFill, SNodeList* pProjectionList) { + if (FILL_MODE_VALUE != pFill->mode) { + return TSDB_CODE_SUCCESS; + } + + int32_t fillNo = 0; + SNodeListNode* pFillValues = (SNodeListNode*)pFill->pValues; + SNode* pProject = NULL; + FOREACH(pProject, pProjectionList) { + if (needFill(pProject)) { + if (fillNo >= LIST_LENGTH(pFillValues->pNodeList)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled values number mismatch"); + } + if (mismatchFillDataType(((SExprNode*)pProject)->resType, + ((SExprNode*)nodesListGetNode(pFillValues->pNodeList, fillNo))->resType)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled data type mismatch"); + } + ++fillNo; + } + } + if (fillNo != LIST_LENGTH(pFillValues->pNodeList)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, "Filled values number mismatch"); + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateFillValues(STranslateContext* pCxt, SSelectStmt* pSelect) { if (NULL == pSelect->pWindow || QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) || NULL == ((SIntervalWindowNode*)pSelect->pWindow)->pFill) { return TSDB_CODE_SUCCESS; } - SFillNode* pFill = (SFillNode*)((SIntervalWindowNode*)pSelect->pWindow)->pFill; - return TSDB_CODE_SUCCESS; + return checkFillValues(pCxt, (SFillNode*)((SIntervalWindowNode*)pSelect->pWindow)->pFill, pSelect->pProjectionList); } static int32_t rewriteProjectAlias(SNodeList* pProjectionList) { @@ -3088,6 +3148,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect if (TSDB_CODE_SUCCESS == code) { code = replaceOrderByAliasForSelect(pCxt, pSelect); } + if (TSDB_CODE_SUCCESS == code) { + code = setTableCacheLastMode(pCxt, pSelect); + } return code; } @@ -3419,6 +3482,9 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->walRetentionSize = pStmt->pOptions->walRetentionSize; pReq->walRollPeriod = pStmt->pOptions->walRollPeriod; pReq->walSegmentSize = pStmt->pOptions->walSegmentSize; + pReq->sstTrigger = pStmt->pOptions->sstTrigger; + pReq->hashPrefix = pStmt->pOptions->tablePrefix; + pReq->hashSuffix = pStmt->pOptions->tableSuffix; pReq->ignoreExist = pStmt->ignoreExists; return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); } @@ -3703,6 +3769,15 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName code = checkDbRangeOption(pCxt, "walSegmentSize", pOptions->walSegmentSize, TSDB_DB_MIN_WAL_SEGMENT_SIZE, INT32_MAX); } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "sstTrigger", pOptions->sstTrigger, TSDB_MIN_SST_TRIGGER, TSDB_MAX_SST_TRIGGER); + } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "tablePrefix", pOptions->tablePrefix, TSDB_MIN_HASH_PREFIX, TSDB_MAX_HASH_PREFIX); + } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbRangeOption(pCxt, "tableSuffix", pOptions->tableSuffix, TSDB_MIN_HASH_SUFFIX, TSDB_MAX_HASH_SUFFIX); + } if (TSDB_CODE_SUCCESS == code) { code = checkOptionsDependency(pCxt, pDbName, pOptions); } @@ -3776,6 +3851,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, pReq->cacheLast = pStmt->pOptions->cacheModel; pReq->cacheLastSize = pStmt->pOptions->cacheLastSize; pReq->replications = pStmt->pOptions->replica; + pReq->sstTrigger = pStmt->pOptions->sstTrigger; return; } @@ -5780,6 +5856,25 @@ static int32_t rewriteShowDnodeVariables(STranslateContext* pCxt, SQuery* pQuery return code; } +static int32_t rewriteShowVnodes(STranslateContext* pCxt, SQuery* pQuery) { + SShowVnodesStmt* pShow = (SShowVnodesStmt*)(pQuery->pRoot); + SSelectStmt* pStmt = NULL; + int32_t code = createSelectStmtForShow(QUERY_NODE_SHOW_VNODES_STMT, &pStmt); + if (TSDB_CODE_SUCCESS == code) { + if (NULL != pShow->pDnodeId) { + code = createOperatorNode(OP_TYPE_EQUAL, "dnode_id", pShow->pDnodeId, &pStmt->pWhere); + } else { + code = createOperatorNode(OP_TYPE_EQUAL, "dnode_ep", pShow->pDnodeEndpoint, &pStmt->pWhere); + } + } + if (TSDB_CODE_SUCCESS == code) { + pQuery->showRewrite = true; + nodesDestroyNode(pQuery->pRoot); + pQuery->pRoot = (SNode*)pStmt; + } + return code; +} + static SNode* createBlockDistInfoFunc() { SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); if (NULL == pFunc) { @@ -6351,8 +6446,9 @@ typedef struct SVgroupDropTableBatch { char dbName[TSDB_DB_NAME_LEN]; } SVgroupDropTableBatch; -static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* pClause, SVgroupInfo* pVgInfo) { - SVDropTbReq req = {.name = pClause->tableName, .igNotExists = pClause->ignoreNotExists}; +static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* pClause, SVgroupInfo* pVgInfo, + uint64_t suid) { + SVDropTbReq req = {.name = pClause->tableName, .suid = suid, .igNotExists = pClause->ignoreNotExists}; SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pVgInfo->vgId, sizeof(pVgInfo->vgId)); if (NULL == pTableBatch) { SVgroupDropTableBatch tBatch = {0}; @@ -6393,7 +6489,7 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl code = getTableHashVgroup(pCxt, pClause->dbName, pClause->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addDropTbReqIntoVgroup(pVgroupHashmap, pClause, &info); + addDropTbReqIntoVgroup(pVgroupHashmap, pClause, &info, pTableMeta->suid); } over: @@ -6889,6 +6985,9 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: code = rewriteShowDnodeVariables(pCxt, pQuery); break; + case QUERY_NODE_SHOW_VNODES_STMT: + code = rewriteShowVnodes(pCxt, pQuery); + break; case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: code = rewriteShowTableDist(pCxt, pQuery); break; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c4bd1aff044a491edede232eff74b8dea1feeadb..0442d262f10591e0b64a2a225626de9dc3a83345 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 426 +#define YYNOCODE 429 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SAlterOption yy5; - int8_t yy59; - int64_t yy69; - EJoinType yy156; - SNodeList* yy172; - EFillMode yy186; - SToken yy209; - int32_t yy232; - SNode* yy272; - bool yy293; - EOperatorType yy392; - ENullOrder yy493; - SDataType yy616; - EOrder yy818; + int32_t yy46; + SNode* yy80; + int64_t yy129; + SDataType yy136; + EOperatorType yy194; + SToken yy239; + SAlterOption yy299; + EOrder yy422; + EFillMode yy426; + int8_t yy509; + SNodeList* yy574; + EJoinType yy750; + ENullOrder yy763; + bool yy845; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 667 -#define YYNRULE 489 -#define YYNTOKEN 305 -#define YY_MAX_SHIFT 666 -#define YY_MIN_SHIFTREDUCE 972 -#define YY_MAX_SHIFTREDUCE 1460 -#define YY_ERROR_ACTION 1461 -#define YY_ACCEPT_ACTION 1462 -#define YY_NO_ACTION 1463 -#define YY_MIN_REDUCE 1464 -#define YY_MAX_REDUCE 1952 +#define YYNSTATE 674 +#define YYNRULE 495 +#define YYNTOKEN 308 +#define YY_MAX_SHIFT 673 +#define YY_MIN_SHIFTREDUCE 983 +#define YY_MAX_SHIFTREDUCE 1477 +#define YY_ERROR_ACTION 1478 +#define YY_ACCEPT_ACTION 1479 +#define YY_NO_ACTION 1480 +#define YY_MIN_REDUCE 1481 +#define YY_MAX_REDUCE 1975 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,650 +216,680 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2259) +#define YY_ACTTAB_COUNT (2464) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 433, 1930, 434, 1499, 1593, 441, 526, 434, 1499, 513, - /* 10 */ 30, 260, 39, 37, 1929, 326, 325, 117, 1927, 1702, - /* 20 */ 339, 1465, 1261, 146, 471, 40, 38, 36, 35, 34, - /* 30 */ 1786, 552, 1606, 1337, 1604, 1259, 344, 552, 1287, 1649, - /* 40 */ 1651, 378, 107, 1774, 526, 106, 105, 104, 103, 102, - /* 50 */ 101, 100, 99, 98, 1770, 117, 1332, 432, 1804, 64, - /* 60 */ 436, 14, 476, 36, 35, 34, 553, 148, 1267, 1476, - /* 70 */ 450, 1756, 1604, 577, 39, 37, 1400, 1595, 1766, 1772, - /* 80 */ 328, 1930, 339, 1526, 1261, 1804, 217, 1286, 1770, 1, - /* 90 */ 571, 1005, 1656, 542, 164, 1337, 1818, 1259, 1927, 327, - /* 100 */ 95, 1787, 580, 1789, 1790, 576, 43, 571, 1654, 158, - /* 110 */ 1864, 663, 1766, 1772, 330, 1860, 159, 513, 1332, 63, - /* 120 */ 1930, 78, 1643, 14, 571, 1339, 1340, 1703, 163, 541, - /* 130 */ 1267, 1009, 1010, 165, 33, 32, 1890, 1927, 40, 38, - /* 140 */ 36, 35, 34, 543, 63, 63, 640, 639, 638, 637, - /* 150 */ 349, 2, 636, 635, 128, 630, 629, 628, 627, 626, - /* 160 */ 625, 624, 139, 620, 619, 618, 348, 347, 615, 614, - /* 170 */ 1262, 107, 1260, 663, 106, 105, 104, 103, 102, 101, - /* 180 */ 100, 99, 98, 440, 1775, 1287, 436, 1339, 1340, 223, - /* 190 */ 224, 11, 10, 1265, 1266, 1770, 1314, 1315, 1317, 1318, - /* 200 */ 1319, 1320, 1321, 1322, 573, 569, 1330, 1331, 1333, 1334, - /* 210 */ 1335, 1336, 1338, 1341, 1464, 496, 1431, 33, 32, 1766, - /* 220 */ 1772, 40, 38, 36, 35, 34, 526, 167, 494, 150, - /* 230 */ 492, 571, 1262, 1564, 1260, 1261, 210, 55, 116, 115, - /* 240 */ 114, 113, 112, 111, 110, 109, 108, 305, 1259, 63, - /* 250 */ 516, 1701, 22, 300, 1604, 1265, 1266, 167, 1314, 1315, - /* 260 */ 1317, 1318, 1319, 1320, 1321, 1322, 573, 569, 1330, 1331, - /* 270 */ 1333, 1334, 1335, 1336, 1338, 1341, 39, 37, 1650, 1651, - /* 280 */ 1373, 1267, 167, 167, 339, 552, 1261, 613, 1286, 49, - /* 290 */ 1160, 1161, 76, 305, 1786, 1487, 516, 1337, 1421, 1259, - /* 300 */ 1118, 602, 601, 600, 1122, 599, 1124, 1125, 598, 1127, - /* 310 */ 595, 342, 1133, 592, 1135, 1136, 589, 586, 1285, 146, - /* 320 */ 1332, 1581, 1804, 173, 663, 14, 479, 478, 1606, 377, - /* 330 */ 553, 376, 1267, 1656, 1930, 1756, 1756, 577, 39, 37, - /* 340 */ 312, 535, 1419, 1420, 1422, 1423, 339, 1928, 1261, 1654, - /* 350 */ 1705, 1927, 84, 2, 42, 71, 1656, 63, 70, 1337, - /* 360 */ 1818, 1259, 1267, 343, 95, 1787, 580, 1789, 1790, 576, - /* 370 */ 605, 571, 1654, 1597, 1864, 663, 345, 1589, 330, 1860, - /* 380 */ 159, 1288, 1332, 1262, 146, 1260, 1022, 167, 1021, 1339, - /* 390 */ 1340, 33, 32, 1606, 1267, 40, 38, 36, 35, 34, - /* 400 */ 1891, 1930, 384, 39, 37, 1342, 1265, 1266, 1486, 1485, - /* 410 */ 611, 339, 1786, 1261, 165, 8, 1023, 438, 1927, 634, - /* 420 */ 632, 1080, 611, 1284, 1337, 622, 1259, 167, 549, 137, - /* 430 */ 136, 608, 607, 606, 1262, 1695, 1260, 663, 1484, 303, - /* 440 */ 1804, 137, 136, 608, 607, 606, 172, 1332, 575, 1756, - /* 450 */ 1756, 1339, 1340, 1756, 1082, 577, 127, 1265, 1266, 1267, - /* 460 */ 1314, 1315, 1317, 1318, 1319, 1320, 1321, 1322, 573, 569, - /* 470 */ 1330, 1331, 1333, 1334, 1335, 1336, 1338, 1341, 1818, 1756, - /* 480 */ 9, 1591, 293, 1787, 580, 1789, 1790, 576, 574, 571, - /* 490 */ 568, 1836, 167, 74, 125, 167, 1262, 222, 1260, 33, - /* 500 */ 32, 1529, 663, 40, 38, 36, 35, 34, 551, 160, - /* 510 */ 1872, 1873, 1587, 1877, 1483, 1600, 1339, 1340, 252, 1265, - /* 520 */ 1266, 1579, 1314, 1315, 1317, 1318, 1319, 1320, 1321, 1322, - /* 530 */ 573, 569, 1330, 1331, 1333, 1334, 1335, 1336, 1338, 1341, - /* 540 */ 1700, 526, 300, 33, 32, 1457, 91, 40, 38, 36, - /* 550 */ 35, 34, 169, 167, 316, 1756, 1241, 1242, 623, 124, - /* 560 */ 1576, 1262, 1879, 1260, 26, 482, 481, 1596, 1462, 1604, - /* 570 */ 33, 32, 123, 1582, 40, 38, 36, 35, 34, 213, - /* 580 */ 1786, 1411, 477, 480, 1265, 1266, 1876, 1314, 1315, 1317, - /* 590 */ 1318, 1319, 1320, 1321, 1322, 573, 569, 1330, 1331, 1333, - /* 600 */ 1334, 1335, 1336, 1338, 1341, 39, 37, 475, 1804, 317, - /* 610 */ 146, 315, 314, 339, 473, 1261, 578, 1361, 475, 1607, - /* 620 */ 549, 1756, 611, 577, 28, 1299, 1337, 354, 1259, 474, - /* 630 */ 33, 32, 1456, 450, 40, 38, 36, 35, 34, 538, - /* 640 */ 474, 137, 136, 608, 607, 606, 1818, 1695, 127, 1332, - /* 650 */ 96, 1787, 580, 1789, 1790, 576, 572, 571, 175, 74, - /* 660 */ 1864, 1267, 526, 609, 1863, 1860, 1647, 1930, 554, 512, - /* 670 */ 33, 32, 122, 382, 40, 38, 36, 35, 34, 27, - /* 680 */ 164, 1599, 9, 1482, 1927, 1022, 125, 1021, 7, 1366, - /* 690 */ 1604, 33, 32, 1481, 1565, 40, 38, 36, 35, 34, - /* 700 */ 469, 250, 1872, 548, 663, 547, 33, 32, 1930, 1930, - /* 710 */ 40, 38, 36, 35, 34, 1023, 544, 539, 1339, 1340, - /* 720 */ 526, 166, 164, 307, 1756, 1927, 1927, 135, 487, 1404, - /* 730 */ 526, 383, 39, 37, 1756, 1286, 1480, 302, 1879, 1284, - /* 740 */ 339, 389, 1261, 497, 307, 526, 412, 604, 1604, 424, - /* 750 */ 526, 549, 1299, 1337, 1477, 1259, 404, 209, 1604, 61, - /* 760 */ 1359, 405, 1875, 1262, 373, 1260, 397, 1479, 425, 1478, - /* 770 */ 399, 490, 255, 1604, 54, 484, 1332, 1756, 1604, 127, - /* 780 */ 208, 1359, 1475, 375, 371, 419, 1265, 1266, 1267, 1314, - /* 790 */ 1315, 1317, 1318, 1319, 1320, 1321, 1322, 573, 569, 1330, - /* 800 */ 1331, 1333, 1334, 1335, 1336, 1338, 1341, 390, 1756, 2, - /* 810 */ 1756, 1397, 58, 526, 1360, 57, 1879, 125, 505, 386, - /* 820 */ 1289, 33, 32, 1756, 448, 40, 38, 36, 35, 34, - /* 830 */ 1474, 663, 161, 1872, 1873, 1360, 1877, 177, 176, 1505, - /* 840 */ 1874, 1604, 1347, 1009, 1010, 1339, 1340, 423, 1286, 1580, - /* 850 */ 418, 417, 416, 415, 414, 411, 410, 409, 408, 407, - /* 860 */ 403, 402, 401, 400, 394, 393, 392, 391, 549, 388, - /* 870 */ 387, 1756, 1656, 616, 1473, 1393, 29, 337, 1354, 1355, - /* 880 */ 1356, 1357, 1358, 1362, 1363, 1364, 1365, 658, 1655, 468, - /* 890 */ 1262, 610, 1260, 1286, 1647, 1068, 127, 29, 337, 1354, - /* 900 */ 1355, 1356, 1357, 1358, 1362, 1363, 1364, 1365, 272, 613, - /* 910 */ 536, 1634, 1316, 1265, 1266, 1756, 1314, 1315, 1317, 1318, - /* 920 */ 1319, 1320, 1321, 1322, 573, 569, 1330, 1331, 1333, 1334, - /* 930 */ 1335, 1336, 1338, 1341, 125, 147, 1472, 1786, 561, 352, - /* 940 */ 278, 351, 1884, 1393, 1743, 482, 481, 1516, 1774, 162, - /* 950 */ 1872, 1873, 123, 1877, 276, 60, 1805, 232, 59, 1770, - /* 960 */ 526, 526, 477, 480, 1471, 1804, 44, 4, 244, 483, - /* 970 */ 145, 449, 1601, 578, 180, 429, 427, 1756, 1756, 1930, - /* 980 */ 577, 1930, 1500, 1766, 1772, 334, 1470, 1786, 1604, 1604, - /* 990 */ 526, 361, 164, 554, 164, 571, 1927, 216, 1927, 498, - /* 1000 */ 556, 499, 1469, 1818, 1468, 1756, 63, 94, 1787, 580, - /* 1010 */ 1789, 1790, 576, 526, 571, 1804, 558, 1864, 1604, 336, - /* 1020 */ 335, 306, 1860, 578, 506, 1316, 526, 1756, 1756, 1275, - /* 1030 */ 577, 201, 77, 1930, 199, 1396, 1644, 510, 526, 1930, - /* 1040 */ 1337, 1604, 1268, 1756, 93, 1756, 166, 1511, 1467, 227, - /* 1050 */ 1927, 350, 164, 1818, 1604, 1786, 1927, 95, 1787, 580, - /* 1060 */ 1789, 1790, 576, 1332, 571, 526, 1604, 1864, 41, 485, - /* 1070 */ 1316, 330, 1860, 1943, 526, 1267, 522, 53, 509, 68, - /* 1080 */ 67, 381, 1898, 1804, 171, 524, 221, 203, 526, 1756, - /* 1090 */ 202, 578, 205, 1604, 207, 204, 1756, 206, 577, 525, - /* 1100 */ 301, 1509, 1604, 369, 1894, 367, 363, 359, 356, 353, - /* 1110 */ 1270, 554, 131, 526, 1786, 1212, 1604, 1269, 566, 567, - /* 1120 */ 526, 1818, 134, 488, 261, 94, 1787, 580, 1789, 1790, - /* 1130 */ 576, 346, 571, 225, 135, 1864, 51, 550, 666, 306, - /* 1140 */ 1860, 1604, 1804, 562, 167, 236, 51, 323, 1604, 41, - /* 1150 */ 578, 1930, 267, 90, 1786, 1756, 617, 577, 41, 519, - /* 1160 */ 1777, 11, 10, 87, 164, 249, 156, 3, 1927, 229, - /* 1170 */ 254, 656, 652, 648, 644, 265, 584, 1276, 1066, 1271, - /* 1180 */ 1818, 1111, 1804, 1418, 294, 1787, 580, 1789, 1790, 576, - /* 1190 */ 578, 571, 239, 1367, 1786, 1756, 1323, 577, 1459, 1460, - /* 1200 */ 1279, 1281, 257, 1779, 259, 271, 134, 92, 135, 5, - /* 1210 */ 230, 1049, 569, 1330, 1331, 1333, 1334, 1335, 1336, 559, - /* 1220 */ 1818, 360, 1804, 1139, 95, 1787, 580, 1789, 1790, 576, - /* 1230 */ 578, 571, 268, 355, 1864, 1756, 119, 577, 330, 1860, - /* 1240 */ 1943, 134, 549, 523, 1050, 313, 1228, 1273, 174, 1921, - /* 1250 */ 385, 1351, 1284, 1143, 1272, 1150, 406, 413, 1697, 421, - /* 1260 */ 1818, 420, 422, 1786, 95, 1787, 580, 1789, 1790, 576, - /* 1270 */ 127, 571, 426, 428, 1864, 219, 430, 1290, 330, 1860, - /* 1280 */ 1943, 431, 439, 1148, 1292, 442, 183, 443, 138, 1883, - /* 1290 */ 554, 1804, 1291, 1235, 185, 212, 444, 1293, 188, 578, - /* 1300 */ 445, 190, 447, 72, 1756, 73, 577, 451, 125, 194, - /* 1310 */ 470, 472, 1594, 198, 118, 1590, 304, 1786, 200, 554, - /* 1320 */ 140, 269, 141, 250, 1872, 548, 1592, 547, 1588, 1818, - /* 1330 */ 1930, 142, 143, 285, 1787, 580, 1789, 1790, 576, 211, - /* 1340 */ 571, 500, 1736, 164, 214, 1804, 507, 1927, 504, 511, - /* 1350 */ 218, 322, 534, 578, 514, 520, 501, 1735, 1756, 1930, - /* 1360 */ 577, 132, 1707, 517, 324, 1289, 81, 1786, 521, 133, - /* 1370 */ 270, 83, 166, 554, 537, 1605, 1927, 530, 1905, 234, - /* 1380 */ 1895, 238, 6, 1818, 1786, 532, 533, 285, 1787, 580, - /* 1390 */ 1789, 1790, 576, 329, 571, 1804, 546, 531, 540, 529, - /* 1400 */ 528, 248, 1288, 578, 1393, 126, 563, 560, 1756, 48, - /* 1410 */ 577, 1880, 1804, 1930, 1904, 85, 1648, 331, 1577, 659, - /* 1420 */ 578, 582, 264, 660, 243, 1756, 164, 577, 153, 1886, - /* 1430 */ 1927, 247, 245, 1818, 1786, 246, 253, 96, 1787, 580, - /* 1440 */ 1789, 1790, 576, 1845, 571, 273, 662, 1864, 299, 275, - /* 1450 */ 1818, 565, 1860, 256, 149, 1787, 580, 1789, 1790, 576, - /* 1460 */ 1786, 571, 1804, 52, 1946, 1926, 557, 286, 296, 258, - /* 1470 */ 578, 564, 295, 1750, 277, 1756, 1749, 577, 65, 1748, - /* 1480 */ 1747, 66, 1744, 357, 358, 1253, 1254, 170, 1804, 362, - /* 1490 */ 1742, 364, 365, 527, 366, 1741, 578, 368, 555, 1944, - /* 1500 */ 1818, 1756, 1740, 577, 96, 1787, 580, 1789, 1790, 576, - /* 1510 */ 1786, 571, 370, 1739, 1864, 372, 1738, 1230, 374, 1861, - /* 1520 */ 1231, 1718, 1786, 379, 380, 1716, 1818, 1717, 1715, 1690, - /* 1530 */ 294, 1787, 580, 1789, 1790, 576, 1786, 571, 1804, 1689, - /* 1540 */ 1200, 129, 1688, 1687, 69, 1686, 578, 395, 1681, 396, - /* 1550 */ 1804, 1756, 1685, 577, 1684, 1683, 1682, 398, 578, 1680, - /* 1560 */ 1679, 1678, 1677, 1756, 1804, 577, 1676, 1675, 1674, 1673, - /* 1570 */ 1672, 1671, 575, 1670, 1669, 1668, 1818, 1756, 1667, 577, - /* 1580 */ 289, 1787, 580, 1789, 1790, 576, 130, 571, 1818, 1786, - /* 1590 */ 1666, 1665, 149, 1787, 580, 1789, 1790, 576, 1664, 571, - /* 1600 */ 1663, 1662, 1818, 1202, 1660, 1659, 293, 1787, 580, 1789, - /* 1610 */ 1790, 576, 1661, 571, 1658, 1837, 1657, 1804, 545, 1531, - /* 1620 */ 178, 1530, 338, 120, 181, 578, 196, 1528, 179, 1496, - /* 1630 */ 1756, 157, 577, 435, 1012, 437, 1011, 1945, 1495, 182, - /* 1640 */ 152, 121, 1786, 452, 453, 467, 463, 459, 455, 195, - /* 1650 */ 1731, 1725, 1714, 189, 1786, 1818, 187, 1713, 1699, 294, - /* 1660 */ 1787, 580, 1789, 1790, 576, 1583, 571, 1527, 1786, 1042, - /* 1670 */ 1804, 1525, 454, 1523, 456, 340, 458, 457, 578, 1521, - /* 1680 */ 460, 75, 1804, 1756, 193, 577, 462, 461, 1519, 464, - /* 1690 */ 578, 465, 466, 1508, 1507, 1756, 1804, 577, 1492, 1585, - /* 1700 */ 1153, 1154, 197, 1584, 578, 1079, 1074, 50, 1818, 1756, - /* 1710 */ 1517, 577, 294, 1787, 580, 1789, 1790, 576, 631, 571, - /* 1720 */ 1818, 1076, 1786, 633, 279, 1787, 580, 1789, 1790, 576, - /* 1730 */ 1075, 571, 1512, 318, 1818, 319, 1786, 1510, 280, 1787, - /* 1740 */ 580, 1789, 1790, 576, 320, 571, 192, 186, 1786, 191, - /* 1750 */ 1804, 486, 489, 446, 1491, 491, 1490, 1489, 578, 493, - /* 1760 */ 495, 97, 1730, 1756, 1804, 577, 1237, 56, 1724, 184, - /* 1770 */ 502, 1712, 578, 1710, 508, 503, 1804, 1756, 215, 577, - /* 1780 */ 1711, 1709, 321, 1708, 578, 15, 144, 220, 1818, 1756, - /* 1790 */ 1245, 577, 281, 1787, 580, 1789, 1790, 576, 1706, 571, - /* 1800 */ 1698, 226, 1818, 518, 79, 1786, 288, 1787, 580, 1789, - /* 1810 */ 1790, 576, 228, 571, 1818, 1786, 515, 80, 290, 1787, - /* 1820 */ 580, 1789, 1790, 576, 82, 571, 87, 41, 231, 23, - /* 1830 */ 47, 1786, 1433, 1804, 233, 241, 235, 1415, 237, 242, - /* 1840 */ 1417, 578, 16, 1804, 25, 1777, 1756, 151, 577, 240, - /* 1850 */ 24, 578, 46, 1410, 86, 1786, 1756, 17, 577, 1804, - /* 1860 */ 1390, 251, 1389, 1776, 154, 1450, 45, 578, 18, 1439, - /* 1870 */ 1445, 1818, 1756, 13, 577, 282, 1787, 580, 1789, 1790, - /* 1880 */ 576, 1818, 571, 1804, 1444, 291, 1787, 580, 1789, 1790, - /* 1890 */ 576, 578, 571, 332, 1449, 1448, 1756, 1818, 577, 333, - /* 1900 */ 10, 283, 1787, 580, 1789, 1790, 576, 1277, 571, 1352, - /* 1910 */ 19, 1786, 1821, 1307, 1327, 570, 155, 1325, 31, 581, - /* 1920 */ 1324, 1818, 12, 20, 168, 292, 1787, 580, 1789, 1790, - /* 1930 */ 576, 1786, 571, 21, 583, 1140, 341, 585, 579, 1804, - /* 1940 */ 1137, 587, 588, 590, 1134, 591, 593, 578, 596, 1132, - /* 1950 */ 594, 1786, 1756, 1128, 577, 1126, 1131, 597, 1117, 1804, - /* 1960 */ 1130, 88, 1149, 603, 1129, 89, 62, 578, 262, 1145, - /* 1970 */ 612, 1786, 1756, 1071, 577, 1070, 1040, 1818, 1069, 1804, - /* 1980 */ 1067, 284, 1787, 580, 1789, 1790, 576, 578, 571, 1065, - /* 1990 */ 1064, 1786, 1756, 1063, 577, 263, 1086, 1818, 1061, 1804, - /* 2000 */ 1060, 297, 1787, 580, 1789, 1790, 576, 578, 571, 621, - /* 2010 */ 1059, 1058, 1756, 1057, 577, 1056, 1055, 1818, 1083, 1804, - /* 2020 */ 1081, 298, 1787, 580, 1789, 1790, 576, 578, 571, 1052, - /* 2030 */ 1051, 1786, 1756, 1048, 577, 1047, 1046, 1818, 1045, 1524, - /* 2040 */ 641, 1798, 1787, 580, 1789, 1790, 576, 1786, 571, 642, - /* 2050 */ 643, 1522, 645, 646, 647, 1520, 649, 1818, 651, 1804, - /* 2060 */ 650, 1797, 1787, 580, 1789, 1790, 576, 578, 571, 1518, - /* 2070 */ 653, 654, 1756, 655, 577, 1804, 1506, 657, 1002, 1488, - /* 2080 */ 266, 661, 664, 578, 1263, 274, 665, 1463, 1756, 1463, - /* 2090 */ 577, 1463, 1463, 1463, 1463, 1463, 1463, 1818, 1786, 1463, - /* 2100 */ 1463, 1796, 1787, 580, 1789, 1790, 576, 1463, 571, 1463, - /* 2110 */ 1463, 1463, 1463, 1818, 1786, 1463, 1463, 310, 1787, 580, - /* 2120 */ 1789, 1790, 576, 1463, 571, 1463, 1804, 1463, 1463, 1463, - /* 2130 */ 1463, 1463, 1463, 1463, 578, 1463, 1463, 1463, 1463, 1756, - /* 2140 */ 1463, 577, 1804, 1463, 1463, 1463, 1463, 1463, 1463, 1463, - /* 2150 */ 578, 1463, 1463, 1463, 1463, 1756, 1463, 577, 1463, 1463, - /* 2160 */ 1463, 1463, 1463, 1463, 1818, 1786, 1463, 1463, 309, 1787, - /* 2170 */ 580, 1789, 1790, 576, 1463, 571, 1463, 1463, 1463, 1463, - /* 2180 */ 1818, 1786, 1463, 1463, 311, 1787, 580, 1789, 1790, 576, - /* 2190 */ 1463, 571, 1463, 1804, 1463, 1463, 1463, 1463, 1463, 1463, - /* 2200 */ 1463, 578, 1463, 1463, 1463, 1463, 1756, 1463, 577, 1804, - /* 2210 */ 1463, 1463, 1463, 1463, 1463, 1463, 1463, 578, 1463, 1463, - /* 2220 */ 1463, 1463, 1756, 1463, 577, 1463, 1463, 1463, 1463, 1463, - /* 2230 */ 1463, 1818, 1463, 1463, 1463, 308, 1787, 580, 1789, 1790, - /* 2240 */ 576, 1463, 571, 1463, 1463, 1463, 1463, 1818, 1463, 1463, - /* 2250 */ 1463, 287, 1787, 580, 1789, 1790, 576, 1463, 571, + /* 0 */ 436, 379, 437, 1516, 1809, 91, 516, 444, 1616, 437, + /* 10 */ 1516, 1614, 39, 37, 553, 64, 30, 260, 124, 1793, + /* 20 */ 340, 1953, 1278, 33, 32, 1016, 1617, 40, 38, 36, + /* 30 */ 35, 34, 1827, 1354, 1952, 1276, 385, 148, 1950, 1493, + /* 40 */ 582, 1953, 127, 1789, 1795, 1779, 1953, 581, 40, 38, + /* 50 */ 36, 35, 34, 556, 164, 575, 1349, 517, 1950, 164, + /* 60 */ 558, 14, 558, 1950, 326, 1020, 1021, 1725, 1284, 1543, + /* 70 */ 1841, 1304, 74, 303, 94, 1810, 584, 1812, 1813, 580, + /* 80 */ 125, 575, 1504, 173, 1887, 122, 217, 345, 306, 1883, + /* 90 */ 1670, 1672, 1, 556, 1620, 250, 1895, 552, 63, 551, + /* 100 */ 1953, 107, 1953, 63, 106, 105, 104, 103, 102, 101, + /* 110 */ 100, 99, 98, 166, 670, 166, 453, 1950, 71, 1950, + /* 120 */ 1421, 70, 63, 1779, 78, 42, 1303, 1303, 1356, 1357, + /* 130 */ 11, 10, 647, 646, 645, 644, 350, 1503, 643, 642, + /* 140 */ 128, 637, 636, 635, 634, 633, 632, 631, 139, 627, + /* 150 */ 626, 625, 349, 348, 622, 621, 620, 619, 618, 530, + /* 160 */ 500, 33, 32, 196, 1481, 40, 38, 36, 35, 34, + /* 170 */ 55, 223, 224, 498, 1279, 496, 1277, 152, 1779, 1175, + /* 180 */ 1176, 1474, 470, 466, 462, 458, 195, 1625, 116, 115, + /* 190 */ 114, 113, 112, 111, 110, 109, 108, 1282, 1283, 63, + /* 200 */ 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, 577, 573, + /* 210 */ 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358, 39, 37, + /* 220 */ 1417, 75, 1390, 302, 193, 1301, 340, 84, 1278, 1809, + /* 230 */ 305, 167, 415, 520, 1953, 427, 353, 167, 530, 1354, + /* 240 */ 542, 1276, 167, 1677, 1798, 553, 1448, 165, 1618, 169, + /* 250 */ 328, 1950, 400, 1677, 428, 1793, 402, 1827, 1953, 1675, + /* 260 */ 344, 167, 1349, 1304, 167, 582, 1625, 14, 1473, 1675, + /* 270 */ 1779, 1951, 581, 127, 1284, 1950, 1953, 33, 32, 1789, + /* 280 */ 1795, 40, 38, 36, 35, 34, 1797, 192, 186, 164, + /* 290 */ 191, 575, 49, 1950, 449, 1841, 393, 1793, 2, 95, + /* 300 */ 1810, 584, 1812, 1813, 580, 1303, 575, 1333, 389, 1887, + /* 310 */ 184, 125, 22, 331, 1883, 1966, 556, 548, 543, 158, + /* 320 */ 670, 1789, 1795, 329, 1921, 555, 160, 1895, 1896, 1724, + /* 330 */ 1900, 300, 1664, 575, 1356, 1357, 426, 1479, 167, 421, + /* 340 */ 420, 419, 418, 417, 414, 413, 412, 411, 410, 406, + /* 350 */ 405, 404, 403, 397, 396, 395, 394, 1522, 391, 390, + /* 360 */ 314, 1902, 1133, 606, 605, 604, 1137, 603, 1139, 1140, + /* 370 */ 602, 1142, 599, 530, 1148, 596, 1150, 1151, 593, 590, + /* 380 */ 1279, 327, 1277, 317, 383, 1899, 33, 32, 43, 146, + /* 390 */ 40, 38, 36, 35, 34, 150, 355, 547, 1627, 1584, + /* 400 */ 1033, 1625, 1032, 1282, 1283, 665, 1331, 1332, 1334, 1335, + /* 410 */ 1336, 1337, 1338, 1339, 577, 573, 1347, 1348, 1350, 1351, + /* 420 */ 1352, 1353, 1355, 1358, 39, 37, 1809, 491, 1671, 1672, + /* 430 */ 1034, 167, 340, 1723, 1278, 300, 1953, 1302, 36, 35, + /* 440 */ 34, 318, 501, 316, 315, 1354, 476, 1276, 1677, 164, + /* 450 */ 478, 1305, 222, 1950, 1827, 312, 209, 1602, 486, 485, + /* 460 */ 1364, 1603, 582, 617, 1675, 123, 1303, 1779, 1349, 581, + /* 470 */ 494, 1428, 477, 14, 488, 481, 484, 26, 343, 208, + /* 480 */ 1284, 480, 558, 33, 32, 346, 146, 40, 38, 36, + /* 490 */ 35, 34, 1841, 146, 7, 1627, 94, 1810, 584, 1812, + /* 500 */ 1813, 580, 1627, 575, 2, 609, 1887, 1378, 553, 530, + /* 510 */ 306, 1883, 1258, 1259, 58, 435, 1953, 57, 439, 1502, + /* 520 */ 117, 453, 1953, 147, 1827, 63, 670, 474, 278, 165, + /* 530 */ 1809, 1501, 546, 1950, 374, 164, 127, 1625, 28, 1950, + /* 540 */ 1356, 1357, 276, 60, 33, 32, 59, 1284, 40, 38, + /* 550 */ 36, 35, 34, 376, 372, 337, 336, 1500, 1827, 530, + /* 560 */ 1779, 615, 180, 432, 430, 1292, 582, 1728, 545, 27, + /* 570 */ 117, 1779, 1779, 581, 125, 517, 1354, 479, 1285, 1383, + /* 580 */ 137, 136, 612, 611, 610, 1726, 1279, 1625, 1277, 161, + /* 590 */ 1895, 1896, 252, 1900, 629, 1499, 1841, 63, 1779, 1349, + /* 600 */ 149, 1810, 584, 1812, 1813, 580, 378, 575, 377, 1282, + /* 610 */ 1283, 1284, 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, + /* 620 */ 577, 573, 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358, + /* 630 */ 39, 37, 1902, 1278, 1498, 93, 1779, 1497, 340, 630, + /* 640 */ 1278, 1597, 441, 1601, 559, 1967, 1276, 1333, 1301, 1610, + /* 650 */ 1033, 1354, 1032, 1276, 33, 32, 1898, 570, 40, 38, + /* 660 */ 36, 35, 34, 1546, 167, 472, 443, 352, 1612, 439, + /* 670 */ 1496, 68, 67, 382, 1349, 1779, 171, 1608, 1779, 1284, + /* 680 */ 1034, 210, 1495, 33, 32, 1410, 1284, 40, 38, 36, + /* 690 */ 35, 34, 301, 530, 1809, 370, 74, 368, 364, 360, + /* 700 */ 357, 354, 1492, 617, 384, 1020, 1021, 1953, 33, 32, + /* 710 */ 8, 1779, 40, 38, 36, 35, 34, 1293, 1621, 1288, + /* 720 */ 164, 1625, 1827, 1779, 1950, 670, 213, 486, 485, 1491, + /* 730 */ 557, 1490, 670, 502, 123, 1779, 167, 581, 76, 305, + /* 740 */ 1296, 1298, 520, 1779, 481, 484, 1356, 1357, 1489, 1095, + /* 750 */ 480, 1902, 573, 1347, 1348, 1350, 1351, 1352, 1353, 1438, + /* 760 */ 1841, 307, 1907, 1410, 95, 1810, 584, 1812, 1813, 580, + /* 770 */ 1779, 575, 1779, 1953, 1887, 1897, 615, 1718, 331, 1883, + /* 780 */ 159, 1414, 1097, 483, 482, 1279, 164, 1277, 172, 1779, + /* 790 */ 1950, 478, 1279, 1316, 1277, 137, 136, 612, 611, 610, + /* 800 */ 1914, 1376, 539, 1436, 1437, 1439, 1440, 145, 1282, 1283, + /* 810 */ 1488, 1809, 1487, 477, 1486, 1282, 1283, 1306, 1331, 1332, + /* 820 */ 1334, 1335, 1336, 1337, 1338, 1339, 577, 573, 1347, 1348, + /* 830 */ 1350, 1351, 1352, 1353, 1355, 1358, 39, 37, 1359, 1827, + /* 840 */ 1482, 146, 422, 509, 340, 1060, 1278, 582, 1485, 167, + /* 850 */ 1628, 1779, 1779, 1779, 581, 1779, 1377, 1354, 1484, 1276, + /* 860 */ 1677, 107, 1718, 61, 106, 105, 104, 103, 102, 101, + /* 870 */ 100, 99, 98, 175, 641, 639, 1676, 1841, 1061, 1303, + /* 880 */ 1349, 96, 1810, 584, 1812, 1813, 580, 613, 575, 1779, + /* 890 */ 1668, 1887, 1284, 44, 4, 1886, 1883, 177, 176, 1779, + /* 900 */ 614, 33, 32, 1668, 1797, 40, 38, 36, 35, 34, + /* 910 */ 272, 135, 576, 1655, 1809, 1793, 9, 1766, 29, 338, + /* 920 */ 1371, 1372, 1373, 1374, 1375, 1379, 1380, 1381, 1382, 33, + /* 930 */ 32, 1809, 530, 40, 38, 36, 35, 34, 670, 1789, + /* 940 */ 1795, 335, 1827, 392, 562, 530, 608, 324, 1533, 386, + /* 950 */ 582, 575, 1356, 1357, 307, 1779, 407, 581, 232, 1827, + /* 960 */ 1625, 54, 387, 201, 362, 203, 199, 582, 202, 1494, + /* 970 */ 487, 530, 1779, 1625, 581, 53, 513, 11, 10, 530, + /* 980 */ 1841, 216, 408, 565, 294, 1810, 584, 1812, 1813, 580, + /* 990 */ 451, 575, 553, 205, 1376, 1528, 204, 1841, 1279, 1625, + /* 1000 */ 1277, 96, 1810, 584, 1812, 1813, 580, 1625, 575, 1413, + /* 1010 */ 207, 1887, 41, 206, 1316, 569, 1883, 489, 255, 77, + /* 1020 */ 127, 1282, 1283, 1526, 1331, 1332, 1334, 1335, 1336, 1337, + /* 1030 */ 1338, 1339, 577, 573, 1347, 1348, 1350, 1351, 1352, 1353, + /* 1040 */ 1355, 1358, 39, 37, 530, 492, 221, 1585, 530, 1377, + /* 1050 */ 340, 131, 1278, 134, 673, 452, 530, 1287, 125, 1622, + /* 1060 */ 1333, 471, 1229, 1354, 1809, 1276, 1286, 503, 267, 1476, + /* 1070 */ 1477, 540, 1625, 162, 1895, 1896, 1625, 1900, 571, 1800, + /* 1080 */ 623, 135, 156, 51, 1625, 90, 1349, 663, 659, 655, + /* 1090 */ 651, 265, 1827, 1600, 244, 87, 225, 531, 1284, 530, + /* 1100 */ 582, 523, 1079, 229, 1809, 1779, 236, 581, 560, 1828, + /* 1110 */ 510, 29, 338, 1371, 1372, 1373, 1374, 1375, 1379, 1380, + /* 1120 */ 1381, 1382, 9, 41, 624, 1802, 92, 1625, 351, 230, + /* 1130 */ 1841, 1126, 1827, 1435, 294, 1810, 584, 1812, 1813, 580, + /* 1140 */ 557, 575, 1665, 51, 670, 1779, 1077, 581, 1517, 41, + /* 1150 */ 588, 563, 530, 1917, 530, 530, 239, 530, 1356, 1357, + /* 1160 */ 554, 134, 527, 514, 249, 227, 526, 254, 528, 257, + /* 1170 */ 1841, 135, 259, 271, 95, 1810, 584, 1812, 1813, 580, + /* 1180 */ 1625, 575, 1625, 1625, 1887, 1625, 3, 5, 331, 1883, + /* 1190 */ 159, 356, 566, 1384, 361, 219, 313, 615, 1290, 1340, + /* 1200 */ 1154, 530, 163, 119, 1279, 134, 1277, 1289, 1245, 174, + /* 1210 */ 1913, 1158, 529, 1252, 1368, 212, 137, 136, 612, 611, + /* 1220 */ 610, 1165, 268, 388, 1301, 409, 1720, 1282, 1283, 1625, + /* 1230 */ 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, 577, 573, + /* 1240 */ 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358, 39, 37, + /* 1250 */ 1809, 530, 530, 1163, 416, 138, 340, 424, 1278, 423, + /* 1260 */ 425, 429, 261, 347, 431, 433, 1307, 1309, 434, 1354, + /* 1270 */ 442, 1276, 445, 183, 446, 185, 1308, 447, 1827, 1625, + /* 1280 */ 1625, 1310, 188, 448, 450, 190, 582, 72, 73, 454, + /* 1290 */ 194, 1779, 1349, 581, 473, 475, 118, 1615, 304, 198, + /* 1300 */ 1611, 1759, 200, 269, 1284, 140, 504, 141, 211, 505, + /* 1310 */ 1809, 1613, 1609, 142, 143, 214, 1841, 511, 218, 515, + /* 1320 */ 95, 1810, 584, 1812, 1813, 580, 553, 575, 2, 538, + /* 1330 */ 1887, 524, 508, 81, 331, 1883, 1966, 323, 1827, 83, + /* 1340 */ 518, 132, 1758, 1730, 521, 1944, 582, 1306, 133, 525, + /* 1350 */ 670, 1779, 1626, 581, 127, 270, 325, 1928, 534, 541, + /* 1360 */ 1918, 536, 6, 234, 1356, 1357, 537, 330, 544, 1909, + /* 1370 */ 550, 535, 533, 238, 558, 532, 1841, 1305, 1410, 126, + /* 1380 */ 95, 1810, 584, 1812, 1813, 580, 567, 575, 564, 48, + /* 1390 */ 1887, 332, 125, 246, 331, 1883, 1966, 1927, 243, 248, + /* 1400 */ 1903, 85, 586, 1669, 1598, 1906, 247, 250, 1895, 552, + /* 1410 */ 1279, 551, 1277, 1868, 1953, 153, 273, 264, 666, 667, + /* 1420 */ 52, 669, 299, 286, 275, 245, 1809, 164, 296, 1773, + /* 1430 */ 277, 1950, 295, 1282, 1283, 65, 1331, 1332, 1334, 1335, + /* 1440 */ 1336, 1337, 1338, 1339, 577, 573, 1347, 1348, 1350, 1351, + /* 1450 */ 1352, 1353, 1355, 1358, 1827, 1969, 1772, 1949, 1771, 253, + /* 1460 */ 1770, 256, 582, 66, 561, 568, 258, 1779, 1767, 581, + /* 1470 */ 359, 358, 1270, 1271, 170, 363, 1765, 365, 366, 367, + /* 1480 */ 1764, 369, 558, 1763, 371, 1762, 373, 1809, 1761, 375, + /* 1490 */ 1248, 1741, 1841, 1247, 1740, 380, 285, 1810, 584, 1812, + /* 1500 */ 1813, 580, 381, 575, 1739, 1738, 1713, 1217, 1712, 1711, + /* 1510 */ 1710, 129, 1709, 1708, 69, 1827, 1707, 1706, 1705, 1704, + /* 1520 */ 1703, 398, 1953, 582, 399, 1702, 401, 1701, 1779, 1700, + /* 1530 */ 581, 1699, 1698, 1697, 1696, 166, 1695, 1694, 1693, 1950, + /* 1540 */ 1692, 1691, 1690, 558, 1809, 1689, 1688, 1687, 1686, 130, + /* 1550 */ 1685, 1684, 1683, 1841, 178, 1547, 179, 285, 1810, 584, + /* 1560 */ 1812, 1813, 580, 1682, 575, 1219, 1681, 1680, 1679, 1678, + /* 1570 */ 1809, 1548, 1827, 1545, 1513, 1023, 438, 181, 120, 1022, + /* 1580 */ 579, 1512, 1754, 1953, 1748, 1779, 1737, 581, 189, 1736, + /* 1590 */ 1722, 1604, 157, 1544, 1542, 121, 164, 182, 1827, 440, + /* 1600 */ 1950, 187, 1540, 1538, 1536, 455, 582, 456, 1525, 1524, + /* 1610 */ 1841, 1779, 459, 581, 293, 1810, 584, 1812, 1813, 580, + /* 1620 */ 578, 575, 572, 1859, 457, 460, 1053, 461, 1809, 1509, + /* 1630 */ 463, 465, 467, 1606, 464, 469, 1841, 1168, 1605, 97, + /* 1640 */ 96, 1810, 584, 1812, 1813, 580, 1809, 575, 468, 1169, + /* 1650 */ 1887, 1094, 1093, 638, 640, 1884, 1827, 1090, 197, 50, + /* 1660 */ 1089, 1088, 1534, 319, 582, 1529, 320, 490, 1527, 1779, + /* 1670 */ 321, 581, 493, 1508, 1827, 1507, 1506, 495, 497, 499, + /* 1680 */ 1753, 1254, 582, 56, 1747, 506, 215, 1779, 144, 581, + /* 1690 */ 1735, 1733, 1734, 1732, 1841, 1731, 1809, 15, 289, 1810, + /* 1700 */ 584, 1812, 1813, 580, 1262, 575, 220, 519, 1729, 1721, + /* 1710 */ 80, 45, 1841, 226, 87, 41, 149, 1810, 584, 1812, + /* 1720 */ 1813, 580, 1809, 575, 1827, 231, 79, 82, 23, 47, + /* 1730 */ 16, 241, 579, 507, 17, 522, 549, 1779, 512, 581, + /* 1740 */ 322, 1462, 1450, 233, 242, 235, 1809, 1432, 237, 1800, + /* 1750 */ 1827, 1434, 151, 240, 25, 339, 228, 1427, 582, 24, + /* 1760 */ 251, 1968, 1841, 1779, 46, 581, 293, 1810, 584, 1812, + /* 1770 */ 1813, 580, 1799, 575, 1827, 1860, 1407, 86, 154, 341, + /* 1780 */ 1406, 18, 582, 1461, 333, 1466, 1465, 1779, 1841, 581, + /* 1790 */ 1467, 334, 294, 1810, 584, 1812, 1813, 580, 1456, 575, + /* 1800 */ 10, 1294, 19, 1369, 1809, 1844, 155, 168, 1344, 574, + /* 1810 */ 1324, 1342, 1841, 1341, 31, 13, 294, 1810, 584, 1812, + /* 1820 */ 1813, 580, 12, 575, 1155, 20, 583, 21, 585, 587, + /* 1830 */ 342, 589, 1827, 1152, 591, 592, 594, 1149, 595, 597, + /* 1840 */ 582, 600, 1132, 1147, 598, 1779, 1143, 581, 1141, 601, + /* 1850 */ 1146, 1164, 1145, 1144, 88, 1809, 89, 62, 607, 1160, + /* 1860 */ 262, 1085, 1051, 616, 1084, 1809, 1083, 1082, 1081, 1080, + /* 1870 */ 1841, 1078, 628, 1076, 279, 1810, 584, 1812, 1813, 580, + /* 1880 */ 1075, 575, 1074, 1827, 1072, 263, 1101, 1071, 1070, 1069, + /* 1890 */ 1068, 582, 1067, 1827, 1066, 1098, 1779, 1096, 581, 1063, + /* 1900 */ 1062, 582, 1059, 1057, 1058, 1056, 1779, 1541, 581, 648, + /* 1910 */ 649, 650, 1539, 652, 654, 1537, 658, 656, 1809, 1535, + /* 1920 */ 653, 1841, 660, 657, 662, 280, 1810, 584, 1812, 1813, + /* 1930 */ 580, 1841, 575, 661, 1809, 281, 1810, 584, 1812, 1813, + /* 1940 */ 580, 1523, 575, 664, 1013, 1505, 1827, 266, 668, 1480, + /* 1950 */ 1280, 274, 671, 672, 582, 1480, 1480, 1480, 1809, 1779, + /* 1960 */ 1480, 581, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 1970 */ 582, 1480, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, + /* 1980 */ 1480, 1480, 1480, 1480, 1841, 1480, 1827, 1480, 288, 1810, + /* 1990 */ 584, 1812, 1813, 580, 582, 575, 1480, 1480, 1480, 1779, + /* 2000 */ 1841, 581, 1480, 1480, 290, 1810, 584, 1812, 1813, 580, + /* 2010 */ 1809, 575, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2020 */ 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480, 282, 1810, + /* 2030 */ 584, 1812, 1813, 580, 1809, 575, 1480, 1480, 1827, 1480, + /* 2040 */ 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480, + /* 2050 */ 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480, 1809, 1480, + /* 2060 */ 1480, 1480, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2070 */ 582, 1480, 1480, 1480, 1809, 1779, 1841, 581, 1480, 1480, + /* 2080 */ 291, 1810, 584, 1812, 1813, 580, 1827, 575, 1480, 1480, + /* 2090 */ 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480, 1480, 1779, + /* 2100 */ 1841, 581, 1827, 1480, 283, 1810, 584, 1812, 1813, 580, + /* 2110 */ 582, 575, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, + /* 2120 */ 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480, 292, 1810, + /* 2130 */ 584, 1812, 1813, 580, 1480, 575, 1480, 1480, 1480, 1480, + /* 2140 */ 1841, 1480, 1480, 1480, 284, 1810, 584, 1812, 1813, 580, + /* 2150 */ 1480, 575, 1809, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2160 */ 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2170 */ 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2180 */ 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, + /* 2190 */ 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480, + /* 2200 */ 1480, 1480, 1480, 1809, 1480, 1480, 1480, 1480, 1480, 1480, + /* 2210 */ 1480, 1480, 1480, 1809, 1480, 1480, 1480, 1480, 1841, 1480, + /* 2220 */ 1480, 1480, 297, 1810, 584, 1812, 1813, 580, 1480, 575, + /* 2230 */ 1480, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582, + /* 2240 */ 1480, 1827, 1480, 1480, 1779, 1480, 581, 1480, 1480, 582, + /* 2250 */ 1480, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480, + /* 2260 */ 1480, 1480, 1480, 1480, 1480, 1480, 1809, 1480, 1480, 1841, + /* 2270 */ 1480, 1480, 1480, 298, 1810, 584, 1812, 1813, 580, 1841, + /* 2280 */ 575, 1480, 1809, 1821, 1810, 584, 1812, 1813, 580, 1480, + /* 2290 */ 575, 1480, 1480, 1480, 1827, 1480, 1480, 1480, 1480, 1480, + /* 2300 */ 1480, 1480, 582, 1480, 1480, 1480, 1809, 1779, 1480, 581, + /* 2310 */ 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, + /* 2320 */ 1480, 1480, 1809, 1779, 1480, 581, 1480, 1480, 1480, 1480, + /* 2330 */ 1480, 1480, 1841, 1480, 1827, 1480, 1820, 1810, 584, 1812, + /* 2340 */ 1813, 580, 582, 575, 1480, 1480, 1809, 1779, 1841, 581, + /* 2350 */ 1827, 1480, 1819, 1810, 584, 1812, 1813, 580, 582, 575, + /* 2360 */ 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480, + /* 2370 */ 1809, 1480, 1841, 1480, 1827, 1480, 310, 1810, 584, 1812, + /* 2380 */ 1813, 580, 582, 575, 1480, 1480, 1809, 1779, 1841, 581, + /* 2390 */ 1480, 1480, 309, 1810, 584, 1812, 1813, 580, 1827, 575, + /* 2400 */ 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480, + /* 2410 */ 1480, 1779, 1841, 581, 1827, 1480, 311, 1810, 584, 1812, + /* 2420 */ 1813, 580, 582, 575, 1480, 1480, 1480, 1779, 1480, 581, + /* 2430 */ 1480, 1480, 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480, + /* 2440 */ 308, 1810, 584, 1812, 1813, 580, 1480, 575, 1480, 1480, + /* 2450 */ 1480, 1480, 1841, 1480, 1480, 1480, 287, 1810, 584, 1812, + /* 2460 */ 1813, 580, 1480, 575, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 312, 404, 314, 315, 337, 312, 316, 314, 315, 351, - /* 10 */ 389, 390, 12, 13, 417, 328, 358, 327, 421, 361, - /* 20 */ 20, 0, 22, 336, 334, 12, 13, 14, 15, 16, - /* 30 */ 308, 20, 345, 33, 344, 35, 347, 20, 20, 350, - /* 40 */ 351, 364, 21, 338, 316, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 349, 327, 56, 313, 336, 4, - /* 60 */ 316, 61, 334, 14, 15, 16, 344, 307, 68, 309, - /* 70 */ 60, 349, 344, 351, 12, 13, 14, 338, 373, 374, - /* 80 */ 375, 404, 20, 0, 22, 336, 56, 20, 349, 89, - /* 90 */ 385, 4, 336, 344, 417, 33, 374, 35, 421, 343, - /* 100 */ 378, 379, 380, 381, 382, 383, 89, 385, 352, 335, - /* 110 */ 388, 111, 373, 374, 392, 393, 394, 351, 56, 89, - /* 120 */ 404, 91, 348, 61, 385, 125, 126, 361, 406, 380, - /* 130 */ 68, 44, 45, 417, 8, 9, 414, 421, 12, 13, - /* 140 */ 14, 15, 16, 20, 89, 89, 63, 64, 65, 66, - /* 150 */ 67, 89, 69, 70, 71, 72, 73, 74, 75, 76, - /* 160 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 170 */ 170, 21, 172, 111, 24, 25, 26, 27, 28, 29, - /* 180 */ 30, 31, 32, 313, 338, 20, 316, 125, 126, 120, - /* 190 */ 121, 1, 2, 193, 194, 349, 196, 197, 198, 199, + /* 0 */ 315, 367, 317, 318, 311, 321, 367, 315, 341, 317, + /* 10 */ 318, 340, 12, 13, 319, 4, 392, 393, 334, 352, + /* 20 */ 20, 407, 22, 8, 9, 4, 342, 12, 13, 14, + /* 30 */ 15, 16, 339, 33, 420, 35, 319, 310, 424, 312, + /* 40 */ 347, 407, 347, 376, 377, 352, 407, 354, 12, 13, + /* 50 */ 14, 15, 16, 20, 420, 388, 56, 354, 424, 420, + /* 60 */ 367, 61, 367, 424, 361, 44, 45, 364, 68, 0, + /* 70 */ 377, 20, 323, 356, 381, 382, 383, 384, 385, 386, + /* 80 */ 385, 388, 311, 56, 391, 336, 56, 350, 395, 396, + /* 90 */ 353, 354, 92, 20, 345, 400, 401, 402, 92, 404, + /* 100 */ 407, 21, 407, 92, 24, 25, 26, 27, 28, 29, + /* 110 */ 30, 31, 32, 420, 114, 420, 60, 424, 91, 424, + /* 120 */ 14, 94, 92, 352, 94, 92, 20, 20, 128, 129, + /* 130 */ 1, 2, 63, 64, 65, 66, 67, 311, 69, 70, + /* 140 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + /* 150 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 319, + /* 160 */ 21, 8, 9, 33, 0, 12, 13, 14, 15, 16, + /* 170 */ 330, 123, 124, 34, 174, 36, 176, 47, 352, 128, + /* 180 */ 129, 166, 52, 53, 54, 55, 56, 347, 24, 25, + /* 190 */ 26, 27, 28, 29, 30, 31, 32, 197, 198, 92, /* 200 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 210 */ 210, 211, 212, 213, 0, 21, 90, 8, 9, 373, - /* 220 */ 374, 12, 13, 14, 15, 16, 316, 227, 34, 321, - /* 230 */ 36, 385, 170, 325, 172, 22, 121, 327, 24, 25, - /* 240 */ 26, 27, 28, 29, 30, 31, 32, 178, 35, 89, - /* 250 */ 181, 360, 43, 362, 344, 193, 194, 227, 196, 197, - /* 260 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - /* 270 */ 208, 209, 210, 211, 212, 213, 12, 13, 350, 351, - /* 280 */ 90, 68, 227, 227, 20, 20, 22, 60, 20, 89, - /* 290 */ 125, 126, 177, 178, 308, 308, 181, 33, 193, 35, - /* 300 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - /* 310 */ 112, 328, 114, 115, 116, 117, 118, 119, 20, 336, - /* 320 */ 56, 0, 336, 56, 111, 61, 322, 323, 345, 169, - /* 330 */ 344, 171, 68, 336, 404, 349, 349, 351, 12, 13, - /* 340 */ 343, 236, 237, 238, 239, 240, 20, 417, 22, 352, - /* 350 */ 0, 421, 318, 89, 89, 88, 336, 89, 91, 33, - /* 360 */ 374, 35, 68, 343, 378, 379, 380, 381, 382, 383, - /* 370 */ 100, 385, 352, 339, 388, 111, 328, 337, 392, 393, - /* 380 */ 394, 20, 56, 170, 336, 172, 20, 227, 22, 125, - /* 390 */ 126, 8, 9, 345, 68, 12, 13, 14, 15, 16, - /* 400 */ 414, 404, 316, 12, 13, 14, 193, 194, 308, 308, - /* 410 */ 101, 20, 308, 22, 417, 89, 50, 14, 421, 322, - /* 420 */ 323, 35, 101, 20, 33, 68, 35, 227, 316, 120, - /* 430 */ 121, 122, 123, 124, 170, 344, 172, 111, 308, 353, - /* 440 */ 336, 120, 121, 122, 123, 124, 355, 56, 344, 349, - /* 450 */ 349, 125, 126, 349, 68, 351, 344, 193, 194, 68, - /* 460 */ 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, - /* 470 */ 206, 207, 208, 209, 210, 211, 212, 213, 374, 349, - /* 480 */ 89, 337, 378, 379, 380, 381, 382, 383, 384, 385, - /* 490 */ 386, 387, 227, 320, 382, 227, 170, 120, 172, 8, - /* 500 */ 9, 0, 111, 12, 13, 14, 15, 16, 396, 397, - /* 510 */ 398, 399, 337, 401, 308, 342, 125, 126, 157, 193, - /* 520 */ 194, 0, 196, 197, 198, 199, 200, 201, 202, 203, - /* 530 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - /* 540 */ 360, 316, 362, 8, 9, 162, 318, 12, 13, 14, - /* 550 */ 15, 16, 327, 227, 37, 349, 179, 180, 324, 331, - /* 560 */ 326, 170, 376, 172, 2, 64, 65, 339, 305, 344, - /* 570 */ 8, 9, 71, 0, 12, 13, 14, 15, 16, 337, - /* 580 */ 308, 90, 81, 82, 193, 194, 400, 196, 197, 198, - /* 590 */ 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, - /* 600 */ 209, 210, 211, 212, 213, 12, 13, 101, 336, 92, - /* 610 */ 336, 94, 95, 20, 97, 22, 344, 152, 101, 345, - /* 620 */ 316, 349, 101, 351, 2, 90, 33, 364, 35, 123, - /* 630 */ 8, 9, 249, 60, 12, 13, 14, 15, 16, 155, - /* 640 */ 123, 120, 121, 122, 123, 124, 374, 344, 344, 56, - /* 650 */ 378, 379, 380, 381, 382, 383, 337, 385, 355, 320, - /* 660 */ 388, 68, 316, 346, 392, 393, 349, 404, 364, 364, - /* 670 */ 8, 9, 333, 327, 12, 13, 14, 15, 16, 214, - /* 680 */ 417, 342, 89, 308, 421, 20, 382, 22, 39, 224, - /* 690 */ 344, 8, 9, 308, 325, 12, 13, 14, 15, 16, - /* 700 */ 35, 397, 398, 399, 111, 401, 8, 9, 404, 404, - /* 710 */ 12, 13, 14, 15, 16, 50, 232, 233, 125, 126, - /* 720 */ 316, 417, 417, 61, 349, 421, 421, 43, 4, 14, - /* 730 */ 316, 327, 12, 13, 349, 20, 308, 18, 376, 20, - /* 740 */ 20, 327, 22, 19, 61, 316, 27, 337, 344, 30, - /* 750 */ 316, 316, 90, 33, 309, 35, 327, 33, 344, 3, - /* 760 */ 98, 327, 400, 170, 165, 172, 47, 308, 49, 308, - /* 770 */ 51, 47, 424, 344, 90, 51, 56, 349, 344, 344, - /* 780 */ 56, 98, 308, 184, 185, 77, 193, 194, 68, 196, - /* 790 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, - /* 800 */ 207, 208, 209, 210, 211, 212, 213, 88, 349, 89, - /* 810 */ 349, 4, 88, 316, 152, 91, 376, 382, 368, 100, - /* 820 */ 20, 8, 9, 349, 327, 12, 13, 14, 15, 16, - /* 830 */ 308, 111, 397, 398, 399, 152, 401, 129, 130, 0, - /* 840 */ 400, 344, 14, 44, 45, 125, 126, 128, 20, 0, - /* 850 */ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - /* 860 */ 141, 142, 143, 144, 145, 146, 147, 148, 316, 150, - /* 870 */ 151, 349, 336, 13, 308, 226, 214, 215, 216, 217, - /* 880 */ 218, 219, 220, 221, 222, 223, 224, 48, 352, 317, - /* 890 */ 170, 346, 172, 20, 349, 35, 344, 214, 215, 216, - /* 900 */ 217, 218, 219, 220, 221, 222, 223, 224, 329, 60, - /* 910 */ 415, 332, 197, 193, 194, 349, 196, 197, 198, 199, - /* 920 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - /* 930 */ 210, 211, 212, 213, 382, 18, 308, 308, 43, 364, - /* 940 */ 23, 364, 225, 226, 0, 64, 65, 0, 338, 397, - /* 950 */ 398, 399, 71, 401, 37, 38, 336, 157, 41, 349, - /* 960 */ 316, 316, 81, 82, 308, 336, 42, 43, 411, 22, - /* 970 */ 157, 327, 327, 344, 57, 58, 59, 349, 349, 404, - /* 980 */ 351, 404, 315, 373, 374, 375, 308, 308, 344, 344, - /* 990 */ 316, 47, 417, 364, 417, 385, 421, 56, 421, 364, - /* 1000 */ 244, 327, 308, 374, 308, 349, 89, 378, 379, 380, - /* 1010 */ 381, 382, 383, 316, 385, 336, 43, 388, 344, 12, - /* 1020 */ 13, 392, 393, 344, 327, 197, 316, 349, 349, 22, - /* 1030 */ 351, 93, 91, 404, 96, 228, 348, 327, 316, 404, - /* 1040 */ 33, 344, 35, 349, 127, 349, 417, 0, 308, 327, - /* 1050 */ 421, 317, 417, 374, 344, 308, 421, 378, 379, 380, - /* 1060 */ 381, 382, 383, 56, 385, 316, 344, 388, 43, 22, - /* 1070 */ 197, 392, 393, 394, 316, 68, 327, 157, 158, 162, - /* 1080 */ 163, 164, 403, 336, 167, 327, 43, 93, 316, 349, - /* 1090 */ 96, 344, 93, 344, 93, 96, 349, 96, 351, 327, - /* 1100 */ 183, 0, 344, 186, 377, 188, 189, 190, 191, 192, - /* 1110 */ 35, 364, 43, 316, 308, 90, 344, 35, 111, 61, - /* 1120 */ 316, 374, 43, 22, 327, 378, 379, 380, 381, 382, - /* 1130 */ 383, 327, 385, 90, 43, 388, 43, 402, 19, 392, - /* 1140 */ 393, 344, 336, 248, 227, 43, 43, 341, 344, 43, - /* 1150 */ 344, 404, 33, 89, 308, 349, 13, 351, 43, 90, - /* 1160 */ 46, 1, 2, 99, 417, 395, 47, 405, 421, 90, - /* 1170 */ 418, 52, 53, 54, 55, 56, 43, 170, 35, 172, - /* 1180 */ 374, 90, 336, 90, 378, 379, 380, 381, 382, 383, - /* 1190 */ 344, 385, 90, 90, 308, 349, 90, 351, 125, 126, - /* 1200 */ 193, 194, 418, 89, 418, 90, 43, 88, 43, 229, - /* 1210 */ 91, 35, 205, 206, 207, 208, 209, 210, 211, 246, - /* 1220 */ 374, 47, 336, 90, 378, 379, 380, 381, 382, 383, - /* 1230 */ 344, 385, 366, 372, 388, 349, 43, 351, 392, 393, - /* 1240 */ 394, 43, 316, 124, 68, 371, 168, 172, 42, 403, - /* 1250 */ 356, 193, 20, 90, 172, 90, 316, 356, 316, 152, - /* 1260 */ 374, 354, 354, 308, 378, 379, 380, 381, 382, 383, - /* 1270 */ 344, 385, 316, 316, 388, 156, 316, 20, 392, 393, - /* 1280 */ 394, 310, 310, 90, 20, 370, 320, 351, 90, 403, - /* 1290 */ 364, 336, 20, 174, 320, 176, 363, 20, 320, 344, - /* 1300 */ 365, 320, 363, 320, 349, 320, 351, 316, 382, 320, - /* 1310 */ 310, 336, 336, 336, 316, 336, 310, 308, 336, 364, - /* 1320 */ 336, 370, 336, 397, 398, 399, 336, 401, 336, 374, - /* 1330 */ 404, 336, 336, 378, 379, 380, 381, 382, 383, 318, - /* 1340 */ 385, 175, 349, 417, 318, 336, 316, 421, 351, 316, - /* 1350 */ 318, 363, 234, 344, 349, 154, 369, 349, 349, 404, - /* 1360 */ 351, 359, 349, 349, 349, 20, 318, 308, 357, 359, - /* 1370 */ 332, 318, 417, 364, 235, 344, 421, 349, 410, 359, - /* 1380 */ 377, 359, 241, 374, 308, 349, 349, 378, 379, 380, - /* 1390 */ 381, 382, 383, 349, 385, 336, 161, 243, 349, 242, - /* 1400 */ 230, 372, 20, 344, 226, 344, 247, 245, 349, 89, - /* 1410 */ 351, 376, 336, 404, 410, 89, 349, 250, 326, 36, - /* 1420 */ 344, 340, 318, 311, 412, 349, 417, 351, 410, 413, - /* 1430 */ 421, 407, 409, 374, 308, 408, 419, 378, 379, 380, - /* 1440 */ 381, 382, 383, 391, 385, 316, 310, 388, 362, 319, - /* 1450 */ 374, 392, 393, 419, 378, 379, 380, 381, 382, 383, - /* 1460 */ 308, 385, 336, 367, 425, 420, 420, 330, 330, 419, - /* 1470 */ 344, 420, 330, 0, 306, 349, 0, 351, 177, 0, - /* 1480 */ 0, 42, 0, 35, 187, 35, 35, 35, 336, 187, - /* 1490 */ 0, 35, 35, 341, 187, 0, 344, 187, 422, 423, - /* 1500 */ 374, 349, 0, 351, 378, 379, 380, 381, 382, 383, - /* 1510 */ 308, 385, 35, 0, 388, 22, 0, 170, 35, 393, - /* 1520 */ 172, 0, 308, 166, 165, 0, 374, 0, 0, 0, - /* 1530 */ 378, 379, 380, 381, 382, 383, 308, 385, 336, 0, - /* 1540 */ 46, 42, 0, 0, 149, 0, 344, 144, 0, 35, - /* 1550 */ 336, 349, 0, 351, 0, 0, 0, 144, 344, 0, - /* 1560 */ 0, 0, 0, 349, 336, 351, 0, 0, 0, 0, - /* 1570 */ 0, 0, 344, 0, 0, 0, 374, 349, 0, 351, - /* 1580 */ 378, 379, 380, 381, 382, 383, 42, 385, 374, 308, - /* 1590 */ 0, 0, 378, 379, 380, 381, 382, 383, 0, 385, - /* 1600 */ 0, 0, 374, 22, 0, 0, 378, 379, 380, 381, - /* 1610 */ 382, 383, 0, 385, 0, 387, 0, 336, 416, 0, - /* 1620 */ 56, 0, 341, 39, 42, 344, 33, 0, 56, 0, - /* 1630 */ 349, 43, 351, 46, 14, 46, 14, 423, 0, 40, - /* 1640 */ 47, 39, 308, 35, 47, 52, 53, 54, 55, 56, - /* 1650 */ 0, 0, 0, 161, 308, 374, 39, 0, 0, 378, - /* 1660 */ 379, 380, 381, 382, 383, 0, 385, 0, 308, 62, - /* 1670 */ 336, 0, 39, 0, 35, 341, 39, 47, 344, 0, - /* 1680 */ 35, 88, 336, 349, 91, 351, 39, 47, 0, 35, - /* 1690 */ 344, 47, 39, 0, 0, 349, 336, 351, 0, 0, - /* 1700 */ 22, 35, 96, 0, 344, 35, 22, 98, 374, 349, - /* 1710 */ 0, 351, 378, 379, 380, 381, 382, 383, 43, 385, - /* 1720 */ 374, 35, 308, 43, 378, 379, 380, 381, 382, 383, - /* 1730 */ 35, 385, 0, 22, 374, 22, 308, 0, 378, 379, - /* 1740 */ 380, 381, 382, 383, 22, 385, 153, 154, 308, 156, - /* 1750 */ 336, 49, 35, 160, 0, 35, 0, 0, 344, 35, - /* 1760 */ 22, 20, 0, 349, 336, 351, 35, 157, 0, 176, - /* 1770 */ 22, 0, 344, 0, 159, 157, 336, 349, 154, 351, - /* 1780 */ 0, 0, 157, 0, 344, 89, 173, 90, 374, 349, - /* 1790 */ 35, 351, 378, 379, 380, 381, 382, 383, 0, 385, - /* 1800 */ 0, 89, 374, 155, 89, 308, 378, 379, 380, 381, - /* 1810 */ 382, 383, 153, 385, 374, 308, 182, 39, 378, 379, - /* 1820 */ 380, 381, 382, 383, 89, 385, 99, 43, 46, 89, - /* 1830 */ 43, 308, 90, 336, 89, 43, 90, 90, 89, 46, - /* 1840 */ 90, 344, 231, 336, 43, 46, 349, 89, 351, 89, - /* 1850 */ 89, 344, 43, 90, 89, 308, 349, 231, 351, 336, - /* 1860 */ 90, 46, 90, 46, 46, 90, 225, 344, 43, 90, - /* 1870 */ 35, 374, 349, 231, 351, 378, 379, 380, 381, 382, - /* 1880 */ 383, 374, 385, 336, 35, 378, 379, 380, 381, 382, - /* 1890 */ 383, 344, 385, 35, 35, 35, 349, 374, 351, 35, - /* 1900 */ 2, 378, 379, 380, 381, 382, 383, 22, 385, 193, - /* 1910 */ 43, 308, 89, 22, 90, 89, 46, 90, 89, 100, - /* 1920 */ 90, 374, 89, 89, 46, 378, 379, 380, 381, 382, - /* 1930 */ 383, 308, 385, 89, 35, 90, 35, 89, 195, 336, - /* 1940 */ 90, 35, 89, 35, 90, 89, 35, 344, 35, 113, - /* 1950 */ 89, 308, 349, 90, 351, 90, 113, 89, 22, 336, - /* 1960 */ 113, 89, 35, 101, 113, 89, 89, 344, 43, 22, - /* 1970 */ 61, 308, 349, 35, 351, 35, 62, 374, 35, 336, - /* 1980 */ 35, 378, 379, 380, 381, 382, 383, 344, 385, 35, - /* 1990 */ 35, 308, 349, 35, 351, 43, 68, 374, 35, 336, - /* 2000 */ 35, 378, 379, 380, 381, 382, 383, 344, 385, 87, - /* 2010 */ 22, 35, 349, 22, 351, 35, 35, 374, 68, 336, - /* 2020 */ 35, 378, 379, 380, 381, 382, 383, 344, 385, 35, - /* 2030 */ 35, 308, 349, 35, 351, 35, 22, 374, 35, 0, - /* 2040 */ 35, 378, 379, 380, 381, 382, 383, 308, 385, 47, - /* 2050 */ 39, 0, 35, 47, 39, 0, 35, 374, 39, 336, - /* 2060 */ 47, 378, 379, 380, 381, 382, 383, 344, 385, 0, - /* 2070 */ 35, 47, 349, 39, 351, 336, 0, 35, 35, 0, - /* 2080 */ 22, 21, 21, 344, 22, 22, 20, 426, 349, 426, - /* 2090 */ 351, 426, 426, 426, 426, 426, 426, 374, 308, 426, - /* 2100 */ 426, 378, 379, 380, 381, 382, 383, 426, 385, 426, - /* 2110 */ 426, 426, 426, 374, 308, 426, 426, 378, 379, 380, - /* 2120 */ 381, 382, 383, 426, 385, 426, 336, 426, 426, 426, - /* 2130 */ 426, 426, 426, 426, 344, 426, 426, 426, 426, 349, - /* 2140 */ 426, 351, 336, 426, 426, 426, 426, 426, 426, 426, - /* 2150 */ 344, 426, 426, 426, 426, 349, 426, 351, 426, 426, - /* 2160 */ 426, 426, 426, 426, 374, 308, 426, 426, 378, 379, - /* 2170 */ 380, 381, 382, 383, 426, 385, 426, 426, 426, 426, - /* 2180 */ 374, 308, 426, 426, 378, 379, 380, 381, 382, 383, - /* 2190 */ 426, 385, 426, 336, 426, 426, 426, 426, 426, 426, - /* 2200 */ 426, 344, 426, 426, 426, 426, 349, 426, 351, 336, - /* 2210 */ 426, 426, 426, 426, 426, 426, 426, 344, 426, 426, - /* 2220 */ 426, 426, 349, 426, 351, 426, 426, 426, 426, 426, - /* 2230 */ 426, 374, 426, 426, 426, 378, 379, 380, 381, 382, - /* 2240 */ 383, 426, 385, 426, 426, 426, 426, 374, 426, 426, - /* 2250 */ 426, 378, 379, 380, 381, 382, 383, 426, 385, 426, - /* 2260 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2270 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2280 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2290 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2300 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2310 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2320 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2330 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2340 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2350 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2360 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2370 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2380 */ 426, 426, 426, 426, 426, 426, 426, 426, 426, 426, - /* 2390 */ 426, 426, + /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 12, 13, + /* 220 */ 14, 91, 93, 18, 94, 20, 20, 321, 22, 311, + /* 230 */ 182, 231, 27, 185, 407, 30, 367, 231, 319, 33, + /* 240 */ 159, 35, 231, 339, 341, 319, 93, 420, 342, 330, + /* 250 */ 346, 424, 47, 339, 49, 352, 51, 339, 407, 355, + /* 260 */ 346, 231, 56, 20, 231, 347, 347, 61, 253, 355, + /* 270 */ 352, 420, 354, 347, 68, 424, 407, 8, 9, 376, + /* 280 */ 377, 12, 13, 14, 15, 16, 341, 157, 158, 420, + /* 290 */ 160, 388, 92, 424, 164, 377, 91, 352, 92, 381, + /* 300 */ 382, 383, 384, 385, 386, 20, 388, 201, 103, 391, + /* 310 */ 180, 385, 43, 395, 396, 397, 20, 236, 237, 338, + /* 320 */ 114, 376, 377, 378, 406, 399, 400, 401, 402, 363, + /* 330 */ 404, 365, 351, 388, 128, 129, 131, 308, 231, 134, + /* 340 */ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + /* 350 */ 145, 146, 147, 148, 149, 150, 151, 0, 153, 154, + /* 360 */ 155, 379, 105, 106, 107, 108, 109, 110, 111, 112, + /* 370 */ 113, 114, 115, 319, 117, 118, 119, 120, 121, 122, + /* 380 */ 174, 331, 176, 37, 330, 403, 8, 9, 92, 339, + /* 390 */ 12, 13, 14, 15, 16, 324, 367, 20, 348, 328, + /* 400 */ 20, 347, 22, 197, 198, 48, 200, 201, 202, 203, + /* 410 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + /* 420 */ 214, 215, 216, 217, 12, 13, 311, 4, 353, 354, + /* 430 */ 50, 231, 20, 363, 22, 365, 407, 20, 14, 15, + /* 440 */ 16, 95, 19, 97, 98, 33, 100, 35, 339, 420, + /* 450 */ 104, 20, 123, 424, 339, 346, 33, 0, 64, 65, + /* 460 */ 14, 0, 347, 60, 355, 71, 20, 352, 56, 354, + /* 470 */ 47, 93, 126, 61, 51, 81, 82, 2, 331, 56, + /* 480 */ 68, 87, 367, 8, 9, 331, 339, 12, 13, 14, + /* 490 */ 15, 16, 377, 339, 39, 348, 381, 382, 383, 384, + /* 500 */ 385, 386, 348, 388, 92, 103, 391, 156, 319, 319, + /* 510 */ 395, 396, 183, 184, 91, 316, 407, 94, 319, 311, + /* 520 */ 330, 60, 407, 18, 339, 92, 114, 337, 23, 420, + /* 530 */ 311, 311, 347, 424, 169, 420, 347, 347, 2, 424, + /* 540 */ 128, 129, 37, 38, 8, 9, 41, 68, 12, 13, + /* 550 */ 14, 15, 16, 188, 189, 12, 13, 311, 339, 319, + /* 560 */ 352, 104, 57, 58, 59, 22, 347, 0, 383, 218, + /* 570 */ 330, 352, 352, 354, 385, 354, 33, 337, 35, 228, + /* 580 */ 123, 124, 125, 126, 127, 364, 174, 347, 176, 400, + /* 590 */ 401, 402, 161, 404, 68, 311, 377, 92, 352, 56, + /* 600 */ 381, 382, 383, 384, 385, 386, 173, 388, 175, 197, + /* 610 */ 198, 68, 200, 201, 202, 203, 204, 205, 206, 207, + /* 620 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, + /* 630 */ 12, 13, 379, 22, 311, 130, 352, 311, 20, 327, + /* 640 */ 22, 329, 14, 0, 425, 426, 35, 201, 20, 340, + /* 650 */ 20, 33, 22, 35, 8, 9, 403, 114, 12, 13, + /* 660 */ 14, 15, 16, 0, 231, 35, 316, 367, 340, 319, + /* 670 */ 311, 166, 167, 168, 56, 352, 171, 340, 352, 68, + /* 680 */ 50, 124, 311, 8, 9, 230, 68, 12, 13, 14, + /* 690 */ 15, 16, 187, 319, 311, 190, 323, 192, 193, 194, + /* 700 */ 195, 196, 311, 60, 330, 44, 45, 407, 8, 9, + /* 710 */ 92, 352, 12, 13, 14, 15, 16, 174, 345, 176, + /* 720 */ 420, 347, 339, 352, 424, 114, 340, 64, 65, 311, + /* 730 */ 347, 311, 114, 367, 71, 352, 231, 354, 181, 182, + /* 740 */ 197, 198, 185, 352, 81, 82, 128, 129, 311, 35, + /* 750 */ 87, 379, 209, 210, 211, 212, 213, 214, 215, 197, + /* 760 */ 377, 61, 229, 230, 381, 382, 383, 384, 385, 386, + /* 770 */ 352, 388, 352, 407, 391, 403, 104, 347, 395, 396, + /* 780 */ 397, 4, 68, 325, 326, 174, 420, 176, 358, 352, + /* 790 */ 424, 104, 174, 93, 176, 123, 124, 125, 126, 127, + /* 800 */ 417, 101, 240, 241, 242, 243, 244, 161, 197, 198, + /* 810 */ 311, 311, 311, 126, 311, 197, 198, 20, 200, 201, + /* 820 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + /* 830 */ 212, 213, 214, 215, 216, 217, 12, 13, 14, 339, + /* 840 */ 0, 339, 77, 371, 20, 35, 22, 347, 311, 231, + /* 850 */ 348, 352, 352, 352, 354, 352, 156, 33, 311, 35, + /* 860 */ 339, 21, 347, 3, 24, 25, 26, 27, 28, 29, + /* 870 */ 30, 31, 32, 358, 325, 326, 355, 377, 68, 20, + /* 880 */ 56, 381, 382, 383, 384, 385, 386, 349, 388, 352, + /* 890 */ 352, 391, 68, 42, 43, 395, 396, 132, 133, 352, + /* 900 */ 349, 8, 9, 352, 341, 12, 13, 14, 15, 16, + /* 910 */ 332, 43, 340, 335, 311, 352, 92, 0, 218, 219, + /* 920 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 8, + /* 930 */ 9, 311, 319, 12, 13, 14, 15, 16, 114, 376, + /* 940 */ 377, 378, 339, 330, 43, 319, 340, 344, 0, 22, + /* 950 */ 347, 388, 128, 129, 61, 352, 330, 354, 161, 339, + /* 960 */ 347, 93, 35, 96, 47, 96, 99, 347, 99, 312, + /* 970 */ 22, 319, 352, 347, 354, 161, 162, 1, 2, 319, + /* 980 */ 377, 56, 330, 43, 381, 382, 383, 384, 385, 386, + /* 990 */ 330, 388, 319, 96, 101, 0, 99, 377, 174, 347, + /* 1000 */ 176, 381, 382, 383, 384, 385, 386, 347, 388, 232, + /* 1010 */ 96, 391, 43, 99, 93, 395, 396, 22, 427, 94, + /* 1020 */ 347, 197, 198, 0, 200, 201, 202, 203, 204, 205, + /* 1030 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + /* 1040 */ 216, 217, 12, 13, 319, 22, 43, 328, 319, 156, + /* 1050 */ 20, 43, 22, 43, 19, 330, 319, 35, 385, 330, + /* 1060 */ 201, 320, 93, 33, 311, 35, 35, 330, 33, 128, + /* 1070 */ 129, 418, 347, 400, 401, 402, 347, 404, 61, 46, + /* 1080 */ 13, 43, 47, 43, 347, 92, 56, 52, 53, 54, + /* 1090 */ 55, 56, 339, 0, 414, 102, 93, 344, 68, 319, + /* 1100 */ 347, 93, 35, 93, 311, 352, 43, 354, 248, 339, + /* 1110 */ 330, 218, 219, 220, 221, 222, 223, 224, 225, 226, + /* 1120 */ 227, 228, 92, 43, 13, 92, 91, 347, 320, 94, + /* 1130 */ 377, 93, 339, 93, 381, 382, 383, 384, 385, 386, + /* 1140 */ 347, 388, 351, 43, 114, 352, 35, 354, 318, 43, + /* 1150 */ 43, 250, 319, 380, 319, 319, 93, 319, 128, 129, + /* 1160 */ 405, 43, 127, 330, 398, 330, 330, 421, 330, 421, + /* 1170 */ 377, 43, 421, 93, 381, 382, 383, 384, 385, 386, + /* 1180 */ 347, 388, 347, 347, 391, 347, 408, 233, 395, 396, + /* 1190 */ 397, 375, 252, 93, 47, 160, 374, 104, 176, 93, + /* 1200 */ 93, 319, 409, 43, 174, 43, 176, 176, 172, 42, + /* 1210 */ 417, 93, 330, 178, 197, 180, 123, 124, 125, 126, + /* 1220 */ 127, 93, 369, 359, 20, 319, 319, 197, 198, 347, + /* 1230 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + /* 1240 */ 210, 211, 212, 213, 214, 215, 216, 217, 12, 13, + /* 1250 */ 311, 319, 319, 93, 359, 93, 20, 156, 22, 357, + /* 1260 */ 357, 319, 330, 330, 319, 319, 20, 20, 313, 33, + /* 1270 */ 313, 35, 373, 323, 354, 323, 20, 366, 339, 347, + /* 1280 */ 347, 20, 323, 368, 366, 323, 347, 323, 323, 319, + /* 1290 */ 323, 352, 56, 354, 313, 339, 319, 339, 313, 339, + /* 1300 */ 339, 352, 339, 373, 68, 339, 179, 339, 321, 372, + /* 1310 */ 311, 339, 339, 339, 339, 321, 377, 319, 321, 319, + /* 1320 */ 381, 382, 383, 384, 385, 386, 319, 388, 92, 238, + /* 1330 */ 391, 158, 354, 321, 395, 396, 397, 366, 339, 321, + /* 1340 */ 352, 362, 352, 352, 352, 406, 347, 20, 362, 360, + /* 1350 */ 114, 352, 347, 354, 347, 335, 352, 413, 352, 239, + /* 1360 */ 380, 352, 245, 362, 128, 129, 352, 352, 352, 416, + /* 1370 */ 165, 247, 246, 362, 367, 234, 377, 20, 230, 347, + /* 1380 */ 381, 382, 383, 384, 385, 386, 251, 388, 249, 92, + /* 1390 */ 391, 254, 385, 411, 395, 396, 397, 413, 415, 375, + /* 1400 */ 379, 92, 343, 352, 329, 406, 410, 400, 401, 402, + /* 1410 */ 174, 404, 176, 394, 407, 413, 319, 321, 36, 314, + /* 1420 */ 370, 313, 365, 333, 322, 412, 311, 420, 333, 0, + /* 1430 */ 309, 424, 333, 197, 198, 181, 200, 201, 202, 203, + /* 1440 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + /* 1450 */ 214, 215, 216, 217, 339, 428, 0, 423, 0, 422, + /* 1460 */ 0, 422, 347, 42, 423, 423, 422, 352, 0, 354, + /* 1470 */ 191, 35, 35, 35, 35, 191, 0, 35, 35, 191, + /* 1480 */ 0, 191, 367, 0, 35, 0, 22, 311, 0, 35, + /* 1490 */ 176, 0, 377, 174, 0, 170, 381, 382, 383, 384, + /* 1500 */ 385, 386, 169, 388, 0, 0, 0, 46, 0, 0, + /* 1510 */ 0, 42, 0, 0, 152, 339, 0, 0, 0, 0, + /* 1520 */ 0, 147, 407, 347, 35, 0, 147, 0, 352, 0, + /* 1530 */ 354, 0, 0, 0, 0, 420, 0, 0, 0, 424, + /* 1540 */ 0, 0, 0, 367, 311, 0, 0, 0, 0, 42, + /* 1550 */ 0, 0, 0, 377, 56, 0, 56, 381, 382, 383, + /* 1560 */ 384, 385, 386, 0, 388, 22, 0, 0, 0, 0, + /* 1570 */ 311, 0, 339, 0, 0, 14, 46, 42, 39, 14, + /* 1580 */ 347, 0, 0, 407, 0, 352, 0, 354, 165, 0, + /* 1590 */ 0, 0, 43, 0, 0, 39, 420, 40, 339, 46, + /* 1600 */ 424, 39, 0, 0, 0, 35, 347, 47, 0, 0, + /* 1610 */ 377, 352, 35, 354, 381, 382, 383, 384, 385, 386, + /* 1620 */ 387, 388, 389, 390, 39, 47, 62, 39, 311, 0, + /* 1630 */ 35, 39, 35, 0, 47, 39, 377, 22, 0, 20, + /* 1640 */ 381, 382, 383, 384, 385, 386, 311, 388, 47, 35, + /* 1650 */ 391, 35, 35, 43, 43, 396, 339, 35, 99, 101, + /* 1660 */ 35, 22, 0, 22, 347, 0, 22, 49, 0, 352, + /* 1670 */ 22, 354, 35, 0, 339, 0, 0, 35, 35, 22, + /* 1680 */ 0, 35, 347, 161, 0, 22, 158, 352, 177, 354, + /* 1690 */ 0, 0, 0, 0, 377, 0, 311, 92, 381, 382, + /* 1700 */ 383, 384, 385, 386, 35, 388, 93, 186, 0, 0, + /* 1710 */ 39, 229, 377, 92, 102, 43, 381, 382, 383, 384, + /* 1720 */ 385, 386, 311, 388, 339, 46, 92, 92, 92, 43, + /* 1730 */ 235, 43, 347, 161, 235, 159, 419, 352, 163, 354, + /* 1740 */ 161, 35, 93, 92, 46, 93, 311, 93, 92, 46, + /* 1750 */ 339, 93, 92, 92, 43, 344, 157, 93, 347, 92, + /* 1760 */ 46, 426, 377, 352, 43, 354, 381, 382, 383, 384, + /* 1770 */ 385, 386, 46, 388, 339, 390, 93, 92, 46, 344, + /* 1780 */ 93, 43, 347, 35, 35, 35, 35, 352, 377, 354, + /* 1790 */ 93, 35, 381, 382, 383, 384, 385, 386, 93, 388, + /* 1800 */ 2, 22, 43, 197, 311, 92, 46, 46, 93, 92, + /* 1810 */ 22, 93, 377, 93, 92, 235, 381, 382, 383, 384, + /* 1820 */ 385, 386, 92, 388, 93, 92, 199, 92, 103, 35, + /* 1830 */ 35, 92, 339, 93, 35, 92, 35, 93, 92, 35, + /* 1840 */ 347, 35, 22, 116, 92, 352, 93, 354, 93, 92, + /* 1850 */ 116, 35, 116, 116, 92, 311, 92, 92, 104, 22, + /* 1860 */ 43, 35, 62, 61, 35, 311, 35, 35, 35, 35, + /* 1870 */ 377, 35, 90, 35, 381, 382, 383, 384, 385, 386, + /* 1880 */ 35, 388, 35, 339, 35, 43, 68, 35, 22, 35, + /* 1890 */ 22, 347, 35, 339, 35, 68, 352, 35, 354, 35, + /* 1900 */ 35, 347, 35, 22, 35, 35, 352, 0, 354, 35, + /* 1910 */ 47, 39, 0, 35, 39, 0, 39, 35, 311, 0, + /* 1920 */ 47, 377, 35, 47, 39, 381, 382, 383, 384, 385, + /* 1930 */ 386, 377, 388, 47, 311, 381, 382, 383, 384, 385, + /* 1940 */ 386, 0, 388, 35, 35, 0, 339, 22, 21, 429, + /* 1950 */ 22, 22, 21, 20, 347, 429, 429, 429, 311, 352, + /* 1960 */ 429, 354, 339, 429, 429, 429, 429, 429, 429, 429, + /* 1970 */ 347, 429, 429, 429, 429, 352, 429, 354, 429, 429, + /* 1980 */ 429, 429, 429, 429, 377, 429, 339, 429, 381, 382, + /* 1990 */ 383, 384, 385, 386, 347, 388, 429, 429, 429, 352, + /* 2000 */ 377, 354, 429, 429, 381, 382, 383, 384, 385, 386, + /* 2010 */ 311, 388, 429, 429, 429, 429, 429, 429, 429, 429, + /* 2020 */ 429, 429, 429, 429, 377, 429, 429, 429, 381, 382, + /* 2030 */ 383, 384, 385, 386, 311, 388, 429, 429, 339, 429, + /* 2040 */ 429, 429, 429, 429, 429, 429, 347, 429, 429, 429, + /* 2050 */ 429, 352, 429, 354, 429, 429, 429, 429, 311, 429, + /* 2060 */ 429, 429, 339, 429, 429, 429, 429, 429, 429, 429, + /* 2070 */ 347, 429, 429, 429, 311, 352, 377, 354, 429, 429, + /* 2080 */ 381, 382, 383, 384, 385, 386, 339, 388, 429, 429, + /* 2090 */ 429, 429, 429, 429, 347, 429, 429, 429, 429, 352, + /* 2100 */ 377, 354, 339, 429, 381, 382, 383, 384, 385, 386, + /* 2110 */ 347, 388, 429, 429, 429, 352, 429, 354, 429, 429, + /* 2120 */ 429, 429, 429, 429, 377, 429, 429, 429, 381, 382, + /* 2130 */ 383, 384, 385, 386, 429, 388, 429, 429, 429, 429, + /* 2140 */ 377, 429, 429, 429, 381, 382, 383, 384, 385, 386, + /* 2150 */ 429, 388, 311, 429, 429, 429, 429, 429, 429, 429, + /* 2160 */ 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, + /* 2170 */ 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, + /* 2180 */ 339, 429, 429, 429, 429, 429, 429, 429, 347, 429, + /* 2190 */ 429, 429, 429, 352, 429, 354, 429, 429, 429, 429, + /* 2200 */ 429, 429, 429, 311, 429, 429, 429, 429, 429, 429, + /* 2210 */ 429, 429, 429, 311, 429, 429, 429, 429, 377, 429, + /* 2220 */ 429, 429, 381, 382, 383, 384, 385, 386, 429, 388, + /* 2230 */ 429, 339, 429, 429, 429, 429, 429, 429, 429, 347, + /* 2240 */ 429, 339, 429, 429, 352, 429, 354, 429, 429, 347, + /* 2250 */ 429, 429, 429, 429, 352, 429, 354, 429, 429, 429, + /* 2260 */ 429, 429, 429, 429, 429, 429, 311, 429, 429, 377, + /* 2270 */ 429, 429, 429, 381, 382, 383, 384, 385, 386, 377, + /* 2280 */ 388, 429, 311, 381, 382, 383, 384, 385, 386, 429, + /* 2290 */ 388, 429, 429, 429, 339, 429, 429, 429, 429, 429, + /* 2300 */ 429, 429, 347, 429, 429, 429, 311, 352, 429, 354, + /* 2310 */ 339, 429, 429, 429, 429, 429, 429, 429, 347, 429, + /* 2320 */ 429, 429, 311, 352, 429, 354, 429, 429, 429, 429, + /* 2330 */ 429, 429, 377, 429, 339, 429, 381, 382, 383, 384, + /* 2340 */ 385, 386, 347, 388, 429, 429, 311, 352, 377, 354, + /* 2350 */ 339, 429, 381, 382, 383, 384, 385, 386, 347, 388, + /* 2360 */ 429, 429, 429, 352, 429, 354, 429, 429, 429, 429, + /* 2370 */ 311, 429, 377, 429, 339, 429, 381, 382, 383, 384, + /* 2380 */ 385, 386, 347, 388, 429, 429, 311, 352, 377, 354, + /* 2390 */ 429, 429, 381, 382, 383, 384, 385, 386, 339, 388, + /* 2400 */ 429, 429, 429, 429, 429, 429, 347, 429, 429, 429, + /* 2410 */ 429, 352, 377, 354, 339, 429, 381, 382, 383, 384, + /* 2420 */ 385, 386, 347, 388, 429, 429, 429, 352, 429, 354, + /* 2430 */ 429, 429, 429, 429, 429, 429, 377, 429, 429, 429, + /* 2440 */ 381, 382, 383, 384, 385, 386, 429, 388, 429, 429, + /* 2450 */ 429, 429, 377, 429, 429, 429, 381, 382, 383, 384, + /* 2460 */ 385, 386, 429, 388, }; -#define YY_SHIFT_COUNT (666) +#define YY_SHIFT_COUNT (673) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2079) +#define YY_SHIFT_MAX (1945) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 917, 0, 0, 62, 62, 264, 264, 264, 326, 326, - /* 10 */ 264, 264, 391, 593, 720, 593, 593, 593, 593, 593, - /* 20 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593, - /* 30 */ 593, 593, 593, 593, 593, 593, 593, 593, 593, 593, - /* 40 */ 593, 593, 265, 265, 17, 17, 17, 1007, 1007, 268, - /* 50 */ 1007, 1007, 160, 30, 56, 200, 56, 11, 11, 87, - /* 60 */ 87, 55, 165, 56, 56, 11, 11, 11, 11, 11, - /* 70 */ 11, 11, 11, 11, 11, 10, 11, 11, 11, 18, - /* 80 */ 11, 11, 67, 11, 11, 67, 123, 11, 67, 67, - /* 90 */ 67, 11, 227, 719, 662, 683, 683, 150, 213, 213, - /* 100 */ 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, - /* 110 */ 213, 213, 213, 213, 213, 213, 213, 517, 881, 165, - /* 120 */ 403, 403, 573, 386, 849, 361, 361, 361, 386, 298, - /* 130 */ 298, 18, 350, 350, 67, 67, 294, 294, 270, 357, - /* 140 */ 198, 198, 198, 198, 198, 198, 198, 1119, 21, 383, - /* 150 */ 501, 105, 665, 484, 715, 828, 366, 799, 506, 800, - /* 160 */ 717, 649, 717, 924, 756, 756, 756, 807, 873, 980, - /* 170 */ 1174, 1078, 1206, 1232, 1232, 1206, 1107, 1107, 1232, 1232, - /* 180 */ 1232, 1257, 1257, 1264, 10, 18, 10, 1272, 1277, 10, - /* 190 */ 1272, 10, 10, 10, 1232, 10, 1257, 67, 67, 67, - /* 200 */ 67, 67, 67, 67, 67, 67, 67, 67, 1232, 1257, - /* 210 */ 294, 1264, 227, 1166, 18, 227, 1232, 1232, 1272, 227, - /* 220 */ 1118, 294, 294, 294, 294, 1118, 294, 1201, 227, 270, - /* 230 */ 227, 298, 1345, 294, 1139, 1118, 294, 294, 1139, 1118, - /* 240 */ 294, 294, 67, 1141, 1235, 1139, 1154, 1157, 1170, 980, - /* 250 */ 1178, 298, 1382, 1159, 1162, 1167, 1159, 1162, 1159, 1162, - /* 260 */ 1320, 1326, 294, 357, 1232, 227, 1383, 1257, 2259, 2259, - /* 270 */ 2259, 2259, 2259, 2259, 2259, 83, 1593, 214, 724, 126, - /* 280 */ 209, 491, 562, 622, 813, 535, 321, 698, 698, 698, - /* 290 */ 698, 698, 698, 698, 698, 521, 309, 13, 13, 115, - /* 300 */ 69, 599, 267, 708, 194, 377, 190, 465, 49, 49, - /* 310 */ 49, 49, 684, 944, 938, 994, 999, 1001, 947, 1047, - /* 320 */ 1101, 941, 920, 1025, 1043, 1069, 1079, 1091, 1093, 1102, - /* 330 */ 1160, 1073, 973, 895, 1103, 1075, 1082, 1058, 1106, 1114, - /* 340 */ 1115, 1133, 1163, 1165, 1193, 1198, 1064, 860, 1143, 1176, - /* 350 */ 839, 1473, 1476, 1301, 1479, 1480, 1439, 1482, 1448, 1297, - /* 360 */ 1450, 1451, 1452, 1302, 1490, 1456, 1457, 1307, 1495, 1310, - /* 370 */ 1502, 1477, 1513, 1493, 1516, 1483, 1348, 1347, 1521, 1527, - /* 380 */ 1357, 1359, 1525, 1528, 1494, 1529, 1499, 1539, 1542, 1543, - /* 390 */ 1395, 1545, 1552, 1554, 1555, 1556, 1403, 1514, 1548, 1413, - /* 400 */ 1559, 1560, 1561, 1562, 1566, 1567, 1568, 1569, 1570, 1571, - /* 410 */ 1573, 1574, 1575, 1578, 1544, 1590, 1591, 1598, 1600, 1601, - /* 420 */ 1612, 1581, 1604, 1605, 1614, 1616, 1619, 1564, 1621, 1572, - /* 430 */ 1627, 1629, 1582, 1584, 1588, 1620, 1587, 1622, 1589, 1638, - /* 440 */ 1599, 1602, 1650, 1651, 1652, 1617, 1492, 1657, 1658, 1665, - /* 450 */ 1607, 1667, 1671, 1608, 1597, 1633, 1673, 1639, 1630, 1637, - /* 460 */ 1679, 1645, 1640, 1647, 1688, 1654, 1644, 1653, 1693, 1694, - /* 470 */ 1698, 1699, 1609, 1606, 1666, 1678, 1703, 1670, 1675, 1680, - /* 480 */ 1686, 1695, 1684, 1710, 1711, 1732, 1713, 1702, 1737, 1722, - /* 490 */ 1717, 1754, 1720, 1756, 1724, 1757, 1738, 1741, 1762, 1610, - /* 500 */ 1731, 1768, 1613, 1748, 1618, 1624, 1771, 1773, 1625, 1615, - /* 510 */ 1780, 1781, 1783, 1696, 1697, 1755, 1634, 1798, 1712, 1648, - /* 520 */ 1715, 1800, 1778, 1659, 1735, 1727, 1782, 1784, 1611, 1740, - /* 530 */ 1742, 1745, 1746, 1747, 1749, 1787, 1750, 1758, 1760, 1761, - /* 540 */ 1763, 1792, 1793, 1799, 1765, 1801, 1626, 1770, 1772, 1815, - /* 550 */ 1641, 1809, 1817, 1818, 1775, 1825, 1642, 1779, 1835, 1849, - /* 560 */ 1858, 1859, 1860, 1864, 1779, 1898, 1885, 1716, 1867, 1823, - /* 570 */ 1824, 1826, 1827, 1829, 1830, 1870, 1833, 1834, 1878, 1891, - /* 580 */ 1743, 1844, 1819, 1845, 1899, 1901, 1848, 1850, 1906, 1853, - /* 590 */ 1854, 1908, 1856, 1863, 1911, 1861, 1865, 1913, 1868, 1836, - /* 600 */ 1843, 1847, 1851, 1936, 1862, 1872, 1876, 1927, 1877, 1925, - /* 610 */ 1925, 1947, 1914, 1909, 1938, 1940, 1943, 1945, 1954, 1955, - /* 620 */ 1958, 1928, 1922, 1952, 1963, 1965, 1988, 1976, 1991, 1980, - /* 630 */ 1981, 1950, 1675, 1985, 1680, 1994, 1995, 1998, 2000, 2014, - /* 640 */ 2003, 2039, 2005, 2002, 2011, 2051, 2017, 2006, 2015, 2055, - /* 650 */ 2021, 2013, 2019, 2069, 2035, 2024, 2034, 2076, 2042, 2043, - /* 660 */ 2079, 2058, 2060, 2062, 2063, 2061, 2066, + /* 0 */ 505, 0, 0, 206, 206, 412, 412, 412, 618, 618, + /* 10 */ 412, 412, 824, 1030, 1236, 1030, 1030, 1030, 1030, 1030, + /* 20 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, + /* 30 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, + /* 40 */ 1030, 1030, 33, 33, 296, 296, 296, 543, 543, 107, + /* 50 */ 543, 543, 433, 30, 6, 200, 6, 73, 73, 21, + /* 60 */ 21, 11, 51, 6, 6, 73, 73, 73, 73, 73, + /* 70 */ 73, 73, 73, 73, 73, 56, 73, 73, 73, 243, + /* 80 */ 73, 73, 285, 73, 73, 285, 377, 73, 285, 285, + /* 90 */ 285, 73, 403, 205, 700, 893, 893, 80, 611, 611, + /* 100 */ 611, 611, 611, 611, 611, 611, 611, 611, 611, 611, + /* 110 */ 611, 611, 611, 611, 611, 611, 611, 346, 394, 51, + /* 120 */ 628, 628, 461, 714, 643, 431, 431, 431, 714, 417, + /* 130 */ 417, 243, 567, 567, 285, 285, 479, 479, 402, 526, + /* 140 */ 257, 257, 257, 257, 257, 257, 257, 1035, 840, 15, + /* 150 */ 663, 562, 630, 81, 106, 446, 380, 661, 687, 797, + /* 160 */ 533, 455, 533, 851, 860, 860, 860, 777, 859, 954, + /* 170 */ 1147, 1036, 1167, 1204, 1204, 1167, 1101, 1101, 1204, 1204, + /* 180 */ 1204, 1246, 1246, 1247, 56, 243, 56, 1256, 1261, 56, + /* 190 */ 1256, 56, 56, 56, 1204, 56, 1246, 285, 285, 285, + /* 200 */ 285, 285, 285, 285, 285, 285, 285, 285, 1204, 1246, + /* 210 */ 479, 1247, 403, 1127, 243, 403, 1204, 1204, 1256, 403, + /* 220 */ 1091, 479, 479, 479, 479, 1091, 479, 1173, 403, 402, + /* 230 */ 403, 417, 1327, 479, 1120, 1091, 479, 479, 1120, 1091, + /* 240 */ 479, 479, 285, 1117, 1205, 1120, 1124, 1126, 1141, 954, + /* 250 */ 1148, 417, 1357, 1135, 1139, 1137, 1135, 1139, 1135, 1139, + /* 260 */ 1297, 1309, 479, 526, 1204, 403, 1382, 1246, 2464, 2464, + /* 270 */ 2464, 2464, 2464, 2464, 2464, 69, 130, 164, 423, 153, + /* 280 */ 269, 378, 475, 536, 646, 921, 457, 675, 675, 675, + /* 290 */ 675, 675, 675, 675, 675, 1093, 672, 36, 36, 557, + /* 300 */ 48, 365, 27, 765, 139, 329, 129, 351, 424, 424, + /* 310 */ 424, 424, 868, 917, 927, 867, 869, 897, 914, 948, + /* 320 */ 995, 1023, 925, 814, 969, 1003, 1008, 1010, 1038, 1040, + /* 330 */ 1063, 976, 941, 901, 940, 1100, 1022, 1031, 1017, 1106, + /* 340 */ 1033, 1080, 1107, 1118, 1128, 1160, 1162, 993, 1067, 1111, + /* 350 */ 810, 357, 1429, 1456, 1254, 1458, 1460, 1421, 1468, 1436, + /* 360 */ 1279, 1437, 1438, 1439, 1284, 1476, 1442, 1443, 1288, 1480, + /* 370 */ 1290, 1483, 1449, 1485, 1464, 1488, 1454, 1314, 1319, 1491, + /* 380 */ 1494, 1325, 1333, 1504, 1505, 1461, 1506, 1508, 1509, 1469, + /* 390 */ 1510, 1512, 1513, 1362, 1516, 1517, 1518, 1519, 1520, 1374, + /* 400 */ 1489, 1525, 1379, 1527, 1529, 1531, 1532, 1533, 1534, 1536, + /* 410 */ 1537, 1538, 1540, 1541, 1542, 1545, 1546, 1507, 1547, 1548, + /* 420 */ 1550, 1551, 1552, 1563, 1543, 1566, 1567, 1568, 1569, 1571, + /* 430 */ 1498, 1555, 1500, 1573, 1574, 1535, 1539, 1549, 1561, 1530, + /* 440 */ 1565, 1553, 1581, 1557, 1556, 1582, 1584, 1586, 1562, 1423, + /* 450 */ 1589, 1590, 1591, 1564, 1593, 1594, 1570, 1560, 1585, 1602, + /* 460 */ 1577, 1578, 1588, 1603, 1595, 1587, 1592, 1604, 1597, 1601, + /* 470 */ 1596, 1608, 1609, 1629, 1633, 1558, 1559, 1614, 1615, 1638, + /* 480 */ 1616, 1617, 1610, 1611, 1622, 1625, 1639, 1662, 1641, 1665, + /* 490 */ 1644, 1618, 1668, 1648, 1637, 1673, 1642, 1675, 1643, 1676, + /* 500 */ 1657, 1619, 1680, 1522, 1646, 1684, 1511, 1663, 1572, 1528, + /* 510 */ 1690, 1691, 1579, 1575, 1692, 1693, 1695, 1605, 1613, 1669, + /* 520 */ 1521, 1708, 1621, 1576, 1634, 1709, 1671, 1599, 1635, 1612, + /* 530 */ 1679, 1672, 1495, 1636, 1649, 1651, 1652, 1654, 1656, 1686, + /* 540 */ 1658, 1660, 1661, 1667, 1664, 1688, 1698, 1703, 1685, 1711, + /* 550 */ 1499, 1683, 1687, 1714, 1482, 1721, 1726, 1732, 1697, 1738, + /* 560 */ 1580, 1705, 1706, 1748, 1749, 1750, 1751, 1756, 1705, 1798, + /* 570 */ 1779, 1606, 1759, 1713, 1715, 1717, 1718, 1722, 1720, 1760, + /* 580 */ 1730, 1733, 1761, 1788, 1627, 1735, 1725, 1731, 1794, 1795, + /* 590 */ 1739, 1740, 1799, 1743, 1744, 1801, 1746, 1753, 1804, 1752, + /* 600 */ 1755, 1806, 1757, 1727, 1734, 1736, 1737, 1820, 1754, 1762, + /* 610 */ 1764, 1816, 1765, 1817, 1817, 1837, 1800, 1802, 1826, 1829, + /* 620 */ 1831, 1832, 1833, 1834, 1836, 1838, 1845, 1847, 1818, 1782, + /* 630 */ 1842, 1849, 1852, 1866, 1854, 1868, 1857, 1859, 1827, 1610, + /* 640 */ 1862, 1611, 1864, 1865, 1867, 1869, 1881, 1870, 1907, 1874, + /* 650 */ 1863, 1872, 1912, 1878, 1873, 1875, 1915, 1882, 1876, 1877, + /* 660 */ 1919, 1887, 1886, 1885, 1941, 1908, 1909, 1945, 1925, 1927, + /* 670 */ 1928, 1929, 1931, 1933, }; #define YY_REDUCE_COUNT (274) -#define YY_REDUCE_MIN (-403) -#define YY_REDUCE_MAX (1873) +#define YY_REDUCE_MIN (-386) +#define YY_REDUCE_MAX (2075) static const short yy_reduce_ofst[] = { - /* 0 */ 263, 629, 747, -278, -14, 679, 846, 886, 955, 1009, - /* 10 */ 272, 1059, 104, 1076, 1126, 806, 1152, 1202, 1214, 1228, - /* 20 */ 1281, 1334, 1346, 1360, 1414, 1428, 1440, 1497, 1507, 1523, - /* 30 */ 1547, 1603, 1623, 1643, 1663, 1683, 1723, 1739, 1790, 1806, - /* 40 */ 1857, 1873, 304, 926, 112, 435, 552, -295, 610, -3, - /* 50 */ -261, -154, -323, 305, 575, 577, 635, -310, -272, -312, - /* 60 */ -307, -403, -311, -284, -70, -90, 225, 346, 404, 414, - /* 70 */ 429, 434, 497, 644, 645, 339, 674, 697, 710, -342, - /* 80 */ 722, 749, -313, 758, 772, -244, -251, 797, -17, 20, - /* 90 */ 48, 804, 228, 86, -379, -379, -379, -240, -13, 100, - /* 100 */ 101, 130, 206, 375, 385, 428, 459, 461, 474, 522, - /* 110 */ 566, 628, 656, 678, 694, 696, 740, -226, -92, -72, - /* 120 */ -256, -130, 173, 4, 34, 186, 362, 440, 97, 91, - /* 130 */ 303, -234, -109, 180, 274, 536, 317, 545, 579, 234, - /* 140 */ -333, 40, 144, 175, 242, 319, 410, 450, 445, 348, - /* 150 */ 369, 495, 572, 557, 620, 620, 734, 667, 688, 727, - /* 160 */ 735, 735, 735, 770, 752, 784, 786, 762, 620, 861, - /* 170 */ 874, 866, 894, 940, 942, 901, 907, 908, 956, 957, - /* 180 */ 960, 971, 972, 915, 966, 936, 974, 933, 935, 978, - /* 190 */ 939, 981, 983, 985, 991, 989, 1000, 975, 976, 977, - /* 200 */ 979, 982, 984, 986, 990, 992, 995, 996, 998, 1006, - /* 210 */ 993, 951, 1021, 987, 997, 1026, 1030, 1033, 988, 1032, - /* 220 */ 1002, 1005, 1008, 1013, 1014, 1010, 1015, 1011, 1048, 1038, - /* 230 */ 1053, 1031, 1003, 1028, 968, 1020, 1036, 1037, 1004, 1022, - /* 240 */ 1044, 1049, 620, 1016, 1012, 1018, 1023, 1027, 1024, 1029, - /* 250 */ 735, 1061, 1035, 1045, 1017, 1039, 1046, 1034, 1051, 1050, - /* 260 */ 1052, 1081, 1067, 1092, 1129, 1104, 1112, 1136, 1096, 1086, - /* 270 */ 1137, 1138, 1142, 1130, 1168, + /* 0 */ 29, -307, 115, 793, 383, -82, 939, 999, 1115, 1176, + /* 10 */ 500, 620, 1233, 219, 1259, 603, 753, 1317, 1335, 1385, + /* 20 */ 1411, 1435, 1493, 1544, 1554, 1607, 1623, 1647, 1699, 1723, + /* 30 */ 1747, 1763, 1841, 1892, 1902, 1955, 1971, 1995, 2011, 2035, + /* 40 */ 2059, 2075, -305, 1007, -74, 189, 673, -55, 563, 109, + /* 50 */ -333, -97, -366, -361, -131, 300, 366, 190, 240, -315, + /* 60 */ -308, -386, -263, -173, -149, -160, -81, 54, 374, 613, + /* 70 */ 626, 652, 660, 725, 729, -251, 737, 780, 833, -297, + /* 80 */ 835, 836, 50, 838, 882, -96, 185, 932, 147, -86, + /* 90 */ 154, 933, -316, -283, -376, -376, -376, -273, -229, -174, + /* 100 */ 208, 220, 246, 284, 323, 326, 359, 371, 391, 418, + /* 110 */ 420, 437, 499, 501, 503, 537, 547, -19, 71, 75, + /* 120 */ 199, 350, 373, 458, -94, -18, 253, 372, 549, 430, + /* 130 */ 515, 221, -34, 70, 502, 521, 538, 551, 578, 312, + /* 140 */ -329, 309, 328, 337, 386, 572, 606, 472, 657, 591, + /* 150 */ 719, 653, 741, 680, 770, 770, 808, 830, 791, 773, + /* 160 */ 755, 755, 755, 766, 746, 748, 751, 778, 770, 816, + /* 170 */ 822, 853, 864, 906, 907, 895, 902, 903, 942, 945, + /* 180 */ 946, 955, 957, 899, 950, 920, 952, 911, 915, 959, + /* 190 */ 918, 962, 964, 965, 970, 967, 981, 956, 958, 960, + /* 200 */ 961, 963, 966, 968, 972, 973, 974, 975, 977, 985, + /* 210 */ 949, 930, 987, 937, 978, 994, 998, 1000, 971, 997, + /* 220 */ 979, 988, 990, 991, 992, 986, 1004, 989, 1012, 1020, + /* 230 */ 1018, 1005, 980, 1006, 944, 1001, 1009, 1014, 984, 1011, + /* 240 */ 1015, 1016, 770, 953, 983, 1002, 1013, 982, 996, 1024, + /* 250 */ 755, 1032, 1021, 1034, 1037, 1027, 1041, 1039, 1042, 1044, + /* 260 */ 1019, 1059, 1051, 1075, 1097, 1096, 1105, 1108, 1050, 1057, + /* 270 */ 1090, 1095, 1099, 1102, 1121, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 10 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 20 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 30 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 40 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 50 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 60 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 70 */ 1461, 1461, 1461, 1461, 1461, 1535, 1461, 1461, 1461, 1461, - /* 80 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 90 */ 1461, 1461, 1533, 1691, 1461, 1866, 1461, 1461, 1461, 1461, - /* 100 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 110 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 120 */ 1461, 1461, 1535, 1461, 1533, 1878, 1878, 1878, 1461, 1461, - /* 130 */ 1461, 1461, 1732, 1732, 1461, 1461, 1461, 1461, 1633, 1461, - /* 140 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1726, 1461, 1947, - /* 150 */ 1461, 1461, 1461, 1901, 1461, 1461, 1461, 1461, 1586, 1893, - /* 160 */ 1870, 1884, 1871, 1868, 1932, 1932, 1932, 1887, 1461, 1897, - /* 170 */ 1461, 1719, 1696, 1461, 1461, 1696, 1693, 1693, 1461, 1461, - /* 180 */ 1461, 1461, 1461, 1461, 1535, 1461, 1535, 1461, 1461, 1535, - /* 190 */ 1461, 1535, 1535, 1535, 1461, 1535, 1461, 1461, 1461, 1461, - /* 200 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 210 */ 1461, 1461, 1533, 1728, 1461, 1533, 1461, 1461, 1461, 1533, - /* 220 */ 1906, 1461, 1461, 1461, 1461, 1906, 1461, 1461, 1533, 1461, - /* 230 */ 1533, 1461, 1461, 1461, 1908, 1906, 1461, 1461, 1908, 1906, - /* 240 */ 1461, 1461, 1461, 1920, 1916, 1908, 1924, 1922, 1899, 1897, - /* 250 */ 1884, 1461, 1461, 1938, 1934, 1950, 1938, 1934, 1938, 1934, - /* 260 */ 1461, 1602, 1461, 1461, 1461, 1533, 1493, 1461, 1721, 1732, - /* 270 */ 1636, 1636, 1636, 1536, 1466, 1461, 1461, 1461, 1461, 1461, - /* 280 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1803, 1919, 1918, - /* 290 */ 1842, 1841, 1840, 1838, 1802, 1461, 1598, 1801, 1800, 1461, - /* 300 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1794, 1795, - /* 310 */ 1793, 1792, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 320 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 330 */ 1867, 1461, 1935, 1939, 1461, 1461, 1461, 1461, 1461, 1778, - /* 340 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 350 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 360 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 370 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 380 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 390 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 400 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 410 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 420 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 430 */ 1461, 1461, 1461, 1461, 1498, 1461, 1461, 1461, 1461, 1461, - /* 440 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 450 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 460 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 470 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1570, 1569, - /* 480 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 490 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 500 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 510 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1736, 1461, 1461, - /* 520 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1900, 1461, 1461, - /* 530 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 540 */ 1461, 1461, 1461, 1778, 1461, 1917, 1461, 1877, 1873, 1461, - /* 550 */ 1461, 1869, 1777, 1461, 1461, 1933, 1461, 1461, 1461, 1461, - /* 560 */ 1461, 1461, 1461, 1461, 1461, 1862, 1461, 1461, 1835, 1820, - /* 570 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 580 */ 1788, 1461, 1461, 1461, 1461, 1461, 1630, 1461, 1461, 1461, - /* 590 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1615, - /* 600 */ 1613, 1612, 1611, 1461, 1608, 1461, 1461, 1461, 1461, 1639, - /* 610 */ 1638, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 620 */ 1461, 1461, 1461, 1554, 1461, 1461, 1461, 1461, 1461, 1461, - /* 630 */ 1461, 1461, 1546, 1461, 1545, 1461, 1461, 1461, 1461, 1461, - /* 640 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 650 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1461, - /* 660 */ 1461, 1461, 1461, 1461, 1461, 1461, 1461, + /* 0 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 10 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 20 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 30 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 40 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 50 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 60 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 70 */ 1478, 1478, 1478, 1478, 1478, 1552, 1478, 1478, 1478, 1478, + /* 80 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 90 */ 1478, 1478, 1550, 1714, 1478, 1889, 1478, 1478, 1478, 1478, + /* 100 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 110 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 120 */ 1478, 1478, 1552, 1478, 1550, 1901, 1901, 1901, 1478, 1478, + /* 130 */ 1478, 1478, 1755, 1755, 1478, 1478, 1478, 1478, 1654, 1478, + /* 140 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1749, 1478, 1970, + /* 150 */ 1478, 1478, 1478, 1924, 1478, 1478, 1478, 1478, 1607, 1916, + /* 160 */ 1893, 1907, 1894, 1891, 1955, 1955, 1955, 1910, 1478, 1920, + /* 170 */ 1478, 1742, 1719, 1478, 1478, 1719, 1716, 1716, 1478, 1478, + /* 180 */ 1478, 1478, 1478, 1478, 1552, 1478, 1552, 1478, 1478, 1552, + /* 190 */ 1478, 1552, 1552, 1552, 1478, 1552, 1478, 1478, 1478, 1478, + /* 200 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 210 */ 1478, 1478, 1550, 1751, 1478, 1550, 1478, 1478, 1478, 1550, + /* 220 */ 1929, 1478, 1478, 1478, 1478, 1929, 1478, 1478, 1550, 1478, + /* 230 */ 1550, 1478, 1478, 1478, 1931, 1929, 1478, 1478, 1931, 1929, + /* 240 */ 1478, 1478, 1478, 1943, 1939, 1931, 1947, 1945, 1922, 1920, + /* 250 */ 1907, 1478, 1478, 1961, 1957, 1973, 1961, 1957, 1961, 1957, + /* 260 */ 1478, 1623, 1478, 1478, 1478, 1550, 1510, 1478, 1744, 1755, + /* 270 */ 1657, 1657, 1657, 1553, 1483, 1478, 1478, 1478, 1478, 1478, + /* 280 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1826, 1942, 1941, + /* 290 */ 1865, 1864, 1863, 1861, 1825, 1478, 1619, 1824, 1823, 1478, + /* 300 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1817, 1818, + /* 310 */ 1816, 1815, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 320 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 330 */ 1478, 1890, 1478, 1958, 1962, 1478, 1478, 1478, 1478, 1478, + /* 340 */ 1801, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 350 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 360 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 370 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 380 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 390 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 400 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 410 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 420 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 430 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1515, 1478, 1478, + /* 440 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 450 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 460 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 470 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 480 */ 1478, 1478, 1590, 1589, 1478, 1478, 1478, 1478, 1478, 1478, + /* 490 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 500 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 510 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 520 */ 1478, 1759, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 530 */ 1478, 1923, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 540 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1801, 1478, 1940, + /* 550 */ 1478, 1900, 1896, 1478, 1478, 1892, 1800, 1478, 1478, 1956, + /* 560 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1885, + /* 570 */ 1478, 1478, 1858, 1843, 1478, 1478, 1478, 1478, 1478, 1478, + /* 580 */ 1478, 1478, 1478, 1478, 1811, 1478, 1478, 1478, 1478, 1478, + /* 590 */ 1651, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 600 */ 1478, 1478, 1478, 1636, 1634, 1633, 1632, 1478, 1629, 1478, + /* 610 */ 1478, 1478, 1478, 1660, 1659, 1478, 1478, 1478, 1478, 1478, + /* 620 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 630 */ 1571, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1563, + /* 640 */ 1478, 1562, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 650 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 660 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, + /* 670 */ 1478, 1478, 1478, 1478, }; /********** End of lemon-generated parsing tables *****************************/ @@ -966,6 +996,9 @@ static const YYCODETYPE yyFallback[] = { 0, /* WAL_RETENTION_SIZE => nothing */ 0, /* WAL_ROLL_PERIOD => nothing */ 0, /* WAL_SEGMENT_SIZE => nothing */ + 0, /* SST_TRIGGER => nothing */ + 0, /* TABLE_PREFIX => nothing */ + 0, /* TABLE_SUFFIX => nothing */ 0, /* NK_COLON => nothing */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ @@ -1031,6 +1064,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* DISTRIBUTED => nothing */ 0, /* CONSUMERS => nothing */ 0, /* SUBSCRIPTIONS => nothing */ + 0, /* VNODES => nothing */ 0, /* LIKE => nothing */ 0, /* INDEX => nothing */ 0, /* FUNCTION => nothing */ @@ -1131,59 +1165,58 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 251, /* AFTER => ABORT */ - 251, /* ATTACH => ABORT */ - 251, /* BEFORE => ABORT */ - 251, /* BEGIN => ABORT */ - 251, /* BITAND => ABORT */ - 251, /* BITNOT => ABORT */ - 251, /* BITOR => ABORT */ - 251, /* BLOCKS => ABORT */ - 251, /* CHANGE => ABORT */ - 251, /* COMMA => ABORT */ - 251, /* COMPACT => ABORT */ - 251, /* CONCAT => ABORT */ - 251, /* CONFLICT => ABORT */ - 251, /* COPY => ABORT */ - 251, /* DEFERRED => ABORT */ - 251, /* DELIMITERS => ABORT */ - 251, /* DETACH => ABORT */ - 251, /* DIVIDE => ABORT */ - 251, /* DOT => ABORT */ - 251, /* EACH => ABORT */ - 251, /* END => ABORT */ - 251, /* FAIL => ABORT */ - 251, /* FILE => ABORT */ - 251, /* FOR => ABORT */ - 251, /* GLOB => ABORT */ - 251, /* ID => ABORT */ - 251, /* IMMEDIATE => ABORT */ - 251, /* IMPORT => ABORT */ - 251, /* INITIALLY => ABORT */ - 251, /* INSTEAD => ABORT */ - 251, /* ISNULL => ABORT */ - 251, /* KEY => ABORT */ - 251, /* NK_BITNOT => ABORT */ - 251, /* NK_SEMI => ABORT */ - 251, /* NOTNULL => ABORT */ - 251, /* OF => ABORT */ - 251, /* PLUS => ABORT */ - 251, /* PRIVILEGE => ABORT */ - 251, /* RAISE => ABORT */ - 251, /* REPLACE => ABORT */ - 251, /* RESTRICT => ABORT */ - 251, /* ROW => ABORT */ - 251, /* SEMI => ABORT */ - 251, /* STAR => ABORT */ - 251, /* STATEMENT => ABORT */ - 251, /* STRING => ABORT */ - 251, /* TIMES => ABORT */ - 251, /* UPDATE => ABORT */ - 251, /* VALUES => ABORT */ - 251, /* VARIABLE => ABORT */ - 251, /* VIEW => ABORT */ - 251, /* VNODES => ABORT */ - 251, /* WAL => ABORT */ + 255, /* AFTER => ABORT */ + 255, /* ATTACH => ABORT */ + 255, /* BEFORE => ABORT */ + 255, /* BEGIN => ABORT */ + 255, /* BITAND => ABORT */ + 255, /* BITNOT => ABORT */ + 255, /* BITOR => ABORT */ + 255, /* BLOCKS => ABORT */ + 255, /* CHANGE => ABORT */ + 255, /* COMMA => ABORT */ + 255, /* COMPACT => ABORT */ + 255, /* CONCAT => ABORT */ + 255, /* CONFLICT => ABORT */ + 255, /* COPY => ABORT */ + 255, /* DEFERRED => ABORT */ + 255, /* DELIMITERS => ABORT */ + 255, /* DETACH => ABORT */ + 255, /* DIVIDE => ABORT */ + 255, /* DOT => ABORT */ + 255, /* EACH => ABORT */ + 255, /* END => ABORT */ + 255, /* FAIL => ABORT */ + 255, /* FILE => ABORT */ + 255, /* FOR => ABORT */ + 255, /* GLOB => ABORT */ + 255, /* ID => ABORT */ + 255, /* IMMEDIATE => ABORT */ + 255, /* IMPORT => ABORT */ + 255, /* INITIALLY => ABORT */ + 255, /* INSTEAD => ABORT */ + 255, /* ISNULL => ABORT */ + 255, /* KEY => ABORT */ + 255, /* NK_BITNOT => ABORT */ + 255, /* NK_SEMI => ABORT */ + 255, /* NOTNULL => ABORT */ + 255, /* OF => ABORT */ + 255, /* PLUS => ABORT */ + 255, /* PRIVILEGE => ABORT */ + 255, /* RAISE => ABORT */ + 255, /* REPLACE => ABORT */ + 255, /* RESTRICT => ABORT */ + 255, /* ROW => ABORT */ + 255, /* SEMI => ABORT */ + 255, /* STAR => ABORT */ + 255, /* STATEMENT => ABORT */ + 255, /* STRING => ABORT */ + 255, /* TIMES => ABORT */ + 255, /* UPDATE => ABORT */ + 255, /* VALUES => ABORT */ + 255, /* VARIABLE => ABORT */ + 255, /* VIEW => ABORT */ + 255, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1358,345 +1391,348 @@ static const char *const yyTokenName[] = { /* 84 */ "WAL_RETENTION_SIZE", /* 85 */ "WAL_ROLL_PERIOD", /* 86 */ "WAL_SEGMENT_SIZE", - /* 87 */ "NK_COLON", - /* 88 */ "TABLE", - /* 89 */ "NK_LP", - /* 90 */ "NK_RP", - /* 91 */ "STABLE", - /* 92 */ "ADD", - /* 93 */ "COLUMN", - /* 94 */ "MODIFY", - /* 95 */ "RENAME", - /* 96 */ "TAG", - /* 97 */ "SET", - /* 98 */ "NK_EQ", - /* 99 */ "USING", - /* 100 */ "TAGS", - /* 101 */ "COMMENT", - /* 102 */ "BOOL", - /* 103 */ "TINYINT", - /* 104 */ "SMALLINT", - /* 105 */ "INT", - /* 106 */ "INTEGER", - /* 107 */ "BIGINT", - /* 108 */ "FLOAT", - /* 109 */ "DOUBLE", - /* 110 */ "BINARY", - /* 111 */ "TIMESTAMP", - /* 112 */ "NCHAR", - /* 113 */ "UNSIGNED", - /* 114 */ "JSON", - /* 115 */ "VARCHAR", - /* 116 */ "MEDIUMBLOB", - /* 117 */ "BLOB", - /* 118 */ "VARBINARY", - /* 119 */ "DECIMAL", - /* 120 */ "MAX_DELAY", - /* 121 */ "WATERMARK", - /* 122 */ "ROLLUP", - /* 123 */ "TTL", - /* 124 */ "SMA", - /* 125 */ "FIRST", - /* 126 */ "LAST", - /* 127 */ "SHOW", - /* 128 */ "DATABASES", - /* 129 */ "TABLES", - /* 130 */ "STABLES", - /* 131 */ "MNODES", - /* 132 */ "MODULES", - /* 133 */ "QNODES", - /* 134 */ "FUNCTIONS", - /* 135 */ "INDEXES", - /* 136 */ "ACCOUNTS", - /* 137 */ "APPS", - /* 138 */ "CONNECTIONS", - /* 139 */ "LICENCES", - /* 140 */ "GRANTS", - /* 141 */ "QUERIES", - /* 142 */ "SCORES", - /* 143 */ "TOPICS", - /* 144 */ "VARIABLES", - /* 145 */ "BNODES", - /* 146 */ "SNODES", - /* 147 */ "CLUSTER", - /* 148 */ "TRANSACTIONS", - /* 149 */ "DISTRIBUTED", - /* 150 */ "CONSUMERS", - /* 151 */ "SUBSCRIPTIONS", - /* 152 */ "LIKE", - /* 153 */ "INDEX", - /* 154 */ "FUNCTION", - /* 155 */ "INTERVAL", - /* 156 */ "TOPIC", - /* 157 */ "AS", - /* 158 */ "WITH", - /* 159 */ "META", - /* 160 */ "CONSUMER", - /* 161 */ "GROUP", - /* 162 */ "DESC", - /* 163 */ "DESCRIBE", - /* 164 */ "RESET", - /* 165 */ "QUERY", - /* 166 */ "CACHE", - /* 167 */ "EXPLAIN", - /* 168 */ "ANALYZE", - /* 169 */ "VERBOSE", - /* 170 */ "NK_BOOL", - /* 171 */ "RATIO", - /* 172 */ "NK_FLOAT", - /* 173 */ "OUTPUTTYPE", - /* 174 */ "AGGREGATE", - /* 175 */ "BUFSIZE", - /* 176 */ "STREAM", - /* 177 */ "INTO", - /* 178 */ "TRIGGER", - /* 179 */ "AT_ONCE", - /* 180 */ "WINDOW_CLOSE", - /* 181 */ "IGNORE", - /* 182 */ "EXPIRED", - /* 183 */ "KILL", - /* 184 */ "CONNECTION", - /* 185 */ "TRANSACTION", - /* 186 */ "BALANCE", - /* 187 */ "VGROUP", - /* 188 */ "MERGE", - /* 189 */ "REDISTRIBUTE", - /* 190 */ "SPLIT", - /* 191 */ "DELETE", - /* 192 */ "INSERT", - /* 193 */ "NULL", - /* 194 */ "NK_QUESTION", - /* 195 */ "NK_ARROW", - /* 196 */ "ROWTS", - /* 197 */ "TBNAME", - /* 198 */ "QSTART", - /* 199 */ "QEND", - /* 200 */ "QDURATION", - /* 201 */ "WSTART", - /* 202 */ "WEND", - /* 203 */ "WDURATION", - /* 204 */ "CAST", - /* 205 */ "NOW", - /* 206 */ "TODAY", - /* 207 */ "TIMEZONE", - /* 208 */ "CLIENT_VERSION", - /* 209 */ "SERVER_VERSION", - /* 210 */ "SERVER_STATUS", - /* 211 */ "CURRENT_USER", - /* 212 */ "COUNT", - /* 213 */ "LAST_ROW", - /* 214 */ "BETWEEN", - /* 215 */ "IS", - /* 216 */ "NK_LT", - /* 217 */ "NK_GT", - /* 218 */ "NK_LE", - /* 219 */ "NK_GE", - /* 220 */ "NK_NE", - /* 221 */ "MATCH", - /* 222 */ "NMATCH", - /* 223 */ "CONTAINS", - /* 224 */ "IN", - /* 225 */ "JOIN", - /* 226 */ "INNER", - /* 227 */ "SELECT", - /* 228 */ "DISTINCT", - /* 229 */ "WHERE", - /* 230 */ "PARTITION", - /* 231 */ "BY", - /* 232 */ "SESSION", - /* 233 */ "STATE_WINDOW", - /* 234 */ "SLIDING", - /* 235 */ "FILL", - /* 236 */ "VALUE", - /* 237 */ "NONE", - /* 238 */ "PREV", - /* 239 */ "LINEAR", - /* 240 */ "NEXT", - /* 241 */ "HAVING", - /* 242 */ "RANGE", - /* 243 */ "EVERY", - /* 244 */ "ORDER", - /* 245 */ "SLIMIT", - /* 246 */ "SOFFSET", - /* 247 */ "LIMIT", - /* 248 */ "OFFSET", - /* 249 */ "ASC", - /* 250 */ "NULLS", - /* 251 */ "ABORT", - /* 252 */ "AFTER", - /* 253 */ "ATTACH", - /* 254 */ "BEFORE", - /* 255 */ "BEGIN", - /* 256 */ "BITAND", - /* 257 */ "BITNOT", - /* 258 */ "BITOR", - /* 259 */ "BLOCKS", - /* 260 */ "CHANGE", - /* 261 */ "COMMA", - /* 262 */ "COMPACT", - /* 263 */ "CONCAT", - /* 264 */ "CONFLICT", - /* 265 */ "COPY", - /* 266 */ "DEFERRED", - /* 267 */ "DELIMITERS", - /* 268 */ "DETACH", - /* 269 */ "DIVIDE", - /* 270 */ "DOT", - /* 271 */ "EACH", - /* 272 */ "END", - /* 273 */ "FAIL", - /* 274 */ "FILE", - /* 275 */ "FOR", - /* 276 */ "GLOB", - /* 277 */ "ID", - /* 278 */ "IMMEDIATE", - /* 279 */ "IMPORT", - /* 280 */ "INITIALLY", - /* 281 */ "INSTEAD", - /* 282 */ "ISNULL", - /* 283 */ "KEY", - /* 284 */ "NK_BITNOT", - /* 285 */ "NK_SEMI", - /* 286 */ "NOTNULL", - /* 287 */ "OF", - /* 288 */ "PLUS", - /* 289 */ "PRIVILEGE", - /* 290 */ "RAISE", - /* 291 */ "REPLACE", - /* 292 */ "RESTRICT", - /* 293 */ "ROW", - /* 294 */ "SEMI", - /* 295 */ "STAR", - /* 296 */ "STATEMENT", - /* 297 */ "STRING", - /* 298 */ "TIMES", - /* 299 */ "UPDATE", - /* 300 */ "VALUES", - /* 301 */ "VARIABLE", - /* 302 */ "VIEW", - /* 303 */ "VNODES", - /* 304 */ "WAL", - /* 305 */ "cmd", - /* 306 */ "account_options", - /* 307 */ "alter_account_options", - /* 308 */ "literal", - /* 309 */ "alter_account_option", - /* 310 */ "user_name", - /* 311 */ "sysinfo_opt", - /* 312 */ "privileges", - /* 313 */ "priv_level", - /* 314 */ "priv_type_list", - /* 315 */ "priv_type", - /* 316 */ "db_name", - /* 317 */ "dnode_endpoint", - /* 318 */ "not_exists_opt", - /* 319 */ "db_options", - /* 320 */ "exists_opt", - /* 321 */ "alter_db_options", - /* 322 */ "integer_list", - /* 323 */ "variable_list", - /* 324 */ "retention_list", - /* 325 */ "alter_db_option", - /* 326 */ "retention", - /* 327 */ "full_table_name", - /* 328 */ "column_def_list", - /* 329 */ "tags_def_opt", - /* 330 */ "table_options", - /* 331 */ "multi_create_clause", - /* 332 */ "tags_def", - /* 333 */ "multi_drop_clause", - /* 334 */ "alter_table_clause", - /* 335 */ "alter_table_options", - /* 336 */ "column_name", - /* 337 */ "type_name", - /* 338 */ "signed_literal", - /* 339 */ "create_subtable_clause", - /* 340 */ "specific_cols_opt", - /* 341 */ "expression_list", - /* 342 */ "drop_table_clause", - /* 343 */ "col_name_list", - /* 344 */ "table_name", - /* 345 */ "column_def", - /* 346 */ "duration_list", - /* 347 */ "rollup_func_list", - /* 348 */ "alter_table_option", - /* 349 */ "duration_literal", - /* 350 */ "rollup_func_name", - /* 351 */ "function_name", - /* 352 */ "col_name", - /* 353 */ "db_name_cond_opt", - /* 354 */ "like_pattern_opt", - /* 355 */ "table_name_cond", - /* 356 */ "from_db_opt", - /* 357 */ "index_options", - /* 358 */ "func_list", - /* 359 */ "sliding_opt", - /* 360 */ "sma_stream_opt", - /* 361 */ "func", - /* 362 */ "stream_options", - /* 363 */ "topic_name", - /* 364 */ "query_expression", - /* 365 */ "cgroup_name", - /* 366 */ "analyze_opt", - /* 367 */ "explain_options", - /* 368 */ "agg_func_opt", - /* 369 */ "bufsize_opt", - /* 370 */ "stream_name", - /* 371 */ "dnode_list", - /* 372 */ "where_clause_opt", - /* 373 */ "signed", - /* 374 */ "literal_func", - /* 375 */ "literal_list", - /* 376 */ "table_alias", - /* 377 */ "column_alias", - /* 378 */ "expression", - /* 379 */ "pseudo_column", - /* 380 */ "column_reference", - /* 381 */ "function_expression", - /* 382 */ "subquery", - /* 383 */ "star_func", - /* 384 */ "star_func_para_list", - /* 385 */ "noarg_func", - /* 386 */ "other_para_list", - /* 387 */ "star_func_para", - /* 388 */ "predicate", - /* 389 */ "compare_op", - /* 390 */ "in_op", - /* 391 */ "in_predicate_value", - /* 392 */ "boolean_value_expression", - /* 393 */ "boolean_primary", - /* 394 */ "common_expression", - /* 395 */ "from_clause_opt", - /* 396 */ "table_reference_list", - /* 397 */ "table_reference", - /* 398 */ "table_primary", - /* 399 */ "joined_table", - /* 400 */ "alias_opt", - /* 401 */ "parenthesized_joined_table", - /* 402 */ "join_type", - /* 403 */ "search_condition", - /* 404 */ "query_specification", - /* 405 */ "set_quantifier_opt", - /* 406 */ "select_list", - /* 407 */ "partition_by_clause_opt", - /* 408 */ "range_opt", - /* 409 */ "every_opt", - /* 410 */ "fill_opt", - /* 411 */ "twindow_clause_opt", - /* 412 */ "group_by_clause_opt", - /* 413 */ "having_clause_opt", - /* 414 */ "select_item", - /* 415 */ "fill_mode", - /* 416 */ "group_by_list", - /* 417 */ "query_expression_body", - /* 418 */ "order_by_clause_opt", - /* 419 */ "slimit_clause_opt", - /* 420 */ "limit_clause_opt", - /* 421 */ "query_primary", - /* 422 */ "sort_specification_list", - /* 423 */ "sort_specification", - /* 424 */ "ordering_specification_opt", - /* 425 */ "null_ordering_opt", + /* 87 */ "SST_TRIGGER", + /* 88 */ "TABLE_PREFIX", + /* 89 */ "TABLE_SUFFIX", + /* 90 */ "NK_COLON", + /* 91 */ "TABLE", + /* 92 */ "NK_LP", + /* 93 */ "NK_RP", + /* 94 */ "STABLE", + /* 95 */ "ADD", + /* 96 */ "COLUMN", + /* 97 */ "MODIFY", + /* 98 */ "RENAME", + /* 99 */ "TAG", + /* 100 */ "SET", + /* 101 */ "NK_EQ", + /* 102 */ "USING", + /* 103 */ "TAGS", + /* 104 */ "COMMENT", + /* 105 */ "BOOL", + /* 106 */ "TINYINT", + /* 107 */ "SMALLINT", + /* 108 */ "INT", + /* 109 */ "INTEGER", + /* 110 */ "BIGINT", + /* 111 */ "FLOAT", + /* 112 */ "DOUBLE", + /* 113 */ "BINARY", + /* 114 */ "TIMESTAMP", + /* 115 */ "NCHAR", + /* 116 */ "UNSIGNED", + /* 117 */ "JSON", + /* 118 */ "VARCHAR", + /* 119 */ "MEDIUMBLOB", + /* 120 */ "BLOB", + /* 121 */ "VARBINARY", + /* 122 */ "DECIMAL", + /* 123 */ "MAX_DELAY", + /* 124 */ "WATERMARK", + /* 125 */ "ROLLUP", + /* 126 */ "TTL", + /* 127 */ "SMA", + /* 128 */ "FIRST", + /* 129 */ "LAST", + /* 130 */ "SHOW", + /* 131 */ "DATABASES", + /* 132 */ "TABLES", + /* 133 */ "STABLES", + /* 134 */ "MNODES", + /* 135 */ "MODULES", + /* 136 */ "QNODES", + /* 137 */ "FUNCTIONS", + /* 138 */ "INDEXES", + /* 139 */ "ACCOUNTS", + /* 140 */ "APPS", + /* 141 */ "CONNECTIONS", + /* 142 */ "LICENCES", + /* 143 */ "GRANTS", + /* 144 */ "QUERIES", + /* 145 */ "SCORES", + /* 146 */ "TOPICS", + /* 147 */ "VARIABLES", + /* 148 */ "BNODES", + /* 149 */ "SNODES", + /* 150 */ "CLUSTER", + /* 151 */ "TRANSACTIONS", + /* 152 */ "DISTRIBUTED", + /* 153 */ "CONSUMERS", + /* 154 */ "SUBSCRIPTIONS", + /* 155 */ "VNODES", + /* 156 */ "LIKE", + /* 157 */ "INDEX", + /* 158 */ "FUNCTION", + /* 159 */ "INTERVAL", + /* 160 */ "TOPIC", + /* 161 */ "AS", + /* 162 */ "WITH", + /* 163 */ "META", + /* 164 */ "CONSUMER", + /* 165 */ "GROUP", + /* 166 */ "DESC", + /* 167 */ "DESCRIBE", + /* 168 */ "RESET", + /* 169 */ "QUERY", + /* 170 */ "CACHE", + /* 171 */ "EXPLAIN", + /* 172 */ "ANALYZE", + /* 173 */ "VERBOSE", + /* 174 */ "NK_BOOL", + /* 175 */ "RATIO", + /* 176 */ "NK_FLOAT", + /* 177 */ "OUTPUTTYPE", + /* 178 */ "AGGREGATE", + /* 179 */ "BUFSIZE", + /* 180 */ "STREAM", + /* 181 */ "INTO", + /* 182 */ "TRIGGER", + /* 183 */ "AT_ONCE", + /* 184 */ "WINDOW_CLOSE", + /* 185 */ "IGNORE", + /* 186 */ "EXPIRED", + /* 187 */ "KILL", + /* 188 */ "CONNECTION", + /* 189 */ "TRANSACTION", + /* 190 */ "BALANCE", + /* 191 */ "VGROUP", + /* 192 */ "MERGE", + /* 193 */ "REDISTRIBUTE", + /* 194 */ "SPLIT", + /* 195 */ "DELETE", + /* 196 */ "INSERT", + /* 197 */ "NULL", + /* 198 */ "NK_QUESTION", + /* 199 */ "NK_ARROW", + /* 200 */ "ROWTS", + /* 201 */ "TBNAME", + /* 202 */ "QSTART", + /* 203 */ "QEND", + /* 204 */ "QDURATION", + /* 205 */ "WSTART", + /* 206 */ "WEND", + /* 207 */ "WDURATION", + /* 208 */ "CAST", + /* 209 */ "NOW", + /* 210 */ "TODAY", + /* 211 */ "TIMEZONE", + /* 212 */ "CLIENT_VERSION", + /* 213 */ "SERVER_VERSION", + /* 214 */ "SERVER_STATUS", + /* 215 */ "CURRENT_USER", + /* 216 */ "COUNT", + /* 217 */ "LAST_ROW", + /* 218 */ "BETWEEN", + /* 219 */ "IS", + /* 220 */ "NK_LT", + /* 221 */ "NK_GT", + /* 222 */ "NK_LE", + /* 223 */ "NK_GE", + /* 224 */ "NK_NE", + /* 225 */ "MATCH", + /* 226 */ "NMATCH", + /* 227 */ "CONTAINS", + /* 228 */ "IN", + /* 229 */ "JOIN", + /* 230 */ "INNER", + /* 231 */ "SELECT", + /* 232 */ "DISTINCT", + /* 233 */ "WHERE", + /* 234 */ "PARTITION", + /* 235 */ "BY", + /* 236 */ "SESSION", + /* 237 */ "STATE_WINDOW", + /* 238 */ "SLIDING", + /* 239 */ "FILL", + /* 240 */ "VALUE", + /* 241 */ "NONE", + /* 242 */ "PREV", + /* 243 */ "LINEAR", + /* 244 */ "NEXT", + /* 245 */ "HAVING", + /* 246 */ "RANGE", + /* 247 */ "EVERY", + /* 248 */ "ORDER", + /* 249 */ "SLIMIT", + /* 250 */ "SOFFSET", + /* 251 */ "LIMIT", + /* 252 */ "OFFSET", + /* 253 */ "ASC", + /* 254 */ "NULLS", + /* 255 */ "ABORT", + /* 256 */ "AFTER", + /* 257 */ "ATTACH", + /* 258 */ "BEFORE", + /* 259 */ "BEGIN", + /* 260 */ "BITAND", + /* 261 */ "BITNOT", + /* 262 */ "BITOR", + /* 263 */ "BLOCKS", + /* 264 */ "CHANGE", + /* 265 */ "COMMA", + /* 266 */ "COMPACT", + /* 267 */ "CONCAT", + /* 268 */ "CONFLICT", + /* 269 */ "COPY", + /* 270 */ "DEFERRED", + /* 271 */ "DELIMITERS", + /* 272 */ "DETACH", + /* 273 */ "DIVIDE", + /* 274 */ "DOT", + /* 275 */ "EACH", + /* 276 */ "END", + /* 277 */ "FAIL", + /* 278 */ "FILE", + /* 279 */ "FOR", + /* 280 */ "GLOB", + /* 281 */ "ID", + /* 282 */ "IMMEDIATE", + /* 283 */ "IMPORT", + /* 284 */ "INITIALLY", + /* 285 */ "INSTEAD", + /* 286 */ "ISNULL", + /* 287 */ "KEY", + /* 288 */ "NK_BITNOT", + /* 289 */ "NK_SEMI", + /* 290 */ "NOTNULL", + /* 291 */ "OF", + /* 292 */ "PLUS", + /* 293 */ "PRIVILEGE", + /* 294 */ "RAISE", + /* 295 */ "REPLACE", + /* 296 */ "RESTRICT", + /* 297 */ "ROW", + /* 298 */ "SEMI", + /* 299 */ "STAR", + /* 300 */ "STATEMENT", + /* 301 */ "STRING", + /* 302 */ "TIMES", + /* 303 */ "UPDATE", + /* 304 */ "VALUES", + /* 305 */ "VARIABLE", + /* 306 */ "VIEW", + /* 307 */ "WAL", + /* 308 */ "cmd", + /* 309 */ "account_options", + /* 310 */ "alter_account_options", + /* 311 */ "literal", + /* 312 */ "alter_account_option", + /* 313 */ "user_name", + /* 314 */ "sysinfo_opt", + /* 315 */ "privileges", + /* 316 */ "priv_level", + /* 317 */ "priv_type_list", + /* 318 */ "priv_type", + /* 319 */ "db_name", + /* 320 */ "dnode_endpoint", + /* 321 */ "not_exists_opt", + /* 322 */ "db_options", + /* 323 */ "exists_opt", + /* 324 */ "alter_db_options", + /* 325 */ "integer_list", + /* 326 */ "variable_list", + /* 327 */ "retention_list", + /* 328 */ "alter_db_option", + /* 329 */ "retention", + /* 330 */ "full_table_name", + /* 331 */ "column_def_list", + /* 332 */ "tags_def_opt", + /* 333 */ "table_options", + /* 334 */ "multi_create_clause", + /* 335 */ "tags_def", + /* 336 */ "multi_drop_clause", + /* 337 */ "alter_table_clause", + /* 338 */ "alter_table_options", + /* 339 */ "column_name", + /* 340 */ "type_name", + /* 341 */ "signed_literal", + /* 342 */ "create_subtable_clause", + /* 343 */ "specific_cols_opt", + /* 344 */ "expression_list", + /* 345 */ "drop_table_clause", + /* 346 */ "col_name_list", + /* 347 */ "table_name", + /* 348 */ "column_def", + /* 349 */ "duration_list", + /* 350 */ "rollup_func_list", + /* 351 */ "alter_table_option", + /* 352 */ "duration_literal", + /* 353 */ "rollup_func_name", + /* 354 */ "function_name", + /* 355 */ "col_name", + /* 356 */ "db_name_cond_opt", + /* 357 */ "like_pattern_opt", + /* 358 */ "table_name_cond", + /* 359 */ "from_db_opt", + /* 360 */ "index_options", + /* 361 */ "func_list", + /* 362 */ "sliding_opt", + /* 363 */ "sma_stream_opt", + /* 364 */ "func", + /* 365 */ "stream_options", + /* 366 */ "topic_name", + /* 367 */ "query_expression", + /* 368 */ "cgroup_name", + /* 369 */ "analyze_opt", + /* 370 */ "explain_options", + /* 371 */ "agg_func_opt", + /* 372 */ "bufsize_opt", + /* 373 */ "stream_name", + /* 374 */ "dnode_list", + /* 375 */ "where_clause_opt", + /* 376 */ "signed", + /* 377 */ "literal_func", + /* 378 */ "literal_list", + /* 379 */ "table_alias", + /* 380 */ "column_alias", + /* 381 */ "expression", + /* 382 */ "pseudo_column", + /* 383 */ "column_reference", + /* 384 */ "function_expression", + /* 385 */ "subquery", + /* 386 */ "star_func", + /* 387 */ "star_func_para_list", + /* 388 */ "noarg_func", + /* 389 */ "other_para_list", + /* 390 */ "star_func_para", + /* 391 */ "predicate", + /* 392 */ "compare_op", + /* 393 */ "in_op", + /* 394 */ "in_predicate_value", + /* 395 */ "boolean_value_expression", + /* 396 */ "boolean_primary", + /* 397 */ "common_expression", + /* 398 */ "from_clause_opt", + /* 399 */ "table_reference_list", + /* 400 */ "table_reference", + /* 401 */ "table_primary", + /* 402 */ "joined_table", + /* 403 */ "alias_opt", + /* 404 */ "parenthesized_joined_table", + /* 405 */ "join_type", + /* 406 */ "search_condition", + /* 407 */ "query_specification", + /* 408 */ "set_quantifier_opt", + /* 409 */ "select_list", + /* 410 */ "partition_by_clause_opt", + /* 411 */ "range_opt", + /* 412 */ "every_opt", + /* 413 */ "fill_opt", + /* 414 */ "twindow_clause_opt", + /* 415 */ "group_by_clause_opt", + /* 416 */ "having_clause_opt", + /* 417 */ "select_item", + /* 418 */ "fill_mode", + /* 419 */ "group_by_list", + /* 420 */ "query_expression_body", + /* 421 */ "order_by_clause_opt", + /* 422 */ "slimit_clause_opt", + /* 423 */ "limit_clause_opt", + /* 424 */ "query_primary", + /* 425 */ "sort_specification_list", + /* 426 */ "sort_specification", + /* 427 */ "ordering_specification_opt", + /* 428 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1804,395 +1840,401 @@ static const char *const yyRuleName[] = { /* 97 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", /* 98 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", /* 99 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", - /* 100 */ "alter_db_options ::= alter_db_option", - /* 101 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 102 */ "alter_db_option ::= CACHEMODEL NK_STRING", - /* 103 */ "alter_db_option ::= CACHESIZE NK_INTEGER", - /* 104 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", - /* 105 */ "alter_db_option ::= KEEP integer_list", - /* 106 */ "alter_db_option ::= KEEP variable_list", - /* 107 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", - /* 108 */ "integer_list ::= NK_INTEGER", - /* 109 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 110 */ "variable_list ::= NK_VARIABLE", - /* 111 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 112 */ "retention_list ::= retention", - /* 113 */ "retention_list ::= retention_list NK_COMMA retention", - /* 114 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 115 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 116 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 117 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 118 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 119 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 120 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 121 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 122 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 123 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 124 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 125 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 126 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 127 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 128 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 129 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 130 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 131 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 132 */ "multi_create_clause ::= create_subtable_clause", - /* 133 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 134 */ "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", - /* 135 */ "multi_drop_clause ::= drop_table_clause", - /* 136 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 137 */ "drop_table_clause ::= exists_opt full_table_name", - /* 138 */ "specific_cols_opt ::=", - /* 139 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 140 */ "full_table_name ::= table_name", - /* 141 */ "full_table_name ::= db_name NK_DOT table_name", - /* 142 */ "column_def_list ::= column_def", - /* 143 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 144 */ "column_def ::= column_name type_name", - /* 145 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 146 */ "type_name ::= BOOL", - /* 147 */ "type_name ::= TINYINT", - /* 148 */ "type_name ::= SMALLINT", - /* 149 */ "type_name ::= INT", - /* 150 */ "type_name ::= INTEGER", - /* 151 */ "type_name ::= BIGINT", - /* 152 */ "type_name ::= FLOAT", - /* 153 */ "type_name ::= DOUBLE", - /* 154 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 155 */ "type_name ::= TIMESTAMP", - /* 156 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 157 */ "type_name ::= TINYINT UNSIGNED", - /* 158 */ "type_name ::= SMALLINT UNSIGNED", - /* 159 */ "type_name ::= INT UNSIGNED", - /* 160 */ "type_name ::= BIGINT UNSIGNED", - /* 161 */ "type_name ::= JSON", - /* 162 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 163 */ "type_name ::= MEDIUMBLOB", - /* 164 */ "type_name ::= BLOB", - /* 165 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 166 */ "type_name ::= DECIMAL", - /* 167 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 168 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 169 */ "tags_def_opt ::=", - /* 170 */ "tags_def_opt ::= tags_def", - /* 171 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 172 */ "table_options ::=", - /* 173 */ "table_options ::= table_options COMMENT NK_STRING", - /* 174 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 175 */ "table_options ::= table_options WATERMARK duration_list", - /* 176 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 177 */ "table_options ::= table_options TTL NK_INTEGER", - /* 178 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 179 */ "alter_table_options ::= alter_table_option", - /* 180 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 181 */ "alter_table_option ::= COMMENT NK_STRING", - /* 182 */ "alter_table_option ::= TTL NK_INTEGER", - /* 183 */ "duration_list ::= duration_literal", - /* 184 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 185 */ "rollup_func_list ::= rollup_func_name", - /* 186 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 187 */ "rollup_func_name ::= function_name", - /* 188 */ "rollup_func_name ::= FIRST", - /* 189 */ "rollup_func_name ::= LAST", - /* 190 */ "col_name_list ::= col_name", - /* 191 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 192 */ "col_name ::= column_name", - /* 193 */ "cmd ::= SHOW DNODES", - /* 194 */ "cmd ::= SHOW USERS", - /* 195 */ "cmd ::= SHOW DATABASES", - /* 196 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 197 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 198 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 199 */ "cmd ::= SHOW MNODES", - /* 200 */ "cmd ::= SHOW MODULES", - /* 201 */ "cmd ::= SHOW QNODES", - /* 202 */ "cmd ::= SHOW FUNCTIONS", - /* 203 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 204 */ "cmd ::= SHOW STREAMS", - /* 205 */ "cmd ::= SHOW ACCOUNTS", - /* 206 */ "cmd ::= SHOW APPS", - /* 207 */ "cmd ::= SHOW CONNECTIONS", - /* 208 */ "cmd ::= SHOW LICENCES", - /* 209 */ "cmd ::= SHOW GRANTS", - /* 210 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 211 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 212 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 213 */ "cmd ::= SHOW QUERIES", - /* 214 */ "cmd ::= SHOW SCORES", - /* 215 */ "cmd ::= SHOW TOPICS", - /* 216 */ "cmd ::= SHOW VARIABLES", - /* 217 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 218 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 219 */ "cmd ::= SHOW BNODES", - /* 220 */ "cmd ::= SHOW SNODES", - /* 221 */ "cmd ::= SHOW CLUSTER", - /* 222 */ "cmd ::= SHOW TRANSACTIONS", - /* 223 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 224 */ "cmd ::= SHOW CONSUMERS", - /* 225 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 226 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 227 */ "db_name_cond_opt ::=", - /* 228 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 229 */ "like_pattern_opt ::=", - /* 230 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 231 */ "table_name_cond ::= table_name", - /* 232 */ "from_db_opt ::=", - /* 233 */ "from_db_opt ::= FROM db_name", - /* 234 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 235 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 236 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 237 */ "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", - /* 238 */ "func_list ::= func", - /* 239 */ "func_list ::= func_list NK_COMMA func", - /* 240 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 241 */ "sma_stream_opt ::=", - /* 242 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 243 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 244 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 245 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 246 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 247 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 248 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 249 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 250 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 251 */ "cmd ::= DESC full_table_name", - /* 252 */ "cmd ::= DESCRIBE full_table_name", - /* 253 */ "cmd ::= RESET QUERY CACHE", - /* 254 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 255 */ "analyze_opt ::=", - /* 256 */ "analyze_opt ::= ANALYZE", - /* 257 */ "explain_options ::=", - /* 258 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 259 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 260 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 261 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 262 */ "agg_func_opt ::=", - /* 263 */ "agg_func_opt ::= AGGREGATE", - /* 264 */ "bufsize_opt ::=", - /* 265 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 266 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression", - /* 267 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 268 */ "stream_options ::=", - /* 269 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 270 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 271 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 272 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 273 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 274 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 275 */ "cmd ::= KILL QUERY NK_STRING", - /* 276 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 277 */ "cmd ::= BALANCE VGROUP", - /* 278 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 279 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 280 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 281 */ "dnode_list ::= DNODE NK_INTEGER", - /* 282 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 283 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 284 */ "cmd ::= query_expression", - /* 285 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression", - /* 286 */ "cmd ::= INSERT INTO full_table_name query_expression", - /* 287 */ "literal ::= NK_INTEGER", - /* 288 */ "literal ::= NK_FLOAT", - /* 289 */ "literal ::= NK_STRING", - /* 290 */ "literal ::= NK_BOOL", - /* 291 */ "literal ::= TIMESTAMP NK_STRING", - /* 292 */ "literal ::= duration_literal", - /* 293 */ "literal ::= NULL", - /* 294 */ "literal ::= NK_QUESTION", - /* 295 */ "duration_literal ::= NK_VARIABLE", - /* 296 */ "signed ::= NK_INTEGER", - /* 297 */ "signed ::= NK_PLUS NK_INTEGER", - /* 298 */ "signed ::= NK_MINUS NK_INTEGER", - /* 299 */ "signed ::= NK_FLOAT", - /* 300 */ "signed ::= NK_PLUS NK_FLOAT", - /* 301 */ "signed ::= NK_MINUS NK_FLOAT", - /* 302 */ "signed_literal ::= signed", - /* 303 */ "signed_literal ::= NK_STRING", - /* 304 */ "signed_literal ::= NK_BOOL", - /* 305 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 306 */ "signed_literal ::= duration_literal", - /* 307 */ "signed_literal ::= NULL", - /* 308 */ "signed_literal ::= literal_func", - /* 309 */ "signed_literal ::= NK_QUESTION", - /* 310 */ "literal_list ::= signed_literal", - /* 311 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 312 */ "db_name ::= NK_ID", - /* 313 */ "table_name ::= NK_ID", - /* 314 */ "column_name ::= NK_ID", - /* 315 */ "function_name ::= NK_ID", - /* 316 */ "table_alias ::= NK_ID", - /* 317 */ "column_alias ::= NK_ID", - /* 318 */ "user_name ::= NK_ID", - /* 319 */ "topic_name ::= NK_ID", - /* 320 */ "stream_name ::= NK_ID", - /* 321 */ "cgroup_name ::= NK_ID", - /* 322 */ "expression ::= literal", - /* 323 */ "expression ::= pseudo_column", - /* 324 */ "expression ::= column_reference", - /* 325 */ "expression ::= function_expression", - /* 326 */ "expression ::= subquery", - /* 327 */ "expression ::= NK_LP expression NK_RP", - /* 328 */ "expression ::= NK_PLUS expression", - /* 329 */ "expression ::= NK_MINUS expression", - /* 330 */ "expression ::= expression NK_PLUS expression", - /* 331 */ "expression ::= expression NK_MINUS expression", - /* 332 */ "expression ::= expression NK_STAR expression", - /* 333 */ "expression ::= expression NK_SLASH expression", - /* 334 */ "expression ::= expression NK_REM expression", - /* 335 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 336 */ "expression ::= expression NK_BITAND expression", - /* 337 */ "expression ::= expression NK_BITOR expression", - /* 338 */ "expression_list ::= expression", - /* 339 */ "expression_list ::= expression_list NK_COMMA expression", - /* 340 */ "column_reference ::= column_name", - /* 341 */ "column_reference ::= table_name NK_DOT column_name", - /* 342 */ "pseudo_column ::= ROWTS", - /* 343 */ "pseudo_column ::= TBNAME", - /* 344 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 345 */ "pseudo_column ::= QSTART", - /* 346 */ "pseudo_column ::= QEND", - /* 347 */ "pseudo_column ::= QDURATION", - /* 348 */ "pseudo_column ::= WSTART", - /* 349 */ "pseudo_column ::= WEND", - /* 350 */ "pseudo_column ::= WDURATION", - /* 351 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 352 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 353 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 354 */ "function_expression ::= literal_func", - /* 355 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 356 */ "literal_func ::= NOW", - /* 357 */ "noarg_func ::= NOW", - /* 358 */ "noarg_func ::= TODAY", - /* 359 */ "noarg_func ::= TIMEZONE", - /* 360 */ "noarg_func ::= DATABASE", - /* 361 */ "noarg_func ::= CLIENT_VERSION", - /* 362 */ "noarg_func ::= SERVER_VERSION", - /* 363 */ "noarg_func ::= SERVER_STATUS", - /* 364 */ "noarg_func ::= CURRENT_USER", - /* 365 */ "noarg_func ::= USER", - /* 366 */ "star_func ::= COUNT", - /* 367 */ "star_func ::= FIRST", - /* 368 */ "star_func ::= LAST", - /* 369 */ "star_func ::= LAST_ROW", - /* 370 */ "star_func_para_list ::= NK_STAR", - /* 371 */ "star_func_para_list ::= other_para_list", - /* 372 */ "other_para_list ::= star_func_para", - /* 373 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 374 */ "star_func_para ::= expression", - /* 375 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 376 */ "predicate ::= expression compare_op expression", - /* 377 */ "predicate ::= expression BETWEEN expression AND expression", - /* 378 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 379 */ "predicate ::= expression IS NULL", - /* 380 */ "predicate ::= expression IS NOT NULL", - /* 381 */ "predicate ::= expression in_op in_predicate_value", - /* 382 */ "compare_op ::= NK_LT", - /* 383 */ "compare_op ::= NK_GT", - /* 384 */ "compare_op ::= NK_LE", - /* 385 */ "compare_op ::= NK_GE", - /* 386 */ "compare_op ::= NK_NE", - /* 387 */ "compare_op ::= NK_EQ", - /* 388 */ "compare_op ::= LIKE", - /* 389 */ "compare_op ::= NOT LIKE", - /* 390 */ "compare_op ::= MATCH", - /* 391 */ "compare_op ::= NMATCH", - /* 392 */ "compare_op ::= CONTAINS", - /* 393 */ "in_op ::= IN", - /* 394 */ "in_op ::= NOT IN", - /* 395 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 396 */ "boolean_value_expression ::= boolean_primary", - /* 397 */ "boolean_value_expression ::= NOT boolean_primary", - /* 398 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 399 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 400 */ "boolean_primary ::= predicate", - /* 401 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 402 */ "common_expression ::= expression", - /* 403 */ "common_expression ::= boolean_value_expression", - /* 404 */ "from_clause_opt ::=", - /* 405 */ "from_clause_opt ::= FROM table_reference_list", - /* 406 */ "table_reference_list ::= table_reference", - /* 407 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 408 */ "table_reference ::= table_primary", - /* 409 */ "table_reference ::= joined_table", - /* 410 */ "table_primary ::= table_name alias_opt", - /* 411 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 412 */ "table_primary ::= subquery alias_opt", - /* 413 */ "table_primary ::= parenthesized_joined_table", - /* 414 */ "alias_opt ::=", - /* 415 */ "alias_opt ::= table_alias", - /* 416 */ "alias_opt ::= AS table_alias", - /* 417 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 418 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 419 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 420 */ "join_type ::=", - /* 421 */ "join_type ::= INNER", - /* 422 */ "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", - /* 423 */ "set_quantifier_opt ::=", - /* 424 */ "set_quantifier_opt ::= DISTINCT", - /* 425 */ "set_quantifier_opt ::= ALL", - /* 426 */ "select_list ::= select_item", - /* 427 */ "select_list ::= select_list NK_COMMA select_item", - /* 428 */ "select_item ::= NK_STAR", - /* 429 */ "select_item ::= common_expression", - /* 430 */ "select_item ::= common_expression column_alias", - /* 431 */ "select_item ::= common_expression AS column_alias", - /* 432 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 433 */ "where_clause_opt ::=", - /* 434 */ "where_clause_opt ::= WHERE search_condition", - /* 435 */ "partition_by_clause_opt ::=", - /* 436 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 437 */ "twindow_clause_opt ::=", - /* 438 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 439 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 440 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 441 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 442 */ "sliding_opt ::=", - /* 443 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 444 */ "fill_opt ::=", - /* 445 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 446 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 447 */ "fill_mode ::= NONE", - /* 448 */ "fill_mode ::= PREV", - /* 449 */ "fill_mode ::= NULL", - /* 450 */ "fill_mode ::= LINEAR", - /* 451 */ "fill_mode ::= NEXT", - /* 452 */ "group_by_clause_opt ::=", - /* 453 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 454 */ "group_by_list ::= expression", - /* 455 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 456 */ "having_clause_opt ::=", - /* 457 */ "having_clause_opt ::= HAVING search_condition", - /* 458 */ "range_opt ::=", - /* 459 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 460 */ "every_opt ::=", - /* 461 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 462 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 463 */ "query_expression_body ::= query_primary", - /* 464 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 465 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 466 */ "query_primary ::= query_specification", - /* 467 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 468 */ "order_by_clause_opt ::=", - /* 469 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 470 */ "slimit_clause_opt ::=", - /* 471 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 472 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 473 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 474 */ "limit_clause_opt ::=", - /* 475 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 476 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 477 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 478 */ "subquery ::= NK_LP query_expression NK_RP", - /* 479 */ "search_condition ::= common_expression", - /* 480 */ "sort_specification_list ::= sort_specification", - /* 481 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 482 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 483 */ "ordering_specification_opt ::=", - /* 484 */ "ordering_specification_opt ::= ASC", - /* 485 */ "ordering_specification_opt ::= DESC", - /* 486 */ "null_ordering_opt ::=", - /* 487 */ "null_ordering_opt ::= NULLS FIRST", - /* 488 */ "null_ordering_opt ::= NULLS LAST", + /* 100 */ "db_options ::= db_options SST_TRIGGER NK_INTEGER", + /* 101 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER", + /* 102 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER", + /* 103 */ "alter_db_options ::= alter_db_option", + /* 104 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 105 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 106 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 107 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 108 */ "alter_db_option ::= KEEP integer_list", + /* 109 */ "alter_db_option ::= KEEP variable_list", + /* 110 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 111 */ "alter_db_option ::= SST_TRIGGER NK_INTEGER", + /* 112 */ "integer_list ::= NK_INTEGER", + /* 113 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 114 */ "variable_list ::= NK_VARIABLE", + /* 115 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 116 */ "retention_list ::= retention", + /* 117 */ "retention_list ::= retention_list NK_COMMA retention", + /* 118 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 119 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 120 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 121 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 122 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 123 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 124 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 125 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 126 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 127 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 128 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 129 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 130 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 131 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 132 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 133 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 134 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 135 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 136 */ "multi_create_clause ::= create_subtable_clause", + /* 137 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 138 */ "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", + /* 139 */ "multi_drop_clause ::= drop_table_clause", + /* 140 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 141 */ "drop_table_clause ::= exists_opt full_table_name", + /* 142 */ "specific_cols_opt ::=", + /* 143 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 144 */ "full_table_name ::= table_name", + /* 145 */ "full_table_name ::= db_name NK_DOT table_name", + /* 146 */ "column_def_list ::= column_def", + /* 147 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 148 */ "column_def ::= column_name type_name", + /* 149 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 150 */ "type_name ::= BOOL", + /* 151 */ "type_name ::= TINYINT", + /* 152 */ "type_name ::= SMALLINT", + /* 153 */ "type_name ::= INT", + /* 154 */ "type_name ::= INTEGER", + /* 155 */ "type_name ::= BIGINT", + /* 156 */ "type_name ::= FLOAT", + /* 157 */ "type_name ::= DOUBLE", + /* 158 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 159 */ "type_name ::= TIMESTAMP", + /* 160 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 161 */ "type_name ::= TINYINT UNSIGNED", + /* 162 */ "type_name ::= SMALLINT UNSIGNED", + /* 163 */ "type_name ::= INT UNSIGNED", + /* 164 */ "type_name ::= BIGINT UNSIGNED", + /* 165 */ "type_name ::= JSON", + /* 166 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 167 */ "type_name ::= MEDIUMBLOB", + /* 168 */ "type_name ::= BLOB", + /* 169 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 170 */ "type_name ::= DECIMAL", + /* 171 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 172 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 173 */ "tags_def_opt ::=", + /* 174 */ "tags_def_opt ::= tags_def", + /* 175 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 176 */ "table_options ::=", + /* 177 */ "table_options ::= table_options COMMENT NK_STRING", + /* 178 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 179 */ "table_options ::= table_options WATERMARK duration_list", + /* 180 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 181 */ "table_options ::= table_options TTL NK_INTEGER", + /* 182 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 183 */ "alter_table_options ::= alter_table_option", + /* 184 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 185 */ "alter_table_option ::= COMMENT NK_STRING", + /* 186 */ "alter_table_option ::= TTL NK_INTEGER", + /* 187 */ "duration_list ::= duration_literal", + /* 188 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 189 */ "rollup_func_list ::= rollup_func_name", + /* 190 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 191 */ "rollup_func_name ::= function_name", + /* 192 */ "rollup_func_name ::= FIRST", + /* 193 */ "rollup_func_name ::= LAST", + /* 194 */ "col_name_list ::= col_name", + /* 195 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 196 */ "col_name ::= column_name", + /* 197 */ "cmd ::= SHOW DNODES", + /* 198 */ "cmd ::= SHOW USERS", + /* 199 */ "cmd ::= SHOW DATABASES", + /* 200 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 201 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 202 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 203 */ "cmd ::= SHOW MNODES", + /* 204 */ "cmd ::= SHOW MODULES", + /* 205 */ "cmd ::= SHOW QNODES", + /* 206 */ "cmd ::= SHOW FUNCTIONS", + /* 207 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 208 */ "cmd ::= SHOW STREAMS", + /* 209 */ "cmd ::= SHOW ACCOUNTS", + /* 210 */ "cmd ::= SHOW APPS", + /* 211 */ "cmd ::= SHOW CONNECTIONS", + /* 212 */ "cmd ::= SHOW LICENCES", + /* 213 */ "cmd ::= SHOW GRANTS", + /* 214 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 215 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 216 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 217 */ "cmd ::= SHOW QUERIES", + /* 218 */ "cmd ::= SHOW SCORES", + /* 219 */ "cmd ::= SHOW TOPICS", + /* 220 */ "cmd ::= SHOW VARIABLES", + /* 221 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 222 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 223 */ "cmd ::= SHOW BNODES", + /* 224 */ "cmd ::= SHOW SNODES", + /* 225 */ "cmd ::= SHOW CLUSTER", + /* 226 */ "cmd ::= SHOW TRANSACTIONS", + /* 227 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 228 */ "cmd ::= SHOW CONSUMERS", + /* 229 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 230 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 231 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 232 */ "cmd ::= SHOW VNODES NK_STRING", + /* 233 */ "db_name_cond_opt ::=", + /* 234 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 235 */ "like_pattern_opt ::=", + /* 236 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 237 */ "table_name_cond ::= table_name", + /* 238 */ "from_db_opt ::=", + /* 239 */ "from_db_opt ::= FROM db_name", + /* 240 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", + /* 241 */ "cmd ::= DROP INDEX exists_opt full_table_name", + /* 242 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 243 */ "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", + /* 244 */ "func_list ::= func", + /* 245 */ "func_list ::= func_list NK_COMMA func", + /* 246 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 247 */ "sma_stream_opt ::=", + /* 248 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 249 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 250 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 252 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 253 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 254 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 255 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 256 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 257 */ "cmd ::= DESC full_table_name", + /* 258 */ "cmd ::= DESCRIBE full_table_name", + /* 259 */ "cmd ::= RESET QUERY CACHE", + /* 260 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 261 */ "analyze_opt ::=", + /* 262 */ "analyze_opt ::= ANALYZE", + /* 263 */ "explain_options ::=", + /* 264 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 265 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 266 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 267 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 268 */ "agg_func_opt ::=", + /* 269 */ "agg_func_opt ::= AGGREGATE", + /* 270 */ "bufsize_opt ::=", + /* 271 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 272 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression", + /* 273 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 274 */ "stream_options ::=", + /* 275 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 276 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 277 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 278 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 279 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 280 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 281 */ "cmd ::= KILL QUERY NK_STRING", + /* 282 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 283 */ "cmd ::= BALANCE VGROUP", + /* 284 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 285 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 286 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 287 */ "dnode_list ::= DNODE NK_INTEGER", + /* 288 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 289 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 290 */ "cmd ::= query_expression", + /* 291 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression", + /* 292 */ "cmd ::= INSERT INTO full_table_name query_expression", + /* 293 */ "literal ::= NK_INTEGER", + /* 294 */ "literal ::= NK_FLOAT", + /* 295 */ "literal ::= NK_STRING", + /* 296 */ "literal ::= NK_BOOL", + /* 297 */ "literal ::= TIMESTAMP NK_STRING", + /* 298 */ "literal ::= duration_literal", + /* 299 */ "literal ::= NULL", + /* 300 */ "literal ::= NK_QUESTION", + /* 301 */ "duration_literal ::= NK_VARIABLE", + /* 302 */ "signed ::= NK_INTEGER", + /* 303 */ "signed ::= NK_PLUS NK_INTEGER", + /* 304 */ "signed ::= NK_MINUS NK_INTEGER", + /* 305 */ "signed ::= NK_FLOAT", + /* 306 */ "signed ::= NK_PLUS NK_FLOAT", + /* 307 */ "signed ::= NK_MINUS NK_FLOAT", + /* 308 */ "signed_literal ::= signed", + /* 309 */ "signed_literal ::= NK_STRING", + /* 310 */ "signed_literal ::= NK_BOOL", + /* 311 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 312 */ "signed_literal ::= duration_literal", + /* 313 */ "signed_literal ::= NULL", + /* 314 */ "signed_literal ::= literal_func", + /* 315 */ "signed_literal ::= NK_QUESTION", + /* 316 */ "literal_list ::= signed_literal", + /* 317 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 318 */ "db_name ::= NK_ID", + /* 319 */ "table_name ::= NK_ID", + /* 320 */ "column_name ::= NK_ID", + /* 321 */ "function_name ::= NK_ID", + /* 322 */ "table_alias ::= NK_ID", + /* 323 */ "column_alias ::= NK_ID", + /* 324 */ "user_name ::= NK_ID", + /* 325 */ "topic_name ::= NK_ID", + /* 326 */ "stream_name ::= NK_ID", + /* 327 */ "cgroup_name ::= NK_ID", + /* 328 */ "expression ::= literal", + /* 329 */ "expression ::= pseudo_column", + /* 330 */ "expression ::= column_reference", + /* 331 */ "expression ::= function_expression", + /* 332 */ "expression ::= subquery", + /* 333 */ "expression ::= NK_LP expression NK_RP", + /* 334 */ "expression ::= NK_PLUS expression", + /* 335 */ "expression ::= NK_MINUS expression", + /* 336 */ "expression ::= expression NK_PLUS expression", + /* 337 */ "expression ::= expression NK_MINUS expression", + /* 338 */ "expression ::= expression NK_STAR expression", + /* 339 */ "expression ::= expression NK_SLASH expression", + /* 340 */ "expression ::= expression NK_REM expression", + /* 341 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 342 */ "expression ::= expression NK_BITAND expression", + /* 343 */ "expression ::= expression NK_BITOR expression", + /* 344 */ "expression_list ::= expression", + /* 345 */ "expression_list ::= expression_list NK_COMMA expression", + /* 346 */ "column_reference ::= column_name", + /* 347 */ "column_reference ::= table_name NK_DOT column_name", + /* 348 */ "pseudo_column ::= ROWTS", + /* 349 */ "pseudo_column ::= TBNAME", + /* 350 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 351 */ "pseudo_column ::= QSTART", + /* 352 */ "pseudo_column ::= QEND", + /* 353 */ "pseudo_column ::= QDURATION", + /* 354 */ "pseudo_column ::= WSTART", + /* 355 */ "pseudo_column ::= WEND", + /* 356 */ "pseudo_column ::= WDURATION", + /* 357 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 358 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 359 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 360 */ "function_expression ::= literal_func", + /* 361 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 362 */ "literal_func ::= NOW", + /* 363 */ "noarg_func ::= NOW", + /* 364 */ "noarg_func ::= TODAY", + /* 365 */ "noarg_func ::= TIMEZONE", + /* 366 */ "noarg_func ::= DATABASE", + /* 367 */ "noarg_func ::= CLIENT_VERSION", + /* 368 */ "noarg_func ::= SERVER_VERSION", + /* 369 */ "noarg_func ::= SERVER_STATUS", + /* 370 */ "noarg_func ::= CURRENT_USER", + /* 371 */ "noarg_func ::= USER", + /* 372 */ "star_func ::= COUNT", + /* 373 */ "star_func ::= FIRST", + /* 374 */ "star_func ::= LAST", + /* 375 */ "star_func ::= LAST_ROW", + /* 376 */ "star_func_para_list ::= NK_STAR", + /* 377 */ "star_func_para_list ::= other_para_list", + /* 378 */ "other_para_list ::= star_func_para", + /* 379 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 380 */ "star_func_para ::= expression", + /* 381 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 382 */ "predicate ::= expression compare_op expression", + /* 383 */ "predicate ::= expression BETWEEN expression AND expression", + /* 384 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 385 */ "predicate ::= expression IS NULL", + /* 386 */ "predicate ::= expression IS NOT NULL", + /* 387 */ "predicate ::= expression in_op in_predicate_value", + /* 388 */ "compare_op ::= NK_LT", + /* 389 */ "compare_op ::= NK_GT", + /* 390 */ "compare_op ::= NK_LE", + /* 391 */ "compare_op ::= NK_GE", + /* 392 */ "compare_op ::= NK_NE", + /* 393 */ "compare_op ::= NK_EQ", + /* 394 */ "compare_op ::= LIKE", + /* 395 */ "compare_op ::= NOT LIKE", + /* 396 */ "compare_op ::= MATCH", + /* 397 */ "compare_op ::= NMATCH", + /* 398 */ "compare_op ::= CONTAINS", + /* 399 */ "in_op ::= IN", + /* 400 */ "in_op ::= NOT IN", + /* 401 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 402 */ "boolean_value_expression ::= boolean_primary", + /* 403 */ "boolean_value_expression ::= NOT boolean_primary", + /* 404 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 405 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 406 */ "boolean_primary ::= predicate", + /* 407 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 408 */ "common_expression ::= expression", + /* 409 */ "common_expression ::= boolean_value_expression", + /* 410 */ "from_clause_opt ::=", + /* 411 */ "from_clause_opt ::= FROM table_reference_list", + /* 412 */ "table_reference_list ::= table_reference", + /* 413 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 414 */ "table_reference ::= table_primary", + /* 415 */ "table_reference ::= joined_table", + /* 416 */ "table_primary ::= table_name alias_opt", + /* 417 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 418 */ "table_primary ::= subquery alias_opt", + /* 419 */ "table_primary ::= parenthesized_joined_table", + /* 420 */ "alias_opt ::=", + /* 421 */ "alias_opt ::= table_alias", + /* 422 */ "alias_opt ::= AS table_alias", + /* 423 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 424 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 425 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 426 */ "join_type ::=", + /* 427 */ "join_type ::= INNER", + /* 428 */ "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", + /* 429 */ "set_quantifier_opt ::=", + /* 430 */ "set_quantifier_opt ::= DISTINCT", + /* 431 */ "set_quantifier_opt ::= ALL", + /* 432 */ "select_list ::= select_item", + /* 433 */ "select_list ::= select_list NK_COMMA select_item", + /* 434 */ "select_item ::= NK_STAR", + /* 435 */ "select_item ::= common_expression", + /* 436 */ "select_item ::= common_expression column_alias", + /* 437 */ "select_item ::= common_expression AS column_alias", + /* 438 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 439 */ "where_clause_opt ::=", + /* 440 */ "where_clause_opt ::= WHERE search_condition", + /* 441 */ "partition_by_clause_opt ::=", + /* 442 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 443 */ "twindow_clause_opt ::=", + /* 444 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 445 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 446 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 447 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 448 */ "sliding_opt ::=", + /* 449 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 450 */ "fill_opt ::=", + /* 451 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 452 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 453 */ "fill_mode ::= NONE", + /* 454 */ "fill_mode ::= PREV", + /* 455 */ "fill_mode ::= NULL", + /* 456 */ "fill_mode ::= LINEAR", + /* 457 */ "fill_mode ::= NEXT", + /* 458 */ "group_by_clause_opt ::=", + /* 459 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 460 */ "group_by_list ::= expression", + /* 461 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 462 */ "having_clause_opt ::=", + /* 463 */ "having_clause_opt ::= HAVING search_condition", + /* 464 */ "range_opt ::=", + /* 465 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 466 */ "every_opt ::=", + /* 467 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 468 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 469 */ "query_expression_body ::= query_primary", + /* 470 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 471 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 472 */ "query_primary ::= query_specification", + /* 473 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 474 */ "order_by_clause_opt ::=", + /* 475 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 476 */ "slimit_clause_opt ::=", + /* 477 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 478 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 479 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 480 */ "limit_clause_opt ::=", + /* 481 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 482 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 483 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 484 */ "subquery ::= NK_LP query_expression NK_RP", + /* 485 */ "search_condition ::= common_expression", + /* 486 */ "sort_specification_list ::= sort_specification", + /* 487 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 488 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 489 */ "ordering_specification_opt ::=", + /* 490 */ "ordering_specification_opt ::= ASC", + /* 491 */ "ordering_specification_opt ::= DESC", + /* 492 */ "null_ordering_opt ::=", + /* 493 */ "null_ordering_opt ::= NULLS FIRST", + /* 494 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2319,179 +2361,179 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 305: /* cmd */ - case 308: /* literal */ - case 319: /* db_options */ - case 321: /* alter_db_options */ - case 326: /* retention */ - case 327: /* full_table_name */ - case 330: /* table_options */ - case 334: /* alter_table_clause */ - case 335: /* alter_table_options */ - case 338: /* signed_literal */ - case 339: /* create_subtable_clause */ - case 342: /* drop_table_clause */ - case 345: /* column_def */ - case 349: /* duration_literal */ - case 350: /* rollup_func_name */ - case 352: /* col_name */ - case 353: /* db_name_cond_opt */ - case 354: /* like_pattern_opt */ - case 355: /* table_name_cond */ - case 356: /* from_db_opt */ - case 357: /* index_options */ - case 359: /* sliding_opt */ - case 360: /* sma_stream_opt */ - case 361: /* func */ - case 362: /* stream_options */ - case 364: /* query_expression */ - case 367: /* explain_options */ - case 372: /* where_clause_opt */ - case 373: /* signed */ - case 374: /* literal_func */ - case 378: /* expression */ - case 379: /* pseudo_column */ - case 380: /* column_reference */ - case 381: /* function_expression */ - case 382: /* subquery */ - case 387: /* star_func_para */ - case 388: /* predicate */ - case 391: /* in_predicate_value */ - case 392: /* boolean_value_expression */ - case 393: /* boolean_primary */ - case 394: /* common_expression */ - case 395: /* from_clause_opt */ - case 396: /* table_reference_list */ - case 397: /* table_reference */ - case 398: /* table_primary */ - case 399: /* joined_table */ - case 401: /* parenthesized_joined_table */ - case 403: /* search_condition */ - case 404: /* query_specification */ - case 408: /* range_opt */ - case 409: /* every_opt */ - case 410: /* fill_opt */ - case 411: /* twindow_clause_opt */ - case 413: /* having_clause_opt */ - case 414: /* select_item */ - case 417: /* query_expression_body */ - case 419: /* slimit_clause_opt */ - case 420: /* limit_clause_opt */ - case 421: /* query_primary */ - case 423: /* sort_specification */ + case 308: /* cmd */ + case 311: /* literal */ + case 322: /* db_options */ + case 324: /* alter_db_options */ + case 329: /* retention */ + case 330: /* full_table_name */ + case 333: /* table_options */ + case 337: /* alter_table_clause */ + case 338: /* alter_table_options */ + case 341: /* signed_literal */ + case 342: /* create_subtable_clause */ + case 345: /* drop_table_clause */ + case 348: /* column_def */ + case 352: /* duration_literal */ + case 353: /* rollup_func_name */ + case 355: /* col_name */ + case 356: /* db_name_cond_opt */ + case 357: /* like_pattern_opt */ + case 358: /* table_name_cond */ + case 359: /* from_db_opt */ + case 360: /* index_options */ + case 362: /* sliding_opt */ + case 363: /* sma_stream_opt */ + case 364: /* func */ + case 365: /* stream_options */ + case 367: /* query_expression */ + case 370: /* explain_options */ + case 375: /* where_clause_opt */ + case 376: /* signed */ + case 377: /* literal_func */ + case 381: /* expression */ + case 382: /* pseudo_column */ + case 383: /* column_reference */ + case 384: /* function_expression */ + case 385: /* subquery */ + case 390: /* star_func_para */ + case 391: /* predicate */ + case 394: /* in_predicate_value */ + case 395: /* boolean_value_expression */ + case 396: /* boolean_primary */ + case 397: /* common_expression */ + case 398: /* from_clause_opt */ + case 399: /* table_reference_list */ + case 400: /* table_reference */ + case 401: /* table_primary */ + case 402: /* joined_table */ + case 404: /* parenthesized_joined_table */ + case 406: /* search_condition */ + case 407: /* query_specification */ + case 411: /* range_opt */ + case 412: /* every_opt */ + case 413: /* fill_opt */ + case 414: /* twindow_clause_opt */ + case 416: /* having_clause_opt */ + case 417: /* select_item */ + case 420: /* query_expression_body */ + case 422: /* slimit_clause_opt */ + case 423: /* limit_clause_opt */ + case 424: /* query_primary */ + case 426: /* sort_specification */ { - nodesDestroyNode((yypminor->yy272)); + nodesDestroyNode((yypminor->yy80)); } break; - case 306: /* account_options */ - case 307: /* alter_account_options */ - case 309: /* alter_account_option */ - case 369: /* bufsize_opt */ + case 309: /* account_options */ + case 310: /* alter_account_options */ + case 312: /* alter_account_option */ + case 372: /* bufsize_opt */ { } break; - case 310: /* user_name */ - case 313: /* priv_level */ - case 316: /* db_name */ - case 317: /* dnode_endpoint */ - case 336: /* column_name */ - case 344: /* table_name */ - case 351: /* function_name */ - case 363: /* topic_name */ - case 365: /* cgroup_name */ - case 370: /* stream_name */ - case 376: /* table_alias */ - case 377: /* column_alias */ - case 383: /* star_func */ - case 385: /* noarg_func */ - case 400: /* alias_opt */ + case 313: /* user_name */ + case 316: /* priv_level */ + case 319: /* db_name */ + case 320: /* dnode_endpoint */ + case 339: /* column_name */ + case 347: /* table_name */ + case 354: /* function_name */ + case 366: /* topic_name */ + case 368: /* cgroup_name */ + case 373: /* stream_name */ + case 379: /* table_alias */ + case 380: /* column_alias */ + case 386: /* star_func */ + case 388: /* noarg_func */ + case 403: /* alias_opt */ { } break; - case 311: /* sysinfo_opt */ + case 314: /* sysinfo_opt */ { } break; - case 312: /* privileges */ - case 314: /* priv_type_list */ - case 315: /* priv_type */ + case 315: /* privileges */ + case 317: /* priv_type_list */ + case 318: /* priv_type */ { } break; - case 318: /* not_exists_opt */ - case 320: /* exists_opt */ - case 366: /* analyze_opt */ - case 368: /* agg_func_opt */ - case 405: /* set_quantifier_opt */ + case 321: /* not_exists_opt */ + case 323: /* exists_opt */ + case 369: /* analyze_opt */ + case 371: /* agg_func_opt */ + case 408: /* set_quantifier_opt */ { } break; - case 322: /* integer_list */ - case 323: /* variable_list */ - case 324: /* retention_list */ - case 328: /* column_def_list */ - case 329: /* tags_def_opt */ - case 331: /* multi_create_clause */ - case 332: /* tags_def */ - case 333: /* multi_drop_clause */ - case 340: /* specific_cols_opt */ - case 341: /* expression_list */ - case 343: /* col_name_list */ - case 346: /* duration_list */ - case 347: /* rollup_func_list */ - case 358: /* func_list */ - case 371: /* dnode_list */ - case 375: /* literal_list */ - case 384: /* star_func_para_list */ - case 386: /* other_para_list */ - case 406: /* select_list */ - case 407: /* partition_by_clause_opt */ - case 412: /* group_by_clause_opt */ - case 416: /* group_by_list */ - case 418: /* order_by_clause_opt */ - case 422: /* sort_specification_list */ + case 325: /* integer_list */ + case 326: /* variable_list */ + case 327: /* retention_list */ + case 331: /* column_def_list */ + case 332: /* tags_def_opt */ + case 334: /* multi_create_clause */ + case 335: /* tags_def */ + case 336: /* multi_drop_clause */ + case 343: /* specific_cols_opt */ + case 344: /* expression_list */ + case 346: /* col_name_list */ + case 349: /* duration_list */ + case 350: /* rollup_func_list */ + case 361: /* func_list */ + case 374: /* dnode_list */ + case 378: /* literal_list */ + case 387: /* star_func_para_list */ + case 389: /* other_para_list */ + case 409: /* select_list */ + case 410: /* partition_by_clause_opt */ + case 415: /* group_by_clause_opt */ + case 419: /* group_by_list */ + case 421: /* order_by_clause_opt */ + case 425: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy172)); + nodesDestroyList((yypminor->yy574)); } break; - case 325: /* alter_db_option */ - case 348: /* alter_table_option */ + case 328: /* alter_db_option */ + case 351: /* alter_table_option */ { } break; - case 337: /* type_name */ + case 340: /* type_name */ { } break; - case 389: /* compare_op */ - case 390: /* in_op */ + case 392: /* compare_op */ + case 393: /* in_op */ { } break; - case 402: /* join_type */ + case 405: /* join_type */ { } break; - case 415: /* fill_mode */ + case 418: /* fill_mode */ { } break; - case 424: /* ordering_specification_opt */ + case 427: /* ordering_specification_opt */ { } break; - case 425: /* null_ordering_opt */ + case 428: /* null_ordering_opt */ { } @@ -2790,495 +2832,501 @@ 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[] = { - { 305, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 305, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 306, 0 }, /* (2) account_options ::= */ - { 306, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 306, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 306, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 306, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 306, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 306, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 306, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 306, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 306, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 307, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 307, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 309, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 309, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 309, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 309, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 309, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 309, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 309, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 309, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 309, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 309, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 305, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 305, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 305, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 305, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 305, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 311, 0 }, /* (29) sysinfo_opt ::= */ - { 311, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 305, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 305, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 312, -1 }, /* (33) privileges ::= ALL */ - { 312, -1 }, /* (34) privileges ::= priv_type_list */ - { 314, -1 }, /* (35) priv_type_list ::= priv_type */ - { 314, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 315, -1 }, /* (37) priv_type ::= READ */ - { 315, -1 }, /* (38) priv_type ::= WRITE */ - { 313, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 313, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 305, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 305, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 305, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 305, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 305, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 305, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 305, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 305, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 317, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 317, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 317, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 305, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 305, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 305, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 305, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 305, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 305, -2 }, /* (64) cmd ::= USE db_name */ - { 305, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 305, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ - { 305, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ - { 318, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ - { 318, 0 }, /* (69) not_exists_opt ::= */ - { 320, -2 }, /* (70) exists_opt ::= IF EXISTS */ - { 320, 0 }, /* (71) exists_opt ::= */ - { 319, 0 }, /* (72) db_options ::= */ - { 319, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ - { 319, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ - { 319, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 319, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ - { 319, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ - { 319, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ - { 319, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ - { 319, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ - { 319, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ - { 319, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ - { 319, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ - { 319, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 319, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */ - { 319, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */ - { 319, -3 }, /* (87) db_options ::= db_options STRICT NK_STRING */ - { 319, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */ - { 319, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 319, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */ - { 319, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 319, -3 }, /* (92) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 319, -3 }, /* (93) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 319, -3 }, /* (94) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 319, -4 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 319, -3 }, /* (96) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 319, -4 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 319, -3 }, /* (98) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 319, -3 }, /* (99) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 321, -1 }, /* (100) alter_db_options ::= alter_db_option */ - { 321, -2 }, /* (101) alter_db_options ::= alter_db_options alter_db_option */ - { 325, -2 }, /* (102) alter_db_option ::= CACHEMODEL NK_STRING */ - { 325, -2 }, /* (103) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 325, -2 }, /* (104) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 325, -2 }, /* (105) alter_db_option ::= KEEP integer_list */ - { 325, -2 }, /* (106) alter_db_option ::= KEEP variable_list */ - { 325, -2 }, /* (107) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 322, -1 }, /* (108) integer_list ::= NK_INTEGER */ - { 322, -3 }, /* (109) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 323, -1 }, /* (110) variable_list ::= NK_VARIABLE */ - { 323, -3 }, /* (111) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 324, -1 }, /* (112) retention_list ::= retention */ - { 324, -3 }, /* (113) retention_list ::= retention_list NK_COMMA retention */ - { 326, -3 }, /* (114) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 305, -9 }, /* (115) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 305, -3 }, /* (116) cmd ::= CREATE TABLE multi_create_clause */ - { 305, -9 }, /* (117) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 305, -3 }, /* (118) cmd ::= DROP TABLE multi_drop_clause */ - { 305, -4 }, /* (119) cmd ::= DROP STABLE exists_opt full_table_name */ - { 305, -3 }, /* (120) cmd ::= ALTER TABLE alter_table_clause */ - { 305, -3 }, /* (121) cmd ::= ALTER STABLE alter_table_clause */ - { 334, -2 }, /* (122) alter_table_clause ::= full_table_name alter_table_options */ - { 334, -5 }, /* (123) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 334, -4 }, /* (124) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 334, -5 }, /* (125) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 334, -5 }, /* (126) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 334, -5 }, /* (127) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 334, -4 }, /* (128) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 334, -5 }, /* (129) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 334, -5 }, /* (130) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 334, -6 }, /* (131) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 331, -1 }, /* (132) multi_create_clause ::= create_subtable_clause */ - { 331, -2 }, /* (133) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 339, -10 }, /* (134) 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 */ - { 333, -1 }, /* (135) multi_drop_clause ::= drop_table_clause */ - { 333, -2 }, /* (136) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 342, -2 }, /* (137) drop_table_clause ::= exists_opt full_table_name */ - { 340, 0 }, /* (138) specific_cols_opt ::= */ - { 340, -3 }, /* (139) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 327, -1 }, /* (140) full_table_name ::= table_name */ - { 327, -3 }, /* (141) full_table_name ::= db_name NK_DOT table_name */ - { 328, -1 }, /* (142) column_def_list ::= column_def */ - { 328, -3 }, /* (143) column_def_list ::= column_def_list NK_COMMA column_def */ - { 345, -2 }, /* (144) column_def ::= column_name type_name */ - { 345, -4 }, /* (145) column_def ::= column_name type_name COMMENT NK_STRING */ - { 337, -1 }, /* (146) type_name ::= BOOL */ - { 337, -1 }, /* (147) type_name ::= TINYINT */ - { 337, -1 }, /* (148) type_name ::= SMALLINT */ - { 337, -1 }, /* (149) type_name ::= INT */ - { 337, -1 }, /* (150) type_name ::= INTEGER */ - { 337, -1 }, /* (151) type_name ::= BIGINT */ - { 337, -1 }, /* (152) type_name ::= FLOAT */ - { 337, -1 }, /* (153) type_name ::= DOUBLE */ - { 337, -4 }, /* (154) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 337, -1 }, /* (155) type_name ::= TIMESTAMP */ - { 337, -4 }, /* (156) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 337, -2 }, /* (157) type_name ::= TINYINT UNSIGNED */ - { 337, -2 }, /* (158) type_name ::= SMALLINT UNSIGNED */ - { 337, -2 }, /* (159) type_name ::= INT UNSIGNED */ - { 337, -2 }, /* (160) type_name ::= BIGINT UNSIGNED */ - { 337, -1 }, /* (161) type_name ::= JSON */ - { 337, -4 }, /* (162) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 337, -1 }, /* (163) type_name ::= MEDIUMBLOB */ - { 337, -1 }, /* (164) type_name ::= BLOB */ - { 337, -4 }, /* (165) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 337, -1 }, /* (166) type_name ::= DECIMAL */ - { 337, -4 }, /* (167) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 337, -6 }, /* (168) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 329, 0 }, /* (169) tags_def_opt ::= */ - { 329, -1 }, /* (170) tags_def_opt ::= tags_def */ - { 332, -4 }, /* (171) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 330, 0 }, /* (172) table_options ::= */ - { 330, -3 }, /* (173) table_options ::= table_options COMMENT NK_STRING */ - { 330, -3 }, /* (174) table_options ::= table_options MAX_DELAY duration_list */ - { 330, -3 }, /* (175) table_options ::= table_options WATERMARK duration_list */ - { 330, -5 }, /* (176) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 330, -3 }, /* (177) table_options ::= table_options TTL NK_INTEGER */ - { 330, -5 }, /* (178) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 335, -1 }, /* (179) alter_table_options ::= alter_table_option */ - { 335, -2 }, /* (180) alter_table_options ::= alter_table_options alter_table_option */ - { 348, -2 }, /* (181) alter_table_option ::= COMMENT NK_STRING */ - { 348, -2 }, /* (182) alter_table_option ::= TTL NK_INTEGER */ - { 346, -1 }, /* (183) duration_list ::= duration_literal */ - { 346, -3 }, /* (184) duration_list ::= duration_list NK_COMMA duration_literal */ - { 347, -1 }, /* (185) rollup_func_list ::= rollup_func_name */ - { 347, -3 }, /* (186) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 350, -1 }, /* (187) rollup_func_name ::= function_name */ - { 350, -1 }, /* (188) rollup_func_name ::= FIRST */ - { 350, -1 }, /* (189) rollup_func_name ::= LAST */ - { 343, -1 }, /* (190) col_name_list ::= col_name */ - { 343, -3 }, /* (191) col_name_list ::= col_name_list NK_COMMA col_name */ - { 352, -1 }, /* (192) col_name ::= column_name */ - { 305, -2 }, /* (193) cmd ::= SHOW DNODES */ - { 305, -2 }, /* (194) cmd ::= SHOW USERS */ - { 305, -2 }, /* (195) cmd ::= SHOW DATABASES */ - { 305, -4 }, /* (196) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 305, -4 }, /* (197) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 305, -3 }, /* (198) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 305, -2 }, /* (199) cmd ::= SHOW MNODES */ - { 305, -2 }, /* (200) cmd ::= SHOW MODULES */ - { 305, -2 }, /* (201) cmd ::= SHOW QNODES */ - { 305, -2 }, /* (202) cmd ::= SHOW FUNCTIONS */ - { 305, -5 }, /* (203) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 305, -2 }, /* (204) cmd ::= SHOW STREAMS */ - { 305, -2 }, /* (205) cmd ::= SHOW ACCOUNTS */ - { 305, -2 }, /* (206) cmd ::= SHOW APPS */ - { 305, -2 }, /* (207) cmd ::= SHOW CONNECTIONS */ - { 305, -2 }, /* (208) cmd ::= SHOW LICENCES */ - { 305, -2 }, /* (209) cmd ::= SHOW GRANTS */ - { 305, -4 }, /* (210) cmd ::= SHOW CREATE DATABASE db_name */ - { 305, -4 }, /* (211) cmd ::= SHOW CREATE TABLE full_table_name */ - { 305, -4 }, /* (212) cmd ::= SHOW CREATE STABLE full_table_name */ - { 305, -2 }, /* (213) cmd ::= SHOW QUERIES */ - { 305, -2 }, /* (214) cmd ::= SHOW SCORES */ - { 305, -2 }, /* (215) cmd ::= SHOW TOPICS */ - { 305, -2 }, /* (216) cmd ::= SHOW VARIABLES */ - { 305, -3 }, /* (217) cmd ::= SHOW LOCAL VARIABLES */ - { 305, -4 }, /* (218) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 305, -2 }, /* (219) cmd ::= SHOW BNODES */ - { 305, -2 }, /* (220) cmd ::= SHOW SNODES */ - { 305, -2 }, /* (221) cmd ::= SHOW CLUSTER */ - { 305, -2 }, /* (222) cmd ::= SHOW TRANSACTIONS */ - { 305, -4 }, /* (223) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 305, -2 }, /* (224) cmd ::= SHOW CONSUMERS */ - { 305, -2 }, /* (225) cmd ::= SHOW SUBSCRIPTIONS */ - { 305, -5 }, /* (226) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 353, 0 }, /* (227) db_name_cond_opt ::= */ - { 353, -2 }, /* (228) db_name_cond_opt ::= db_name NK_DOT */ - { 354, 0 }, /* (229) like_pattern_opt ::= */ - { 354, -2 }, /* (230) like_pattern_opt ::= LIKE NK_STRING */ - { 355, -1 }, /* (231) table_name_cond ::= table_name */ - { 356, 0 }, /* (232) from_db_opt ::= */ - { 356, -2 }, /* (233) from_db_opt ::= FROM db_name */ - { 305, -8 }, /* (234) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 305, -4 }, /* (235) cmd ::= DROP INDEX exists_opt full_table_name */ - { 357, -10 }, /* (236) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 357, -12 }, /* (237) 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 */ - { 358, -1 }, /* (238) func_list ::= func */ - { 358, -3 }, /* (239) func_list ::= func_list NK_COMMA func */ - { 361, -4 }, /* (240) func ::= function_name NK_LP expression_list NK_RP */ - { 360, 0 }, /* (241) sma_stream_opt ::= */ - { 360, -3 }, /* (242) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 360, -3 }, /* (243) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 305, -6 }, /* (244) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 305, -7 }, /* (245) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 305, -9 }, /* (246) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 305, -7 }, /* (247) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 305, -9 }, /* (248) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 305, -4 }, /* (249) cmd ::= DROP TOPIC exists_opt topic_name */ - { 305, -7 }, /* (250) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 305, -2 }, /* (251) cmd ::= DESC full_table_name */ - { 305, -2 }, /* (252) cmd ::= DESCRIBE full_table_name */ - { 305, -3 }, /* (253) cmd ::= RESET QUERY CACHE */ - { 305, -4 }, /* (254) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 366, 0 }, /* (255) analyze_opt ::= */ - { 366, -1 }, /* (256) analyze_opt ::= ANALYZE */ - { 367, 0 }, /* (257) explain_options ::= */ - { 367, -3 }, /* (258) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 367, -3 }, /* (259) explain_options ::= explain_options RATIO NK_FLOAT */ - { 305, -10 }, /* (260) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 305, -4 }, /* (261) cmd ::= DROP FUNCTION exists_opt function_name */ - { 368, 0 }, /* (262) agg_func_opt ::= */ - { 368, -1 }, /* (263) agg_func_opt ::= AGGREGATE */ - { 369, 0 }, /* (264) bufsize_opt ::= */ - { 369, -2 }, /* (265) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 305, -9 }, /* (266) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ - { 305, -4 }, /* (267) cmd ::= DROP STREAM exists_opt stream_name */ - { 362, 0 }, /* (268) stream_options ::= */ - { 362, -3 }, /* (269) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 362, -3 }, /* (270) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 362, -4 }, /* (271) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 362, -3 }, /* (272) stream_options ::= stream_options WATERMARK duration_literal */ - { 362, -4 }, /* (273) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 305, -3 }, /* (274) cmd ::= KILL CONNECTION NK_INTEGER */ - { 305, -3 }, /* (275) cmd ::= KILL QUERY NK_STRING */ - { 305, -3 }, /* (276) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 305, -2 }, /* (277) cmd ::= BALANCE VGROUP */ - { 305, -4 }, /* (278) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 305, -4 }, /* (279) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 305, -3 }, /* (280) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 371, -2 }, /* (281) dnode_list ::= DNODE NK_INTEGER */ - { 371, -3 }, /* (282) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 305, -4 }, /* (283) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 305, -1 }, /* (284) cmd ::= query_expression */ - { 305, -7 }, /* (285) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ - { 305, -4 }, /* (286) cmd ::= INSERT INTO full_table_name query_expression */ - { 308, -1 }, /* (287) literal ::= NK_INTEGER */ - { 308, -1 }, /* (288) literal ::= NK_FLOAT */ - { 308, -1 }, /* (289) literal ::= NK_STRING */ - { 308, -1 }, /* (290) literal ::= NK_BOOL */ - { 308, -2 }, /* (291) literal ::= TIMESTAMP NK_STRING */ - { 308, -1 }, /* (292) literal ::= duration_literal */ - { 308, -1 }, /* (293) literal ::= NULL */ - { 308, -1 }, /* (294) literal ::= NK_QUESTION */ - { 349, -1 }, /* (295) duration_literal ::= NK_VARIABLE */ - { 373, -1 }, /* (296) signed ::= NK_INTEGER */ - { 373, -2 }, /* (297) signed ::= NK_PLUS NK_INTEGER */ - { 373, -2 }, /* (298) signed ::= NK_MINUS NK_INTEGER */ - { 373, -1 }, /* (299) signed ::= NK_FLOAT */ - { 373, -2 }, /* (300) signed ::= NK_PLUS NK_FLOAT */ - { 373, -2 }, /* (301) signed ::= NK_MINUS NK_FLOAT */ - { 338, -1 }, /* (302) signed_literal ::= signed */ - { 338, -1 }, /* (303) signed_literal ::= NK_STRING */ - { 338, -1 }, /* (304) signed_literal ::= NK_BOOL */ - { 338, -2 }, /* (305) signed_literal ::= TIMESTAMP NK_STRING */ - { 338, -1 }, /* (306) signed_literal ::= duration_literal */ - { 338, -1 }, /* (307) signed_literal ::= NULL */ - { 338, -1 }, /* (308) signed_literal ::= literal_func */ - { 338, -1 }, /* (309) signed_literal ::= NK_QUESTION */ - { 375, -1 }, /* (310) literal_list ::= signed_literal */ - { 375, -3 }, /* (311) literal_list ::= literal_list NK_COMMA signed_literal */ - { 316, -1 }, /* (312) db_name ::= NK_ID */ - { 344, -1 }, /* (313) table_name ::= NK_ID */ - { 336, -1 }, /* (314) column_name ::= NK_ID */ - { 351, -1 }, /* (315) function_name ::= NK_ID */ - { 376, -1 }, /* (316) table_alias ::= NK_ID */ - { 377, -1 }, /* (317) column_alias ::= NK_ID */ - { 310, -1 }, /* (318) user_name ::= NK_ID */ - { 363, -1 }, /* (319) topic_name ::= NK_ID */ - { 370, -1 }, /* (320) stream_name ::= NK_ID */ - { 365, -1 }, /* (321) cgroup_name ::= NK_ID */ - { 378, -1 }, /* (322) expression ::= literal */ - { 378, -1 }, /* (323) expression ::= pseudo_column */ - { 378, -1 }, /* (324) expression ::= column_reference */ - { 378, -1 }, /* (325) expression ::= function_expression */ - { 378, -1 }, /* (326) expression ::= subquery */ - { 378, -3 }, /* (327) expression ::= NK_LP expression NK_RP */ - { 378, -2 }, /* (328) expression ::= NK_PLUS expression */ - { 378, -2 }, /* (329) expression ::= NK_MINUS expression */ - { 378, -3 }, /* (330) expression ::= expression NK_PLUS expression */ - { 378, -3 }, /* (331) expression ::= expression NK_MINUS expression */ - { 378, -3 }, /* (332) expression ::= expression NK_STAR expression */ - { 378, -3 }, /* (333) expression ::= expression NK_SLASH expression */ - { 378, -3 }, /* (334) expression ::= expression NK_REM expression */ - { 378, -3 }, /* (335) expression ::= column_reference NK_ARROW NK_STRING */ - { 378, -3 }, /* (336) expression ::= expression NK_BITAND expression */ - { 378, -3 }, /* (337) expression ::= expression NK_BITOR expression */ - { 341, -1 }, /* (338) expression_list ::= expression */ - { 341, -3 }, /* (339) expression_list ::= expression_list NK_COMMA expression */ - { 380, -1 }, /* (340) column_reference ::= column_name */ - { 380, -3 }, /* (341) column_reference ::= table_name NK_DOT column_name */ - { 379, -1 }, /* (342) pseudo_column ::= ROWTS */ - { 379, -1 }, /* (343) pseudo_column ::= TBNAME */ - { 379, -3 }, /* (344) pseudo_column ::= table_name NK_DOT TBNAME */ - { 379, -1 }, /* (345) pseudo_column ::= QSTART */ - { 379, -1 }, /* (346) pseudo_column ::= QEND */ - { 379, -1 }, /* (347) pseudo_column ::= QDURATION */ - { 379, -1 }, /* (348) pseudo_column ::= WSTART */ - { 379, -1 }, /* (349) pseudo_column ::= WEND */ - { 379, -1 }, /* (350) pseudo_column ::= WDURATION */ - { 381, -4 }, /* (351) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 381, -4 }, /* (352) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 381, -6 }, /* (353) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 381, -1 }, /* (354) function_expression ::= literal_func */ - { 374, -3 }, /* (355) literal_func ::= noarg_func NK_LP NK_RP */ - { 374, -1 }, /* (356) literal_func ::= NOW */ - { 385, -1 }, /* (357) noarg_func ::= NOW */ - { 385, -1 }, /* (358) noarg_func ::= TODAY */ - { 385, -1 }, /* (359) noarg_func ::= TIMEZONE */ - { 385, -1 }, /* (360) noarg_func ::= DATABASE */ - { 385, -1 }, /* (361) noarg_func ::= CLIENT_VERSION */ - { 385, -1 }, /* (362) noarg_func ::= SERVER_VERSION */ - { 385, -1 }, /* (363) noarg_func ::= SERVER_STATUS */ - { 385, -1 }, /* (364) noarg_func ::= CURRENT_USER */ - { 385, -1 }, /* (365) noarg_func ::= USER */ - { 383, -1 }, /* (366) star_func ::= COUNT */ - { 383, -1 }, /* (367) star_func ::= FIRST */ - { 383, -1 }, /* (368) star_func ::= LAST */ - { 383, -1 }, /* (369) star_func ::= LAST_ROW */ - { 384, -1 }, /* (370) star_func_para_list ::= NK_STAR */ - { 384, -1 }, /* (371) star_func_para_list ::= other_para_list */ - { 386, -1 }, /* (372) other_para_list ::= star_func_para */ - { 386, -3 }, /* (373) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 387, -1 }, /* (374) star_func_para ::= expression */ - { 387, -3 }, /* (375) star_func_para ::= table_name NK_DOT NK_STAR */ - { 388, -3 }, /* (376) predicate ::= expression compare_op expression */ - { 388, -5 }, /* (377) predicate ::= expression BETWEEN expression AND expression */ - { 388, -6 }, /* (378) predicate ::= expression NOT BETWEEN expression AND expression */ - { 388, -3 }, /* (379) predicate ::= expression IS NULL */ - { 388, -4 }, /* (380) predicate ::= expression IS NOT NULL */ - { 388, -3 }, /* (381) predicate ::= expression in_op in_predicate_value */ - { 389, -1 }, /* (382) compare_op ::= NK_LT */ - { 389, -1 }, /* (383) compare_op ::= NK_GT */ - { 389, -1 }, /* (384) compare_op ::= NK_LE */ - { 389, -1 }, /* (385) compare_op ::= NK_GE */ - { 389, -1 }, /* (386) compare_op ::= NK_NE */ - { 389, -1 }, /* (387) compare_op ::= NK_EQ */ - { 389, -1 }, /* (388) compare_op ::= LIKE */ - { 389, -2 }, /* (389) compare_op ::= NOT LIKE */ - { 389, -1 }, /* (390) compare_op ::= MATCH */ - { 389, -1 }, /* (391) compare_op ::= NMATCH */ - { 389, -1 }, /* (392) compare_op ::= CONTAINS */ - { 390, -1 }, /* (393) in_op ::= IN */ - { 390, -2 }, /* (394) in_op ::= NOT IN */ - { 391, -3 }, /* (395) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 392, -1 }, /* (396) boolean_value_expression ::= boolean_primary */ - { 392, -2 }, /* (397) boolean_value_expression ::= NOT boolean_primary */ - { 392, -3 }, /* (398) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 392, -3 }, /* (399) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 393, -1 }, /* (400) boolean_primary ::= predicate */ - { 393, -3 }, /* (401) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 394, -1 }, /* (402) common_expression ::= expression */ - { 394, -1 }, /* (403) common_expression ::= boolean_value_expression */ - { 395, 0 }, /* (404) from_clause_opt ::= */ - { 395, -2 }, /* (405) from_clause_opt ::= FROM table_reference_list */ - { 396, -1 }, /* (406) table_reference_list ::= table_reference */ - { 396, -3 }, /* (407) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 397, -1 }, /* (408) table_reference ::= table_primary */ - { 397, -1 }, /* (409) table_reference ::= joined_table */ - { 398, -2 }, /* (410) table_primary ::= table_name alias_opt */ - { 398, -4 }, /* (411) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 398, -2 }, /* (412) table_primary ::= subquery alias_opt */ - { 398, -1 }, /* (413) table_primary ::= parenthesized_joined_table */ - { 400, 0 }, /* (414) alias_opt ::= */ - { 400, -1 }, /* (415) alias_opt ::= table_alias */ - { 400, -2 }, /* (416) alias_opt ::= AS table_alias */ - { 401, -3 }, /* (417) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 401, -3 }, /* (418) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 399, -6 }, /* (419) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 402, 0 }, /* (420) join_type ::= */ - { 402, -1 }, /* (421) join_type ::= INNER */ - { 404, -12 }, /* (422) 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 */ - { 405, 0 }, /* (423) set_quantifier_opt ::= */ - { 405, -1 }, /* (424) set_quantifier_opt ::= DISTINCT */ - { 405, -1 }, /* (425) set_quantifier_opt ::= ALL */ - { 406, -1 }, /* (426) select_list ::= select_item */ - { 406, -3 }, /* (427) select_list ::= select_list NK_COMMA select_item */ - { 414, -1 }, /* (428) select_item ::= NK_STAR */ - { 414, -1 }, /* (429) select_item ::= common_expression */ - { 414, -2 }, /* (430) select_item ::= common_expression column_alias */ - { 414, -3 }, /* (431) select_item ::= common_expression AS column_alias */ - { 414, -3 }, /* (432) select_item ::= table_name NK_DOT NK_STAR */ - { 372, 0 }, /* (433) where_clause_opt ::= */ - { 372, -2 }, /* (434) where_clause_opt ::= WHERE search_condition */ - { 407, 0 }, /* (435) partition_by_clause_opt ::= */ - { 407, -3 }, /* (436) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 411, 0 }, /* (437) twindow_clause_opt ::= */ - { 411, -6 }, /* (438) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 411, -4 }, /* (439) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 411, -6 }, /* (440) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 411, -8 }, /* (441) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 359, 0 }, /* (442) sliding_opt ::= */ - { 359, -4 }, /* (443) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 410, 0 }, /* (444) fill_opt ::= */ - { 410, -4 }, /* (445) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 410, -6 }, /* (446) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 415, -1 }, /* (447) fill_mode ::= NONE */ - { 415, -1 }, /* (448) fill_mode ::= PREV */ - { 415, -1 }, /* (449) fill_mode ::= NULL */ - { 415, -1 }, /* (450) fill_mode ::= LINEAR */ - { 415, -1 }, /* (451) fill_mode ::= NEXT */ - { 412, 0 }, /* (452) group_by_clause_opt ::= */ - { 412, -3 }, /* (453) group_by_clause_opt ::= GROUP BY group_by_list */ - { 416, -1 }, /* (454) group_by_list ::= expression */ - { 416, -3 }, /* (455) group_by_list ::= group_by_list NK_COMMA expression */ - { 413, 0 }, /* (456) having_clause_opt ::= */ - { 413, -2 }, /* (457) having_clause_opt ::= HAVING search_condition */ - { 408, 0 }, /* (458) range_opt ::= */ - { 408, -6 }, /* (459) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 409, 0 }, /* (460) every_opt ::= */ - { 409, -4 }, /* (461) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 364, -4 }, /* (462) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 417, -1 }, /* (463) query_expression_body ::= query_primary */ - { 417, -4 }, /* (464) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 417, -3 }, /* (465) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 421, -1 }, /* (466) query_primary ::= query_specification */ - { 421, -6 }, /* (467) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 418, 0 }, /* (468) order_by_clause_opt ::= */ - { 418, -3 }, /* (469) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 419, 0 }, /* (470) slimit_clause_opt ::= */ - { 419, -2 }, /* (471) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 419, -4 }, /* (472) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 419, -4 }, /* (473) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 420, 0 }, /* (474) limit_clause_opt ::= */ - { 420, -2 }, /* (475) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 420, -4 }, /* (476) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 420, -4 }, /* (477) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 382, -3 }, /* (478) subquery ::= NK_LP query_expression NK_RP */ - { 403, -1 }, /* (479) search_condition ::= common_expression */ - { 422, -1 }, /* (480) sort_specification_list ::= sort_specification */ - { 422, -3 }, /* (481) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 423, -3 }, /* (482) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 424, 0 }, /* (483) ordering_specification_opt ::= */ - { 424, -1 }, /* (484) ordering_specification_opt ::= ASC */ - { 424, -1 }, /* (485) ordering_specification_opt ::= DESC */ - { 425, 0 }, /* (486) null_ordering_opt ::= */ - { 425, -2 }, /* (487) null_ordering_opt ::= NULLS FIRST */ - { 425, -2 }, /* (488) null_ordering_opt ::= NULLS LAST */ + { 308, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 308, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 309, 0 }, /* (2) account_options ::= */ + { 309, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 309, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 309, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 309, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 309, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 309, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 309, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 309, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 309, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 310, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 310, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 312, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 312, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 312, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 312, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 312, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 312, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 312, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 312, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 312, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 312, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 308, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 308, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 308, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 308, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 308, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 314, 0 }, /* (29) sysinfo_opt ::= */ + { 314, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 308, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 308, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 315, -1 }, /* (33) privileges ::= ALL */ + { 315, -1 }, /* (34) privileges ::= priv_type_list */ + { 317, -1 }, /* (35) priv_type_list ::= priv_type */ + { 317, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 318, -1 }, /* (37) priv_type ::= READ */ + { 318, -1 }, /* (38) priv_type ::= WRITE */ + { 316, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 316, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 308, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 308, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 308, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 308, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 308, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 308, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 308, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 308, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 320, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 320, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 320, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 308, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 308, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 308, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 308, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 308, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 308, -2 }, /* (64) cmd ::= USE db_name */ + { 308, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 308, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */ + { 308, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */ + { 321, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */ + { 321, 0 }, /* (69) not_exists_opt ::= */ + { 323, -2 }, /* (70) exists_opt ::= IF EXISTS */ + { 323, 0 }, /* (71) exists_opt ::= */ + { 322, 0 }, /* (72) db_options ::= */ + { 322, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */ + { 322, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */ + { 322, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 322, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */ + { 322, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */ + { 322, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */ + { 322, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */ + { 322, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */ + { 322, -3 }, /* (81) db_options ::= db_options KEEP integer_list */ + { 322, -3 }, /* (82) db_options ::= db_options KEEP variable_list */ + { 322, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */ + { 322, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 322, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */ + { 322, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */ + { 322, -3 }, /* (87) db_options ::= db_options STRICT NK_STRING */ + { 322, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */ + { 322, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 322, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */ + { 322, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 322, -3 }, /* (92) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 322, -3 }, /* (93) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 322, -3 }, /* (94) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 322, -4 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 322, -3 }, /* (96) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 322, -4 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 322, -3 }, /* (98) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 322, -3 }, /* (99) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 322, -3 }, /* (100) db_options ::= db_options SST_TRIGGER NK_INTEGER */ + { 322, -3 }, /* (101) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 322, -3 }, /* (102) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 324, -1 }, /* (103) alter_db_options ::= alter_db_option */ + { 324, -2 }, /* (104) alter_db_options ::= alter_db_options alter_db_option */ + { 328, -2 }, /* (105) alter_db_option ::= CACHEMODEL NK_STRING */ + { 328, -2 }, /* (106) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 328, -2 }, /* (107) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 328, -2 }, /* (108) alter_db_option ::= KEEP integer_list */ + { 328, -2 }, /* (109) alter_db_option ::= KEEP variable_list */ + { 328, -2 }, /* (110) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 328, -2 }, /* (111) alter_db_option ::= SST_TRIGGER NK_INTEGER */ + { 325, -1 }, /* (112) integer_list ::= NK_INTEGER */ + { 325, -3 }, /* (113) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 326, -1 }, /* (114) variable_list ::= NK_VARIABLE */ + { 326, -3 }, /* (115) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 327, -1 }, /* (116) retention_list ::= retention */ + { 327, -3 }, /* (117) retention_list ::= retention_list NK_COMMA retention */ + { 329, -3 }, /* (118) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 308, -9 }, /* (119) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 308, -3 }, /* (120) cmd ::= CREATE TABLE multi_create_clause */ + { 308, -9 }, /* (121) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 308, -3 }, /* (122) cmd ::= DROP TABLE multi_drop_clause */ + { 308, -4 }, /* (123) cmd ::= DROP STABLE exists_opt full_table_name */ + { 308, -3 }, /* (124) cmd ::= ALTER TABLE alter_table_clause */ + { 308, -3 }, /* (125) cmd ::= ALTER STABLE alter_table_clause */ + { 337, -2 }, /* (126) alter_table_clause ::= full_table_name alter_table_options */ + { 337, -5 }, /* (127) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 337, -4 }, /* (128) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 337, -5 }, /* (129) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 337, -5 }, /* (130) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 337, -5 }, /* (131) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 337, -4 }, /* (132) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 337, -5 }, /* (133) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 337, -5 }, /* (134) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 337, -6 }, /* (135) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 334, -1 }, /* (136) multi_create_clause ::= create_subtable_clause */ + { 334, -2 }, /* (137) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 342, -10 }, /* (138) 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 */ + { 336, -1 }, /* (139) multi_drop_clause ::= drop_table_clause */ + { 336, -2 }, /* (140) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 345, -2 }, /* (141) drop_table_clause ::= exists_opt full_table_name */ + { 343, 0 }, /* (142) specific_cols_opt ::= */ + { 343, -3 }, /* (143) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 330, -1 }, /* (144) full_table_name ::= table_name */ + { 330, -3 }, /* (145) full_table_name ::= db_name NK_DOT table_name */ + { 331, -1 }, /* (146) column_def_list ::= column_def */ + { 331, -3 }, /* (147) column_def_list ::= column_def_list NK_COMMA column_def */ + { 348, -2 }, /* (148) column_def ::= column_name type_name */ + { 348, -4 }, /* (149) column_def ::= column_name type_name COMMENT NK_STRING */ + { 340, -1 }, /* (150) type_name ::= BOOL */ + { 340, -1 }, /* (151) type_name ::= TINYINT */ + { 340, -1 }, /* (152) type_name ::= SMALLINT */ + { 340, -1 }, /* (153) type_name ::= INT */ + { 340, -1 }, /* (154) type_name ::= INTEGER */ + { 340, -1 }, /* (155) type_name ::= BIGINT */ + { 340, -1 }, /* (156) type_name ::= FLOAT */ + { 340, -1 }, /* (157) type_name ::= DOUBLE */ + { 340, -4 }, /* (158) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 340, -1 }, /* (159) type_name ::= TIMESTAMP */ + { 340, -4 }, /* (160) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 340, -2 }, /* (161) type_name ::= TINYINT UNSIGNED */ + { 340, -2 }, /* (162) type_name ::= SMALLINT UNSIGNED */ + { 340, -2 }, /* (163) type_name ::= INT UNSIGNED */ + { 340, -2 }, /* (164) type_name ::= BIGINT UNSIGNED */ + { 340, -1 }, /* (165) type_name ::= JSON */ + { 340, -4 }, /* (166) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 340, -1 }, /* (167) type_name ::= MEDIUMBLOB */ + { 340, -1 }, /* (168) type_name ::= BLOB */ + { 340, -4 }, /* (169) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 340, -1 }, /* (170) type_name ::= DECIMAL */ + { 340, -4 }, /* (171) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 340, -6 }, /* (172) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 332, 0 }, /* (173) tags_def_opt ::= */ + { 332, -1 }, /* (174) tags_def_opt ::= tags_def */ + { 335, -4 }, /* (175) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 333, 0 }, /* (176) table_options ::= */ + { 333, -3 }, /* (177) table_options ::= table_options COMMENT NK_STRING */ + { 333, -3 }, /* (178) table_options ::= table_options MAX_DELAY duration_list */ + { 333, -3 }, /* (179) table_options ::= table_options WATERMARK duration_list */ + { 333, -5 }, /* (180) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 333, -3 }, /* (181) table_options ::= table_options TTL NK_INTEGER */ + { 333, -5 }, /* (182) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 338, -1 }, /* (183) alter_table_options ::= alter_table_option */ + { 338, -2 }, /* (184) alter_table_options ::= alter_table_options alter_table_option */ + { 351, -2 }, /* (185) alter_table_option ::= COMMENT NK_STRING */ + { 351, -2 }, /* (186) alter_table_option ::= TTL NK_INTEGER */ + { 349, -1 }, /* (187) duration_list ::= duration_literal */ + { 349, -3 }, /* (188) duration_list ::= duration_list NK_COMMA duration_literal */ + { 350, -1 }, /* (189) rollup_func_list ::= rollup_func_name */ + { 350, -3 }, /* (190) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 353, -1 }, /* (191) rollup_func_name ::= function_name */ + { 353, -1 }, /* (192) rollup_func_name ::= FIRST */ + { 353, -1 }, /* (193) rollup_func_name ::= LAST */ + { 346, -1 }, /* (194) col_name_list ::= col_name */ + { 346, -3 }, /* (195) col_name_list ::= col_name_list NK_COMMA col_name */ + { 355, -1 }, /* (196) col_name ::= column_name */ + { 308, -2 }, /* (197) cmd ::= SHOW DNODES */ + { 308, -2 }, /* (198) cmd ::= SHOW USERS */ + { 308, -2 }, /* (199) cmd ::= SHOW DATABASES */ + { 308, -4 }, /* (200) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 308, -4 }, /* (201) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 308, -3 }, /* (202) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 308, -2 }, /* (203) cmd ::= SHOW MNODES */ + { 308, -2 }, /* (204) cmd ::= SHOW MODULES */ + { 308, -2 }, /* (205) cmd ::= SHOW QNODES */ + { 308, -2 }, /* (206) cmd ::= SHOW FUNCTIONS */ + { 308, -5 }, /* (207) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 308, -2 }, /* (208) cmd ::= SHOW STREAMS */ + { 308, -2 }, /* (209) cmd ::= SHOW ACCOUNTS */ + { 308, -2 }, /* (210) cmd ::= SHOW APPS */ + { 308, -2 }, /* (211) cmd ::= SHOW CONNECTIONS */ + { 308, -2 }, /* (212) cmd ::= SHOW LICENCES */ + { 308, -2 }, /* (213) cmd ::= SHOW GRANTS */ + { 308, -4 }, /* (214) cmd ::= SHOW CREATE DATABASE db_name */ + { 308, -4 }, /* (215) cmd ::= SHOW CREATE TABLE full_table_name */ + { 308, -4 }, /* (216) cmd ::= SHOW CREATE STABLE full_table_name */ + { 308, -2 }, /* (217) cmd ::= SHOW QUERIES */ + { 308, -2 }, /* (218) cmd ::= SHOW SCORES */ + { 308, -2 }, /* (219) cmd ::= SHOW TOPICS */ + { 308, -2 }, /* (220) cmd ::= SHOW VARIABLES */ + { 308, -3 }, /* (221) cmd ::= SHOW LOCAL VARIABLES */ + { 308, -4 }, /* (222) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 308, -2 }, /* (223) cmd ::= SHOW BNODES */ + { 308, -2 }, /* (224) cmd ::= SHOW SNODES */ + { 308, -2 }, /* (225) cmd ::= SHOW CLUSTER */ + { 308, -2 }, /* (226) cmd ::= SHOW TRANSACTIONS */ + { 308, -4 }, /* (227) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 308, -2 }, /* (228) cmd ::= SHOW CONSUMERS */ + { 308, -2 }, /* (229) cmd ::= SHOW SUBSCRIPTIONS */ + { 308, -5 }, /* (230) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 308, -3 }, /* (231) cmd ::= SHOW VNODES NK_INTEGER */ + { 308, -3 }, /* (232) cmd ::= SHOW VNODES NK_STRING */ + { 356, 0 }, /* (233) db_name_cond_opt ::= */ + { 356, -2 }, /* (234) db_name_cond_opt ::= db_name NK_DOT */ + { 357, 0 }, /* (235) like_pattern_opt ::= */ + { 357, -2 }, /* (236) like_pattern_opt ::= LIKE NK_STRING */ + { 358, -1 }, /* (237) table_name_cond ::= table_name */ + { 359, 0 }, /* (238) from_db_opt ::= */ + { 359, -2 }, /* (239) from_db_opt ::= FROM db_name */ + { 308, -8 }, /* (240) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 308, -4 }, /* (241) cmd ::= DROP INDEX exists_opt full_table_name */ + { 360, -10 }, /* (242) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 360, -12 }, /* (243) 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 */ + { 361, -1 }, /* (244) func_list ::= func */ + { 361, -3 }, /* (245) func_list ::= func_list NK_COMMA func */ + { 364, -4 }, /* (246) func ::= function_name NK_LP expression_list NK_RP */ + { 363, 0 }, /* (247) sma_stream_opt ::= */ + { 363, -3 }, /* (248) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 363, -3 }, /* (249) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 308, -6 }, /* (250) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 308, -7 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 308, -9 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 308, -7 }, /* (253) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 308, -9 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 308, -4 }, /* (255) cmd ::= DROP TOPIC exists_opt topic_name */ + { 308, -7 }, /* (256) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 308, -2 }, /* (257) cmd ::= DESC full_table_name */ + { 308, -2 }, /* (258) cmd ::= DESCRIBE full_table_name */ + { 308, -3 }, /* (259) cmd ::= RESET QUERY CACHE */ + { 308, -4 }, /* (260) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 369, 0 }, /* (261) analyze_opt ::= */ + { 369, -1 }, /* (262) analyze_opt ::= ANALYZE */ + { 370, 0 }, /* (263) explain_options ::= */ + { 370, -3 }, /* (264) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 370, -3 }, /* (265) explain_options ::= explain_options RATIO NK_FLOAT */ + { 308, -10 }, /* (266) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 308, -4 }, /* (267) cmd ::= DROP FUNCTION exists_opt function_name */ + { 371, 0 }, /* (268) agg_func_opt ::= */ + { 371, -1 }, /* (269) agg_func_opt ::= AGGREGATE */ + { 372, 0 }, /* (270) bufsize_opt ::= */ + { 372, -2 }, /* (271) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 308, -9 }, /* (272) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ + { 308, -4 }, /* (273) cmd ::= DROP STREAM exists_opt stream_name */ + { 365, 0 }, /* (274) stream_options ::= */ + { 365, -3 }, /* (275) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 365, -3 }, /* (276) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 365, -4 }, /* (277) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 365, -3 }, /* (278) stream_options ::= stream_options WATERMARK duration_literal */ + { 365, -4 }, /* (279) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 308, -3 }, /* (280) cmd ::= KILL CONNECTION NK_INTEGER */ + { 308, -3 }, /* (281) cmd ::= KILL QUERY NK_STRING */ + { 308, -3 }, /* (282) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 308, -2 }, /* (283) cmd ::= BALANCE VGROUP */ + { 308, -4 }, /* (284) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 308, -4 }, /* (285) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 308, -3 }, /* (286) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 374, -2 }, /* (287) dnode_list ::= DNODE NK_INTEGER */ + { 374, -3 }, /* (288) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 308, -4 }, /* (289) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 308, -1 }, /* (290) cmd ::= query_expression */ + { 308, -7 }, /* (291) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ + { 308, -4 }, /* (292) cmd ::= INSERT INTO full_table_name query_expression */ + { 311, -1 }, /* (293) literal ::= NK_INTEGER */ + { 311, -1 }, /* (294) literal ::= NK_FLOAT */ + { 311, -1 }, /* (295) literal ::= NK_STRING */ + { 311, -1 }, /* (296) literal ::= NK_BOOL */ + { 311, -2 }, /* (297) literal ::= TIMESTAMP NK_STRING */ + { 311, -1 }, /* (298) literal ::= duration_literal */ + { 311, -1 }, /* (299) literal ::= NULL */ + { 311, -1 }, /* (300) literal ::= NK_QUESTION */ + { 352, -1 }, /* (301) duration_literal ::= NK_VARIABLE */ + { 376, -1 }, /* (302) signed ::= NK_INTEGER */ + { 376, -2 }, /* (303) signed ::= NK_PLUS NK_INTEGER */ + { 376, -2 }, /* (304) signed ::= NK_MINUS NK_INTEGER */ + { 376, -1 }, /* (305) signed ::= NK_FLOAT */ + { 376, -2 }, /* (306) signed ::= NK_PLUS NK_FLOAT */ + { 376, -2 }, /* (307) signed ::= NK_MINUS NK_FLOAT */ + { 341, -1 }, /* (308) signed_literal ::= signed */ + { 341, -1 }, /* (309) signed_literal ::= NK_STRING */ + { 341, -1 }, /* (310) signed_literal ::= NK_BOOL */ + { 341, -2 }, /* (311) signed_literal ::= TIMESTAMP NK_STRING */ + { 341, -1 }, /* (312) signed_literal ::= duration_literal */ + { 341, -1 }, /* (313) signed_literal ::= NULL */ + { 341, -1 }, /* (314) signed_literal ::= literal_func */ + { 341, -1 }, /* (315) signed_literal ::= NK_QUESTION */ + { 378, -1 }, /* (316) literal_list ::= signed_literal */ + { 378, -3 }, /* (317) literal_list ::= literal_list NK_COMMA signed_literal */ + { 319, -1 }, /* (318) db_name ::= NK_ID */ + { 347, -1 }, /* (319) table_name ::= NK_ID */ + { 339, -1 }, /* (320) column_name ::= NK_ID */ + { 354, -1 }, /* (321) function_name ::= NK_ID */ + { 379, -1 }, /* (322) table_alias ::= NK_ID */ + { 380, -1 }, /* (323) column_alias ::= NK_ID */ + { 313, -1 }, /* (324) user_name ::= NK_ID */ + { 366, -1 }, /* (325) topic_name ::= NK_ID */ + { 373, -1 }, /* (326) stream_name ::= NK_ID */ + { 368, -1 }, /* (327) cgroup_name ::= NK_ID */ + { 381, -1 }, /* (328) expression ::= literal */ + { 381, -1 }, /* (329) expression ::= pseudo_column */ + { 381, -1 }, /* (330) expression ::= column_reference */ + { 381, -1 }, /* (331) expression ::= function_expression */ + { 381, -1 }, /* (332) expression ::= subquery */ + { 381, -3 }, /* (333) expression ::= NK_LP expression NK_RP */ + { 381, -2 }, /* (334) expression ::= NK_PLUS expression */ + { 381, -2 }, /* (335) expression ::= NK_MINUS expression */ + { 381, -3 }, /* (336) expression ::= expression NK_PLUS expression */ + { 381, -3 }, /* (337) expression ::= expression NK_MINUS expression */ + { 381, -3 }, /* (338) expression ::= expression NK_STAR expression */ + { 381, -3 }, /* (339) expression ::= expression NK_SLASH expression */ + { 381, -3 }, /* (340) expression ::= expression NK_REM expression */ + { 381, -3 }, /* (341) expression ::= column_reference NK_ARROW NK_STRING */ + { 381, -3 }, /* (342) expression ::= expression NK_BITAND expression */ + { 381, -3 }, /* (343) expression ::= expression NK_BITOR expression */ + { 344, -1 }, /* (344) expression_list ::= expression */ + { 344, -3 }, /* (345) expression_list ::= expression_list NK_COMMA expression */ + { 383, -1 }, /* (346) column_reference ::= column_name */ + { 383, -3 }, /* (347) column_reference ::= table_name NK_DOT column_name */ + { 382, -1 }, /* (348) pseudo_column ::= ROWTS */ + { 382, -1 }, /* (349) pseudo_column ::= TBNAME */ + { 382, -3 }, /* (350) pseudo_column ::= table_name NK_DOT TBNAME */ + { 382, -1 }, /* (351) pseudo_column ::= QSTART */ + { 382, -1 }, /* (352) pseudo_column ::= QEND */ + { 382, -1 }, /* (353) pseudo_column ::= QDURATION */ + { 382, -1 }, /* (354) pseudo_column ::= WSTART */ + { 382, -1 }, /* (355) pseudo_column ::= WEND */ + { 382, -1 }, /* (356) pseudo_column ::= WDURATION */ + { 384, -4 }, /* (357) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 384, -4 }, /* (358) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 384, -6 }, /* (359) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 384, -1 }, /* (360) function_expression ::= literal_func */ + { 377, -3 }, /* (361) literal_func ::= noarg_func NK_LP NK_RP */ + { 377, -1 }, /* (362) literal_func ::= NOW */ + { 388, -1 }, /* (363) noarg_func ::= NOW */ + { 388, -1 }, /* (364) noarg_func ::= TODAY */ + { 388, -1 }, /* (365) noarg_func ::= TIMEZONE */ + { 388, -1 }, /* (366) noarg_func ::= DATABASE */ + { 388, -1 }, /* (367) noarg_func ::= CLIENT_VERSION */ + { 388, -1 }, /* (368) noarg_func ::= SERVER_VERSION */ + { 388, -1 }, /* (369) noarg_func ::= SERVER_STATUS */ + { 388, -1 }, /* (370) noarg_func ::= CURRENT_USER */ + { 388, -1 }, /* (371) noarg_func ::= USER */ + { 386, -1 }, /* (372) star_func ::= COUNT */ + { 386, -1 }, /* (373) star_func ::= FIRST */ + { 386, -1 }, /* (374) star_func ::= LAST */ + { 386, -1 }, /* (375) star_func ::= LAST_ROW */ + { 387, -1 }, /* (376) star_func_para_list ::= NK_STAR */ + { 387, -1 }, /* (377) star_func_para_list ::= other_para_list */ + { 389, -1 }, /* (378) other_para_list ::= star_func_para */ + { 389, -3 }, /* (379) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 390, -1 }, /* (380) star_func_para ::= expression */ + { 390, -3 }, /* (381) star_func_para ::= table_name NK_DOT NK_STAR */ + { 391, -3 }, /* (382) predicate ::= expression compare_op expression */ + { 391, -5 }, /* (383) predicate ::= expression BETWEEN expression AND expression */ + { 391, -6 }, /* (384) predicate ::= expression NOT BETWEEN expression AND expression */ + { 391, -3 }, /* (385) predicate ::= expression IS NULL */ + { 391, -4 }, /* (386) predicate ::= expression IS NOT NULL */ + { 391, -3 }, /* (387) predicate ::= expression in_op in_predicate_value */ + { 392, -1 }, /* (388) compare_op ::= NK_LT */ + { 392, -1 }, /* (389) compare_op ::= NK_GT */ + { 392, -1 }, /* (390) compare_op ::= NK_LE */ + { 392, -1 }, /* (391) compare_op ::= NK_GE */ + { 392, -1 }, /* (392) compare_op ::= NK_NE */ + { 392, -1 }, /* (393) compare_op ::= NK_EQ */ + { 392, -1 }, /* (394) compare_op ::= LIKE */ + { 392, -2 }, /* (395) compare_op ::= NOT LIKE */ + { 392, -1 }, /* (396) compare_op ::= MATCH */ + { 392, -1 }, /* (397) compare_op ::= NMATCH */ + { 392, -1 }, /* (398) compare_op ::= CONTAINS */ + { 393, -1 }, /* (399) in_op ::= IN */ + { 393, -2 }, /* (400) in_op ::= NOT IN */ + { 394, -3 }, /* (401) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 395, -1 }, /* (402) boolean_value_expression ::= boolean_primary */ + { 395, -2 }, /* (403) boolean_value_expression ::= NOT boolean_primary */ + { 395, -3 }, /* (404) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 395, -3 }, /* (405) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 396, -1 }, /* (406) boolean_primary ::= predicate */ + { 396, -3 }, /* (407) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 397, -1 }, /* (408) common_expression ::= expression */ + { 397, -1 }, /* (409) common_expression ::= boolean_value_expression */ + { 398, 0 }, /* (410) from_clause_opt ::= */ + { 398, -2 }, /* (411) from_clause_opt ::= FROM table_reference_list */ + { 399, -1 }, /* (412) table_reference_list ::= table_reference */ + { 399, -3 }, /* (413) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 400, -1 }, /* (414) table_reference ::= table_primary */ + { 400, -1 }, /* (415) table_reference ::= joined_table */ + { 401, -2 }, /* (416) table_primary ::= table_name alias_opt */ + { 401, -4 }, /* (417) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 401, -2 }, /* (418) table_primary ::= subquery alias_opt */ + { 401, -1 }, /* (419) table_primary ::= parenthesized_joined_table */ + { 403, 0 }, /* (420) alias_opt ::= */ + { 403, -1 }, /* (421) alias_opt ::= table_alias */ + { 403, -2 }, /* (422) alias_opt ::= AS table_alias */ + { 404, -3 }, /* (423) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 404, -3 }, /* (424) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 402, -6 }, /* (425) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 405, 0 }, /* (426) join_type ::= */ + { 405, -1 }, /* (427) join_type ::= INNER */ + { 407, -12 }, /* (428) 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 */ + { 408, 0 }, /* (429) set_quantifier_opt ::= */ + { 408, -1 }, /* (430) set_quantifier_opt ::= DISTINCT */ + { 408, -1 }, /* (431) set_quantifier_opt ::= ALL */ + { 409, -1 }, /* (432) select_list ::= select_item */ + { 409, -3 }, /* (433) select_list ::= select_list NK_COMMA select_item */ + { 417, -1 }, /* (434) select_item ::= NK_STAR */ + { 417, -1 }, /* (435) select_item ::= common_expression */ + { 417, -2 }, /* (436) select_item ::= common_expression column_alias */ + { 417, -3 }, /* (437) select_item ::= common_expression AS column_alias */ + { 417, -3 }, /* (438) select_item ::= table_name NK_DOT NK_STAR */ + { 375, 0 }, /* (439) where_clause_opt ::= */ + { 375, -2 }, /* (440) where_clause_opt ::= WHERE search_condition */ + { 410, 0 }, /* (441) partition_by_clause_opt ::= */ + { 410, -3 }, /* (442) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 414, 0 }, /* (443) twindow_clause_opt ::= */ + { 414, -6 }, /* (444) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 414, -4 }, /* (445) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 414, -6 }, /* (446) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 414, -8 }, /* (447) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 362, 0 }, /* (448) sliding_opt ::= */ + { 362, -4 }, /* (449) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 413, 0 }, /* (450) fill_opt ::= */ + { 413, -4 }, /* (451) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 413, -6 }, /* (452) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 418, -1 }, /* (453) fill_mode ::= NONE */ + { 418, -1 }, /* (454) fill_mode ::= PREV */ + { 418, -1 }, /* (455) fill_mode ::= NULL */ + { 418, -1 }, /* (456) fill_mode ::= LINEAR */ + { 418, -1 }, /* (457) fill_mode ::= NEXT */ + { 415, 0 }, /* (458) group_by_clause_opt ::= */ + { 415, -3 }, /* (459) group_by_clause_opt ::= GROUP BY group_by_list */ + { 419, -1 }, /* (460) group_by_list ::= expression */ + { 419, -3 }, /* (461) group_by_list ::= group_by_list NK_COMMA expression */ + { 416, 0 }, /* (462) having_clause_opt ::= */ + { 416, -2 }, /* (463) having_clause_opt ::= HAVING search_condition */ + { 411, 0 }, /* (464) range_opt ::= */ + { 411, -6 }, /* (465) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 412, 0 }, /* (466) every_opt ::= */ + { 412, -4 }, /* (467) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 367, -4 }, /* (468) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 420, -1 }, /* (469) query_expression_body ::= query_primary */ + { 420, -4 }, /* (470) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 420, -3 }, /* (471) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 424, -1 }, /* (472) query_primary ::= query_specification */ + { 424, -6 }, /* (473) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 421, 0 }, /* (474) order_by_clause_opt ::= */ + { 421, -3 }, /* (475) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 422, 0 }, /* (476) slimit_clause_opt ::= */ + { 422, -2 }, /* (477) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 422, -4 }, /* (478) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 422, -4 }, /* (479) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 423, 0 }, /* (480) limit_clause_opt ::= */ + { 423, -2 }, /* (481) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 423, -4 }, /* (482) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 423, -4 }, /* (483) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 385, -3 }, /* (484) subquery ::= NK_LP query_expression NK_RP */ + { 406, -1 }, /* (485) search_condition ::= common_expression */ + { 425, -1 }, /* (486) sort_specification_list ::= sort_specification */ + { 425, -3 }, /* (487) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 426, -3 }, /* (488) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 427, 0 }, /* (489) ordering_specification_opt ::= */ + { 427, -1 }, /* (490) ordering_specification_opt ::= ASC */ + { 427, -1 }, /* (491) ordering_specification_opt ::= DESC */ + { 428, 0 }, /* (492) null_ordering_opt ::= */ + { 428, -2 }, /* (493) null_ordering_opt ::= NULLS FIRST */ + { 428, -2 }, /* (494) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3367,11 +3415,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,306,&yymsp[0].minor); + yy_destructor(yypParser,309,&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,307,&yymsp[0].minor); + yy_destructor(yypParser,310,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3385,20 +3433,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,306,&yymsp[-2].minor); +{ yy_destructor(yypParser,309,&yymsp[-2].minor); { } - yy_destructor(yypParser,308,&yymsp[0].minor); + yy_destructor(yypParser,311,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,309,&yymsp[0].minor); +{ yy_destructor(yypParser,312,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,307,&yymsp[-1].minor); +{ yy_destructor(yypParser,310,&yymsp[-1].minor); { } - yy_destructor(yypParser,309,&yymsp[0].minor); + yy_destructor(yypParser,312,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3412,72 +3460,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,308,&yymsp[0].minor); + yy_destructor(yypParser,311,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy0, yymsp[0].minor.yy59); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy239, &yymsp[-1].minor.yy0, yymsp[0].minor.yy509); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, 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.yy209, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, 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.yy209, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy239); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy59 = 1; } +{ yymsp[1].minor.yy509 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy59 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy509 = 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.yy69, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy69, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy69 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy69 = yymsp[0].minor.yy69; } - yymsp[0].minor.yy69 = yylhsminor.yy69; +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy69 = yymsp[-2].minor.yy69 | yymsp[0].minor.yy69; } - yymsp[-2].minor.yy69 = yylhsminor.yy69; +{ yylhsminor.yy129 = yymsp[-2].minor.yy129 | yymsp[0].minor.yy129; } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy69 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy69 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy209 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy209 = yylhsminor.yy209; +{ yylhsminor.yy239 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy239 = yylhsminor.yy239; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy209 = yymsp[-2].minor.yy209; } - yymsp[-2].minor.yy209 = yylhsminor.yy209; +{ yylhsminor.yy239 = yymsp[-2].minor.yy239; } + yymsp[-2].minor.yy239 = yylhsminor.yy239; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy239, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy239); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3494,31 +3542,31 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 312: /* db_name ::= NK_ID */ yytestcase(yyruleno==312); - case 313: /* table_name ::= NK_ID */ yytestcase(yyruleno==313); - case 314: /* column_name ::= NK_ID */ yytestcase(yyruleno==314); - case 315: /* function_name ::= NK_ID */ yytestcase(yyruleno==315); - case 316: /* table_alias ::= NK_ID */ yytestcase(yyruleno==316); - case 317: /* column_alias ::= NK_ID */ yytestcase(yyruleno==317); - case 318: /* user_name ::= NK_ID */ yytestcase(yyruleno==318); - case 319: /* topic_name ::= NK_ID */ yytestcase(yyruleno==319); - case 320: /* stream_name ::= NK_ID */ yytestcase(yyruleno==320); - case 321: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==321); - case 357: /* noarg_func ::= NOW */ yytestcase(yyruleno==357); - case 358: /* noarg_func ::= TODAY */ yytestcase(yyruleno==358); - case 359: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==359); - case 360: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==360); - case 361: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==361); - case 362: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==362); - case 363: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==363); - case 364: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==364); - case 365: /* noarg_func ::= USER */ yytestcase(yyruleno==365); - case 366: /* star_func ::= COUNT */ yytestcase(yyruleno==366); - case 367: /* star_func ::= FIRST */ yytestcase(yyruleno==367); - case 368: /* star_func ::= LAST */ yytestcase(yyruleno==368); - case 369: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==369); -{ yylhsminor.yy209 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 318: /* db_name ::= NK_ID */ yytestcase(yyruleno==318); + case 319: /* table_name ::= NK_ID */ yytestcase(yyruleno==319); + case 320: /* column_name ::= NK_ID */ yytestcase(yyruleno==320); + case 321: /* function_name ::= NK_ID */ yytestcase(yyruleno==321); + case 322: /* table_alias ::= NK_ID */ yytestcase(yyruleno==322); + case 323: /* column_alias ::= NK_ID */ yytestcase(yyruleno==323); + case 324: /* user_name ::= NK_ID */ yytestcase(yyruleno==324); + case 325: /* topic_name ::= NK_ID */ yytestcase(yyruleno==325); + case 326: /* stream_name ::= NK_ID */ yytestcase(yyruleno==326); + case 327: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==327); + case 363: /* noarg_func ::= NOW */ yytestcase(yyruleno==363); + case 364: /* noarg_func ::= TODAY */ yytestcase(yyruleno==364); + case 365: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==365); + case 366: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==366); + case 367: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==367); + case 368: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==368); + case 369: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==369); + case 370: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==370); + case 371: /* noarg_func ::= USER */ yytestcase(yyruleno==371); + case 372: /* star_func ::= COUNT */ yytestcase(yyruleno==372); + case 373: /* star_func ::= FIRST */ yytestcase(yyruleno==373); + case 374: /* star_func ::= LAST */ yytestcase(yyruleno==374); + case 375: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==375); +{ yylhsminor.yy239 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy239 = yylhsminor.yy239; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3551,1261 +3599,1282 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy293, &yymsp[-1].minor.yy209, yymsp[0].minor.yy272); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy845, &yymsp[-1].minor.yy239, yymsp[0].minor.yy80); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy293, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy239); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy272); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy239, yymsp[0].minor.yy80); } break; case 66: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy239); } break; case 67: /* cmd ::= TRIM DATABASE db_name */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy239); } break; case 68: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy293 = true; } +{ yymsp[-2].minor.yy845 = true; } break; case 69: /* not_exists_opt ::= */ case 71: /* exists_opt ::= */ yytestcase(yyruleno==71); - case 255: /* analyze_opt ::= */ yytestcase(yyruleno==255); - case 262: /* agg_func_opt ::= */ yytestcase(yyruleno==262); - case 423: /* set_quantifier_opt ::= */ yytestcase(yyruleno==423); -{ yymsp[1].minor.yy293 = false; } + case 261: /* analyze_opt ::= */ yytestcase(yyruleno==261); + case 268: /* agg_func_opt ::= */ yytestcase(yyruleno==268); + case 429: /* set_quantifier_opt ::= */ yytestcase(yyruleno==429); +{ yymsp[1].minor.yy845 = false; } break; case 70: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy293 = true; } +{ yymsp[-1].minor.yy845 = true; } break; case 72: /* db_options ::= */ -{ yymsp[1].minor.yy272 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy80 = createDefaultDatabaseOptions(pCxt); } break; case 73: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 74: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 75: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 76: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 77: /* db_options ::= db_options DURATION NK_INTEGER */ case 78: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==78); -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 80: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 81: /* db_options ::= db_options KEEP integer_list */ case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82); -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_KEEP, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP, yymsp[0].minor.yy574); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 83: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 85: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 86: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 87: /* db_options ::= db_options STRICT NK_STRING */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 88: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 89: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 90: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_RETENTIONS, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_RETENTIONS, yymsp[0].minor.yy574); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 91: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 92: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 93: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 94: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 95: /* 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.yy272 = setDatabaseOption(pCxt, yymsp[-3].minor.yy272, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; case 96: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 97: /* 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.yy272 = setDatabaseOption(pCxt, yymsp[-3].minor.yy272, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; case 98: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; case 99: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy272 = setDatabaseOption(pCxt, yymsp[-2].minor.yy272, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 100: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy272 = createAlterDatabaseOptions(pCxt); yylhsminor.yy272 = setAlterDatabaseOption(pCxt, yylhsminor.yy272, &yymsp[0].minor.yy5); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 101: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy272 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy272, &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; - break; - case 102: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } - break; - case 103: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } - break; - case 104: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } - break; - case 105: /* alter_db_option ::= KEEP integer_list */ - case 106: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==106); -{ yymsp[-1].minor.yy5.type = DB_OPTION_KEEP; yymsp[-1].minor.yy5.pList = yymsp[0].minor.yy172; } - break; - case 107: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_WAL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } - break; - case 108: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy172 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; - break; - case 109: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 282: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==282); -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-2].minor.yy172, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; - break; - case 110: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy172 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; - break; - case 111: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-2].minor.yy172, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; - break; - case 112: /* retention_list ::= retention */ - case 132: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==132); - case 135: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==135); - case 142: /* column_def_list ::= column_def */ yytestcase(yyruleno==142); - case 185: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==185); - case 190: /* col_name_list ::= col_name */ yytestcase(yyruleno==190); - case 238: /* func_list ::= func */ yytestcase(yyruleno==238); - case 310: /* literal_list ::= signed_literal */ yytestcase(yyruleno==310); - case 372: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==372); - case 426: /* select_list ::= select_item */ yytestcase(yyruleno==426); - case 480: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==480); -{ yylhsminor.yy172 = createNodeList(pCxt, yymsp[0].minor.yy272); } - yymsp[0].minor.yy172 = yylhsminor.yy172; - break; - case 113: /* retention_list ::= retention_list NK_COMMA retention */ - case 143: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==143); - case 186: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==186); - case 191: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==191); - case 239: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==239); - case 311: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==311); - case 373: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==373); - case 427: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==427); - case 481: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==481); -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-2].minor.yy172, yymsp[0].minor.yy272); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; - break; - case 114: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy272 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 115: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 117: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==117); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy293, yymsp[-5].minor.yy272, yymsp[-3].minor.yy172, yymsp[-1].minor.yy172, yymsp[0].minor.yy272); } - break; - case 116: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy172); } - break; - case 118: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy172); } - break; - case 119: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy293, yymsp[0].minor.yy272); } - break; - case 120: /* cmd ::= ALTER TABLE alter_table_clause */ - case 284: /* cmd ::= query_expression */ yytestcase(yyruleno==284); -{ pCxt->pRootNode = yymsp[0].minor.yy272; } - break; - case 121: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy272); } - break; - case 122: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy272 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; - break; - case 123: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy272 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy209, yymsp[0].minor.yy616); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; - break; - case 124: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy272 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy272, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy209); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; - break; - case 125: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy272 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy616); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 100: /* db_options ::= db_options SST_TRIGGER NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SST_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 101: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 102: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ +{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 103: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy80 = createAlterDatabaseOptions(pCxt); yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yylhsminor.yy80, &yymsp[0].minor.yy299); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 104: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy80, &yymsp[0].minor.yy299); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; + break; + case 105: /* alter_db_option ::= CACHEMODEL NK_STRING */ +{ yymsp[-1].minor.yy299.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } + break; + case 106: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +{ yymsp[-1].minor.yy299.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } + break; + case 107: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy299.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } + break; + case 108: /* alter_db_option ::= KEEP integer_list */ + case 109: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==109); +{ yymsp[-1].minor.yy299.type = DB_OPTION_KEEP; yymsp[-1].minor.yy299.pList = yymsp[0].minor.yy574; } + break; + case 110: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +{ yymsp[-1].minor.yy299.type = DB_OPTION_WAL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } + break; + case 111: /* alter_db_option ::= SST_TRIGGER NK_INTEGER */ +{ yymsp[-1].minor.yy299.type = DB_OPTION_SST_TRIGGER; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } + break; + case 112: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy574 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy574 = yylhsminor.yy574; + break; + case 113: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 288: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==288); +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy574 = yylhsminor.yy574; + break; + case 114: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy574 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy574 = yylhsminor.yy574; + break; + case 115: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy574 = yylhsminor.yy574; + break; + case 116: /* retention_list ::= retention */ + case 136: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==136); + case 139: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==139); + case 146: /* column_def_list ::= column_def */ yytestcase(yyruleno==146); + case 189: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==189); + case 194: /* col_name_list ::= col_name */ yytestcase(yyruleno==194); + case 244: /* func_list ::= func */ yytestcase(yyruleno==244); + case 316: /* literal_list ::= signed_literal */ yytestcase(yyruleno==316); + case 378: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==378); + case 432: /* select_list ::= select_item */ yytestcase(yyruleno==432); + case 486: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==486); +{ yylhsminor.yy574 = createNodeList(pCxt, yymsp[0].minor.yy80); } + yymsp[0].minor.yy574 = yylhsminor.yy574; + break; + case 117: /* retention_list ::= retention_list NK_COMMA retention */ + case 147: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==147); + case 190: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==190); + case 195: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==195); + case 245: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==245); + case 317: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==317); + case 379: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==379); + case 433: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==433); + case 487: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==487); +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy574 = yylhsminor.yy574; + break; + case 118: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy80 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 119: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 121: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==121); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy845, yymsp[-5].minor.yy80, yymsp[-3].minor.yy574, yymsp[-1].minor.yy574, yymsp[0].minor.yy80); } + break; + case 120: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy574); } + break; + case 122: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy574); } + break; + case 123: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); } + break; + case 124: /* cmd ::= ALTER TABLE alter_table_clause */ + case 290: /* cmd ::= query_expression */ yytestcase(yyruleno==290); +{ pCxt->pRootNode = yymsp[0].minor.yy80; } + break; + case 125: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy80); } + break; + case 126: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy80 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; + break; + case 127: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 128: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy239); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; + break; + case 129: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 126: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy272 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + case 130: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 127: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy272 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy209, yymsp[0].minor.yy616); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; - break; - case 128: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy272 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy272, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy209); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 131: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; + break; + case 132: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy239); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 129: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy272 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy209, yymsp[0].minor.yy616); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + case 133: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 130: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy272 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy272, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + case 134: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 131: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy272 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy272, &yymsp[-2].minor.yy209, yymsp[0].minor.yy272); } - yymsp[-5].minor.yy272 = yylhsminor.yy272; + case 135: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy80 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy80, &yymsp[-2].minor.yy239, yymsp[0].minor.yy80); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 133: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 136: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==136); -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-1].minor.yy172, yymsp[0].minor.yy272); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 137: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 140: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==140); +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-1].minor.yy574, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy574 = yylhsminor.yy574; break; - case 134: /* 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.yy272 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy293, yymsp[-8].minor.yy272, yymsp[-6].minor.yy272, yymsp[-5].minor.yy172, yymsp[-2].minor.yy172, yymsp[0].minor.yy272); } - yymsp[-9].minor.yy272 = yylhsminor.yy272; + case 138: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ +{ yylhsminor.yy80 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy845, yymsp[-8].minor.yy80, yymsp[-6].minor.yy80, yymsp[-5].minor.yy574, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); } + yymsp[-9].minor.yy80 = yylhsminor.yy80; break; - case 137: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy272 = createDropTableClause(pCxt, yymsp[-1].minor.yy293, yymsp[0].minor.yy272); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 141: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy80 = createDropTableClause(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 138: /* specific_cols_opt ::= */ - case 169: /* tags_def_opt ::= */ yytestcase(yyruleno==169); - case 435: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==435); - case 452: /* group_by_clause_opt ::= */ yytestcase(yyruleno==452); - case 468: /* order_by_clause_opt ::= */ yytestcase(yyruleno==468); -{ yymsp[1].minor.yy172 = NULL; } + case 142: /* specific_cols_opt ::= */ + case 173: /* tags_def_opt ::= */ yytestcase(yyruleno==173); + case 441: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==441); + case 458: /* group_by_clause_opt ::= */ yytestcase(yyruleno==458); + case 474: /* order_by_clause_opt ::= */ yytestcase(yyruleno==474); +{ yymsp[1].minor.yy574 = NULL; } break; - case 139: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy172 = yymsp[-1].minor.yy172; } + case 143: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy574 = yymsp[-1].minor.yy574; } break; - case 140: /* full_table_name ::= table_name */ -{ yylhsminor.yy272 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 144: /* full_table_name ::= table_name */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy239, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 141: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy272 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 145: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 144: /* column_def ::= column_name type_name */ -{ yylhsminor.yy272 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy616, NULL); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 148: /* column_def ::= column_name type_name */ +{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136, NULL); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 145: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy272 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy616, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 149: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-2].minor.yy136, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 146: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 150: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 147: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 151: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 148: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 152: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 149: /* type_name ::= INT */ - case 150: /* type_name ::= INTEGER */ yytestcase(yyruleno==150); -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_INT); } + case 153: /* type_name ::= INT */ + case 154: /* type_name ::= INTEGER */ yytestcase(yyruleno==154); +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 151: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 155: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 152: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 156: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 153: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 157: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 154: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy616 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 158: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 155: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 159: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 156: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy616 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 160: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 157: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy616 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 161: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 158: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy616 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 162: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 159: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy616 = createDataType(TSDB_DATA_TYPE_UINT); } + case 163: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 160: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy616 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 164: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 161: /* type_name ::= JSON */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_JSON); } + case 165: /* type_name ::= JSON */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 162: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy616 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 166: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 163: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 167: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 164: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 168: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 165: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy616 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 169: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 166: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy616 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 170: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 167: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy616 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 171: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 168: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy616 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 172: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 170: /* tags_def_opt ::= tags_def */ - case 371: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==371); -{ yylhsminor.yy172 = yymsp[0].minor.yy172; } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 174: /* tags_def_opt ::= tags_def */ + case 377: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==377); +{ yylhsminor.yy574 = yymsp[0].minor.yy574; } + yymsp[0].minor.yy574 = yylhsminor.yy574; break; - case 171: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy172 = yymsp[-1].minor.yy172; } + case 175: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy574 = yymsp[-1].minor.yy574; } break; - case 172: /* table_options ::= */ -{ yymsp[1].minor.yy272 = createDefaultTableOptions(pCxt); } + case 176: /* table_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultTableOptions(pCxt); } break; - case 173: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-2].minor.yy272, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 177: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 174: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-2].minor.yy272, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 178: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy574); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 175: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-2].minor.yy272, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 179: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy574); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 176: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-4].minor.yy272, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy172); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + case 180: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy574); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 177: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-2].minor.yy272, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 181: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 178: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-4].minor.yy272, TABLE_OPTION_SMA, yymsp[-1].minor.yy172); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + case 182: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_SMA, yymsp[-1].minor.yy574); } + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 179: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy272 = createAlterTableOptions(pCxt); yylhsminor.yy272 = setTableOption(pCxt, yylhsminor.yy272, yymsp[0].minor.yy5.type, &yymsp[0].minor.yy5.val); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 183: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy80 = createAlterTableOptions(pCxt); yylhsminor.yy80 = setTableOption(pCxt, yylhsminor.yy80, yymsp[0].minor.yy299.type, &yymsp[0].minor.yy299.val); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 180: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy272 = setTableOption(pCxt, yymsp[-1].minor.yy272, yymsp[0].minor.yy5.type, &yymsp[0].minor.yy5.val); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 184: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy299.type, &yymsp[0].minor.yy299.val); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 181: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy5.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } + case 185: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy299.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } break; - case 182: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } + case 186: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy299.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; } break; - case 183: /* duration_list ::= duration_literal */ - case 338: /* expression_list ::= expression */ yytestcase(yyruleno==338); -{ yylhsminor.yy172 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 187: /* duration_list ::= duration_literal */ + case 344: /* expression_list ::= expression */ yytestcase(yyruleno==344); +{ yylhsminor.yy574 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[0].minor.yy574 = yylhsminor.yy574; break; - case 184: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 339: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==339); -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-2].minor.yy172, releaseRawExprNode(pCxt, yymsp[0].minor.yy272)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 188: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 345: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==345); +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } + yymsp[-2].minor.yy574 = yylhsminor.yy574; break; - case 187: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy272 = createFunctionNode(pCxt, &yymsp[0].minor.yy209, NULL); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 191: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy239, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 188: /* rollup_func_name ::= FIRST */ - case 189: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==189); -{ yylhsminor.yy272 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 192: /* rollup_func_name ::= FIRST */ + case 193: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==193); +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 192: /* col_name ::= column_name */ -{ yylhsminor.yy272 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 196: /* col_name ::= column_name */ +{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy239); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 193: /* cmd ::= SHOW DNODES */ + case 197: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 194: /* cmd ::= SHOW USERS */ + case 198: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 195: /* cmd ::= SHOW DATABASES */ + case 199: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 196: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, OP_TYPE_LIKE); } + case 200: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); } break; - case 197: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, OP_TYPE_LIKE); } + case 201: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); } break; - case 198: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy272, NULL, OP_TYPE_LIKE); } + case 202: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); } break; - case 199: /* cmd ::= SHOW MNODES */ + case 203: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 200: /* cmd ::= SHOW MODULES */ + case 204: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } break; - case 201: /* cmd ::= SHOW QNODES */ + case 205: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 202: /* cmd ::= SHOW FUNCTIONS */ + case 206: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 203: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy272, yymsp[-1].minor.yy272, OP_TYPE_EQUAL); } + case 207: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } break; - case 204: /* cmd ::= SHOW STREAMS */ + case 208: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 205: /* cmd ::= SHOW ACCOUNTS */ + case 209: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 206: /* cmd ::= SHOW APPS */ + case 210: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 207: /* cmd ::= SHOW CONNECTIONS */ + case 211: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 208: /* cmd ::= SHOW LICENCES */ - case 209: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==209); + case 212: /* cmd ::= SHOW LICENCES */ + case 213: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==213); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 210: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy209); } + case 214: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy239); } break; - case 211: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy272); } + case 215: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy80); } break; - case 212: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy272); } + case 216: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy80); } break; - case 213: /* cmd ::= SHOW QUERIES */ + case 217: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 214: /* cmd ::= SHOW SCORES */ + case 218: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 215: /* cmd ::= SHOW TOPICS */ + case 219: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 216: /* cmd ::= SHOW VARIABLES */ + case 220: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 217: /* cmd ::= SHOW LOCAL VARIABLES */ + case 221: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 218: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 222: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 219: /* cmd ::= SHOW BNODES */ + case 223: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 220: /* cmd ::= SHOW SNODES */ + case 224: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 221: /* cmd ::= SHOW CLUSTER */ + case 225: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 222: /* cmd ::= SHOW TRANSACTIONS */ + case 226: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 223: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy272); } + case 227: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy80); } break; - case 224: /* cmd ::= SHOW CONSUMERS */ + case 228: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 225: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 229: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 226: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy272, yymsp[-1].minor.yy272, OP_TYPE_EQUAL); } + case 230: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); } + break; + case 231: /* cmd ::= SHOW VNODES NK_INTEGER */ +{ pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } + break; + case 232: /* cmd ::= SHOW VNODES NK_STRING */ +{ pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 227: /* db_name_cond_opt ::= */ - case 232: /* from_db_opt ::= */ yytestcase(yyruleno==232); -{ yymsp[1].minor.yy272 = createDefaultDatabaseCondValue(pCxt); } + case 233: /* db_name_cond_opt ::= */ + case 238: /* from_db_opt ::= */ yytestcase(yyruleno==238); +{ yymsp[1].minor.yy80 = createDefaultDatabaseCondValue(pCxt); } break; - case 228: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy209); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 234: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy239); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 229: /* like_pattern_opt ::= */ - case 404: /* from_clause_opt ::= */ yytestcase(yyruleno==404); - case 433: /* where_clause_opt ::= */ yytestcase(yyruleno==433); - case 437: /* twindow_clause_opt ::= */ yytestcase(yyruleno==437); - case 442: /* sliding_opt ::= */ yytestcase(yyruleno==442); - case 444: /* fill_opt ::= */ yytestcase(yyruleno==444); - case 456: /* having_clause_opt ::= */ yytestcase(yyruleno==456); - case 458: /* range_opt ::= */ yytestcase(yyruleno==458); - case 460: /* every_opt ::= */ yytestcase(yyruleno==460); - case 470: /* slimit_clause_opt ::= */ yytestcase(yyruleno==470); - case 474: /* limit_clause_opt ::= */ yytestcase(yyruleno==474); -{ yymsp[1].minor.yy272 = NULL; } + case 235: /* like_pattern_opt ::= */ + case 410: /* from_clause_opt ::= */ yytestcase(yyruleno==410); + case 439: /* where_clause_opt ::= */ yytestcase(yyruleno==439); + case 443: /* twindow_clause_opt ::= */ yytestcase(yyruleno==443); + case 448: /* sliding_opt ::= */ yytestcase(yyruleno==448); + case 450: /* fill_opt ::= */ yytestcase(yyruleno==450); + case 462: /* having_clause_opt ::= */ yytestcase(yyruleno==462); + case 464: /* range_opt ::= */ yytestcase(yyruleno==464); + case 466: /* every_opt ::= */ yytestcase(yyruleno==466); + case 476: /* slimit_clause_opt ::= */ yytestcase(yyruleno==476); + case 480: /* limit_clause_opt ::= */ yytestcase(yyruleno==480); +{ yymsp[1].minor.yy80 = NULL; } break; - case 230: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 236: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 231: /* table_name_cond ::= table_name */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 237: /* table_name_cond ::= table_name */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy239); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 233: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy209); } + case 239: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy239); } break; - case 234: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy293, yymsp[-3].minor.yy272, yymsp[-1].minor.yy272, NULL, yymsp[0].minor.yy272); } + case 240: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy845, yymsp[-3].minor.yy80, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } break; - case 235: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy293, yymsp[0].minor.yy272); } + case 241: /* cmd ::= DROP INDEX exists_opt full_table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); } break; - case 236: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy272 = createIndexOption(pCxt, yymsp[-7].minor.yy172, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), NULL, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } + case 242: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy80 = createIndexOption(pCxt, yymsp[-7].minor.yy574, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 237: /* 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.yy272 = createIndexOption(pCxt, yymsp[-9].minor.yy172, releaseRawExprNode(pCxt, yymsp[-5].minor.yy272), releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } + case 243: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy80 = createIndexOption(pCxt, yymsp[-9].minor.yy574, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 240: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy272 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy172); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 246: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-1].minor.yy574); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 241: /* sma_stream_opt ::= */ - case 268: /* stream_options ::= */ yytestcase(yyruleno==268); -{ yymsp[1].minor.yy272 = createStreamOptions(pCxt); } + case 247: /* sma_stream_opt ::= */ + case 274: /* stream_options ::= */ yytestcase(yyruleno==274); +{ yymsp[1].minor.yy80 = createStreamOptions(pCxt); } break; - case 242: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 272: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==272); -{ ((SStreamOptions*)yymsp[-2].minor.yy272)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy272); yylhsminor.yy272 = yymsp[-2].minor.yy272; } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 248: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 278: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==278); +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 243: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy272)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy272); yylhsminor.yy272 = yymsp[-2].minor.yy272; } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 249: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 244: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy293, &yymsp[-2].minor.yy209, yymsp[0].minor.yy272); } + case 250: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy239, yymsp[0].minor.yy80); } break; - case 245: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy293, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy209, false); } + case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy239, &yymsp[0].minor.yy239, false); } break; - case 246: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy293, &yymsp[-5].minor.yy209, &yymsp[0].minor.yy209, true); } + case 252: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, &yymsp[0].minor.yy239, true); } break; - case 247: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy293, &yymsp[-3].minor.yy209, yymsp[0].minor.yy272, false); } + case 253: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy239, yymsp[0].minor.yy80, false); } break; - case 248: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy293, &yymsp[-5].minor.yy209, yymsp[0].minor.yy272, true); } + case 254: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, yymsp[0].minor.yy80, true); } break; - case 249: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy293, &yymsp[0].minor.yy209); } + case 255: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); } break; - case 250: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy293, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209); } + case 256: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); } break; - case 251: /* cmd ::= DESC full_table_name */ - case 252: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==252); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy272); } + case 257: /* cmd ::= DESC full_table_name */ + case 258: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==258); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy80); } break; - case 253: /* cmd ::= RESET QUERY CACHE */ + case 259: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 254: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy293, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } + case 260: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 256: /* analyze_opt ::= ANALYZE */ - case 263: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==263); - case 424: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==424); -{ yymsp[0].minor.yy293 = true; } + case 262: /* analyze_opt ::= ANALYZE */ + case 269: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==269); + case 430: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==430); +{ yymsp[0].minor.yy845 = true; } break; - case 257: /* explain_options ::= */ -{ yymsp[1].minor.yy272 = createDefaultExplainOptions(pCxt); } + case 263: /* explain_options ::= */ +{ yymsp[1].minor.yy80 = createDefaultExplainOptions(pCxt); } break; - case 258: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy272 = setExplainVerbose(pCxt, yymsp[-2].minor.yy272, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 264: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy80 = setExplainVerbose(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 259: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy272 = setExplainRatio(pCxt, yymsp[-2].minor.yy272, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 265: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy80 = setExplainRatio(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 260: /* 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.yy293, yymsp[-8].minor.yy293, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy616, yymsp[0].minor.yy232); } + case 266: /* 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.yy845, yymsp[-8].minor.yy845, &yymsp[-5].minor.yy239, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy136, yymsp[0].minor.yy46); } break; - case 261: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy293, &yymsp[0].minor.yy209); } + case 267: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); } break; - case 264: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy232 = 0; } + case 270: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy46 = 0; } break; - case 265: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy232 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 271: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy46 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 266: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy293, &yymsp[-5].minor.yy209, yymsp[-2].minor.yy272, yymsp[-4].minor.yy272, yymsp[0].minor.yy272); } + case 272: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, yymsp[-2].minor.yy80, yymsp[-4].minor.yy80, yymsp[0].minor.yy80); } break; - case 267: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy293, &yymsp[0].minor.yy209); } + case 273: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); } break; - case 269: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy272)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy272 = yymsp[-2].minor.yy272; } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 275: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 270: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy272)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy272 = yymsp[-2].minor.yy272; } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 276: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy80)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy80 = yymsp[-2].minor.yy80; } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 271: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy272)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy272)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy272); yylhsminor.yy272 = yymsp[-3].minor.yy272; } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 277: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy80)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-3].minor.yy80; } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 273: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy272)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy272 = yymsp[-3].minor.yy272; } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 279: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy80)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy80 = yymsp[-3].minor.yy80; } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 274: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 280: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 275: /* cmd ::= KILL QUERY NK_STRING */ + case 281: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 276: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 282: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 277: /* cmd ::= BALANCE VGROUP */ + case 283: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 278: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 284: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 279: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy172); } + case 285: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy574); } break; - case 280: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 286: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 281: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy172 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - break; - case 283: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } - break; - case 285: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy272, yymsp[-2].minor.yy172, yymsp[0].minor.yy272); } - break; - case 286: /* cmd ::= INSERT INTO full_table_name query_expression */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy272, NULL, yymsp[0].minor.yy272); } - break; - case 287: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 288: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 289: /* literal ::= NK_STRING */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 290: /* literal ::= NK_BOOL */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 291: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; - break; - case 292: /* literal ::= duration_literal */ - case 302: /* signed_literal ::= signed */ yytestcase(yyruleno==302); - case 322: /* expression ::= literal */ yytestcase(yyruleno==322); - case 323: /* expression ::= pseudo_column */ yytestcase(yyruleno==323); - case 324: /* expression ::= column_reference */ yytestcase(yyruleno==324); - case 325: /* expression ::= function_expression */ yytestcase(yyruleno==325); - case 326: /* expression ::= subquery */ yytestcase(yyruleno==326); - case 354: /* function_expression ::= literal_func */ yytestcase(yyruleno==354); - case 396: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==396); - case 400: /* boolean_primary ::= predicate */ yytestcase(yyruleno==400); - case 402: /* common_expression ::= expression */ yytestcase(yyruleno==402); - case 403: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==403); - case 406: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==406); - case 408: /* table_reference ::= table_primary */ yytestcase(yyruleno==408); - case 409: /* table_reference ::= joined_table */ yytestcase(yyruleno==409); - case 413: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==413); - case 463: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==463); - case 466: /* query_primary ::= query_specification */ yytestcase(yyruleno==466); -{ yylhsminor.yy272 = yymsp[0].minor.yy272; } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 293: /* literal ::= NULL */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 294: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 295: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 296: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 297: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 298: /* signed ::= NK_MINUS NK_INTEGER */ + case 287: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy574 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 289: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } + break; + case 291: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy80, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); } + break; + case 292: /* cmd ::= INSERT INTO full_table_name query_expression */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); } + break; + case 293: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 294: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 295: /* literal ::= NK_STRING */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 296: /* literal ::= NK_BOOL */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 297: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; + break; + case 298: /* literal ::= duration_literal */ + case 308: /* signed_literal ::= signed */ yytestcase(yyruleno==308); + case 328: /* expression ::= literal */ yytestcase(yyruleno==328); + case 329: /* expression ::= pseudo_column */ yytestcase(yyruleno==329); + case 330: /* expression ::= column_reference */ yytestcase(yyruleno==330); + case 331: /* expression ::= function_expression */ yytestcase(yyruleno==331); + case 332: /* expression ::= subquery */ yytestcase(yyruleno==332); + case 360: /* function_expression ::= literal_func */ yytestcase(yyruleno==360); + case 402: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==402); + case 406: /* boolean_primary ::= predicate */ yytestcase(yyruleno==406); + case 408: /* common_expression ::= expression */ yytestcase(yyruleno==408); + case 409: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==409); + case 412: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==412); + case 414: /* table_reference ::= table_primary */ yytestcase(yyruleno==414); + case 415: /* table_reference ::= joined_table */ yytestcase(yyruleno==415); + case 419: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==419); + case 469: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==469); + case 472: /* query_primary ::= query_specification */ yytestcase(yyruleno==472); +{ yylhsminor.yy80 = yymsp[0].minor.yy80; } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 299: /* literal ::= NULL */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 300: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 301: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 302: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 303: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 304: /* 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.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 299: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 305: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 300: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 306: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 301: /* signed ::= NK_MINUS NK_FLOAT */ + case 307: /* 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.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 303: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 309: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 304: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 310: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 305: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 311: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 306: /* signed_literal ::= duration_literal */ - case 308: /* signed_literal ::= literal_func */ yytestcase(yyruleno==308); - case 374: /* star_func_para ::= expression */ yytestcase(yyruleno==374); - case 429: /* select_item ::= common_expression */ yytestcase(yyruleno==429); - case 479: /* search_condition ::= common_expression */ yytestcase(yyruleno==479); -{ yylhsminor.yy272 = releaseRawExprNode(pCxt, yymsp[0].minor.yy272); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 312: /* signed_literal ::= duration_literal */ + case 314: /* signed_literal ::= literal_func */ yytestcase(yyruleno==314); + case 380: /* star_func_para ::= expression */ yytestcase(yyruleno==380); + case 435: /* select_item ::= common_expression */ yytestcase(yyruleno==435); + case 485: /* search_condition ::= common_expression */ yytestcase(yyruleno==485); +{ yylhsminor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 307: /* signed_literal ::= NULL */ -{ yylhsminor.yy272 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 313: /* signed_literal ::= NULL */ +{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 309: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy272 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 315: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy80 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 327: /* expression ::= NK_LP expression NK_RP */ - case 401: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==401); -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 333: /* expression ::= NK_LP expression NK_RP */ + case 407: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==407); +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 328: /* expression ::= NK_PLUS expression */ + case 334: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy272)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 329: /* expression ::= NK_MINUS expression */ + case 335: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy272), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 330: /* expression ::= expression NK_PLUS expression */ + case 336: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 331: /* expression ::= expression NK_MINUS expression */ + case 337: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 332: /* expression ::= expression NK_STAR expression */ + case 338: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 333: /* expression ::= expression NK_SLASH expression */ + case 339: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 334: /* expression ::= expression NK_REM expression */ + case 340: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 335: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 341: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 336: /* expression ::= expression NK_BITAND expression */ + case 342: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 337: /* expression ::= expression NK_BITOR expression */ + case 343: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 340: /* column_reference ::= column_name */ -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 341: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 342: /* pseudo_column ::= ROWTS */ - case 343: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==343); - case 345: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==345); - case 346: /* pseudo_column ::= QEND */ yytestcase(yyruleno==346); - case 347: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==347); - case 348: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==348); - case 349: /* pseudo_column ::= WEND */ yytestcase(yyruleno==349); - case 350: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==350); - case 356: /* literal_func ::= NOW */ yytestcase(yyruleno==356); -{ yylhsminor.yy272 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy272 = yylhsminor.yy272; - break; - case 344: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy209)))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 351: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 352: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==352); -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy172)); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; - break; - case 353: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), yymsp[-1].minor.yy616)); } - yymsp[-5].minor.yy272 = yylhsminor.yy272; - break; - case 355: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy209, NULL)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 370: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy172 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; - break; - case 375: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 432: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==432); -{ yylhsminor.yy272 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; - break; - case 376: /* predicate ::= expression compare_op expression */ - case 381: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==381); + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 346: /* column_reference ::= column_name */ +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy239, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy239)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 347: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239, createColumnNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 348: /* pseudo_column ::= ROWTS */ + case 349: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==349); + case 351: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==351); + case 352: /* pseudo_column ::= QEND */ yytestcase(yyruleno==352); + case 353: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==353); + case 354: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==354); + case 355: /* pseudo_column ::= WEND */ yytestcase(yyruleno==355); + case 356: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==356); + case 362: /* literal_func ::= NOW */ yytestcase(yyruleno==362); +{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy80 = yylhsminor.yy80; + break; + case 350: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy239)))); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 357: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 358: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==358); +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-1].minor.yy574)); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; + break; + case 359: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy136)); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; + break; + case 361: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy239, NULL)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 376: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy574 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy574 = yylhsminor.yy574; + break; + case 381: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 438: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==438); +{ yylhsminor.yy80 = createColumnNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; + break; + case 382: /* predicate ::= expression compare_op expression */ + case 387: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==387); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy392, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy194, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 377: /* predicate ::= expression BETWEEN expression AND expression */ + case 383: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy272), releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-4].minor.yy272 = yylhsminor.yy272; + yymsp[-4].minor.yy80 = yylhsminor.yy80; break; - case 378: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 384: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy272), releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-5].minor.yy272 = yylhsminor.yy272; + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 379: /* predicate ::= expression IS NULL */ + case 385: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), NULL)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 380: /* predicate ::= expression IS NOT NULL */ + case 386: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL)); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 382: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy392 = OP_TYPE_LOWER_THAN; } + case 388: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy194 = OP_TYPE_LOWER_THAN; } break; - case 383: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy392 = OP_TYPE_GREATER_THAN; } + case 389: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy194 = OP_TYPE_GREATER_THAN; } break; - case 384: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy392 = OP_TYPE_LOWER_EQUAL; } + case 390: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy194 = OP_TYPE_LOWER_EQUAL; } break; - case 385: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy392 = OP_TYPE_GREATER_EQUAL; } + case 391: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy194 = OP_TYPE_GREATER_EQUAL; } break; - case 386: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy392 = OP_TYPE_NOT_EQUAL; } + case 392: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy194 = OP_TYPE_NOT_EQUAL; } break; - case 387: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy392 = OP_TYPE_EQUAL; } + case 393: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy194 = OP_TYPE_EQUAL; } break; - case 388: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy392 = OP_TYPE_LIKE; } + case 394: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy194 = OP_TYPE_LIKE; } break; - case 389: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy392 = OP_TYPE_NOT_LIKE; } + case 395: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy194 = OP_TYPE_NOT_LIKE; } break; - case 390: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy392 = OP_TYPE_MATCH; } + case 396: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy194 = OP_TYPE_MATCH; } break; - case 391: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy392 = OP_TYPE_NMATCH; } + case 397: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy194 = OP_TYPE_NMATCH; } break; - case 392: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy392 = OP_TYPE_JSON_CONTAINS; } + case 398: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy194 = OP_TYPE_JSON_CONTAINS; } break; - case 393: /* in_op ::= IN */ -{ yymsp[0].minor.yy392 = OP_TYPE_IN; } + case 399: /* in_op ::= IN */ +{ yymsp[0].minor.yy194 = OP_TYPE_IN; } break; - case 394: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy392 = OP_TYPE_NOT_IN; } + case 400: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy194 = OP_TYPE_NOT_IN; } break; - case 395: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy172)); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 401: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy574)); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 397: /* boolean_value_expression ::= NOT boolean_primary */ + case 403: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy272), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL)); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 398: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 404: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 399: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 405: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy272); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy272); - yylhsminor.yy272 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80); + yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 405: /* from_clause_opt ::= FROM table_reference_list */ - case 434: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==434); - case 457: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==457); -{ yymsp[-1].minor.yy272 = yymsp[0].minor.yy272; } + case 411: /* from_clause_opt ::= FROM table_reference_list */ + case 440: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==440); + case 463: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==463); +{ yymsp[-1].minor.yy80 = yymsp[0].minor.yy80; } break; - case 407: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy272 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy272, yymsp[0].minor.yy272, NULL); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 413: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy80 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, NULL); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 410: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy272 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 416: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 411: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy272 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 417: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-3].minor.yy239, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 412: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy272 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 418: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy80 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy239); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 414: /* alias_opt ::= */ -{ yymsp[1].minor.yy209 = nil_token; } + case 420: /* alias_opt ::= */ +{ yymsp[1].minor.yy239 = nil_token; } break; - case 415: /* alias_opt ::= table_alias */ -{ yylhsminor.yy209 = yymsp[0].minor.yy209; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 421: /* alias_opt ::= table_alias */ +{ yylhsminor.yy239 = yymsp[0].minor.yy239; } + yymsp[0].minor.yy239 = yylhsminor.yy239; break; - case 416: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } + case 422: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy239 = yymsp[0].minor.yy239; } break; - case 417: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 418: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==418); -{ yymsp[-2].minor.yy272 = yymsp[-1].minor.yy272; } + case 423: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 424: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==424); +{ yymsp[-2].minor.yy80 = yymsp[-1].minor.yy80; } break; - case 419: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy272 = createJoinTableNode(pCxt, yymsp[-4].minor.yy156, yymsp[-5].minor.yy272, yymsp[-2].minor.yy272, yymsp[0].minor.yy272); } - yymsp[-5].minor.yy272 = yylhsminor.yy272; + case 425: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy80 = createJoinTableNode(pCxt, yymsp[-4].minor.yy750, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-5].minor.yy80 = yylhsminor.yy80; break; - case 420: /* join_type ::= */ -{ yymsp[1].minor.yy156 = JOIN_TYPE_INNER; } + case 426: /* join_type ::= */ +{ yymsp[1].minor.yy750 = JOIN_TYPE_INNER; } break; - case 421: /* join_type ::= INNER */ -{ yymsp[0].minor.yy156 = JOIN_TYPE_INNER; } + case 427: /* join_type ::= INNER */ +{ yymsp[0].minor.yy750 = JOIN_TYPE_INNER; } break; - case 422: /* 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 428: /* 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.yy272 = createSelectStmt(pCxt, yymsp[-10].minor.yy293, yymsp[-9].minor.yy172, yymsp[-8].minor.yy272); - yymsp[-11].minor.yy272 = addWhereClause(pCxt, yymsp[-11].minor.yy272, yymsp[-7].minor.yy272); - yymsp[-11].minor.yy272 = addPartitionByClause(pCxt, yymsp[-11].minor.yy272, yymsp[-6].minor.yy172); - yymsp[-11].minor.yy272 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy272, yymsp[-2].minor.yy272); - yymsp[-11].minor.yy272 = addGroupByClause(pCxt, yymsp[-11].minor.yy272, yymsp[-1].minor.yy172); - yymsp[-11].minor.yy272 = addHavingClause(pCxt, yymsp[-11].minor.yy272, yymsp[0].minor.yy272); - yymsp[-11].minor.yy272 = addRangeClause(pCxt, yymsp[-11].minor.yy272, yymsp[-5].minor.yy272); - yymsp[-11].minor.yy272 = addEveryClause(pCxt, yymsp[-11].minor.yy272, yymsp[-4].minor.yy272); - yymsp[-11].minor.yy272 = addFillClause(pCxt, yymsp[-11].minor.yy272, yymsp[-3].minor.yy272); + yymsp[-11].minor.yy80 = createSelectStmt(pCxt, yymsp[-10].minor.yy845, yymsp[-9].minor.yy574, yymsp[-8].minor.yy80); + yymsp[-11].minor.yy80 = addWhereClause(pCxt, yymsp[-11].minor.yy80, yymsp[-7].minor.yy80); + yymsp[-11].minor.yy80 = addPartitionByClause(pCxt, yymsp[-11].minor.yy80, yymsp[-6].minor.yy574); + yymsp[-11].minor.yy80 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy80, yymsp[-2].minor.yy80); + yymsp[-11].minor.yy80 = addGroupByClause(pCxt, yymsp[-11].minor.yy80, yymsp[-1].minor.yy574); + yymsp[-11].minor.yy80 = addHavingClause(pCxt, yymsp[-11].minor.yy80, yymsp[0].minor.yy80); + yymsp[-11].minor.yy80 = addRangeClause(pCxt, yymsp[-11].minor.yy80, yymsp[-5].minor.yy80); + yymsp[-11].minor.yy80 = addEveryClause(pCxt, yymsp[-11].minor.yy80, yymsp[-4].minor.yy80); + yymsp[-11].minor.yy80 = addFillClause(pCxt, yymsp[-11].minor.yy80, yymsp[-3].minor.yy80); } break; - case 425: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy293 = false; } + case 431: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy845 = false; } break; - case 428: /* select_item ::= NK_STAR */ -{ yylhsminor.yy272 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy272 = yylhsminor.yy272; + case 434: /* select_item ::= NK_STAR */ +{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy80 = yylhsminor.yy80; break; - case 430: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy272 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy272 = yylhsminor.yy272; + case 436: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy239); } + yymsp[-1].minor.yy80 = yylhsminor.yy80; break; - case 431: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy272 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), &yymsp[0].minor.yy209); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 437: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), &yymsp[0].minor.yy239); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 436: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 453: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==453); - case 469: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==469); -{ yymsp[-2].minor.yy172 = yymsp[0].minor.yy172; } + case 442: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 459: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==459); + case 475: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==475); +{ yymsp[-2].minor.yy574 = yymsp[0].minor.yy574; } break; - case 438: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy272 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); } + case 444: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy80 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 439: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy272 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); } + case 445: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy80 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 440: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy272 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), NULL, yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } + case 446: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 441: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy272 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy272), releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), yymsp[-1].minor.yy272, yymsp[0].minor.yy272); } + case 447: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); } break; - case 443: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 461: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==461); -{ yymsp[-3].minor.yy272 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy272); } + case 449: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 467: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==467); +{ yymsp[-3].minor.yy80 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy80); } break; - case 445: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy272 = createFillNode(pCxt, yymsp[-1].minor.yy186, NULL); } + case 451: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy80 = createFillNode(pCxt, yymsp[-1].minor.yy426, NULL); } break; - case 446: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy272 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy172)); } + case 452: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy574)); } break; - case 447: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy186 = FILL_MODE_NONE; } + case 453: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy426 = FILL_MODE_NONE; } break; - case 448: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy186 = FILL_MODE_PREV; } + case 454: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy426 = FILL_MODE_PREV; } break; - case 449: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy186 = FILL_MODE_NULL; } + case 455: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy426 = FILL_MODE_NULL; } break; - case 450: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy186 = FILL_MODE_LINEAR; } + case 456: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy426 = FILL_MODE_LINEAR; } break; - case 451: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy186 = FILL_MODE_NEXT; } + case 457: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy426 = FILL_MODE_NEXT; } break; - case 454: /* group_by_list ::= expression */ -{ yylhsminor.yy172 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 460: /* group_by_list ::= expression */ +{ yylhsminor.yy574 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } + yymsp[0].minor.yy574 = yylhsminor.yy574; break; - case 455: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy172 = addNodeToList(pCxt, yymsp[-2].minor.yy172, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy272))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 461: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); } + yymsp[-2].minor.yy574 = yylhsminor.yy574; break; - case 459: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy272 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy272), releaseRawExprNode(pCxt, yymsp[-1].minor.yy272)); } + case 465: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy80 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); } break; - case 462: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 468: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy272 = addOrderByClause(pCxt, yymsp[-3].minor.yy272, yymsp[-2].minor.yy172); - yylhsminor.yy272 = addSlimitClause(pCxt, yylhsminor.yy272, yymsp[-1].minor.yy272); - yylhsminor.yy272 = addLimitClause(pCxt, yylhsminor.yy272, yymsp[0].minor.yy272); + yylhsminor.yy80 = addOrderByClause(pCxt, yymsp[-3].minor.yy80, yymsp[-2].minor.yy574); + yylhsminor.yy80 = addSlimitClause(pCxt, yylhsminor.yy80, yymsp[-1].minor.yy80); + yylhsminor.yy80 = addLimitClause(pCxt, yylhsminor.yy80, yymsp[0].minor.yy80); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 464: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy272 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy272, yymsp[0].minor.yy272); } - yymsp[-3].minor.yy272 = yylhsminor.yy272; + case 470: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-3].minor.yy80 = yylhsminor.yy80; break; - case 465: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy272 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy272, yymsp[0].minor.yy272); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 471: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 467: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + case 473: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ { - yymsp[-5].minor.yy272 = addOrderByClause(pCxt, yymsp[-4].minor.yy272, yymsp[-3].minor.yy172); - yymsp[-5].minor.yy272 = addSlimitClause(pCxt, yymsp[-5].minor.yy272, yymsp[-2].minor.yy272); - yymsp[-5].minor.yy272 = addLimitClause(pCxt, yymsp[-5].minor.yy272, yymsp[-1].minor.yy272); + yymsp[-5].minor.yy80 = addOrderByClause(pCxt, yymsp[-4].minor.yy80, yymsp[-3].minor.yy574); + yymsp[-5].minor.yy80 = addSlimitClause(pCxt, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80); + yymsp[-5].minor.yy80 = addLimitClause(pCxt, yymsp[-5].minor.yy80, yymsp[-1].minor.yy80); } break; - case 471: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 475: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==475); -{ yymsp[-1].minor.yy272 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 477: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 481: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==481); +{ yymsp[-1].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 472: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 476: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==476); -{ yymsp[-3].minor.yy272 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 478: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 482: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==482); +{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 473: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 477: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==477); -{ yymsp[-3].minor.yy272 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 479: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 483: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==483); +{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 478: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy272 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy272); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 484: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy80); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 482: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy272 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy272), yymsp[-1].minor.yy818, yymsp[0].minor.yy493); } - yymsp[-2].minor.yy272 = yylhsminor.yy272; + case 488: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy80 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), yymsp[-1].minor.yy422, yymsp[0].minor.yy763); } + yymsp[-2].minor.yy80 = yylhsminor.yy80; break; - case 483: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy818 = ORDER_ASC; } + case 489: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy422 = ORDER_ASC; } break; - case 484: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy818 = ORDER_ASC; } + case 490: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy422 = ORDER_ASC; } break; - case 485: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy818 = ORDER_DESC; } + case 491: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy422 = ORDER_DESC; } break; - case 486: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy493 = NULL_ORDER_DEFAULT; } + case 492: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy763 = NULL_ORDER_DEFAULT; } break; - case 487: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy493 = NULL_ORDER_FIRST; } + case 493: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_FIRST; } break; - case 488: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy493 = NULL_ORDER_LAST; } + case 494: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy763 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index b376c33d1aca8951ed31297cd12a1843ebf47462..7725674200c9e9c931f4640a1eecbed7e16b55f2 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -32,100 +32,59 @@ namespace { void generateInformationSchema(MockCatalogService* mcs) { - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1) - .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1) - .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1) - .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1) - .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DATABASES, TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_FUNCTIONS, TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_INDEXES, TSDB_SYSTEM_TABLE, 3) - .addColumn("index_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STABLES, TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS, TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1) - .addColumn("dnode_id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CLUSTER, TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN); - builder.done(); - } + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1) + .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DATABASES, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_FUNCTIONS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_INDEXES, TSDB_SYSTEM_TABLE, 3) + .addColumn("index_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USERS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1) + .addColumn("dnode_id", TSDB_DATA_TYPE_INT) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CLUSTER, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN) + .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VNODES, TSDB_SYSTEM_TABLE, 2) + .addColumn("dnode_id", TSDB_DATA_TYPE_INT) + .addColumn("dnode_ep", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN) + .done(); } void generatePerformanceSchema(MockCatalogService* mcs) { @@ -137,7 +96,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) { } { ITableBuilder& builder = - mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); } @@ -149,7 +108,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) { } { ITableBuilder& builder = - mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); } diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 1caba6eab0384019b01f0c4957a6b9b9ffa1a5d1..8eb64719b28414b34c7969fae9876d36a33925ef 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -88,6 +88,7 @@ TEST_F(ParserInitialATest, alterDnode) { * | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica * | STRICT {'off' | 'on'} -- todo: default 'off' * | WAL_LEVEL int_value -- enum 1, 2, default 1 + * | SST_TRIGGER int_value -- rang [1, 128], default 8 * } */ TEST_F(ParserInitialATest, alterDatabase) { @@ -112,6 +113,7 @@ TEST_F(ParserInitialATest, alterDatabase) { expect.cacheLast = -1; expect.cacheLastSize = -1; expect.replications = -1; + expect.sstTrigger = -1; }; auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; }; auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; }; @@ -128,6 +130,7 @@ TEST_F(ParserInitialATest, alterDatabase) { auto setAlterDbStrict = [&](int8_t strict) { expect.strict = strict; }; auto setAlterDbCacheModel = [&](int8_t cacheModel) { expect.cacheLast = cacheModel; }; auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; }; + auto setAlterDbSstTrigger = [&](int8_t sstTrigger) { expect.sstTrigger = sstTrigger; }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT); @@ -146,6 +149,7 @@ TEST_F(ParserInitialATest, alterDatabase) { ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLast, expect.cacheLast); ASSERT_EQ(req.replications, expect.replications); + ASSERT_EQ(req.sstTrigger, expect.sstTrigger); }); const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE; @@ -157,7 +161,8 @@ TEST_F(ParserInitialATest, alterDatabase) { setAlterDbFsync(200); setAlterDbWal(1); setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_ROW); - run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 WAL_LEVEL 1"); + setAlterDbSstTrigger(20); + run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 WAL_LEVEL 1 SST_TRIGGER 20"); clearAlterDbReq(); initAlterDb("test"); @@ -231,6 +236,8 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) { run("ALTER DATABASE test KEEP 1w", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test WAL_LEVEL 0", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test WAL_LEVEL 3", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("ALTER DATABASE test SST_TRIGGER 0", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("ALTER DATABASE test SST_TRIGGER 129", TSDB_CODE_PAR_INVALID_DB_OPTION); // Regardless of the specific sentence run("ALTER DATABASE db WAL_LEVEL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE); } diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 68c4ac3706e2a42fd370a96a85d1adf6df162774..28bcae53ef4036ae7aa07e43fd93d059669b828b 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -111,10 +111,13 @@ TEST_F(ParserInitialCTest, createDatabase) { expect.numOfVgroups = TSDB_DEFAULT_VN_PER_DB; expect.numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE; expect.schemaless = TSDB_DEFAULT_DB_SCHEMALESS; - expect.walRetentionPeriod = TSDB_DEFAULT_DB_WAL_RETENTION_PERIOD; - expect.walRetentionSize = TSDB_DEFAULT_DB_WAL_RETENTION_SIZE; - expect.walRollPeriod = TSDB_DEFAULT_DB_WAL_ROLL_PERIOD; + expect.walRetentionPeriod = TSDB_REP_DEF_DB_WAL_RET_PERIOD; + expect.walRetentionSize = TSDB_REP_DEF_DB_WAL_RET_SIZE; + expect.walRollPeriod = TSDB_REP_DEF_DB_WAL_ROLL_PERIOD; expect.walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE; + expect.sstTrigger = TSDB_DEFAULT_SST_TRIGGER; + expect.hashPrefix = TSDB_DEFAULT_HASH_PREFIX; + expect.hashSuffix = TSDB_DEFAULT_HASH_SUFFIX; }; auto setDbBufferFunc = [&](int32_t buffer) { expect.buffer = buffer; }; @@ -155,6 +158,9 @@ TEST_F(ParserInitialCTest, createDatabase) { auto setDbWalRetentionSize = [&](int32_t walRetentionSize) { expect.walRetentionSize = walRetentionSize; }; auto setDbWalRollPeriod = [&](int32_t walRollPeriod) { expect.walRollPeriod = walRollPeriod; }; auto setDbWalSegmentSize = [&](int32_t walSegmentSize) { expect.walSegmentSize = walSegmentSize; }; + auto setDbSstTrigger = [&](int32_t sstTrigger) { expect.sstTrigger = sstTrigger; }; + auto setDbHashPrefix = [&](int32_t hashPrefix) { expect.hashPrefix = hashPrefix; }; + auto setDbHashSuffix = [&](int32_t hashSuffix) { expect.hashSuffix = hashSuffix; }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DATABASE_STMT); @@ -185,7 +191,9 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize); ASSERT_EQ(req.walRollPeriod, expect.walRollPeriod); ASSERT_EQ(req.walSegmentSize, expect.walSegmentSize); - // ASSERT_EQ(req.schemaless, expect.schemaless); + ASSERT_EQ(req.sstTrigger, expect.sstTrigger); + ASSERT_EQ(req.hashPrefix, expect.hashPrefix); + ASSERT_EQ(req.hashSuffix, expect.hashSuffix); ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); if (expect.numOfRetensions > 0) { @@ -233,6 +241,9 @@ TEST_F(ParserInitialCTest, createDatabase) { setDbWalRetentionSize(-1); setDbWalRollPeriod(10); setDbWalSegmentSize(20); + setDbSstTrigger(16); + setDbHashPrefix(3); + setDbHashSuffix(4); run("CREATE DATABASE IF NOT EXISTS wxy_db " "BUFFER 64 " "CACHEMODEL 'last_value' " @@ -256,7 +267,10 @@ TEST_F(ParserInitialCTest, createDatabase) { "WAL_RETENTION_PERIOD -1 " "WAL_RETENTION_SIZE -1 " "WAL_ROLL_PERIOD 10 " - "WAL_SEGMENT_SIZE 20"); + "WAL_SEGMENT_SIZE 20 " + "SST_TRIGGER 16 " + "TABLE_PREFIX 3" + "TABLE_SUFFIX 4"); clearCreateDbReq(); setCreateDbReqFunc("wxy_db", 1); @@ -266,6 +280,14 @@ TEST_F(ParserInitialCTest, createDatabase) { "DURATION 100m " "KEEP 1440m,300h,400d "); clearCreateDbReq(); + + setCreateDbReqFunc("wxy_db", 1); + setDbReplicaFunc(3); + setDbWalRetentionPeriod(TSDB_REPS_DEF_DB_WAL_RET_PERIOD); + setDbWalRetentionSize(TSDB_REPS_DEF_DB_WAL_RET_SIZE); + setDbWalRollPeriod(TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD); + run("CREATE DATABASE IF NOT EXISTS wxy_db REPLICA 3"); + clearCreateDbReq(); } TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) { diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index 6590378565849e8b39bab100a324823e2d665848..e33252c072fb1b34e5801098e27c2a51bef51c68 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -218,7 +218,13 @@ TEST_F(ParserShowToUseTest, showVgroups) { run("SHOW test.vgroups"); } -// todo SHOW vnodes +TEST_F(ParserShowToUseTest, showVnodes) { + useDb("root", "test"); + + run("SHOW VNODES 1"); + + run("SHOW VNODES 'node1:7030'"); +} TEST_F(ParserShowToUseTest, splitVgroup) { useDb("root", "test"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 0667c5f5b9e2984d119dab5297abb16e374977fb..bf72f5210577d6f43f8ae97d098091b3020aeb16 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -197,28 +197,21 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols return SCAN_TYPE_TABLE; } -static SNode* createPrimaryKeyCol(uint64_t tableId) { +static SNode* createFirstCol(uint64_t tableId, const SSchema* pSchema) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { return NULL; } - pCol->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP; - pCol->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + pCol->node.resType.type = pSchema->type; + pCol->node.resType.bytes = pSchema->bytes; pCol->tableId = tableId; - pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + pCol->colId = pSchema->colId; pCol->colType = COLUMN_TYPE_COLUMN; - strcpy(pCol->colName, "#primarykey"); + strcpy(pCol->colName, pSchema->name); return (SNode*)pCol; } -static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) { - if (NULL == *pCols) { - *pCols = nodesMakeList(); - if (NULL == *pCols) { - return TSDB_CODE_OUT_OF_MEMORY; - } - } - +static int32_t addPrimaryKeyCol(uint64_t tableId, const SSchema* pSchema, SNodeList** pCols) { bool found = false; SNode* pCol = NULL; FOREACH(pCol, *pCols) { @@ -229,13 +222,25 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) { } if (!found) { - if (TSDB_CODE_SUCCESS != nodesListStrictAppend(*pCols, createPrimaryKeyCol(tableId))) { - return TSDB_CODE_OUT_OF_MEMORY; - } + return nodesListMakeStrictAppend(pCols, createFirstCol(tableId, pSchema)); } return TSDB_CODE_SUCCESS; } +static int32_t addSystableFirstCol(uint64_t tableId, const SSchema* pSchema, SNodeList** pCols) { + if (LIST_LENGTH(*pCols) > 0) { + return TSDB_CODE_SUCCESS; + } + return nodesListMakeStrictAppend(pCols, createFirstCol(tableId, pSchema)); +} + +static int32_t addDefaultScanCol(const STableMeta* pMeta, SNodeList** pCols) { + if (TSDB_SYSTEM_TABLE == pMeta->tableType) { + return addSystableFirstCol(pMeta->uid, pMeta->schema, pCols); + } + return addPrimaryKeyCol(pMeta->uid, pMeta->schema, pCols); +} + static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealTable, bool hasRepeatScanFuncs, SLogicNode** pLogicNode) { SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); @@ -299,8 +304,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pScan->hasNormalCols = true; } - if (TSDB_CODE_SUCCESS == code && SCAN_TYPE_SYSTEM_TABLE != pScan->scanType) { - code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols); + if (TSDB_CODE_SUCCESS == code) { + code = addDefaultScanCol(pRealTable->pMeta, &pScan->pScanCols); } // set output @@ -787,10 +792,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele static EDealRes needFillValueImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { SColumnNode* pCol = (SColumnNode*)pNode; - if (COLUMN_TYPE_WINDOW_START != pCol->colType && - COLUMN_TYPE_WINDOW_END != pCol->colType && - COLUMN_TYPE_WINDOW_DURATION != pCol->colType && - COLUMN_TYPE_GROUP_KEY != pCol->colType) { + if (COLUMN_TYPE_WINDOW_START != pCol->colType && COLUMN_TYPE_WINDOW_END != pCol->colType && + COLUMN_TYPE_WINDOW_DURATION != pCol->colType && COLUMN_TYPE_GROUP_KEY != pCol->colType) { *(bool*)pContext = true; return DEAL_RES_END; } @@ -1008,7 +1011,8 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets); if (TSDB_CODE_SUCCESS == code && NULL == pPartition->node.pTargets) { - code = nodesListMakeStrictAppend(&pPartition->node.pTargets, nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); + code = nodesListMakeStrictAppend(&pPartition->node.pTargets, + nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); } if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 653291d3a478adbe2ada475de8d64f24ed146e67..b160f45479a8e11a160fc092b7af536c4165436a 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -16,6 +16,7 @@ #include "filter.h" #include "functionMgt.h" #include "planInt.h" +#include "tglobal.h" #include "ttime.h" #define OPTIMIZE_FLAG_MASK(n) (1 << n) @@ -1665,7 +1666,10 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { return false; } - if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { + // Super table scan requires project operator to merge packets to improve performance. + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) || + (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0)) && + TSDB_SUPER_TABLE == ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->tableType)) { return false; } @@ -2407,7 +2411,7 @@ static const SOptimizeRule optimizeRuleSet[] = { static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule)); static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { - if (0 == (qDebugFlag & DEBUG_DEBUG)) { + if (!tsQueryPlannerTrace) { return; } char* pStr = NULL; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index cafae18dbe812546f6ef931d804ca4a9e5c1a6fa..0cbb833a4d4506b5123b45a0184bbc6023b53c2a 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1324,7 +1324,8 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { SPartitionPhysiNode* pPart = - (SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION); + (SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, + pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION : QUERY_NODE_PHYSICAL_PLAN_PARTITION); if (NULL == pPart) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index c582994b7c319778477238ab26b99ce844cb8c1c..beb938b161ca1656f09d15c559351aa2e081df2a 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1427,7 +1427,7 @@ static const SSplitRule splitRuleSet[] = { static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { - if (0 == (qDebugFlag & DEBUG_DEBUG)) { + if (!tsQueryPlannerTrace) { return; } char* pStr = NULL; diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index c1296982e0217ae9b3c2e67b210f1922492cf547..baa1d1074c7d4bea0df280649777db4a659247cb 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -17,9 +17,10 @@ #include "planInt.h" #include "scalar.h" +#include "tglobal.h" static void dumpQueryPlan(SQueryPlan* pPlan) { - if (0 == (qDebugFlag & DEBUG_DEBUG)) { + if (!tsQueryPlannerTrace) { return; } char* pStr = NULL; diff --git a/source/libs/planner/test/planSysTbTest.cpp b/source/libs/planner/test/planSysTbTest.cpp index 921f86f09a41d36448ab0d435ab6a439645b9bfc..6b40e381cc18cb75cc9271352cd654d31a74242b 100644 --- a/source/libs/planner/test/planSysTbTest.cpp +++ b/source/libs/planner/test/planSysTbTest.cpp @@ -32,3 +32,9 @@ TEST_F(PlanSysTableTest, informationSchema) { run("SELECT * FROM information_schema.ins_databases WHERE name = 'information_schema'"); } + +TEST_F(PlanSysTableTest, withAgg) { + useDb("root", "information_schema"); + + run("SELECT COUNT(1) FROM ins_users"); +} diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index f904643be91298fd8bcd1164334663af32851e98..96f7d29230bafc94639be35fcc56550c029ffbac 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -278,12 +278,12 @@ class PlannerTestBaseImpl { } void dump(DumpModule module) { + cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; + if (DUMP_MODULE_NOTHING == module) { return; } - cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; - if (DUMP_MODULE_ALL == module || DUMP_MODULE_PARSER == module) { if (res_.prepareAst_.empty()) { cout << "+++++++++++++++++++++syntax tree : " << endl; diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index 87327a365763771775106851f6442a66887d5bbc..e7695b2f04ea4fed2ebf9a77bf00717e1978003e 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -276,7 +276,7 @@ struct SFilterInfo { #define FILTER_CLR_FLAG(st, f) st &= (~f) #define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src) -#define FILTER_PACKAGE_UNIT_HASH_KEY(v, optr, idx1, idx2) do { char *_t = (char *)v; _t[0] = optr; *(uint32_t *)(_t + 1) = idx1; *(uint32_t *)(_t + 3) = idx2; } while (0) +#define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) do { char *_t = (char *)(v); _t[0] = (op1); _t[1] = (op2); *(uint32_t *)(_t + 2) = (lidx); *(uint32_t *)(_t + 2 + sizeof(uint32_t)) = (ridx); } while (0) #define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RANGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag,RANGE_FLG_EXCLUDE)))) #define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 5555a52c8e171a50bac4fa9f7b894ce4b8156b60..9e676354374fce6c2e733ac8d42c45baef9bada8 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1068,14 +1068,14 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f return TSDB_CODE_SUCCESS; } -int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint32_t *uidx) { +int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint8_t optr2, SFilterFieldId *right2, uint32_t *uidx) { if (FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { if (info->pctx.unitHash == NULL) { info->pctx.unitHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_UNIT_SIZE, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, false); } else { - int64_t v = 0; - FILTER_PACKAGE_UNIT_HASH_KEY(&v, optr, left->idx, right ? right->idx : -1); - void *hu = taosHashGet(info->pctx.unitHash, &v, sizeof(v)); + char v[14] = {0}; + FLT_PACKAGE_UNIT_HASH_KEY(&v, optr, optr2, left->idx, (right ? right->idx : -1), (right2 ? right2->idx : -1)); + void *hu = taosHashGet(info->pctx.unitHash, v, sizeof(v)); if (hu) { *uidx = *(uint32_t *)hu; return TSDB_CODE_SUCCESS; @@ -1097,7 +1097,11 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi if (right) { u->right = *right; } - + u->compare.optr2 = optr2; + if (right2) { + u->right2 = *right2; + } + if (u->right.type == FLD_TYPE_VALUE) { SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); assert(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); @@ -1118,9 +1122,9 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi *uidx = info->unitNum; if (FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { - int64_t v = 0; - FILTER_PACKAGE_UNIT_HASH_KEY(&v, optr, left->idx, right ? right->idx : -1); - taosHashPut(info->pctx.unitHash, &v, sizeof(v), uidx, sizeof(*uidx)); + char v[14] = {0}; + FLT_PACKAGE_UNIT_HASH_KEY(&v, optr, optr2, left->idx, (right ? right->idx : -1), (right2 ? right2->idx : -1)); + taosHashPut(info->pctx.unitHash, v, sizeof(v), uidx, sizeof(*uidx)); } ++info->unitNum; @@ -1129,6 +1133,9 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi } +int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint32_t *uidx) { + return filterAddUnitImpl(info, optr, left, right, 0, NULL, uidx); +} int32_t filterAddUnitToGroup(SFilterGroup *group, uint32_t unitIdx) { if (group->unitNum >= group->unitSize) { @@ -1305,8 +1312,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan SIMPLE_COPY_VALUES(data2, &ra->e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); - filterAddUnitRight(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, uidx); + filterAddUnitImpl(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, + FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, &uidx); filterAddUnitToGroup(g, uidx); return TSDB_CODE_SUCCESS; } @@ -1380,8 +1387,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan SIMPLE_COPY_VALUES(data2, &r->ra.e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); - filterAddUnitRight(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, uidx); + filterAddUnitImpl(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, + FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, &uidx); filterAddUnitToGroup(g, uidx); } @@ -2231,6 +2238,44 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t return TSDB_CODE_SUCCESS; } +bool filterIsSameUnits(SFilterColInfo* pCol1, SFilterColInfo* pCol2) { + if (pCol1->type != pCol2->type) { + return false; + } + + if (RANGE_TYPE_MR_CTX == pCol1->type) { + SFilterRangeCtx* pCtx1 = (SFilterRangeCtx*)pCol1->info; + SFilterRangeCtx* pCtx2 = (SFilterRangeCtx*)pCol2->info; + + if ((pCtx1->isnull != pCtx2->isnull) || (pCtx1->notnull != pCtx2->notnull) || (pCtx1->isrange != pCtx2->isrange)) { + return false; + } + + + SFilterRangeNode* pNode1 = pCtx1->rs; + SFilterRangeNode* pNode2 = pCtx2->rs; + + while (true) { + if (NULL == pNode1 && NULL == pNode2) { + break; + } + + if (NULL == pNode1 || NULL == pNode2) { + return false; + } + + if (pNode1->ra.s != pNode2->ra.s || pNode1->ra.e != pNode2->ra.e || pNode1->ra.sflag != pNode2->ra.sflag || pNode1->ra.eflag != pNode2->ra.eflag) { + return false; + } + + pNode1 = pNode1->next; + pNode2 = pNode2->next; + } + } + + return true; +} + void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool *conflict) { uint32_t idx1 = 0, idx2 = 0, m = 0, n = 0; bool equal = false; @@ -2256,6 +2301,11 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool return; } + if (!filterIsSameUnits(&gRes1->colInfo[idx1], &gRes2->colInfo[idx2])) { + *conflict = true; + return; + } + // for long in operation if (gRes1->colInfo[idx1].optr == OP_TYPE_EQUAL && gRes2->colInfo[idx2].optr == OP_TYPE_EQUAL) { SFilterRangeCtx* ctx = gRes1->colInfo[idx1].info; @@ -2869,17 +2919,22 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 for (uint32_t g = 0; g < info->groupNum; ++g) { SFilterGroup *group = &info->groups[g]; + // first is block unint num for a group, following append unitNum blkUnitIdx for this group *unitNum = group->unitNum; all = 0; empty = 0; + // save group idx start pointer + uint32_t * pGroupIdx = unitIdx; for (uint32_t u = 0; u < group->unitNum; ++u) { uint32_t uidx = group->unitIdxs[u]; if (info->blkUnitRes[uidx] == 1) { + // blkUnitRes == 1 is always true, so need not compare every time, delete this unit from group --(*unitNum); all = 1; continue; } else if (info->blkUnitRes[uidx] == -1) { + // blkUnitRes == -1 is alwary false, so in group is alwary false, need delete this group from blkGroupNum *unitNum = 0; empty = 1; break; @@ -2889,6 +2944,9 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 } if (*unitNum == 0) { + // if unit num is zero, reset unitIdx to start on this group + unitIdx = pGroupIdx; + --info->blkGroupNum; assert(empty || all); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 9d4010f60e5fcb222e235181a2ce12b8d4dc4102..a2a45938e4f0091b0588bcb3ca4ac653045d27f7 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -243,6 +243,36 @@ FAIL: return 0; } +int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock, int32_t vgSz, + int64_t groupId) { + char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, groupId); + SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos; + + // TODO: get hash function by hashMethod + uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName)); + taosMemoryFree(ctbName); + bool found = false; + // TODO: optimize search + int32_t j; + for (j = 0; j < vgSz; j++) { + SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j); + ASSERT(pVgInfo->vgId > 0); + if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) { + if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) { + return -1; + } + if (pReqs[j].blockNum == 0) { + atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1); + } + pReqs[j].blockNum++; + found = true; + break; + } + } + ASSERT(found); + return 0; +} + int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pData) { int32_t code = -1; int32_t blockNum = taosArrayGetSize(pData->blocks); @@ -317,20 +347,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat for (int32_t i = 0; i < blockNum; i++) { SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i); - char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId); - - // TODO: get hash function by hashMethod - uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName)); - - taosMemoryFree(ctbName); - bool found = false; - // TODO: optimize search - int32_t j; - for (j = 0; j < vgSz; j++) { - SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j); - ASSERT(pVgInfo->vgId > 0); - if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) { + // TODO: do not use broadcast + if (pDataBlock->info.type == STREAM_DELETE_RESULT) { + for (int32_t j = 0; j < vgSz; j++) { if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) { goto FAIL_SHUFFLE_DISPATCH; } @@ -338,11 +358,13 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1); } pReqs[j].blockNum++; - found = true; - break; } + continue; + } + + if (streamSearchAndAddBlock(pTask, pReqs, pDataBlock, vgSz, pDataBlock->info.groupId) < 0) { + goto FAIL_SHUFFLE_DISPATCH; } - ASSERT(found); } for (int32_t i = 0; i < vgSz; i++) { diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index d053662bd30287d5d9589a3881c8588fd3eb82ec..332f7ad2fd7be60f532b1394eb2d72adf985b82a 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -170,8 +170,17 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { if (ts < maxTs - pInfo->watermark) { // this window has been closed. if (pInfo->pCloseWinSBF) { - return tScalableBfPut(pInfo->pCloseWinSBF, &ts, sizeof(TSKEY)); + res = tScalableBfPut(pInfo->pCloseWinSBF, &ts, sizeof(TSKEY)); + if (res == TSDB_CODE_SUCCESS) { + return false; + } else { + qDebug("===stream===Update close window sbf. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, + maxTs, *pMapMaxTs, ts); + return true; + } } + qDebug("===stream===Update close window. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, + maxTs, *pMapMaxTs, ts); return true; } @@ -193,7 +202,7 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { } if (ts < pInfo->minTS) { - qDebug("===stream===Update. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, + qDebug("===stream===Update min ts. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, maxTs, *pMapMaxTs, ts); return true; } else if (res == TSDB_CODE_SUCCESS) { diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 07c4fa8429dc539609d3ae788caab3352b0a3e60..3bda9bcd51a1fe41fbeb09a1e4a39c3a53f1cd74 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -163,6 +163,7 @@ int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pR } } ASSERT(0); + return -1; } void syncIndexMgrSetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t recvTime) { @@ -190,6 +191,7 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa } } ASSERT(0); + return -1; } // for debug ------------------- @@ -245,4 +247,5 @@ SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftI } } ASSERT(0); + return -1; } \ No newline at end of file diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 5489a107e76082106961a0ed107413e5ec9b4a64..0be3392a9a52b69e29cbcedcb910cdbc0f9a6234 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -583,7 +583,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap &(pReceiver->snapshot)); if (code != 0) { syncNodeErrorLog(pReceiver->pSyncNode, "snapshot stop writer true error"); - ASSERT(0); + // ASSERT(0); return -1; } pReceiver->pWriter = NULL; diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index af15c377fbc36ae523776824962f282462ff2bc9..c3c8131cbb31c3d4ac0b9fb59afc7bc751096329 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -91,16 +91,16 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { } else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) { if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->electTimerCounter); - sInfo("vgId:%d, sync timeout, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId, - ths->electTimerCounter, ths->electTimerLogicClockUser); + sTrace("vgId:%d, sync timer, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId, + ths->electTimerCounter, ths->electTimerLogicClockUser); syncNodeElect(ths); } } else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) { if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->heartbeatTimerCounter); - sInfo("vgId:%d, sync timeout, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId, - ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); + sTrace("vgId:%d, sync timer, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId, + ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); syncNodeReplicate(ths, true); } } else { diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index 386ea95dd795b93bcaa2826d471a6e4c97f81b7b..275e7b42cc10ed2a77934da84ed544a1874e0b28 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -21,6 +21,7 @@ #include "taoserror.h" #include "tlog.h" +// clang-format on #define HTTP_RECV_BUF_SIZE 1024 @@ -29,7 +30,7 @@ typedef struct SHttpClient { uv_tcp_t tcp; uv_write_t req; uv_buf_t* wbuf; - char *rbuf; + char* rbuf; char* addr; uint16_t port; } SHttpClient; @@ -130,35 +131,36 @@ static void destroyHttpClient(SHttpClient* cli) { taosMemoryFree(cli->rbuf); taosMemoryFree(cli->addr); taosMemoryFree(cli); - } static void clientCloseCb(uv_handle_t* handle) { SHttpClient* cli = handle->data; destroyHttpClient(cli); } -static void clientAllocBuffCb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { - SHttpClient* cli = handle->data; - buf->base = cli->rbuf; - buf->len = HTTP_RECV_BUF_SIZE; +static void clientAllocBuffCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { + SHttpClient* cli = handle->data; + buf->base = cli->rbuf; + buf->len = HTTP_RECV_BUF_SIZE; } -static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t *buf) { - SHttpClient* cli = handle->data; +static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { + SHttpClient* cli = handle->data; if (nread < 0) { uError("http-report recv error:%s", uv_err_name(nread)); } else { uTrace("http-report succ to recv %d bytes, just ignore it", nread); } uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); -} +} static void clientSentCb(uv_write_t* req, int32_t status) { SHttpClient* cli = req->data; if (status != 0) { terrno = TAOS_SYSTEM_ERROR(status); uError("http-report failed to send data %s", uv_strerror(status)); + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + return; } else { uTrace("http-report succ to send data"); } - uv_read_start((uv_stream_t *)&cli->tcp, clientAllocBuffCb, clientRecvCb); + uv_read_start((uv_stream_t*)&cli->tcp, clientAllocBuffCb, clientRecvCb); } static void clientConnCb(uv_connect_t* req, int32_t status) { SHttpClient* cli = req->data; @@ -210,7 +212,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32 cli->tcp.data = cli; cli->req.data = cli; cli->wbuf = wb; - cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE); + cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE); cli->addr = tstrdup(server); cli->port = port; @@ -231,4 +233,3 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32 uv_loop_close(loop); return terrno; } -// clang-format on diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 0a0dcef378bde92a18b9455b203774a3c28aa428..9e0a8f2a10c282cc8ef20e59f89aed477d5c1eef 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -43,7 +43,7 @@ void* rpcOpen(const SRpcInit* pInit) { return NULL; } if (pInit->label) { - tstrncpy(pRpc->label, pInit->label, strlen(pInit->label) + 1); + tstrncpy(pRpc->label, pInit->label, TSDB_LABEL_LEN); } // register callback handle pRpc->cfp = pInit->cfp; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 7052b0b915137678d6aff528a26540a973cd74f5..4b5441f738d303fd8286e4cf856d1feacfee3eb5 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -16,7 +16,7 @@ #include "transComm.h" typedef struct SConnList { - queue conn; + queue conns; int32_t size; } SConnList; @@ -107,11 +107,11 @@ static void doCloseIdleConn(void* param); static void cliReadTimeoutCb(uv_timer_t* handle); // register timer in each thread to clear expire conn // static void cliTimeoutCb(uv_timer_t* handle); -// alloc buf for recv +// alloc buffer for recv static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf); -// callback after read nbytes from socket +// callback after recv nbytes from socket static void cliRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf); -// callback after write data to socket +// callback after send data to socket static void cliSendCb(uv_write_t* req, int status); // callback after conn to server static void cliConnCb(uv_connect_t* req, int status); @@ -129,19 +129,14 @@ static SCliConn* cliCreateConn(SCliThrd* thrd); static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); static void cliDestroy(uv_handle_t* handle); static void cliSend(SCliConn* pConn); +static void cliDestroyConnMsgs(SCliConn* conn, bool destroy); -static bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) { - if (code != 0) return false; - if (pCtx->retryCnt == 0) return false; - if (transEpSetIsEqual(&pCtx->epSet, &pCtx->origEpSet)) return false; - return true; -} +// cli util func +static bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx); +static void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr); + +static int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* resp); -void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr); -/* - * set TCP connection timeout per-socket level - */ -static int cliCreateSocket(); // process data read from server, add decompress etc later static void cliHandleResp(SCliConn* conn); // handle except about conn @@ -169,15 +164,14 @@ static void destroyThrdObj(SCliThrd* pThrd); static void cliWalkCb(uv_handle_t* handle, void* arg); static void cliReleaseUnfinishedMsg(SCliConn* conn) { - SCliMsg* pMsg = NULL; for (int i = 0; i < transQueueSize(&conn->cliMsgs); i++) { - pMsg = transQueueGet(&conn->cliMsgs, i); - if (pMsg != NULL && pMsg->ctx != NULL) { - if (conn->ctx.freeFunc != NULL) { - conn->ctx.freeFunc(pMsg->ctx->ahandle); + SCliMsg* msg = transQueueGet(&conn->cliMsgs, i); + if (msg != NULL && msg->ctx != NULL) { + if (conn->ctx.freeFunc != NULL && msg->ctx->ahandle != NULL) { + conn->ctx.freeFunc(msg->ctx->ahandle); } } - destroyCmsg(pMsg); + destroyCmsg(msg); } } #define CLI_RELEASE_UV(loop) \ @@ -217,8 +211,10 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { } \ if (i == sz) { \ pMsg = NULL; \ + tDebug("msg not found, %" PRIu64 "", ahandle); \ } else { \ pMsg = transQueueRm(&conn->cliMsgs, i); \ + tDebug("msg found, %" PRIu64 "", ahandle); \ } \ } while (0) #define CONN_GET_NEXT_SENDMSG(conn) \ @@ -470,8 +466,8 @@ void* createConnPool(int size) { void* destroyConnPool(void* pool) { SConnList* connList = taosHashIterate((SHashObj*)pool, NULL); while (connList != NULL) { - while (!QUEUE_IS_EMPTY(&connList->conn)) { - queue* h = QUEUE_HEAD(&connList->conn); + while (!QUEUE_IS_EMPTY(&connList->conns)) { + queue* h = QUEUE_HEAD(&connList->conns); SCliConn* c = QUEUE_DATA(h, SCliConn, q); cliDestroyConn(c, true); } @@ -484,21 +480,21 @@ void* destroyConnPool(void* pool) { static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { char key[32] = {0}; CONN_CONSTRUCT_HASH_KEY(key, ip, port); - SHashObj* pPool = pool; - SConnList* plist = taosHashGet(pPool, key, strlen(key)); + + SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key)); if (plist == NULL) { SConnList list = {0}; - taosHashPut(pPool, key, strlen(key), (void*)&list, sizeof(list)); - plist = taosHashGet(pPool, key, strlen(key)); - QUEUE_INIT(&plist->conn); + taosHashPut((SHashObj*)pool, key, strlen(key), (void*)&list, sizeof(list)); + plist = taosHashGet((SHashObj*)pool, key, strlen(key)); + QUEUE_INIT(&plist->conns); } - if (QUEUE_IS_EMPTY(&plist->conn)) { + if (QUEUE_IS_EMPTY(&plist->conns)) { return NULL; } plist->size -= 1; - queue* h = QUEUE_HEAD(&plist->conn); + queue* h = QUEUE_HEAD(&plist->conns); SCliConn* conn = QUEUE_DATA(h, SCliConn, q); conn->status = ConnNormal; QUEUE_REMOVE(&conn->q); @@ -514,22 +510,21 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->status == ConnInPool) { return; } - SCliThrd* thrd = conn->hostThrd; - CONN_HANDLE_THREAD_QUIT(thrd); - allocConnRef(conn, true); + SCliThrd* thrd = conn->hostThrd; if (conn->timer != NULL) { uv_timer_stop(conn->timer); taosArrayPush(thrd->timerList, &conn->timer); conn->timer->data = NULL; conn->timer = NULL; } + if (T_REF_VAL_GET(conn) > 1) { + transUnrefCliHandle(conn); + } + + cliDestroyConnMsgs(conn, false); - STrans* pTransInst = thrd->pTransInst; - cliReleaseUnfinishedMsg(conn); - transQueueClear(&conn->cliMsgs); - transCtxCleanup(&conn->ctx); conn->status = ConnInPool; if (conn->list == NULL) { @@ -540,18 +535,15 @@ static void addConnToPool(void* pool, SCliConn* conn) { } else { tTrace("%s conn %p added to conn pool, read buf cap:%d", CONN_GET_INST_LABEL(conn), conn, conn->readBuf.cap); } - assert(conn->list != NULL); - QUEUE_INIT(&conn->q); - QUEUE_PUSH(&conn->list->conn, &conn->q); + QUEUE_PUSH(&conn->list->conns, &conn->q); conn->list->size += 1; - conn->task = NULL; - assert(!QUEUE_IS_EMPTY(&conn->list->conn)); - if (conn->list->size >= 50) { STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); arg->param1 = conn; arg->param2 = thrd; + + STrans* pTransInst = thrd->pTransInst; conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, CONN_PERSIST_TIME(pTransInst->idleTime)); } } @@ -691,11 +683,10 @@ static void cliDestroy(uv_handle_t* handle) { transRemoveExHandle(transGetRefMgt(), conn->refId); taosMemoryFree(conn->ip); - conn->stream->data = NULL; taosMemoryFree(conn->stream); - transCtxCleanup(&conn->ctx); - cliReleaseUnfinishedMsg(conn); - transQueueDestroy(&conn->cliMsgs); + + cliDestroyConnMsgs(conn, true); + tTrace("%s conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); transReqQueueClear(&conn->wreqQueue); transDestroyBuffer(&conn->readBuf); @@ -738,8 +729,6 @@ static void cliSendCb(uv_write_t* req, int status) { } void cliSend(SCliConn* pConn) { - CONN_HANDLE_BROKEN(pConn); - assert(!transQueueEmpty(&pConn->cliMsgs)); SCliMsg* pCliMsg = NULL; @@ -756,8 +745,8 @@ void cliSend(SCliConn* pConn) { pMsg->pCont = (void*)rpcMallocCont(0); pMsg->contLen = 0; } - int msgLen = transMsgLenFromCont(pMsg->contLen); + int msgLen = transMsgLenFromCont(pMsg->contLen); STransMsgHead* pHead = transHeadFromCont(pMsg->pCont); pHead->ahandle = pCtx != NULL ? (uint64_t)pCtx->ahandle : 0; pHead->noResp = REQUEST_NO_RESP(pMsg) ? 1 : 0; @@ -769,8 +758,6 @@ void cliSend(SCliConn* pConn) { pHead->traceId = pMsg->info.traceId; pHead->magicNum = htonl(TRANS_MAGIC_NUM); - uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); - STraceId* trace = &pMsg->info.traceId; tGDebug("%s conn %p %s is sent to %s, local info %s, len:%d", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, pMsg->contLen); @@ -792,6 +779,8 @@ void cliSend(SCliConn* pConn) { tGTrace("%s conn %p start timer for msg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType)); uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0); } + + uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); uv_write_t* req = transReqQueuePush(&pConn->wreqQueue); uv_write(req, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb); return; @@ -807,7 +796,6 @@ void cliConnCb(uv_connect_t* req, int status) { cliHandleExcept(pConn); return; } - // int addrlen = sizeof(pConn->addr); struct sockaddr peername, sockname; int addrlen = sizeof(peername); @@ -840,7 +828,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) { int64_t refId = (int64_t)(pMsg->msg.info.handle); SExHandle* exh = transAcquireExHandle(transGetRefMgt(), refId); if (exh == NULL) { - tDebug("%" PRId64 " already release", refId); + tDebug("%" PRId64 " already released", refId); destroyCmsg(pMsg); return; } @@ -856,6 +844,9 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) { return; } cliSend(conn); + } else { + tError("%s conn %p already released", CONN_GET_INST_LABEL(conn), conn); + destroyCmsg(pMsg); } } static void cliHandleUpdate(SCliMsg* pMsg, SCliThrd* pThrd) { @@ -905,6 +896,27 @@ void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) { } } } + +bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) { + if (code != 0) return false; + if (pCtx->retryCnt == 0) return false; + if (transEpSetIsEqual(&pCtx->epSet, &pCtx->origEpSet)) return false; + return true; +} + +int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) { + if (pMsg == NULL) return -1; + + memset(pResp, 0, sizeof(STransMsg)); + + pResp->code = TSDB_CODE_RPC_BROKEN_LINK; + pResp->msgType = pMsg->msg.msgType + 1; + pResp->info.ahandle = pMsg->ctx ? pMsg->ctx->ahandle : NULL; + pResp->info.traceId = pMsg->msg.info.traceId; + + return 0; +} + void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { STrans* pTransInst = pThrd->pTransInst; STransConnCtx* pCtx = pMsg->ctx; @@ -920,13 +932,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { SCliConn* conn = cliGetConn(pMsg, pThrd, &ignore); if (ignore == true) { // persist conn already release by server - STransMsg resp = {0}; - resp.code = TSDB_CODE_RPC_BROKEN_LINK; - resp.msgType = pMsg->msg.msgType + 1; - - resp.info.ahandle = pMsg && pMsg->ctx ? pMsg->ctx->ahandle : NULL; - resp.info.traceId = pMsg->msg.info.traceId; - + STransMsg resp; + cliBuildExceptResp(pMsg, &resp); pTransInst->cfp(pTransInst->parent, &resp, NULL); destroyCmsg(pMsg); return; @@ -991,9 +998,6 @@ static void cliAsyncCb(uv_async_t* handle) { QUEUE_REMOVE(h); SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q); - if (pMsg == NULL) { - continue; - } (*cliAsyncHandle[pMsg->type])(pMsg, pThrd); count++; } @@ -1035,24 +1039,58 @@ static void cliPrepareCb(uv_prepare_t* handle) { if (thrd->stopMsg != NULL) cliHandleQuit(thrd->stopMsg, thrd); } +void cliDestroyConnMsgs(SCliConn* conn, bool destroy) { + transCtxCleanup(&conn->ctx); + cliReleaseUnfinishedMsg(conn); + if (destroy == 1) { + transQueueDestroy(&conn->cliMsgs); + } else { + transQueueClear(&conn->cliMsgs); + } +} + +void cliIteraConnMsgs(SCliConn* conn) { + SCliThrd* pThrd = conn->hostThrd; + STrans* pTransInst = pThrd->pTransInst; + + for (int i = 0; i < transQueueSize(&conn->cliMsgs); i++) { + SCliMsg* cmsg = transQueueGet(&conn->cliMsgs, i); + if (cmsg->type == Release || REQUEST_NO_RESP(&cmsg->msg) || cmsg->msg.msgType == TDMT_SCH_DROP_TASK) { + continue; + } + + STransMsg resp = {0}; + if (-1 == cliBuildExceptResp(cmsg, &resp)) { + continue; + } + pTransInst->cfp(pTransInst->parent, &resp, NULL); + + cmsg->ctx->ahandle = NULL; + } +} bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) { if (pHead->release == 1 && (pHead->msgLen) == sizeof(*pHead)) { uint64_t ahandle = pHead->ahandle; + tDebug("ahandle = %" PRIu64 "", ahandle); SCliMsg* pMsg = NULL; CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle); + transClearBuffer(&conn->readBuf); transFreeMsg(transContFromHead((char*)pHead)); - if (transQueueSize(&conn->cliMsgs) > 0 && ahandle == 0) { - SCliMsg* cliMsg = transQueueGet(&conn->cliMsgs, 0); - if (cliMsg->type == Release) return true; + + for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) { + SCliMsg* cliMsg = transQueueGet(&conn->cliMsgs, i); + if (cliMsg->type == Release) { + assert(pMsg == NULL); + return true; + } } + + cliIteraConnMsgs(conn); + tDebug("%s conn %p receive release request, refId:%" PRId64 "", CONN_GET_INST_LABEL(conn), conn, conn->refId); - if (T_REF_VAL_GET(conn) > 1) { - transUnrefCliHandle(conn); - } destroyCmsg(pMsg); - cliReleaseUnfinishedMsg(conn); - transQueueClear(&conn->cliMsgs); + addConnToPool(((SCliThrd*)conn->hostThrd)->pool, conn); return true; } @@ -1266,11 +1304,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pTransInst->cfp(pTransInst->parent, pResp, NULL); return 0; } - /* - * no retry - * 1. query conn - * 2. rpc thread already receive quit msg - */ + STransConnCtx* pCtx = pMsg->ctx; int32_t code = pResp->code; diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index a4d679b281512ff13757eab7c9c42a11e0edb36b..dea96fa3acf106f2956435dbff9b3511a8db1219 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -287,10 +287,10 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) { STransCtxVal* sVal = (STransCtxVal*)iter; key = taosHashGetKey(sVal, &klen); - STransCtxVal* dVal = taosHashGet(dst->args, key, klen); - if (dVal) { - dst->freeFunc(dVal->val); - } + // STransCtxVal* dVal = taosHashGet(dst->args, key, klen); + // if (dVal) { + // dst->freeFunc(dVal->val); + // } taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal)); iter = taosHashIterate(src->args, iter); } diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 207b967923fad439ed043a71752d127bac13934c..7007079f8760c944c70bbfe0798fb0fc518cf958 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -492,7 +492,6 @@ void uvWorkerAsyncCb(uv_async_t* handle) { // release handle to rpc init if (msg->type == Quit) { (*transAsyncHandle[msg->type])(msg, pThrd); - continue; } else { STransMsg transMsg = msg->msg; @@ -771,7 +770,7 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { // conn set QUEUE_INIT(&pThrd->conn); - pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 1, pThrd, uvWorkerAsyncCb); + pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 5, pThrd, uvWorkerAsyncCb); uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb); // uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); return true; @@ -907,23 +906,30 @@ static void uvDestroyConn(uv_handle_t* handle) { } } static void uvPipeListenCb(uv_stream_t* handle, int status) { - ASSERT(status == 0); + if (status != 0) { + tError("server failed to init pipe"); + return; + } SServerObj* srv = container_of(handle, SServerObj, pipeListen); uv_pipe_t* pipe = &(srv->pipe[srv->numOfWorkerReady][0]); - ASSERT(0 == uv_pipe_init(srv->loop, pipe, 1)); - ASSERT(0 == uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe)); - ASSERT(1 == uv_is_readable((uv_stream_t*)pipe)); - ASSERT(1 == uv_is_writable((uv_stream_t*)pipe)); - ASSERT(0 == uv_is_closing((uv_handle_t*)pipe)); + int ret = uv_pipe_init(srv->loop, pipe, 1); + assert(ret == 0); - srv->numOfWorkerReady++; + ret = uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe); + assert(ret == 0); - // ASSERT(0 == uv_listen((uv_stream_t*)&ctx.send.tcp, 512, uvOnAcceptCb)); + ret = uv_is_readable((uv_stream_t*)pipe); + assert(ret == 1); - // r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, read_cb); - // ASSERT(r == 0); + ret = uv_is_writable((uv_stream_t*)pipe); + assert(ret == 1); + + ret = uv_is_closing((uv_handle_t*)pipe); + assert(ret == 0); + + srv->numOfWorkerReady++; } void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { @@ -938,7 +944,9 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, srv->port = port; uv_loop_init(srv->loop); - assert(0 == uv_pipe_init(srv->loop, &srv->pipeListen, 0)); + int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0); + assert(ret == 0); + #ifdef WINDOWS char pipeName[64]; snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-" PRIu64, taosSafeRand(), GetCurrentProcessId()); @@ -947,8 +955,11 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(), taosGetSelfPthreadId()); #endif - assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName)); - assert(0 == uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb)); + ret = uv_pipe_bind(&srv->pipeListen, pipeName); + assert(ret == 0); + + ret = uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb); + assert(ret == 0); for (int i = 0; i < srv->numOfThreads; i++) { SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd)); diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index a5b5a2b7b4cac113978d8278ecf0a57686a67257..9db7d6c4554e3231399abd5ab470ea71f8207a37 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -372,7 +372,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) { int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) { int64_t code; - ASSERT(pRead->curVersion == pHead->head.version); +// ASSERT(pRead->curVersion == pHead->head.version); code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR); if (code < 0) { diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 30aaa01dae0bf26bb930271f056d77226e808a4d..3dfb1458ad2fc802af761f68a4fe4407098fff25 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -160,6 +160,66 @@ int32_t taosMulMkDir(const char *dirname) { return code; } +int32_t taosMulModeMkDir(const char *dirname, int mode) { + if (dirname == NULL) return -1; + char temp[1024]; + char *pos = temp; + int32_t code = 0; +#ifdef WINDOWS + taosRealPath(dirname, temp, sizeof(temp)); + if (temp[1] == ':') pos += 3; +#else + strcpy(temp, dirname); +#endif + + if (taosDirExist(temp)) { + chmod(temp, mode); + return code; + } + + if (strncmp(temp, TD_DIRSEP, 1) == 0) { + pos += 1; + } else if (strncmp(temp, "." TD_DIRSEP, 2) == 0) { + pos += 2; + } + + for (; *pos != '\0'; pos++) { + if (*pos == TD_DIRSEP[0]) { + *pos = '\0'; +#ifdef WINDOWS + code = _mkdir(temp, mode); +#else + code = mkdir(temp, mode); +#endif + if (code < 0 && errno != EEXIST) { + terrno = TAOS_SYSTEM_ERROR(errno); + return code; + } + *pos = TD_DIRSEP[0]; + } + } + + if (*(pos - 1) != TD_DIRSEP[0]) { +#ifdef WINDOWS + code = _mkdir(temp, mode); +#else + code = mkdir(temp, mode); +#endif + if (code < 0 && errno != EEXIST) { + terrno = TAOS_SYSTEM_ERROR(errno); + return code; + } + } + + if (code < 0 && errno == EEXIST) { + chmod(temp, mode); + return 0; + } + + chmod(temp, mode); + return code; +} + void taosRemoveOldFiles(const char *dirname, int32_t keepDays) { TdDirPtr pDir = taosOpenDir(dirname); if (pDir == NULL) return; diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 5353cd9bfec94b460fc1f5c3d9ad657ead6ad76b..699f0db7a193b1e0390efd12de6f639de5b69f86 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -201,6 +201,7 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size return (c > 0) ? p : (midx > 0 ? p - size : NULL); } else { ASSERT(0); + return NULL; } } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 7032f397442464681557e00589d183011fe6b2d0..cbda4e46557e7931d1ce5dea31c2baa4f2d6ddef 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -244,6 +244,7 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) { return 0; }else{ assert(0); + return 0; } } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 662a3f0c88012191f3a7d76c78eb6d06a8b20292..044cdc86b4d91cbb26e00435cb241f39c0442f00 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -121,7 +121,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_CONN_KILLED, "Connection killed") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SQL_SYNTAX_ERROR, "Syntax error in SQL") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DB_NOT_SELECTED, "Database not specified or available") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_NAME, "Table does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too long, check maxSQLLength config") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too long") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_FILE_EMPTY, "File is empty") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_LINE_SYNTAX_ERROR, "Syntax error in Line") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_META_CACHED, "No table meta cached") @@ -618,10 +618,11 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_REMOVE_EXISTS, "Rsma remove exists" TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP, "Rsma fetch msg is messed up") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_EMPTY_INFO, "Rsma info is empty") TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_SCHEMA, "Rsma invalid schema") +TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_REGEX_MATCH, "Rsma regex match") //index TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding") -TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Invalid index file") +TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_INVALID_FILE, "Index file is invalid") //tmq TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_MSG, "Invalid message") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index a2d65d6a542f72eae239f15c79be7c64c8df3bd1..46203658f15848fffca902606ba0df50647dac86 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -97,7 +97,7 @@ int32_t tqDebugFlag = 135; int32_t fsDebugFlag = 135; int32_t metaDebugFlag = 135; int32_t udfDebugFlag = 135; -int32_t smaDebugFlag = 135; +int32_t smaDebugFlag = 131; int32_t idxDebugFlag = 135; int64_t dbgEmptyW = 0; @@ -446,7 +446,10 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b } if (dflag & DEBUG_SCREEN) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" write(1, buffer, (uint32_t)len); +#pragma GCC diagnostic pop } } diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c index 0970485dade90bb8719a2fa39facb047e07bcfff..65f1bac60aa51c48fe65895dbe0ded241d22590d 100644 --- a/source/util/src/trbtree.c +++ b/source/util/src/trbtree.c @@ -13,179 +13,297 @@ * along with this program. If not, see . */ -#include "os.h" +#include "trbtree.h" -typedef int32_t (*tRBTreeCmprFn)(void *, void *); - -typedef struct SRBTree SRBTree; -typedef struct SRBTreeNode SRBTreeNode; -typedef struct SRBTreeIter SRBTreeIter; - -struct SRBTreeNode { - enum { RED, BLACK } color; - SRBTreeNode *parent; - SRBTreeNode *left; - SRBTreeNode *right; - uint8_t payload[]; -}; - -struct SRBTree { - tRBTreeCmprFn cmprFn; - SRBTreeNode *root; -}; - -struct SRBTreeIter { - SRBTree *pTree; -}; - -#define RBTREE_NODE_COLOR(N) ((N) ? (N)->color : BLACK) - -// APIs ================================================ -static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *pNode) { - SRBTreeNode *right = pNode->right; - - pNode->right = right->left; - if (pNode->right) { - pNode->right->parent = pNode; +static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *x) { + SRBTreeNode *y = x->right; + x->right = y->left; + if (y->left != pTree->NIL) { + y->left->parent = x; } - - right->parent = pNode->parent; - if (pNode->parent == NULL) { - pTree->root = right; - } else if (pNode == pNode->parent->left) { - pNode->parent->left = right; + y->parent = x->parent; + if (x->parent == pTree->NIL) { + pTree->root = y; + } else if (x == x->parent->left) { + x->parent->left = y; } else { - pNode->parent->right = right; + x->parent->right = y; } - - right->left = pNode; - pNode->parent = right; + y->left = x; + x->parent = y; } -static void tRBTreeRotateRight(SRBTree *pTree, SRBTreeNode *pNode) { - SRBTreeNode *left = pNode->left; - - pNode->left = left->right; - if (pNode->left) { - pNode->left->parent = pNode; +static void tRBTreeRotateRight(SRBTree *pTree, SRBTreeNode *x) { + SRBTreeNode *y = x->left; + x->left = y->right; + if (y->right != pTree->NIL) { + y->right->parent = x; } - - left->parent = pNode->parent; - if (pNode->parent == NULL) { - pTree->root = left; - } else if (pNode == pNode->parent->left) { - pNode->parent->left = left; + y->parent = x->parent; + if (x->parent == pTree->NIL) { + pTree->root = y; + } else if (x == x->parent->right) { + x->parent->right = y; } else { - pNode->parent->right = left; + x->parent->left = y; } - - left->right = pNode; - pNode->parent = left; + y->right = x; + x->parent = y; } -#define tRBTreeCreate(compare) \ - (SRBTree) { .cmprFn = (compare), .root = NULL } - -SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *pNew) { - pNew->left = NULL; - pNew->right = NULL; - pNew->color = RED; - - // insert - if (pTree->root == NULL) { - pNew->parent = NULL; - pTree->root = pNew; - } else { - SRBTreeNode *pNode = pTree->root; - while (true) { - ASSERT(pNode); - - int32_t c = pTree->cmprFn(pNew->payload, pNode->payload); - if (c < 0) { - if (pNode->left) { - pNode = pNode->left; - } else { - pNew->parent = pNode; - pNode->left = pNew; - break; - } - } else if (c > 0) { - if (pNode->right) { - pNode = pNode->right; - } else { - pNew->parent = pNode; - pNode->right = pNew; - break; +static void tRBTreePutFix(SRBTree *pTree, SRBTreeNode *z) { + while (z->parent->color == RED) { + if (z->parent == z->parent->parent->left) { // z.parent is the left child + + SRBTreeNode *y = z->parent->parent->right; // uncle of z + + if (y->color == RED) { // case 1 + z->parent->color = BLACK; + y->color = BLACK; + z->parent->parent->color = RED; + z = z->parent->parent; + } else { // case2 or case3 + if (z == z->parent->right) { // case2 + z = z->parent; // marked z.parent as new z + tRBTreeRotateLeft(pTree, z); } + // case3 + z->parent->color = BLACK; // made parent black + z->parent->parent->color = RED; // made parent red + tRBTreeRotateRight(pTree, z->parent->parent); + } + } else { // z.parent is the right child + SRBTreeNode *y = z->parent->parent->left; // uncle of z + + if (y->color == RED) { + z->parent->color = BLACK; + y->color = BLACK; + z->parent->parent->color = RED; + z = z->parent->parent; } else { - return NULL; + if (z == z->parent->left) { + z = z->parent; // marked z.parent as new z + tRBTreeRotateRight(pTree, z); + } + z->parent->color = BLACK; // made parent black + z->parent->parent->color = RED; // made parent red + tRBTreeRotateLeft(pTree, z->parent->parent); } } } + pTree->root->color = BLACK; +} - // fix - SRBTreeNode *pNode = pNew; - while (pNode->parent && pNode->parent->color == RED) { - SRBTreeNode *p = pNode->parent; - SRBTreeNode *g = p->parent; - - if (p == g->left) { - SRBTreeNode *u = g->right; - - if (RBTREE_NODE_COLOR(u) == RED) { - p->color = BLACK; - u->color = BLACK; - g->color = RED; - pNode = g; +static void tRBTreeTransplant(SRBTree *pTree, SRBTreeNode *u, SRBTreeNode *v) { + if (u->parent == pTree->NIL) + pTree->root = v; + else if (u == u->parent->left) + u->parent->left = v; + else + u->parent->right = v; + v->parent = u->parent; +} + +static void tRBTreeDropFix(SRBTree *pTree, SRBTreeNode *x) { + while (x != pTree->root && x->color == BLACK) { + if (x == x->parent->left) { + SRBTreeNode *w = x->parent->right; + if (w->color == RED) { + w->color = BLACK; + x->parent->color = RED; + tRBTreeRotateLeft(pTree, x->parent); + w = x->parent->right; + } + if (w->left->color == BLACK && w->right->color == BLACK) { + w->color = RED; + x = x->parent; } else { - if (pNode == p->right) { - pNode = p; - tRBTreeRotateLeft(pTree, pNode); + if (w->right->color == BLACK) { + w->left->color = BLACK; + w->color = RED; + tRBTreeRotateRight(pTree, w); + w = x->parent->right; } - pNode->parent->color = BLACK; - pNode->parent->parent->color = RED; - tRBTreeRotateRight(pTree, pNode->parent->parent); + w->color = x->parent->color; + x->parent->color = BLACK; + w->right->color = BLACK; + tRBTreeRotateLeft(pTree, x->parent); + x = pTree->root; } } else { - SRBTreeNode *u = g->left; - - if (RBTREE_NODE_COLOR(u) == RED) { - p->color = BLACK; - u->color = BLACK; - g->color = RED; + SRBTreeNode *w = x->parent->left; + if (w->color == RED) { + w->color = BLACK; + x->parent->color = RED; + tRBTreeRotateRight(pTree, x->parent); + w = x->parent->left; + } + if (w->right->color == BLACK && w->left->color == BLACK) { + w->color = RED; + x = x->parent; } else { - if (pNode == p->left) { - pNode = p; - tRBTreeRotateRight(pTree, pNode); + if (w->left->color == BLACK) { + w->right->color = BLACK; + w->color = RED; + tRBTreeRotateLeft(pTree, w); + w = x->parent->left; } - pNode->parent->color = BLACK; - pNode->parent->parent->color = RED; - tRBTreeRotateLeft(pTree, pNode->parent->parent); + w->color = x->parent->color; + x->parent->color = BLACK; + w->left->color = BLACK; + tRBTreeRotateRight(pTree, x->parent); + x = pTree->root; } } } + x->color = BLACK; +} - pTree->root->color = BLACK; - return pNew; +static SRBTreeNode *tRBTreeSuccessor(SRBTree *pTree, SRBTreeNode *pNode) { + if (pNode->right != pTree->NIL) { + pNode = pNode->right; + while (pNode->left != pTree->NIL) { + pNode = pNode->left; + } + } else { + while (true) { + if (pNode->parent == pTree->NIL || pNode == pNode->parent->left) { + pNode = pNode->parent; + break; + } else { + pNode = pNode->parent; + } + } + } + + return pNode; } -SRBTreeNode *tRBTreeDrop(SRBTree *pTree, void *pKey) { - SRBTreeNode *pNode = pTree->root; +static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) { + if (pNode->left != pTree->NIL) { + pNode = pNode->left; + while (pNode->right != pTree->NIL) { + pNode = pNode->right; + } + } else { + while (true) { + if (pNode->parent == pTree->NIL || pNode == pNode->parent->right) { + pNode = pNode->parent; + break; + } else { + pNode = pNode->parent; + } + } + } - while (pNode) { - int32_t c = pTree->cmprFn(pKey, pNode->payload); + return pNode; +} +void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn) { + pTree->cmprFn = cmprFn; + pTree->n = 0; + pTree->NIL = &pTree->NILNODE; + pTree->NIL->color = BLACK; + pTree->NIL->parent = NULL; + pTree->NIL->left = NULL; + pTree->NIL->right = NULL; + pTree->root = pTree->NIL; + pTree->min = pTree->NIL; + pTree->max = pTree->NIL; +} + +SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) { + SRBTreeNode *y = pTree->NIL; // variable for the parent of the added node + SRBTreeNode *temp = pTree->root; + + while (temp != pTree->NIL) { + y = temp; + + int32_t c = pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(temp)); if (c < 0) { - pNode = pNode->left; + temp = temp->left; } else if (c > 0) { - pNode = pNode->right; + temp = temp->right; } else { - break; + return NULL; } } + z->parent = y; + + if (y == pTree->NIL) { + pTree->root = z; + } else if (pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(y)) < 0) { + y->left = z; + } else { + y->right = z; + } + + z->color = RED; + z->left = pTree->NIL; + z->right = pTree->NIL; + + tRBTreePutFix(pTree, z); + + // update min/max node + if (pTree->min == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->min), RBTREE_NODE_PAYLOAD(z)) > 0) { + pTree->min = z; + } + if (pTree->max == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->max), RBTREE_NODE_PAYLOAD(z)) < 0) { + pTree->max = z; + } + pTree->n++; + return z; +} + +void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z) { + SRBTreeNode *y = z; + SRBTreeNode *x; + ECOLOR y_orignal_color = y->color; + + // update min/max node + if (pTree->min == z) { + pTree->min = tRBTreeSuccessor(pTree, pTree->min); + } + if (pTree->max == z) { + pTree->max = tRBTreePredecessor(pTree, pTree->max); + } + + // drop impl + if (z->left == pTree->NIL) { + x = z->right; + tRBTreeTransplant(pTree, z, z->right); + } else if (z->right == pTree->NIL) { + x = z->left; + tRBTreeTransplant(pTree, z, z->left); + } else { + y = tRBTreeSuccessor(pTree, z); + y_orignal_color = y->color; + x = y->right; + if (y->parent == z) { + x->parent = z; + } else { + tRBTreeTransplant(pTree, y, y->right); + y->right = z->right; + y->right->parent = y; + } + tRBTreeTransplant(pTree, z, y); + y->left = z->left; + y->left->parent = y; + y->color = z->color; + } + + // fix + if (y_orignal_color == BLACK) { + tRBTreeDropFix(pTree, x); + } + pTree->n--; +} + +SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) { + SRBTreeNode *pNode = tRBTreeGet(pTree, pKey); if (pNode) { - // TODO + tRBTreeDrop(pTree, pNode); } return pNode; @@ -194,8 +312,8 @@ SRBTreeNode *tRBTreeDrop(SRBTree *pTree, void *pKey) { SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey) { SRBTreeNode *pNode = pTree->root; - while (pNode) { - int32_t c = pTree->cmprFn(pKey, pNode->payload); + while (pNode != pTree->NIL) { + int32_t c = pTree->cmprFn(pKey, RBTREE_NODE_PAYLOAD(pNode)); if (c < 0) { pNode = pNode->left; @@ -206,5 +324,23 @@ SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey) { } } - return pNode; + return (pNode == pTree->NIL) ? NULL : pNode; } + +// SRBTreeIter ================================================ +SRBTreeNode *tRBTreeIterNext(SRBTreeIter *pIter) { + SRBTreeNode *pNode = pIter->pNode; + + if (pIter->pNode != pIter->pTree->NIL) { + if (pIter->asc) { + // ascend + pIter->pNode = tRBTreeSuccessor(pIter->pTree, pIter->pNode); + } else { + // descend + pIter->pNode = tRBTreePredecessor(pIter->pTree, pIter->pNode); + } + } + +_exit: + return (pNode == pIter->pTree->NIL) ? NULL : pNode; +} \ No newline at end of file diff --git a/source/util/src/version.c.in b/source/util/src/version.c.in index be1a4a404875739cdef349a901e52e195c2a9cde..cb307b57fce37ba4243aea83995e66612f3c4371 100644 --- a/source/util/src/version.c.in +++ b/source/util/src/version.c.in @@ -1,4 +1,4 @@ -char version[12] = "${TD_VER_NUMBER}"; +char version[64] = "${TD_VER_NUMBER}"; char compatible_version[12] = "${TD_VER_COMPATIBLE}"; char gitinfo[48] = "${TD_VER_GIT}"; char buildinfo[64] = "Built at ${TD_VER_DATE}"; diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt index d2a503e6613909c39af8cfb961dd5b51f36120c3..6e42ef7e75eac38a5a072bfef8521152fd74ae06 100644 --- a/source/util/test/CMakeLists.txt +++ b/source/util/test/CMakeLists.txt @@ -75,4 +75,12 @@ target_link_libraries(taosbsearchTest os util gtest_main) add_test( NAME taosbsearchTest COMMAND taosbsearchTest +) + +# trbtreeTest +add_executable(rbtreeTest "trbtreeTest.cpp") +target_link_libraries(rbtreeTest os util gtest_main) +add_test( + NAME rbtreeTest + COMMAND rbtreeTest ) \ No newline at end of file diff --git a/source/util/test/trbtreeTest.cpp b/source/util/test/trbtreeTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cabf315df0a2d32c6f2adcf1ac81a3e1565e6e0c --- /dev/null +++ b/source/util/test/trbtreeTest.cpp @@ -0,0 +1,40 @@ +#include + +#include +#include + +#include "trbtree.h" + +static int32_t tCmprInteger(const void *p1, const void *p2) { + if (*(int *)p1 < *(int *)p2) { + return -1; + } else if (*(int *)p1 > *(int *)p2) { + return 1; + } + return 0; +} + +TEST(trbtreeTest, rbtree_test1) { +#if 0 + SRBTree rt; + tRBTreeCreate(&rt, tCmprInteger); + int a[] = {1, 3, 4, 2, 7, 5, 8}; + + for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) { + SRBTreeNode *pNode = (SRBTreeNode *)taosMemoryMalloc(sizeof(*pNode) + sizeof(int)); + *(int *)pNode->payload = a[i]; + + tRBTreePut(&rt, pNode); + } + + SRBTreeIter rti = tRBTreeIterCreate(&rt, 1); + SRBTreeNode *pNode = tRBTreeIterNext(&rti); + int la = 0; + while (pNode) { + GTEST_ASSERT_GT(*(int *)pNode->payload, la); + la = *(int *)pNode->payload; + // printf("%d\n", la); + pNode = tRBTreeIterNext(&rti); + } +#endif +} \ No newline at end of file diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py index a8117ec04c79aff5c00dcfa604c1124854473d30..8a85ce10ed53946abe4f8ecd4a022752e07f94c1 100644 --- a/tests/pytest/tools/taosdumpTest2.py +++ b/tests/pytest/tools/taosdumpTest2.py @@ -11,15 +11,19 @@ # -*- coding: utf-8 -*- +from logging.config import dictConfig import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * +import string +import random class TDTestCase: + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) @@ -47,12 +51,19 @@ class TDTestCase: return "" return paths[0] + def generateString(self, length): + chars = string.ascii_uppercase + string.ascii_lowercase + v = "" + for i in range(length): + v += random.choice(chars) + return v + def run(self): if not os.path.exists("./taosdumptest/tmp"): os.makedirs("./taosdumptest/tmp") else: - os.system("rm -rf ./taosdumptest/tmp") - os.makedirs("./taosdumptest/tmp") + print("directory exists") + os.system("rm -rf ./taosdumptest/tmp/*") tdSql.prepare() @@ -76,17 +87,19 @@ class TDTestCase: tdLog.info("taosdump found in %s" % binPath) os.system("rm ./taosdumptest/tmp/*.sql") + os.system("rm ./taosdumptest/tmp/*.avro*") + os.system("rm -rf ./taosdumptest/taosdump.*") os.system( - "%s --databases db -o ./taosdumptest/tmp -B 32766 -L 1048576" % + "%s --databases db -o ./taosdumptest/tmp " % binPath) tdSql.execute("drop database db") - tdSql.query("select * from information_schema.ins_databases") + tdSql.query("show databases") tdSql.checkRows(2) - os.system("%s -i ./taosdumptest/tmp" % binPath) + os.system("%s -i ./taosdumptest/tmp -y" % binPath) - tdSql.query("select * from information_schema.ins_databases") + tdSql.query("show databases") tdSql.checkRows(3) tdSql.checkData(2, 0, 'db') @@ -105,23 +118,22 @@ class TDTestCase: "create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") tdSql.execute( "insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % - ("16374", - "16374", - "16374")) + (self.generateString(16374), + self.generateString(16374), + self.generateString(16374))) -# sys.exit(0) os.system("rm ./taosdumptest/tmp/*.sql") os.system("rm ./taosdumptest/tmp/*.avro*") + os.system("rm -rf ./taosdumptest/tmp/taosdump.*") os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath) tdSql.execute("drop database test") - tdSql.query("select * from information_schema.ins_databases") + tdSql.query("show databases") tdSql.checkRows(3) os.system("%s -i ./taosdumptest/tmp -y" % binPath) tdSql.execute("use test") - tdSql.error("show vnodes '' ") tdSql.query("show stables") tdSql.checkRows(1) tdSql.checkData(0, 0, 'stb') diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 33ef92bf735a5211044ebd37c3c8300abd8843a8..9ffebcbdad5f0fa07e26f1bb4d249643ab7bbe42 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -199,22 +199,22 @@ class TDCom: res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0]) return res - def cleanTb(self, type="taosc"): + def cleanTb(self, type="taosc", dbname="db"): ''' type is taosc or restful ''' - query_sql = "show stables" + query_sql = f"show {dbname}.stables" res_row_list = tdSql.query(query_sql, True) stb_list = map(lambda x: x[0], res_row_list) for stb in stb_list: if type == "taosc": - tdSql.execute(f'drop table if exists `{stb}`') + tdSql.execute(f'drop table if exists {dbname}.`{stb}`') if not stb[0].isdigit(): - tdSql.execute(f'drop table if exists {stb}') + tdSql.execute(f'drop table if exists {dbname}.{stb}') elif type == "restful": - self.restApiPost(f"drop table if exists `{stb}`") + self.restApiPost(f"drop table if exists {dbname}.`{stb}`") if not stb[0].isdigit(): - self.restApiPost(f"drop table if exists {stb}") + self.restApiPost(f"drop table if exists {dbname}.{stb}") def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index e530695d1e53c4628fb28175b308b67d149c16a3..89b7fe00ebb0cf04b4570643966d553a4bccea9b 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -36,9 +36,9 @@ class TDSimClient: "rpcDebugFlag": "143", "tmrDebugFlag": "131", "cDebugFlag": "143", - "udebugFlag": "143", - "jnidebugFlag": "143", - "qdebugFlag": "143", + "uDebugFlag": "143", + "jniDebugFlag": "143", + "qDebugFlag": "143", "supportVnodes": "1024", "telemetryReporting": "0", } @@ -134,7 +134,6 @@ class TDDnode: "uDebugFlag": "131", "sDebugFlag": "143", "wDebugFlag": "143", - "qdebugFlag": "143", "numOfLogLines": "100000000", "statusInterval": "1", "supportVnodes": "1024", @@ -484,7 +483,7 @@ class TDDnode: psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") - + onlyKillOnceWindows = 0 while(processID): if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'): diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 753c41e094701271ca3b49a53eabde1461bd1e08..b320cf5995fd0063352f0da7a2dc04933022a7d2 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -102,7 +102,7 @@ class TDSql: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, sql, repr(e)) tdLog.notice("%s(%d) failed: sql:%s, %s" % args) - raise Exception(repr(e)) + raise Exception(repr(e)) i+=1 time.sleep(1) pass @@ -225,25 +225,21 @@ class TDSql: # suppose user want to check nanosecond timestamp if a longer data passed if (len(data) >= 28): if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): - tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") else: if self.queryResult[row][col] == _parse_datetime(data): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") return if str(self.queryResult[row][col]) == str(data): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") return + elif isinstance(data, float): if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: - tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: - tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") else: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) @@ -254,21 +250,7 @@ class TDSql: args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) - if data is None: - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) - elif isinstance(data, str): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) - elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) - elif isinstance(data, float): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) - else: - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") def getData(self, row, col): self.checkRowCol(row, col) @@ -307,7 +289,7 @@ class TDSql: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, sql, repr(e)) tdLog.notice("%s(%d) failed: sql:%s, %s" % args) - raise Exception(repr(e)) + raise Exception(repr(e)) i+=1 time.sleep(1) pass @@ -329,7 +311,7 @@ class TDSql: tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args) def __check_equal(self, elm, expect_elm): - if not type(elm) in(list, tuple) and elm == expect_elm: + if elm == expect_elm: return True if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple): if len(elm) != len(expect_elm): diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 97295d75e072c3c561f579bfc8cb2c15489da858..46bae734ea72901ef704969045186a10c52a9a72 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -344,6 +344,7 @@ # --- scalar ---- ./test.sh -f tsim/scalar/in.sim ./test.sh -f tsim/scalar/scalar.sim +./test.sh -f tsim/scalar/filter.sim # ---- alter ---- ./test.sh -f tsim/alter/cached_schema_after_alter.sim diff --git a/tests/script/tsim/compute/interval.sim b/tests/script/tsim/compute/interval.sim index 4e7960ac4ae958f2e594fbad3bb6f7b50b13ed94..dc11c20ec925be39d12d2a7d1e92bbcb1da830b1 100644 --- a/tests/script/tsim/compute/interval.sim +++ b/tests/script/tsim/compute/interval.sim @@ -101,7 +101,7 @@ $ms = 1601481600000 + $cc $cc = 1 * 60000 $ms2 = 1601481600000 - $cc -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0,0,0,0,0) print ===> $rows if $rows < 30 then print expect greater than 30, actual: $rows @@ -180,7 +180,7 @@ $ms1 = 1601481600000 + $cc $cc = 1 * 60000 $ms2 = 1601481600000 - $cc -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0,0,0,0,0) if $rows < 30 then return -1 endi diff --git a/tests/script/tsim/db/basic1.sim b/tests/script/tsim/db/basic1.sim index 69eeb9347b22b154c7609b2ff89e36aa43f63a82..5d7d0bd9e9a682a761ffb33f486545f7028f5bfc 100644 --- a/tests/script/tsim/db/basic1.sim +++ b/tests/script/tsim/db/basic1.sim @@ -107,6 +107,37 @@ if $data30 != 12 then return -1 endi +print =============== show vnodes +sql show vnodes 1 +if $rows != 9 then + return -1 +endi + +if $data(4)[1] != 1 then + return -1 +endi + +if $data(4)[2] != leader then + return -1 +endi + +if $data(4)[3] != d2 then + return -1 +endi + +if $data(4)[4] != 1 then + return -1 +endi + +if $data(4)[5] != localhost:7100 then + return -1 +endi + +sql show vnodes 'localhost:7100' +if $rows != 9 then + return -1 +endi + print =============== drop database sql drop database d2 sql drop database d3 diff --git a/tests/script/tsim/parser/columnValue_bigint.sim b/tests/script/tsim/parser/columnValue_bigint.sim index 2cf0151a053f3c62b7ab904156361c8705dc554e..0a024029a534232aa5829d0cf59807f8c65d71f2 100644 --- a/tests/script/tsim/parser/columnValue_bigint.sim +++ b/tests/script/tsim/parser/columnValue_bigint.sim @@ -373,7 +373,7 @@ sql_error insert into st_bigint_e7 values (now, "123abc") sql_error insert into st_bigint_e9 values (now, abc) sql_error insert into st_bigint_e10 values (now, "abc") sql_error insert into st_bigint_e11 values (now, " ") -sql insert into st_bigint_e12 values (now, '') +sql_error insert into st_bigint_e12 values (now, '') sql_error insert into st_bigint_e13 using mt_bigint tags (033) values (now, 9223372036854775808) sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, -9223372036854775808) @@ -386,7 +386,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags (033) values (now, "123 sql_error insert into st_bigint_e22 using mt_bigint tags (033) values (now, abc) sql_error insert into st_bigint_e23 using mt_bigint tags (033) values (now, "abc") sql_error insert into st_bigint_e24 using mt_bigint tags (033) values (now, " ") -sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') +sql_error insert into st_bigint_e25 using mt_bigint tags (033) values (now, '') sql_error insert into st_bigint_e13_0 using mt_bigint tags (9223372036854775808) values (now, -033) sql insert into st_bigint_e14_0 using mt_bigint tags (-9223372036854775808) values (now, -033) diff --git a/tests/script/tsim/parser/columnValue_double.sim b/tests/script/tsim/parser/columnValue_double.sim index da09b77353fc12f237e4fb94dc99b69bd8bec9c1..bfcf338faca3669b18b2e821f10b5e3b4b0f328e 100644 --- a/tests/script/tsim/parser/columnValue_double.sim +++ b/tests/script/tsim/parser/columnValue_double.sim @@ -476,7 +476,7 @@ sql_error insert into st_double_e7 values (now, "123abc") sql_error insert into st_double_e9 values (now, abc) sql_error insert into st_double_e10 values (now, "abc") sql_error insert into st_double_e11 values (now, " ") -sql insert into st_double_e12 values (now, '') +sql_error insert into st_double_e12 values (now, '') sql_error insert into st_double_e13 using mt_double tags (033) values (now, 11.7976931348623157e+308) sql_error insert into st_double_e14 using mt_double tags (033) values (now, -11.7976931348623157e+308) @@ -489,7 +489,7 @@ sql_error insert into st_double_e20 using mt_double tags (033) values (now, "123 sql_error insert into st_double_e22 using mt_double tags (033) values (now, abc) sql_error insert into st_double_e23 using mt_double tags (033) values (now, "abc") sql_error insert into st_double_e24 using mt_double tags (033) values (now, " ") -sql insert into st_double_e25_1 using mt_double tags (033) values (now, '') +sql_error insert into st_double_e25_1 using mt_double tags (033) values (now, '') sql_error insert into st_double_e13 using mt_double tags (31.7976931348623157e+308) values (now, -033) sql_error insert into st_double_e14 using mt_double tags (-31.7976931348623157e+308) values (now, -033) diff --git a/tests/script/tsim/parser/columnValue_float.sim b/tests/script/tsim/parser/columnValue_float.sim index 3e20e178c373b9bf55b4be0e666e27e3d5787447..b2db7dff2b875d8839e1bdf356c40ba4d6d9e916 100644 --- a/tests/script/tsim/parser/columnValue_float.sim +++ b/tests/script/tsim/parser/columnValue_float.sim @@ -506,7 +506,7 @@ sql_error insert into st_float_e7 values (now, "123abc") sql_error insert into st_float_e9 values (now, abc) sql_error insert into st_float_e10 values (now, "abc") sql_error insert into st_float_e11 values (now, " ") -sql insert into st_float_e12 values (now, '') +sql_error insert into st_float_e12 values (now, '') sql_error insert into st_float_e13 using mt_float tags (033) values (now, 3.50282347e+38) sql_error insert into st_float_e14 using mt_float tags (033) values (now, -3.50282347e+38) @@ -519,7 +519,7 @@ sql_error insert into st_float_e20 using mt_float tags (033) values (now, "123ab sql_error insert into st_float_e22 using mt_float tags (033) values (now, abc) sql_error insert into st_float_e23 using mt_float tags (033) values (now, "abc") sql_error insert into st_float_e24 using mt_float tags (033) values (now, " ") -sql insert into st_float_e25_1 using mt_float tags (033) values (now, '') +sql_error insert into st_float_e25_1 using mt_float tags (033) values (now, '') sql_error insert into st_float_e13 using mt_float tags (3.50282347e+38) values (now, -033) sql_error insert into st_float_e14 using mt_float tags (-3.50282347e+38) values (now, -033) diff --git a/tests/script/tsim/parser/columnValue_int.sim b/tests/script/tsim/parser/columnValue_int.sim index 009fbd1ede718245b6145b9a292d9c325d2a872c..4a3b8ebd0ba46a08ee737de44cf07c1cb10aa555 100644 --- a/tests/script/tsim/parser/columnValue_int.sim +++ b/tests/script/tsim/parser/columnValue_int.sim @@ -371,7 +371,7 @@ sql_error insert into st_int_e7 values (now, "123abc") sql_error insert into st_int_e9 values (now, abc) sql_error insert into st_int_e10 values (now, "abc") sql_error insert into st_int_e11 values (now, " ") -sql insert into st_int_e12 values (now, '') +sql_error insert into st_int_e12 values (now, '') sql_error insert into st_int_e13 using mt_int tags (033) values (now, 2147483648) sql insert into st_int_e14 using mt_int tags (033) values (now, -2147483648) @@ -384,7 +384,7 @@ sql_error insert into st_int_e20 using mt_int tags (033) values (now, "123abc") sql_error insert into st_int_e22 using mt_int tags (033) values (now, abc) sql_error insert into st_int_e23 using mt_int tags (033) values (now, "abc") sql_error insert into st_int_e24 using mt_int tags (033) values (now, " ") -sql insert into st_int_e25 using mt_int tags (033) values (now, '') +sql_error insert into st_int_e25 using mt_int tags (033) values (now, '') sql_error insert into st_int_e13 using mt_int tags (2147483648) values (now, -033) sql insert into st_int_e14_1 using mt_int tags (-2147483648) values (now, -033) diff --git a/tests/script/tsim/parser/columnValue_smallint.sim b/tests/script/tsim/parser/columnValue_smallint.sim index 0dcb0d85f4f9dad62dc71aa7fd2df916c6fd7a63..eb364f36302df811549a968eaf5bf05a823b84b3 100644 --- a/tests/script/tsim/parser/columnValue_smallint.sim +++ b/tests/script/tsim/parser/columnValue_smallint.sim @@ -374,7 +374,7 @@ sql_error insert into st_smallint_e7 values (now, "123abc") sql_error insert into st_smallint_e9 values (now, abc) sql_error insert into st_smallint_e10 values (now, "abc") sql_error insert into st_smallint_e11 values (now, " ") -sql insert into st_smallint_e12 values (now, '') +sql_error insert into st_smallint_e12 values (now, '') sql_error insert into st_smallint_e13 using mt_smallint tags (033) values (now, 32768) sql insert into st_smallint_e14_1 using mt_smallint tags (033) values (now, -32768) @@ -387,7 +387,7 @@ sql_error insert into st_smallint_e20 using mt_smallint tags (033) values (now, sql_error insert into st_smallint_e22 using mt_smallint tags (033) values (now, abc) sql_error insert into st_smallint_e23 using mt_smallint tags (033) values (now, "abc") sql_error insert into st_smallint_e24 using mt_smallint tags (033) values (now, " ") -sql insert into st_smallint_e25_1 using mt_smallint tags (033) values (now, '') +sql_error insert into st_smallint_e25_1 using mt_smallint tags (033) values (now, '') sql_error insert into st_smallint_e13 using mt_smallint tags (32768) values (now, -033) sql insert into st_smallint_e14 using mt_smallint tags (-32768) values (now, -033) diff --git a/tests/script/tsim/parser/columnValue_tinyint.sim b/tests/script/tsim/parser/columnValue_tinyint.sim index 62ae4e5228f94e466dd0bc44e681b7b4b940fcdb..d7938aa739fb3584c8fd549005bd02e44ac39bc0 100644 --- a/tests/script/tsim/parser/columnValue_tinyint.sim +++ b/tests/script/tsim/parser/columnValue_tinyint.sim @@ -372,7 +372,7 @@ sql_error insert into st_tinyint_e7 values (now, "123abc") sql_error insert into st_tinyint_e9 values (now, abc) sql_error insert into st_tinyint_e10 values (now, "abc") sql_error insert into st_tinyint_e11 values (now, " ") -sql insert into st_tinyint_e12 values (now, '') +sql_error insert into st_tinyint_e12 values (now, '') sql_error insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 128) sql insert into st_tinyint_e14_1 using mt_tinyint tags (033) values (now, -128) @@ -385,7 +385,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags (033) values (now, "1 sql_error insert into st_tinyint_e22 using mt_tinyint tags (033) values (now, abc) sql_error insert into st_tinyint_e23 using mt_tinyint tags (033) values (now, "abc") sql_error insert into st_tinyint_e24 using mt_tinyint tags (033) values (now, " ") -sql insert into st_tinyint_e25_2 using mt_tinyint tags (033) values (now, '') +sql_error insert into st_tinyint_e25_2 using mt_tinyint tags (033) values (now, '') sql_error insert into st_tinyint_e13 using mt_tinyint tags (128) values (now, -033) sql insert into st_tinyint_e14 using mt_tinyint tags (-128) values (now, -033) diff --git a/tests/script/tsim/parser/fill.sim b/tests/script/tsim/parser/fill.sim index f688d815e79fb76ce536fd75a1312230306dda41..4892345e12ed4b22a1c3d96ae2e6233e7e9fe642 100644 --- a/tests/script/tsim/parser/fill.sim +++ b/tests/script/tsim/parser/fill.sim @@ -47,31 +47,10 @@ $tsu = $tsu + $ts0 ## fill syntax test # number of fill values exceeds number of selected columns -sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) -if $data11 != 6 then - return -1 -endi -if $data12 != 6 then - return -1 -endi -if $data13 != 6.00000 then - return -1 -endi -if $data14 != 6.000000000 then - return -1 -endi +sql_error select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) # number of fill values is smaller than number of selected columns -sql select _wstart, max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) -if $data11 != 6 then - return -1 -endi -if $data12 != 6 then - return -1 -endi -if $data13 != 6.00000 then - return -1 -endi +sql_error select _wstart, max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) # unspecified filling method sql_error select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) @@ -182,7 +161,7 @@ endi # min_with_fill print min_with_fill -sql select _wstart, min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select _wstart, min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) if $rows != 9 then return -1 endi @@ -216,7 +195,7 @@ endi # first_with_fill print first_with_fill -sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, '6', '6') if $rows != 9 then return -1 endi @@ -305,7 +284,7 @@ endi # last_with_fill print last_with_fill -sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, '6', '6') if $rows != 9 then return -1 endi @@ -351,7 +330,7 @@ if $data11 != -1 then endi # fill_char_values_to_arithmetic_fields -sql select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') # fill_multiple_columns sql_error select sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) @@ -376,37 +355,25 @@ endi # fill_into_nonarithmetic_fieds print select _wstart, first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) -sql select _wstart, first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) -if $data01 != 1 then - return -1 -endi -if $data11 != NULL then - return -1 -endi +sql_error select _wstart, first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') # fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 # fill values into binary or nchar columns will be set to NULL automatically Note:2018-10-24 sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') # fill nonarithmetic values into arithmetic fields sql_error select count(*) where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); -sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); +sql_error select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); print select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); -sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); -if $rows != 9 then - return -1 -endi -if $data01 != 1 then - return -1 -endi +sql_error select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1); if $rows != 9 then @@ -416,13 +383,7 @@ if $data01 != 1 then return -1 endi -sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); -if $rows != 9 then - return -1 -endi -if $data01 != 1 then - return -1 -endi +sql_error select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); ## linear fill # feature currently switched off 2018/09/29 @@ -859,8 +820,8 @@ sql insert into tm0 values('2020-1-1 1:3:8', 8); sql insert into tm0 values('2020-1-1 1:3:9', 9); sql insert into tm0 values('2020-1-1 1:4:10', 10); -print select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85); -sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85); +print select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90); +sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90); if $rows != 8 then return -1 endi @@ -958,14 +919,14 @@ if $data12 != NULL then return -1 endi -sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 4:2:15' interval(500a) fill(value, 99,91,90,89,88,87,86,85) ; +sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 4:2:15' interval(500a) fill(value, 99,91,90) ; if $rows != 21749 then print expect 21749, actual: $rows return -1 endi -print select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85) ; -sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85) ; +print select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89) ; +sql select _wstart, max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89) ; if $rows != 8 then return -1 endi diff --git a/tests/script/tsim/parser/fill_us.sim b/tests/script/tsim/parser/fill_us.sim index 0a45c02f58a039baa22d5c71fff04d8e56a6fed6..f760ba3577281fa358e0da9180624b7de2e69b76 100644 --- a/tests/script/tsim/parser/fill_us.sim +++ b/tests/script/tsim/parser/fill_us.sim @@ -48,32 +48,11 @@ $tsu = $tsu + $ts0 ## fill syntax test # number of fill values exceeds number of selected columns print select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) -sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) -if $data11 != 6 then - return -1 -endi -if $data12 != 6 then - return -1 -endi -if $data13 != 6.00000 then - return -1 -endi -if $data14 != 6.000000000 then - return -1 -endi +sql_error select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) # number of fill values is smaller than number of selected columns print sql select _wstart, max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) -sql select _wstart, max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) -if $data11 != 6 then - return -1 -endi -if $data12 != 6 then - return -1 -endi -if $data13 != 6.00000 then - return -1 -endi +sql_error select _wstart, max(c1), max(c2), max(c3) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6) # unspecified filling method sql_error select max(c1), max(c2), max(c3), max(c4), max(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill (6, 6, 6, 6, 6) @@ -185,7 +164,7 @@ endi # min_with_fill print min_with_fill -sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select min(c1), min(c2), min(c3), min(c4), min(c5) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6) if $rows != 9 then return -1 endi @@ -219,7 +198,7 @@ endi # first_with_fill print first_with_fill -sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, '6', '6') if $rows != 9 then return -1 endi @@ -308,7 +287,7 @@ endi # last_with_fill print last_with_fill -sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, 6, 6) +sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 6, 6, 6, 6, 6, 6, '6', '6') if $rows != 9 then return -1 endi @@ -353,7 +332,7 @@ if $data11 != -1 then endi # fill_char_values_to_arithmetic_fields -sql select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') +sql_error select sum(c1), avg(c2), max(c3), min(c4), avg(c4), count(c6), last(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c') # fill_multiple_columns sql_error select _wstart, sum(c1), avg(c2), min(c3), max(c4), count(c6), first(c7), last(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 99, 99, 99, 99, 99, abc, abc) @@ -379,34 +358,24 @@ endi # fill_into_nonarithmetic_fieds -sql select _wstart, first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) -#if $data11 != 20000000 then -if $data11 != NULL then - return -1 -endi +sql_error select _wstart, first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 20000000, 20000000, 20000000) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1, 1, 1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1.1, 1.1, 1.1) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') # fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 # fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') -sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) +sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') # fill nonarithmetic values into arithmetic fields sql_error select count(*) where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, abc); -sql select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); +sql_error select count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true'); -sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); -if $rows != 9 then - return -1 -endi -if $data01 != 1 then - return -1 -endi +sql_error select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e1'); sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1); if $rows != 9 then @@ -416,14 +385,7 @@ if $data01 != 1 then return -1 endi -sql select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); -if $rows != 9 then - return -1 -endi -if $data01 != 1 then - return -1 -endi - +sql_error select _wstart, count(*) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '10'); ## linear fill # feature currently switched off 2018/09/29 diff --git a/tests/script/tsim/parser/slimit_alter_tags.sim b/tests/script/tsim/parser/slimit_alter_tags.sim index 3827b14b453132687c254250538d53ae51ab7279..b5afbfa56eea5fb6ba440e08818e861d5a96da3d 100644 --- a/tests/script/tsim/parser/slimit_alter_tags.sim +++ b/tests/script/tsim/parser/slimit_alter_tags.sim @@ -128,6 +128,7 @@ if $rows != 5 then return -1 endi if $data00 != $rowNum then + print expect $rowNum , actual: $data00 return -1 endi if $data10 != $rowNum then diff --git a/tests/script/tsim/parser/slimit_query.sim b/tests/script/tsim/parser/slimit_query.sim index 1e04a31099b0a9d948d1fd5fff229b0db940390c..acf0489d3c667834f630b41977240da86dcf4cfd 100644 --- a/tests/script/tsim/parser/slimit_query.sim +++ b/tests/script/tsim/parser/slimit_query.sim @@ -93,25 +93,25 @@ if $rows != 3 then endi ### slimit + fill -sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 0 offset 0 +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1 interval(5m) fill(linear) slimit 4 soffset 4 limit 0 offset 0 if $rows != 0 then return -1 endi -sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0 -print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0 +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(linear) slimit 4 soffset 4 limit 2 offset 0 +print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(linear) slimit 4 soffset 4 limit 2 offset 0 print $rows $data00 $data01 $data02 $data03 if $rows != 8 then return -1 endi # desc -sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0 +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(linear) slimit 4 soffset 4 limit 2 offset 0 if $rows != 8 then return -1 endi -sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 598 +sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(linear) slimit 4 soffset 4 limit 2 offset 598 if $rows != 4 then return -1 endi diff --git a/tests/script/tsim/parser/timestamp_query.sim b/tests/script/tsim/parser/timestamp_query.sim index 6e92dbcb3ab28518dc452e474aee955a3003c596..24058cbc84912033b41f49b3e05ee2fecbe4d221 100644 --- a/tests/script/tsim/parser/timestamp_query.sim +++ b/tests/script/tsim/parser/timestamp_query.sim @@ -28,7 +28,7 @@ sql select * from ts_stb0 where ts <> $ts0 ##### select from supertable $tb = $tbPrefix . 0 -sql select _wstart, first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, -1) +sql select _wstart, first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, -1, -1) $res = $rowNum * 2 $n = $res - 2 print ============>$n @@ -47,7 +47,7 @@ if $data13 != 598.000000000 then return -1 endi -sql select _wstart, first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, NULL) +sql select _wstart, first(c1), last(c1), (1537325400 - 1537146000)/(5*60) v from $tb where ts >= $ts0 and ts < $tsu interval(5m) fill(value, NULL, NULL) if $data13 != 598.000000000 then print expect 598.000000000, actual $data03 return -1 diff --git a/tests/script/tsim/scalar/filter.sim b/tests/script/tsim/scalar/filter.sim new file mode 100644 index 0000000000000000000000000000000000000000..923166227856189e91848150ed9e848f946b066d --- /dev/null +++ b/tests/script/tsim/scalar/filter.sim @@ -0,0 +1,38 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 +sql drop database if exists db1; +sql create database db1 vgroups 3; +sql use db1; +sql create stable st1 (fts timestamp, fbool bool, ftiny tinyint, fsmall smallint, fint int, fbig bigint, futiny tinyint unsigned, fusmall smallint unsigned, fuint int unsigned, fubig bigint unsigned, ffloat float, fdouble double, fbin binary(10), fnchar nchar(10)) tags(tts timestamp, tbool bool, ttiny tinyint, tsmall smallint, tint int, tbig bigint, tutiny tinyint unsigned, tusmall smallint unsigned, tuint int unsigned, tubig bigint unsigned, tfloat float, tdouble double, tbin binary(10), tnchar nchar(10)); +sql create table tb1 using st1 tags('2022-07-10 16:31:00', true, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a'); +sql create table tb2 using st1 tags('2022-07-10 16:32:00', false, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b'); +sql create table tb3 using st1 tags('2022-07-10 16:33:00', true, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c'); + +sql insert into tb1 values ('2022-07-10 16:31:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a'); +sql insert into tb1 values ('2022-07-10 16:31:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b'); +sql insert into tb1 values ('2022-07-10 16:31:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c'); +sql insert into tb1 values ('2022-07-10 16:31:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd'); +sql insert into tb1 values ('2022-07-10 16:31:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e'); + +sql insert into tb2 values ('2022-07-10 16:32:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a'); +sql insert into tb2 values ('2022-07-10 16:32:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b'); +sql insert into tb2 values ('2022-07-10 16:32:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c'); +sql insert into tb2 values ('2022-07-10 16:32:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd'); +sql insert into tb2 values ('2022-07-10 16:32:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e'); + +sql insert into tb3 values ('2022-07-10 16:33:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a'); +sql insert into tb3 values ('2022-07-10 16:33:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b'); +sql insert into tb3 values ('2022-07-10 16:33:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c'); +sql insert into tb3 values ('2022-07-10 16:33:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd'); +sql insert into tb3 values ('2022-07-10 16:33:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e'); + +sql select * from st1 where (ttiny > 2 or ftiny < 5) and ftiny > 2; +if $rows != 7 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_comment.sim b/tests/script/tsim/stable/alter_comment.sim index beb049985c90ca7f8c7521c004c950609cc05347..7c2d6edfcbe48e6e4afc55536e893cbc7d0dbc20 100644 --- a/tests/script/tsim/stable/alter_comment.sim +++ b/tests/script/tsim/stable/alter_comment.sim @@ -95,7 +95,7 @@ sql_error alter table db.stb add tag t1 int sql_error alter table db.stb add tag t2 int sql_error alter table db.stb add tag t3 int sql alter table db.stb add tag t4 bigint -sql alter table db.stb add tag c1 int +sql alter table db.stb add tag c1 int sql alter table db.stb add tag t5 binary(12) sql select * from information_schema.ins_stables where db_name = 'db' diff --git a/tests/script/tsim/stable/alter_count.sim b/tests/script/tsim/stable/alter_count.sim index 83ea4b14fa733821316814dc6b4f47c7f239e1e8..4a2aeca029175c73a82d622b59777782f27639ab 100644 --- a/tests/script/tsim/stable/alter_count.sim +++ b/tests/script/tsim/stable/alter_count.sim @@ -5,8 +5,8 @@ print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 -sql create database d1 replica 1 duration 7 keep 50 +print ======== step1 +sql create database d1 replica 1 duration 7 keep 50 sql use d1 sql create table tb (ts timestamp, a int) sql insert into tb values(now-28d, -28) @@ -83,7 +83,7 @@ if $data00 != 3 then endi print ======== step8 -# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) sql alter table tb add column h binary(10) sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0') sql insert into tb values(now-6d, -6, 19, 1, 1, 1, 1, 1, '1') @@ -260,4 +260,4 @@ if $data00 != 31 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_import.sim b/tests/script/tsim/stable/alter_import.sim index b968eb6a124a8f8d232f03090e4ce67b06be735e..7431ea698acbe5f504e5d8c6abf64c1877420fd5 100644 --- a/tests/script/tsim/stable/alter_import.sim +++ b/tests/script/tsim/stable/alter_import.sim @@ -5,7 +5,7 @@ print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d1 replica 1 duration 7 keep 50 sql use d1 sql create table tb (ts timestamp, a int) @@ -42,4 +42,4 @@ if $data00 != 6 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_insert1.sim b/tests/script/tsim/stable/alter_insert1.sim index bcea0b48c4032fa1d0ddd56a2c467559a39e8a77..0e5617e92d63a049e288c318e007bfdfd79e7b9b 100644 --- a/tests/script/tsim/stable/alter_insert1.sim +++ b/tests/script/tsim/stable/alter_insert1.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d3 sql use d3 sql create table tb (ts timestamp, a int) @@ -1137,4 +1137,4 @@ if $data79 != null then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_insert2.sim b/tests/script/tsim/stable/alter_insert2.sim index faae24d32aee731b9bee8ca4e5b89816c58cfb1c..a6046f3dda81458c4f760fb0c48b1352e21105fe 100644 --- a/tests/script/tsim/stable/alter_insert2.sim +++ b/tests/script/tsim/stable/alter_insert2.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d4 sql use d4 sql create table tb (ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10)) @@ -662,4 +662,4 @@ if $data62 != null then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_metrics.sim b/tests/script/tsim/stable/alter_metrics.sim index e32250de130210612a8f7bf70df7225da381c1ab..203f41e18bcf3148ab6b954288320b326bb3c07d 100644 --- a/tests/script/tsim/stable/alter_metrics.sim +++ b/tests/script/tsim/stable/alter_metrics.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d2 sql use d2 sql create table mt (ts timestamp, a int) TAGS (t int) @@ -757,8 +757,8 @@ endi print ======= over sql drop database d2 sql select * from information_schema.ins_databases -if $rows != 2 then +if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/column_add.sim b/tests/script/tsim/stable/column_add.sim index c0f3b4f4907402a863e5c4b25bcb8c4ee3d6f46f..05189f6c7d9f6800e7d8229c29c9bcd7284d238f 100644 --- a/tests/script/tsim/stable/column_add.sim +++ b/tests/script/tsim/stable/column_add.sim @@ -116,7 +116,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != NULL then return -1 endi @@ -153,7 +153,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != NULL then return -1 endi @@ -299,4 +299,4 @@ if $rows != 10 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/column_modify.sim b/tests/script/tsim/stable/column_modify.sim index e2752ccf951cef30587aa1f604f92cbbaa265b85..43284ba829ecd662872b24cefc13a51db28d025b 100644 --- a/tests/script/tsim/stable/column_modify.sim +++ b/tests/script/tsim/stable/column_modify.sim @@ -31,7 +31,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -92,7 +92,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -106,4 +106,4 @@ if $data[1][3] != 101 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/disk.sim b/tests/script/tsim/stable/disk.sim index e0e51b2625d5d90640dc846cefa0d151d9e4efb5..8edd0a845ecf7ced9638b32640d3278e73c93835 100644 --- a/tests/script/tsim/stable/disk.sim +++ b/tests/script/tsim/stable/disk.sim @@ -188,4 +188,4 @@ if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/refcount.sim b/tests/script/tsim/stable/refcount.sim index a83c0ca53f3033513e48dd21252a9db53eab4774..35d8767efd55df3d6a0126c1d9fd0e33c0f41176 100644 --- a/tests/script/tsim/stable/refcount.sim +++ b/tests/script/tsim/stable/refcount.sim @@ -123,4 +123,4 @@ if $rows != 2 then endi print =============== step6 -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_add.sim b/tests/script/tsim/stable/tag_add.sim index 7ee9aee974681a21ba7b186cd3d84f9492f6523e..4f5f0e745234e39ecce1e24a0e918094db8676f9 100644 --- a/tests/script/tsim/stable/tag_add.sim +++ b/tests/script/tsim/stable/tag_add.sim @@ -139,7 +139,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -170,7 +170,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -190,4 +190,4 @@ if $rows != 7 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_drop.sim b/tests/script/tsim/stable/tag_drop.sim index 7902358817c1ee9ba6038233a08810504be6fc70..b457bf195b8991721c59a581e6bd252b8f823906 100644 --- a/tests/script/tsim/stable/tag_drop.sim +++ b/tests/script/tsim/stable/tag_drop.sim @@ -165,7 +165,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -196,7 +196,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 201 then return -1 endi @@ -229,7 +229,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 201 then return -1 endi @@ -261,7 +261,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 301 then return -1 endi @@ -323,7 +323,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 302 then return -1 endi @@ -334,4 +334,4 @@ if $data[0][5] != 304 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_filter.sim b/tests/script/tsim/stable/tag_filter.sim index f44142fbbffdb4f19b32afd51f6d75fa2e798e88..de2a87d6c4a710d8fcb2af773d20ac1bfc252f84 100644 --- a/tests/script/tsim/stable/tag_filter.sim +++ b/tests/script/tsim/stable/tag_filter.sim @@ -27,47 +27,47 @@ sql create table db.ctb6 using db.stb tags(6, "102") sql insert into db.ctb6 values(now, 6, "2") sql select * from db.stb where t1 = 1 -if $rows != 1 then +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 < 1 -if $rows != 0 then +sql select * from db.stb where t1 < 1 +if $rows != 0 then return -=1 endi -sql select * from db.stb where t1 < 2 -if $rows != 1 then +sql select * from db.stb where t1 < 2 +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 <= 2 -if $rows != 2 then +sql select * from db.stb where t1 <= 2 +if $rows != 2 then return -1 endi -sql select * from db.stb where t1 >= 1 -if $rows != 6 then +sql select * from db.stb where t1 >= 1 +if $rows != 6 then return -1 endi -sql select * from db.stb where t1 > 1 -if $rows != 5 then +sql select * from db.stb where t1 > 1 +if $rows != 5 then return -1 endi -sql select * from db.stb where t1 between 1 and 1 -if $rows != 1 then +sql select * from db.stb where t1 between 1 and 1 +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 between 1 and 6 -if $rows != 6 then +sql select * from db.stb where t1 between 1 and 6 +if $rows != 6 then return -1 endi -sql select * from db.stb where t1 between 1 and 7 -if $rows != 6 then +sql select * from db.stb where t1 between 1 and 7 +if $rows != 6 then return -1 endi @@ -88,25 +88,25 @@ sql insert into db.ctbBin2 values(now, 3, "2") sql create table db.ctbBin3 using db.stbBin tags("d") sql insert into db.ctbBin3 values(now, 4, "2") -sql select * from db.stbBin where t1 = "a" -if $rows != 1 then +sql select * from db.stbBin where t1 = "a" +if $rows != 1 then return -1 endi -sql select * from db.stbBin where t1 < "a" -if $rows != 0 then +sql select * from db.stbBin where t1 < "a" +if $rows != 0 then return -=1 endi -sql select * from db.stbBin where t1 < "b" -if $rows != 1 then +sql select * from db.stbBin where t1 < "b" +if $rows != 1 then return -1 endi -sql select * from db.stbBin where t1 between "a" and "e" -if $rows != 4 then +sql select * from db.stbBin where t1 between "a" and "e" +if $rows != 4 then return -1 endi @@ -127,25 +127,25 @@ sql insert into db.ctbNc2 values(now, 3, "2") sql create table db.ctbNc3 using db.stbNc tags("d") sql insert into db.ctbNc3 values(now, 4, "2") -sql select * from db.stbNc where t1 = "a" -if $rows != 1 then +sql select * from db.stbNc where t1 = "a" +if $rows != 1 then return -1 endi -sql select * from db.stbNc where t1 < "a" -if $rows != 0 then +sql select * from db.stbNc where t1 < "a" +if $rows != 0 then return -=1 endi -sql select * from db.stbNc where t1 < "b" -if $rows != 1 then +sql select * from db.stbNc where t1 < "b" +if $rows != 1 then return -1 endi -sql select * from db.stbNc where t1 between "a" and "e" -if $rows != 4 then +sql select * from db.stbNc where t1 between "a" and "e" +if $rows != 4 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_modify.sim b/tests/script/tsim/stable/tag_modify.sim index 909ed7935944aa63f7776bbc75f27b7b156bf0fe..53e7227d1b43f32bbd14e719837b15c2b27e3ca5 100644 --- a/tests/script/tsim/stable/tag_modify.sim +++ b/tests/script/tsim/stable/tag_modify.sim @@ -28,7 +28,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -55,7 +55,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -120,4 +120,4 @@ if $data[4][2] != 5 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_rename.sim b/tests/script/tsim/stable/tag_rename.sim index 5bdfa24990d6742d25dee2a45d5aefd94230f648..c85ed183de1946ea7b876f989473189e7834e4e6 100644 --- a/tests/script/tsim/stable/tag_rename.sim +++ b/tests/script/tsim/stable/tag_rename.sim @@ -28,7 +28,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -52,7 +52,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -117,4 +117,4 @@ if $data[4][2] != 4 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/basic1.sim b/tests/script/tsim/stream/basic1.sim index 5392979c0a218884a50d0ebe9ddb39558e82304f..d9777d5133e8226364805d85fb0918caac763adb 100644 --- a/tests/script/tsim/stream/basic1.sim +++ b/tests/script/tsim/stream/basic1.sim @@ -462,10 +462,10 @@ if $data25 != 3 then return -1 endi -sql create database test2 vgroups 1 -sql select * from information_schema.ins_databases +sql create database test2 vgroups 1; +sql select * from information_schema.ins_databases; -sql use test2 +sql use test2; sql create stable st(ts timestamp, a int, b int, c int, d double) 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); diff --git a/tests/script/tsim/stream/partitionbyColumn0.sim b/tests/script/tsim/stream/partitionbyColumn0.sim new file mode 100644 index 0000000000000000000000000000000000000000..d91d4b7bf0c2f81cd00368b938898a15aec34091 --- /dev/null +++ b/tests/script/tsim/stream/partitionbyColumn0.sim @@ -0,0 +1,570 @@ +$loop_all = 0 +looptest: + +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 + +sql drop stream if exists streams0; +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 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, d double); +sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3, _group_key(a) c4 from t1 partition by a interval(10s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); + +$loop_count = 0 + +loop0: +sleep 100 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop0 +endi + +if $data02 != NULL then + print =====data02=$data02 + goto loop0 +endi + + +sql insert into t1 values(1648791213000,1,2,3,1.0); + +$loop_count = 0 + +loop1: +sleep 100 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop1 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); + +$loop_count = 0 + +loop2: +sleep 100 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop2 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791213001,2,2,3,1.0); +sql insert into t1 values(1648791213002,2,2,3,1.0); +sql insert into t1 values(1648791213002,1,2,3,1.0); + +$loop_count = 0 + +loop3: +sleep 100 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop3 +endi + +if $data11 != 2 then + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop3 +endi + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t1 values(1648791223001,1,2,3,1.0); +sql insert into t1 values(1648791223002,3,2,3,1.0); +sql insert into t1 values(1648791223003,3,2,3,1.0); +sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); + +$loop_count = 0 + +loop4: +sleep 100 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop4 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop4 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop4 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop4 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop4 +endi + +if $data22 != 1 then + print =====data22=$data22 + goto loop4 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop4 +endi + +if $data32 != 2 then + print =====data32=$data32 + goto loop4 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop4 +endi + +if $data42 != 3 then + print =====data42=$data42 + goto loop4 +endi + +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, d double); +sql create stream streams1 trigger at_once into streamt1 as select _wstart c1, count(*) c2, max(c) c3, _group_key(a+b) c4 from t1 partition by a+b interval(10s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,1,2,1,1.0); +sql insert into t1 values(1648791213001,2,1,2,2.0); +sql insert into t1 values(1648791213001,1,2,3,2.0); + +$loop_count = 0 + +loop5: +sleep 100 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop5 +endi + +sql insert into t1 values(1648791223000,1,2,4,2.0); +sql insert into t1 values(1648791223001,1,2,5,2.0); +sql insert into t1 values(1648791223002,1,2,5,2.0); +sql insert into t1 values(1648791213001,1,1,6,2.0) (1648791223002,1,1,7,2.0); + +$loop_count = 0 + +loop6: +sleep 100 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop6 +endi + +if $data02 != 6 then + print =====data02=$data02 + goto loop6 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop6 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop6 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop6 +endi + +if $data22 != 7 then + print =====data22=$data22 + goto loop6 +endi + +if $data31 != 2 then + print =====data31=$data31 + goto loop6 +endi + +if $data32 != 5 then + print =====data32=$data32 + goto loop6 +endi + +sql drop stream if exists streams2; +sql drop database if exists test2; +sql create database test2 vgroups 4; +sql use test2; +sql create stable st(ts timestamp, a int, b int, c int, d double) 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 test.streamt2 as select _wstart c1, count(*) c2, max(a) c3 from st partition by a interval(10s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL); + +$loop_count = 0 + +loop7: +sleep 100 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop7 +endi + +if $data02 != NULL then + print =====data02=$data02 + goto loop7 +endi + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t2 values(1648791213000,1,2,3,1.0); + +$loop_count = 0 + +loop8: +sleep 100 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop8 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop8 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); + +$loop_count = 0 + +loop9: +sleep 100 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop9 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop9 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791213001,2,2,3,1.0); +sql insert into t1 values(1648791213002,2,2,3,1.0); +sql insert into t1 values(1648791213002,1,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213001,2,2,3,1.0); +sql insert into t2 values(1648791213002,2,2,3,1.0); +sql insert into t2 values(1648791213002,1,2,3,1.0); + +$loop_count = 0 + +loop10: +sleep 100 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop10 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop10 +endi + +if $data11 != 4 thenloop4 + print =====data11=$data11 + goto loop10 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop10 +endi + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t1 values(1648791223001,1,2,3,1.0); +sql insert into t1 values(1648791223002,3,2,3,1.0); +sql insert into t1 values(1648791223003,3,2,3,1.0); +sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); +sql insert into t2 values(1648791223000,1,2,3,1.0); +sql insert into t2 values(1648791223001,1,2,3,1.0); +sql insert into t2 values(1648791223002,3,2,3,1.0); +sql insert into t2 values(1648791223003,3,2,3,1.0); +sql insert into t2 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); + +$loop_count = 0 + +loop11: +sleep 100 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop11 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop11 +endi + +if $data11 != 4 then + print =====data11=$data11 + goto loop11 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop11 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop11 +endi + +if $data22 != 2 then + print =====data22=$data22 + goto loop11 +endi + +if $data31 != 2 then + print =====data31=$data31 + goto loop11 +endi + +if $data32 != 3 then + print =====data32=$data32 + goto loop11 +endi + +if $data41 != 4 then + print =====data41=$data41 + goto loop11 +endi + +if $data42 != 1 then + print =====data42=$data42 + goto loop11 +endi + +sql drop stream if exists streams4; +sql drop database if exists test4; +sql create database test4 vgroups 4; +sql use test4; +sql create stable st(ts timestamp, a int, b int, c int, d double) 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(2,2,2); +sql create table t4 using st tags(2,2,2); +sql create stream streams4 trigger at_once into test.streamt4 as select _wstart c1, count(*) c2, max(a) c3 from st partition by a interval(10s); + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +sql insert into t3 values(1648791213000,2,2,3,1.0); +sql insert into t4 values(1648791213000,2,2,3,1.0); +sql insert into t4 values(1648791213000,1,2,3,1.0); + +$loop_count = 0 + +loop13: +sleep 100 +sql select * from test.streamt4 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $rows != 2 then + print =====rows=$rows + goto loop13 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop13 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop13 +endi + +if $data11 != 3 then + print =====data11=$data11 + goto loop13 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop13 +endi + +sql insert into t4 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791233000,2,2,3,1.0); + + +sql insert into t1 values(1648791213000,1,2,3,1.0); + +$loop_count = 0 + +loop14: +sleep 100 +sql select * from test.streamt4 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +if $rows != 3 then + print =====rows=$rows + goto loop14 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop14 +endi + +if $data11 != 3 then + print =====data11=$data11 + goto loop14 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop14 +endi + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +system sh/stop_dnodes.sh + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/partitionbyColumn1.sim b/tests/script/tsim/stream/partitionbyColumn1.sim new file mode 100644 index 0000000000000000000000000000000000000000..7f5c53ebe3855693e5974aa4c2945af1af235216 --- /dev/null +++ b/tests/script/tsim/stream/partitionbyColumn1.sim @@ -0,0 +1,546 @@ +$loop_all = 0 +looptest: + +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 + +sql drop stream if exists streams0; +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 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, d double); +sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3, _group_key(a) c4 from t1 partition by a session(ts, 5s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); + +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop0 +endi + +if $data02 != NULL then + print =====data02=$data02 + goto loop0 +endi + + +sql insert into t1 values(1648791213000,1,2,3,1.0); + +loop1: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop1 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); + +loop2: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop2 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791213001,2,2,3,1.0); +sql insert into t1 values(1648791213002,2,2,3,1.0); +sql insert into t1 values(1648791213002,1,2,3,1.0); + +loop3: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop3 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop3 +endi + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t1 values(1648791223001,1,2,3,1.0); +sql insert into t1 values(1648791223002,3,2,3,1.0); +sql insert into t1 values(1648791223003,3,2,3,1.0); +sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); + +loop4: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop4 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop4 +endi + +if $data11 != 2 then + print =====data11=$data11 + goto loop4 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop4 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop4 +endi + +if $data22 != 1 then + print =====data22=$data22 + goto loop4 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop4 +endi + +if $data32 != 2 then + print =====data32=$data32 + goto loop4 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop4 +endi + +if $data42 != 3 then + print =====data42=$data42 + goto loop4 +endi + +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, d double); +sql create stream streams1 trigger at_once into streamt1 as select _wstart c1, count(*) c2, max(c) c3, _group_key(a+b) c4 from t1 partition by a+b session(ts, 5s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,1,2,1,1.0); +sql insert into t1 values(1648791213001,2,1,2,2.0); +sql insert into t1 values(1648791213001,1,2,3,2.0); + +$loop_count = 0 + +loop5: +sleep 300 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop5 +endi + +sql insert into t1 values(1648791223000,1,2,4,2.0); +sql insert into t1 values(1648791223001,1,2,5,2.0); +sql insert into t1 values(1648791223002,1,2,5,2.0); +sql insert into t1 values(1648791213001,1,1,6,2.0) (1648791223002,1,1,7,2.0); + +loop6: +sleep 300 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop6 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop6 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop6 +endi + +if $data12 != 6 then + print =====data12=$data12 + goto loop6 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop6 +endi + +if $data22 != 5 then + print =====data22=$data22 + goto loop6 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop6 +endi + +if $data32 != 7 then + print =====data32=$data32 + goto loop6 +endi + +sql drop database if exists test2; +sql create database test2 vgroups 4; +sql use test2; +sql create stable st(ts timestamp, a int, b int, c int, d double) 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 test.streamt2 as select _wstart c1, count(*) c2, max(a) c3 from st partition by a session(ts, 5s); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL); + +$loop_count = 0 + +loop7: +sleep 300 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop7 +endi + +if $data02 != NULL then + print =====data02=$data02 + goto loop7 +endi + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t2 values(1648791213000,1,2,3,1.0); + +loop8: +sleep 300 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop8 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop8 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +loop9: +sleep 300 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop9 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop9 +endi + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791213001,2,2,3,1.0); +sql insert into t1 values(1648791213002,2,2,3,1.0); +sql insert into t1 values(1648791213002,1,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213001,2,2,3,1.0); +sql insert into t2 values(1648791213002,2,2,3,1.0); +sql insert into t2 values(1648791213002,1,2,3,1.0); + +loop10: +sleep 300 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 4 then + print =====data01=$data01 + goto loop10 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop10 +endi + +if $data11 != 2 thenloop4 + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop10 +endi + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t1 values(1648791223001,1,2,3,1.0); +sql insert into t1 values(1648791223002,3,2,3,1.0); +sql insert into t1 values(1648791223003,3,2,3,1.0); +sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); +sql insert into t2 values(1648791223000,1,2,3,1.0); +sql insert into t2 values(1648791223001,1,2,3,1.0); +sql insert into t2 values(1648791223002,3,2,3,1.0); +sql insert into t2 values(1648791223003,3,2,3,1.0); +sql insert into t2 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); + +loop11: +sleep 300 +sql select * from test.streamt2 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop11 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop11 +endi + +if $data11 != 4 then + print =====data11=$data11 + goto loop11 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop11 +endi + +if $data21 != 4 then + print =====data21=$data21 + goto loop11 +endi + +if $data22 != 1 then + print =====data22=$data22 + goto loop11 +endi + +if $data31 != 2 then + print =====data31=$data31 + goto loop11 +endi + +if $data32 != 2 then + print =====data32=$data32 + goto loop11 +endi + +if $data41 != 2 then + print =====data41=$data41 + goto loop11 +endi + +if $data42 != 3 then + print =====data42=$data42 + goto loop11 +endi + +sql drop database if exists test4; +sql create database test4 vgroups 4; +sql use test4; +sql create stable st(ts timestamp, a int, b int, c int, d double) 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(2,2,2); +sql create table t4 using st tags(2,2,2); +sql create stream streams4 trigger at_once into test.streamt4 as select _wstart c1, count(*) c2, max(a) c3 from st partition by a session(ts, 5s); + +sql insert into t1 values(1648791213000,2,2,3,1.0); +sql insert into t2 values(1648791213000,2,2,3,1.0); +sql insert into t3 values(1648791213000,2,2,3,1.0); +sql insert into t4 values(1648791213000,2,2,3,1.0); +sql insert into t4 values(1648791213000,1,2,3,1.0); + +$loop_count = 0 + +loop13: +sleep 300 +sql select * from test.streamt4 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then + print =====rows=$rows + goto loop14 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop13 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop13 +endi + +if $data11 != 3 then + print =====data11=$data11 + goto loop11 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop11 +endi + +sql insert into t4 values(1648791213000,2,2,3,1.0); +sql insert into t1 values(1648791233000,2,2,3,1.0); + + +sql insert into t1 values(1648791213000,1,2,3,1.0); + +loop14: +sleep 300 +sql select * from test.streamt4 order by c1, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 3 then + print =====rows=$rows + goto loop14 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop14 +endi + +if $data11 != 3 then + print =====data11=$data11 + goto loop14 +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop14 +endi + +system sh/stop_dnodes.sh + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +#goto looptest \ No newline at end of file diff --git a/tests/script/tsim/stream/partitionbyColumn2.sim b/tests/script/tsim/stream/partitionbyColumn2.sim new file mode 100644 index 0000000000000000000000000000000000000000..3d9acbcac50e360fc445b9ebe5fdbedec4009a7b --- /dev/null +++ b/tests/script/tsim/stream/partitionbyColumn2.sim @@ -0,0 +1,269 @@ +$loop_all = 0 +looptest: + +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 + +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, d double); +sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3, _group_key(a) c4 from t1 partition by a state_window(b); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); + +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop0 +endi + +if $data02 != NULL then + print =====data02=$data02 + goto loop0 +endi + + +sql insert into t1 values(1648791213000,1,1,3,1.0); + +loop1: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop1 +endi + +sql insert into t1 values(1648791213000,2,1,3,1.0); + +loop2: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop2 +endi + +sql insert into t1 values(1648791213000,2,1,3,1.0); +sql insert into t1 values(1648791213001,2,1,3,1.0); +sql insert into t1 values(1648791213002,2,1,3,1.0); +sql insert into t1 values(1648791213002,1,1,3,1.0); + +loop3: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop3 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop3 +endi + +sql insert into t1 values(1648791223000,1,2,3,1.0); +sql insert into t1 values(1648791223001,1,2,3,1.0); +sql insert into t1 values(1648791223002,3,2,3,1.0); +sql insert into t1 values(1648791223003,3,2,3,1.0); +sql insert into t1 values(1648791213001,1,1,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0); + +loop4: +sleep 300 +sql select * from streamt order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop4 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop4 +endi + +if $data11 != 2 then + print =====data11=$data11 + goto loop4 +endi + +if $data12 != 1 then + print =====data12=$data12 + goto loop4 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop4 +endi + +if $data22 != 1 then + print =====data22=$data22 + goto loop4 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop4 +endi + +if $data32 != 2 then + print =====data32=$data32 + goto loop4 +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop4 +endi + +if $data42 != 3 then + print =====data42=$data42 + goto loop4 +endi + +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, d int); +sql create stream streams1 trigger at_once into streamt1 as select _wstart c1, count(*) c2, max(d) c3, _group_key(a+b) c4 from t1 partition by a+b state_window(c); + +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL); +sql insert into t1 values(1648791213000,1,2,1,1); +sql insert into t1 values(1648791213001,2,1,1,2); +sql insert into t1 values(1648791213001,1,2,1,3); + +$loop_count = 0 + +loop5: +sleep 300 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop5 +endi + +sql insert into t1 values(1648791223000,1,2,2,4); +sql insert into t1 values(1648791223001,1,2,2,5); +sql insert into t1 values(1648791223002,1,2,2,6); +sql insert into t1 values(1648791213001,1,1,1,7) (1648791223002,1,1,2,8); + +loop6: +sleep 300 +sql select * from streamt1 order by c1, c4, c2, c3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop6 +endi + +if $data02 != 1 then + print =====data02=$data02 + goto loop6 +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop6 +endi + +if $data12 != 7 then + print =====data12=$data12 + goto loop6 +endi + +if $data21 != 2 then + print =====data21=$data21 + goto loop6 +endi + +if $data22 != 5 then + print =====data22=$data22 + goto loop6 +endi + +if $data31 != 1 then + print =====data31=$data31 + goto loop6 +endi + +if $data32 != 8 then + print =====data32=$data32 + goto loop6 +endi + +system sh/stop_dnodes.sh + +$loop_all = $loop_all + 1 +print ============loop_all=$loop_all + +#goto looptest diff --git a/tests/script/tsim/sync/create-mnode.sim b/tests/script/tsim/sync/create-mnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..cfaafc8208e7e10f7b53be76a6eaa94e718efbbd --- /dev/null +++ b/tests/script/tsim/sync/create-mnode.sim @@ -0,0 +1,20 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 + +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start + +sql connect +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +sql create mnode on dnode 2 +sql create mnode on dnode 3 diff --git a/tests/script/tsim/user/privilege_sysinfo.sim b/tests/script/tsim/user/privilege_sysinfo.sim index e8348d92d43ede9c594ffa8487e22f27a95de503..86f95755d09f7e2f1c0654b94f63f471f9a074d0 100644 --- a/tests/script/tsim/user/privilege_sysinfo.sim +++ b/tests/script/tsim/user/privilege_sysinfo.sim @@ -163,6 +163,9 @@ sql select * from information_schema.ins_stables sql select * from information_schema.ins_tables sql select * from information_schema.ins_tags sql select * from information_schema.ins_users +sql select * from information_schema.ins_topics +sql select * from information_schema.ins_subscriptions +sql select * from information_schema.ins_streams sql_error select * from information_schema.ins_grants sql_error select * from information_schema.ins_vgroups sql_error select * from information_schema.ins_configs @@ -172,11 +175,8 @@ print =============== check performance_schema sql use performance_schema; sql select * from performance_schema.perf_connections sql select * from performance_schema.perf_queries -sql select * from performance_schema.perf_topics sql select * from performance_schema.perf_consumers -sql select * from performance_schema.perf_subscriptions sql select * from performance_schema.perf_trans -sql select * from performance_schema.perf_streams sql select * from performance_schema.perf_apps #system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/checkError6.sim b/tests/script/tsim/valgrind/checkError6.sim index fcc5b04c907852f87c469a3dc9d32c5ba1295327..11a387ed4dffd7258120154adb9d7874ee0b21b5 100644 --- a/tests/script/tsim/valgrind/checkError6.sim +++ b/tests/script/tsim/valgrind/checkError6.sim @@ -67,17 +67,17 @@ sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20 order by ts sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m) sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol order by tgcol sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20 sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from tb1 interval(10s, 2s) sliding(10s) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) order by tgcol desc sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from tb1 sql select length("abcd1234"), char_length("abcd1234=-+*") from tb1 sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from tb1 sql select * from tb1 where tbcol not in (1,2,3,null); sql select * from tb1 where tbcol + 3 <> null; -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) sql select tbcol5 - tbcol3 from tb1 print =============== step4: stb @@ -97,8 +97,8 @@ sql select first(tbcol), last(tbcol) as c from stb group by tgcol sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m) sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m) sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 and tgcol = 1 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 and tgcol = 1 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) order by tgcol desc sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from stb interval(10s, 2s) sliding(10s) sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from stb @@ -108,7 +108,7 @@ sql select * from stb where tbcol not in (1,2,3,null); sql select * from stb where tbcol + 3 <> null; sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb where tbcol = 1 and tbcol2 = 1 and tbcol3 = 1 partition by tgcol interval(1d) sql select _wstart, count(*) from tb1 session(ts, 1m) -sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) sql select tbcol5 - tbcol3 from stb sql select spread( tbcol2 )/44, spread(tbcol2), 0.204545455 * 44 from stb; @@ -127,8 +127,8 @@ sql explain analyze select count(*),sum(tbcol) from stb; sql explain analyze select count(*),sum(tbcol) from stb group by tbcol; sql explain analyze select * from information_schema.ins_stables; sql explain analyze verbose true select * from information_schema.ins_stables where db_name='db2'; -sql explain analyze verbose true select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) -sql explain select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) +sql explain analyze verbose true select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) +sql explain select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0,0,0,0,0) print =============== step6: in cast sql select 1+1n; @@ -158,6 +158,8 @@ print =============== restart system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s start -v +sleep 1000 + sql select avg(tbcol) as c from stb sql select avg(tbcol) as c from stb where ts <= 1601481840000 sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000 diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 3be59f0adf691f9479cce2c927c9161741bc8130..a20b7b17bccf9a04d52e46d56af2a2d0b0e489fb 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -282,12 +282,12 @@ class TDTestCase: use.error(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())") elif check_priv == PRIVILEGES_WRITE: use.query(f"use {DBNAME}") - use.query(f"show {DBNAME}.tables") + use.error(f"show {DBNAME}.tables") use.error(f"select * from {DBNAME}.{CTBNAME}") use.query(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())") elif check_priv is None: use.error(f"use {DBNAME}") - # use.error(f"show {DBNAME}.tables") + use.error(f"show {DBNAME}.tables") use.error(f"show tables") use.error(f"select * from {DBNAME}.{CTBNAME}") use.error(f"insert into {DBNAME}.{CTBNAME} (ts) values (now())") diff --git a/tests/system-test/1-insert/influxdb_line_taosc_insert.py b/tests/system-test/1-insert/influxdb_line_taosc_insert.py index 25e2378f4611aea030011ed29ecce6b9b96cad84..cae4294bc90c16ad3fed032eff610f5b943d789e 100644 --- a/tests/system-test/1-insert/influxdb_line_taosc_insert.py +++ b/tests/system-test/1-insert/influxdb_line_taosc_insert.py @@ -31,7 +31,7 @@ if platform.system().lower() == 'windows': class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) + tdSql.init(conn.cursor(), False) self._conn = conn def createDb(self, name="test", db_update_tag=0): @@ -357,7 +357,7 @@ class TDTestCase: """ normal tags and cols, one for every elm """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) @@ -365,7 +365,7 @@ class TDTestCase: """ check all normal type """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) @@ -379,7 +379,7 @@ class TDTestCase: please test : binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' ''' - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = f'L{binary_symbols}' input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols) @@ -390,7 +390,7 @@ class TDTestCase: test ts list --> ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"] # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过 """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") ts_list = ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0] for ts in ts_list: input_sql, stb_name = self.genFullTypeSql(ts=ts) @@ -401,7 +401,7 @@ class TDTestCase: check id.index in tags eg: t0=**,id=**,t1=** """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) self.resCmp(input_sql, stb_name) @@ -410,7 +410,7 @@ class TDTestCase: check id param eg: id and ID """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True) self.resCmp(input_sql, stb_name) input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True) @@ -420,7 +420,7 @@ class TDTestCase: """ id not exist """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True) self.resCmp(input_sql, stb_name) query_sql = f"select tbname from {stb_name}" @@ -436,10 +436,10 @@ class TDTestCase: max col count is ?? """ for input_sql in [self.genLongSql(127, 1)[0], self.genLongSql(1, 4093)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) except SchemalessError as err: @@ -450,7 +450,7 @@ class TDTestCase: test illegal id name mix "~!@#$¥%^&*()-+|[]、「」【】;:《》<>?" """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") rstr = list("~!@#$¥%^&*()-+|[]、「」【】;:《》<>?") for i in rstr: stb_name=f"aaa{i}bbb" @@ -462,7 +462,7 @@ class TDTestCase: """ id is start with num """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -473,7 +473,7 @@ class TDTestCase: """ check now unsupported """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="now")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -484,7 +484,7 @@ class TDTestCase: """ check date format ts unsupported """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -495,7 +495,7 @@ class TDTestCase: """ check ts format like 16260068336390us19 """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="16260068336390us19")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -506,7 +506,7 @@ class TDTestCase: """ check full type tag value limit """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # i8 for t1 in ["-128i8", "127i8"]: input_sql, stb_name = self.genFullTypeSql(t1=t1) @@ -602,7 +602,7 @@ class TDTestCase: """ check full type col value limit """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # i8 for c1 in ["-128i8", "127i8"]: input_sql, stb_name = self.genFullTypeSql(c1=c1) @@ -699,7 +699,7 @@ class TDTestCase: """ test illegal tag col value """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # bool for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: input_sql1 = self.genFullTypeSql(t0=i)[0] @@ -758,7 +758,7 @@ class TDTestCase: """ check duplicate Id Tag Col """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql_id = self.genFullTypeSql(id_double_tag=True)[0] try: self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -792,7 +792,7 @@ class TDTestCase: """ case no id when stb exist """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f") self.resCmp(input_sql, stb_name) input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f") @@ -805,7 +805,7 @@ class TDTestCase: """ check duplicate insert when stb exist """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) @@ -816,7 +816,7 @@ class TDTestCase: """ check length increase """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) tb_name = tdCom.getLongName(5, "letters") @@ -833,7 +833,7 @@ class TDTestCase: * col is added without value when update==0 * col is added with value when update==1 """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") for db_update_tag in [0, 1]: if db_update_tag == 1 : @@ -850,7 +850,7 @@ class TDTestCase: """ check column and tag count add """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f") self.resCmp(input_sql, stb_name) @@ -866,7 +866,7 @@ class TDTestCase: condition: stb not change insert two table, keep tag unchange, change col """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True) self.resCmp(input_sql, stb_name) tb_name1 = self.getNoIdTbName(stb_name) @@ -888,7 +888,7 @@ class TDTestCase: """ every binary and nchar must be length+2 """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000' @@ -928,7 +928,7 @@ class TDTestCase: """ check nchar length limit """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000' @@ -963,7 +963,7 @@ class TDTestCase: """ test batch insert """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") # tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", @@ -982,7 +982,7 @@ class TDTestCase: """ test multi insert """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") sql_list = [] stb_name = tdCom.getLongName(8, "letters") # tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') @@ -996,7 +996,7 @@ class TDTestCase: """ test batch error insert """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"] @@ -1068,7 +1068,7 @@ class TDTestCase: """ thread input different stb """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genSqlList()[0] self.multiThreadRun(self.genMultiThreadSeq(input_sql)) tdSql.query(f"show tables;") @@ -1078,7 +1078,7 @@ class TDTestCase: """ thread input same stb tb, different data, result keep first data """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1095,7 +1095,7 @@ class TDTestCase: """ thread input same stb tb, different data, add columes and tags, result keep first data """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1112,7 +1112,7 @@ class TDTestCase: """ thread input same stb tb, different data, minus columes and tags, result keep first data """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1129,7 +1129,7 @@ class TDTestCase: """ thread input same stb, different tb, different data """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4] @@ -1144,7 +1144,7 @@ class TDTestCase: """ thread input same stb, different tb, different data, add col, mul tag """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5] @@ -1159,7 +1159,7 @@ class TDTestCase: """ thread input same stb, different tb, different data, add tag, mul col """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6] @@ -1171,7 +1171,7 @@ class TDTestCase: """ thread input same stb tb, different ts """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1186,7 +1186,7 @@ class TDTestCase: """ thread input same stb tb, different ts, add col, mul tag """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1205,7 +1205,7 @@ class TDTestCase: """ thread input same stb tb, different ts, add tag, mul col """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name) self.resCmp(input_sql, stb_name) @@ -1226,7 +1226,7 @@ class TDTestCase: """ thread input same stb, different tb, data, ts """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10] @@ -1241,7 +1241,7 @@ class TDTestCase: """ thread input same stb, different tb, data, ts, add col, mul tag """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11] diff --git a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py index 003abe9d10346f9b7cce1dbdb6f6f0ed73e3ea55..3b01784000b74c1f6bb072f24e8be36e99d37f4f 100644 --- a/tests/system-test/1-insert/opentsdb_json_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_json_taosc_insert.py @@ -459,7 +459,7 @@ class TDTestCase: normal tags and cols, one for every elm """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(value_type=value_type) self.resCmp(input_json, stb_name) @@ -468,7 +468,7 @@ class TDTestCase: check all normal type """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] for t_type in full_type_list: input_json_list = [self.genFullTypeJson(tag_value=self.genTagValue(t0_value=t_type))[0], @@ -489,7 +489,7 @@ class TDTestCase: binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' ''' tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = binary_symbols input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type), @@ -505,7 +505,7 @@ class TDTestCase: # ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") ts_list = ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006834", 0] for ts in ts_list: if "s" in str(ts): @@ -571,7 +571,7 @@ class TDTestCase: eg: t0=**,id=**,t1=** """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(id_change_tag=True, value_type=value_type) self.resCmp(input_json, stb_name) @@ -581,7 +581,7 @@ class TDTestCase: eg: id and ID """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(id_upper_tag=True, value_type=value_type) self.resCmp(input_json, stb_name) input_json, stb_name = self.genFullTypeJson(id_mixul_tag=True, value_type=value_type) @@ -594,7 +594,7 @@ class TDTestCase: id not exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(id_noexist_tag=True, value_type=value_type) self.resCmp(input_json, stb_name) query_sql = f"select tbname from {stb_name}" @@ -610,10 +610,10 @@ class TDTestCase: """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') for input_json in [self.genLongJson(128, value_type)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) for input_json in [self.genLongJson(129, value_type)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) except SchemalessError as err: @@ -625,7 +625,7 @@ class TDTestCase: mix "`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") rstr = list("`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?") for i in rstr: input_json = self.genFullTypeJson(tb_name=f'aa{i}bb', value_type=value_type)[0] @@ -639,7 +639,7 @@ class TDTestCase: id is start with num """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(tb_name="1aaabbb", value_type=value_type)[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -651,7 +651,7 @@ class TDTestCase: check now unsupported """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="now", t_type="ns", value_type=value_type))[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -663,7 +663,7 @@ class TDTestCase: check date format ts unsupported """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="2021-07-21\ 19:01:46.920", t_type="ns", value_type=value_type))[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -675,7 +675,7 @@ class TDTestCase: check ts format like 16260068336390us19 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="16260068336390us19", t_type="us", value_type=value_type))[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -690,7 +690,7 @@ class TDTestCase: length of stb_name tb_name <= 192 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tdSql.execute('reset query cache') stb_name_192 = tdCom.getLongName(len=192, mode="letters") tb_name_192 = tdCom.getLongName(len=192, mode="letters") @@ -715,7 +715,7 @@ class TDTestCase: check tag name limit <= 62 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tag_name = tdCom.getLongName(61, "letters") tag_name = f't{tag_name}' stb_name = tdCom.getLongName(7, "letters") @@ -733,7 +733,7 @@ class TDTestCase: check full type tag value limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # i8 for t1 in [-127, 127]: input_json, stb_name = self.genFullTypeJson(tag_value=self.genTagValue(t1_value=t1, value_type=value_type)) @@ -854,12 +854,12 @@ class TDTestCase: check full type col value limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # i8 for value in [-128, 127]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="tinyint", value_type=value_type)) self.resCmp(input_json, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-129, 128]: input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="tinyint"))[0] try: @@ -868,11 +868,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) # i16 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-32768]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="smallint", value_type=value_type)) self.resCmp(input_json, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-32769, 32768]: input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="smallint"))[0] try: @@ -882,11 +882,11 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # i32 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-2147483648]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="int", value_type=value_type)) self.resCmp(input_json, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-2147483649, 2147483648]: input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="int"))[0] try: @@ -896,12 +896,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # i64 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-9223372036854775808]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint", value_type=value_type)) self.resCmp(input_json, stb_name) # ! bug - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # for value in [-9223372036854775809, 9223372036854775808]: # print(value) # input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint"))[0] @@ -913,12 +913,12 @@ class TDTestCase: # tdSql.checkNotEqual(err.errno, 0) # f32 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-3.4028234663852885981170418348451692544*(10**38), 3.4028234663852885981170418348451692544*(10**38)]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float", value_type=value_type)) self.resCmp(input_json, stb_name) # * limit set to 4028234664*(10**38) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-3.4028234664*(10**38), 3.4028234664*(10**38)]: input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float"))[0] try: @@ -928,12 +928,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # f64 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308), -1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)]: input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="double", value_type=value_type)) self.resCmp(input_json, stb_name) # * limit set to 1.797693134862316*(10**308) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [-1.797693134862316*(10**308), -1.797693134862316*(10**308)]: input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="double", value_type=value_type))[0] try: @@ -944,12 +944,12 @@ class TDTestCase: # if value_type == "obj": # # binary - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # stb_name = tdCom.getLongName(7, "letters") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16375, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # try: # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -959,12 +959,12 @@ class TDTestCase: # # nchar # # * legal nchar could not be larger than 16374/4 - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # stb_name = tdCom.getLongName(7, "letters") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(4093, "letters"), 'type': 'nchar'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(4094, "letters"), 'type': 'nchar'}, "tags": {"t0": {'value': True, 'type': 'bool'}}} # try: # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -973,14 +973,14 @@ class TDTestCase: # tdSql.checkNotEqual(err.errno, 0) # elif value_type == "default": # # binary - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # stb_name = tdCom.getLongName(7, "letters") # if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary": # input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(16374, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}} # elif tdSql.getVariable("defaultJSONStrType")[0].lower() == "nchar": # input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(4093, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}} # self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary": # input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(16375, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}} # elif tdSql.getVariable("defaultJSONStrType")[0].lower() == "nchar": @@ -997,7 +997,7 @@ class TDTestCase: test illegal tag col value """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # bool for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: try: @@ -1046,7 +1046,7 @@ class TDTestCase: check duplicate Id Tag Col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(id_double_tag=True, value_type=value_type)[0] print(input_json) try: @@ -1068,7 +1068,7 @@ class TDTestCase: case no id when stb exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(tb_name="sub_table_0123456", col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type)) self.resCmp(input_json, stb_name) input_json, stb_name = self.genFullTypeJson(stb_name=stb_name, id_noexist_tag=True, col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type)) @@ -1081,7 +1081,7 @@ class TDTestCase: check duplicate insert when stb exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(value_type=value_type) self.resCmp(input_json, stb_name) self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1091,7 +1091,7 @@ class TDTestCase: """ check length increase """ - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(value_type=value_type) self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) self.resCmp(input_json, stb_name) @@ -1105,7 +1105,7 @@ class TDTestCase: check length increase """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = "test_crash" input_json = self.genFullTypeJson(stb_name=stb_name)[0] self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1128,7 +1128,7 @@ class TDTestCase: * col is added with value when update==1 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") for db_update_tag in [0, 1]: if db_update_tag == 1 : @@ -1154,7 +1154,7 @@ class TDTestCase: check tag count add """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type)) self.resCmp(input_json, stb_name) @@ -1171,7 +1171,7 @@ class TDTestCase: insert two table, keep tag unchange, change col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type), id_noexist_tag=True) self.resCmp(input_json, stb_name) tb_name1 = self.getNoIdTbName(stb_name) @@ -1194,7 +1194,7 @@ class TDTestCase: every binary and nchar must be length+2 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' tag_value = {"t0": {"value": True, "type": "bool"}} @@ -1240,7 +1240,7 @@ class TDTestCase: check nchar length limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(7, "letters") tb_name = f'{stb_name}_1' tag_value = {"t0": True} @@ -1284,7 +1284,7 @@ class TDTestCase: test batch insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = "stb_name" tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') input_json = [{"metric": "st123456", "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": {"value": 1, "type": "bigint"}, "tags": {"t1": {"value": 3, "type": "bigint"}, "t2": {"value": 4, "type": "double"}, "t3": {"value": "t3", "type": "binary"}}}, @@ -1319,7 +1319,7 @@ class TDTestCase: test multi insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") sql_list = list() stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') @@ -1335,7 +1335,7 @@ class TDTestCase: test batch error insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = [{"metric": "st123456", "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": {"value": "tt", "type": "bool"}, "tags": {"t1": {"value": 3, "type": "bigint"}, "t2": {"value": 4, "type": "double"}, "t3": {"value": "t3", "type": "binary"}}}, {"metric": "st123456", "timestamp": {"value": 1626006933641000000, "type": "ns"}, "value": {"value": 9, "type": "bigint"}, "tags": {"t1": {"value": 4, "type": "bigint"}, "t3": {"value": "t4", "type": "binary"}, "t2": {"value": 5, "type": "double"}, "t4": {"value": 5, "type": "double"}}}] try: @@ -1349,7 +1349,7 @@ class TDTestCase: test multi cols insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(c_multi_tag=True, value_type=value_type)[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1362,7 +1362,7 @@ class TDTestCase: test blank col insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(c_blank_tag=True, value_type=value_type)[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1375,7 +1375,7 @@ class TDTestCase: test blank tag insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(t_blank_tag=True, value_type=value_type)[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1388,7 +1388,7 @@ class TDTestCase: check nchar ---> chinese """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(chinese_tag=True) self.resCmp(input_json, stb_name) @@ -1397,7 +1397,7 @@ class TDTestCase: multi_field ''' tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(multi_field_tag=True, value_type=value_type)[0] try: self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) @@ -1407,7 +1407,7 @@ class TDTestCase: def spellCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") input_json_list = [{"metric": f'{stb_name}_1', "timestamp": {"value": 1626006833639000000, "type": "Ns"}, "value": {"value": 1, "type": "Bigint"}, "tags": {"t1": {"value": 127, "type": "tinYint"}}}, {"metric": f'{stb_name}_2', "timestamp": {"value": 1626006833639000001, "type": "nS"}, "value": {"value": 32767, "type": "smallInt"}, "tags": {"t1": {"value": 32767, "type": "smallInt"}}}, @@ -1426,7 +1426,7 @@ class TDTestCase: def tbnameTagsColsNameCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = {'metric': 'rFa$sta', 'timestamp': {'value': 1626006834, 'type': 's'}, 'value': {'value': True, 'type': 'bool'}, 'tags': {'Tt!0': {'value': False, 'type': 'bool'}, 'tT@1': {'value': 127, 'type': 'tinyint'}, 't@2': {'value': 32767, 'type': 'smallint'}, 't$3': {'value': 2147483647, 'type': 'int'}, 't%4': {'value': 9223372036854775807, 'type': 'bigint'}, 't^5': {'value': 11.12345027923584, 'type': 'float'}, 't&6': {'value': 22.123456789, 'type': 'double'}, 't*7': {'value': 'binaryTagValue', 'type': 'binary'}, 't!@#$%^&*()_+[];:<>?,9': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': 'rFas$ta_1'}} self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) query_sql = 'select * from `rFa$sta`' @@ -1441,7 +1441,7 @@ class TDTestCase: metric value "." trans to "_" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genFullTypeJson(point_trans_tag=True, value_type=value_type)[0] self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None) tdSql.execute("drop table `.point.trans.test`") @@ -1509,7 +1509,7 @@ class TDTestCase: thread input different stb """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json = self.genSqlList(value_type=value_type)[0] self.multiThreadRun(self.genMultiThreadSeq(input_json)) tdSql.query(f"show tables;") @@ -1520,7 +1520,7 @@ class TDTestCase: thread input same stb tb, different data, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) @@ -1538,7 +1538,7 @@ class TDTestCase: thread input same stb tb, different data, add columes and tags, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) @@ -1556,7 +1556,7 @@ class TDTestCase: thread input same stb tb, different data, minus columes and tags, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) @@ -1574,7 +1574,7 @@ class TDTestCase: thread input same stb, different tb, different data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) s_stb_d_tb_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[4] @@ -1587,7 +1587,7 @@ class TDTestCase: thread input same stb, different tb, different data, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) s_stb_d_tb_m_tag_list = [({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "omfdhyom", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'), @@ -1605,7 +1605,7 @@ class TDTestCase: thread input same stb, different tb, different data, add tag, mul col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) s_stb_d_tb_a_tag_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[6] @@ -1618,7 +1618,7 @@ class TDTestCase: thread input same stb tb, different ts """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) @@ -1638,7 +1638,7 @@ class TDTestCase: thread input same stb tb, different ts, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) @@ -1660,7 +1660,7 @@ class TDTestCase: thread input same stb tb, different ts, add tag, mul col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) @@ -1683,7 +1683,7 @@ class TDTestCase: thread input same stb, different tb, data, ts """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type)) self.resCmp(input_json, stb_name) s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[10] @@ -1696,7 +1696,7 @@ class TDTestCase: thread input same stb, different tb, data, ts, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary")) self.resCmp(input_json, stb_name) s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'), diff --git a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py index 3c47a65746b89c96b77408b6c910c88a8703e147..209cfb724e460207493dc2ca1ab0dd3522eb333b 100644 --- a/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py +++ b/tests/system-test/1-insert/opentsdb_telnet_line_taosc_insert.py @@ -30,7 +30,7 @@ if platform.system().lower() == 'windows': class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) + tdSql.init(conn.cursor(), False) self._conn = conn self.smlChildTableName_value = "id" @@ -351,7 +351,7 @@ class TDTestCase: normal tags and cols, one for every elm """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) @@ -360,7 +360,7 @@ class TDTestCase: check all normal type """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"] for t_type in full_type_list: input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol) @@ -375,7 +375,7 @@ class TDTestCase: binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"' ''' tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"' nchar_symbols = f'L{binary_symbols}' input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol) @@ -388,7 +388,7 @@ class TDTestCase: test ts list --> ["1626006833640ms", "1626006834s", "1626006822639022"] """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(ts=1626006833640) self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MILLI_SECOND.value) input_sql, stb_name = self.genFullTypeSql(ts=1626006833640) @@ -407,7 +407,7 @@ class TDTestCase: def openTstbTelnetTsCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = f'{tdCom.getLongName(len=10, mode="letters")} 0 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64' stb_name = input_sql.split(" ")[0] self.resCmp(input_sql, stb_name, ts=0) @@ -431,7 +431,7 @@ class TDTestCase: eg: t0=**,id=**,t1=** """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) @@ -441,7 +441,7 @@ class TDTestCase: eg: id and ID """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True, protocol=protocol) @@ -454,7 +454,7 @@ class TDTestCase: id not exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) query_sql = f"select tbname from {stb_name}" @@ -470,10 +470,10 @@ class TDTestCase: """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') for input_sql in [self.genLongSql(128)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) for input_sql in [self.genLongSql(129)[0]]: - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) raise Exception("should not reach here") @@ -486,7 +486,7 @@ class TDTestCase: mix "`~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") rstr = list("~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?") for i in rstr: input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"", protocol=protocol) @@ -498,7 +498,7 @@ class TDTestCase: id is start with num """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb", protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol) @@ -507,7 +507,7 @@ class TDTestCase: check now unsupported """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="now")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -520,7 +520,7 @@ class TDTestCase: check date format ts unsupported """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -533,7 +533,7 @@ class TDTestCase: check ts format like 16260068336390us19 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(ts="16260068336390us19")[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -551,7 +551,7 @@ class TDTestCase: tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') stb_name_192 = tdCom.getLongName(len=192, mode="letters") tb_name_192 = tdCom.getLongName(len=192, mode="letters") - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name_192, tb_name=tb_name_192) self.resCmp(input_sql, stb_name) tdSql.query(f'select * from {stb_name}') @@ -581,7 +581,7 @@ class TDTestCase: check tag name limit <= 62 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tag_name = tdCom.getLongName(61, "letters") tag_name = f'T{tag_name}' stb_name = tdCom.getLongName(7, "letters") @@ -599,7 +599,7 @@ class TDTestCase: check full type tag value limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # nchar # * legal nchar could not be larger than 16374/4 stb_name = tdCom.getLongName(7, "letters") @@ -618,12 +618,12 @@ class TDTestCase: check full type col value limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # i8 for value in ["-128i8", "127i8"]: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-129i8", "128i8"]: input_sql = self.genFullTypeSql(value=value)[0] try: @@ -632,11 +632,11 @@ class TDTestCase: except SchemalessError as err: tdSql.checkNotEqual(err.errno, 0) # i16 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-32768i16"]: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-32769i16", "32768i16"]: input_sql = self.genFullTypeSql(value=value)[0] try: @@ -646,11 +646,11 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # i32 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-2147483648i32"]: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-2147483649i32", "2147483648i32"]: input_sql = self.genFullTypeSql(value=value)[0] try: @@ -660,11 +660,11 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # i64 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-9223372036854775808i64"]: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in ["-9223372036854775809i64", "9223372036854775808i64"]: input_sql = self.genFullTypeSql(value=value)[0] try: @@ -674,12 +674,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # f32 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) # * limit set to 4028234664*(10**38) - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]: input_sql = self.genFullTypeSql(value=value)[0] try: @@ -689,12 +689,12 @@ class TDTestCase: tdSql.checkNotEqual(err.errno, 0) # f64 - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") for value in [f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64', f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64']: input_sql, stb_name = self.genFullTypeSql(value=value) self.resCmp(input_sql, stb_name) # # * limit set to 1.797693134862316*(10**308) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # for value in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']: # input_sql = self.genFullTypeSql(value=value)[0] # try: @@ -704,12 +704,12 @@ class TDTestCase: # tdSql.checkNotEqual(err.errno, 0) # # # binary - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t' # try: # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -719,12 +719,12 @@ class TDTestCase: # # nchar # # * legal nchar could not be larger than 16374/4 - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # stb_name = tdCom.getLongName(7, "letters") # input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4093, "letters")}" t0=t' # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) - # tdCom.cleanTb() + # tdCom.cleanTb(dbname="test") # input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4094, "letters")}" t0=t' # try: # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -738,7 +738,7 @@ class TDTestCase: test illegal tag col value """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # bool for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]: input_sql1, stb_name = self.genFullTypeSql(t0=i) @@ -774,7 +774,7 @@ class TDTestCase: check blank case ''' tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") # input_sql_list = [f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc aaa" t0=t', # f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0="abaaa"', # f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=L"abaaa"', @@ -792,7 +792,7 @@ class TDTestCase: check duplicate Id Tag Col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql_id = self.genFullTypeSql(id_double_tag=True)[0] try: self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.TELNET.value, None) @@ -815,7 +815,7 @@ class TDTestCase: case no id when stb exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", value="f") self.resCmp(input_sql, stb_name) input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", value="f") @@ -828,7 +828,7 @@ class TDTestCase: check duplicate insert when stb exist """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -840,7 +840,7 @@ class TDTestCase: check length increase """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql() self.resCmp(input_sql, stb_name) tb_name = tdCom.getLongName(5, "letters") @@ -858,7 +858,7 @@ class TDTestCase: * col is added with value when update==1 """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") for db_update_tag in [0, 1]: if db_update_tag == 1 : @@ -885,7 +885,7 @@ class TDTestCase: check tag count add """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", value="f") self.resCmp(input_sql, stb_name) @@ -902,7 +902,7 @@ class TDTestCase: insert two table, keep tag unchange, change col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(t0="f", value="f", id_noexist_tag=True) self.resCmp(input_sql, stb_name) tb_name1 = self.getNoIdTbName(stb_name) @@ -925,7 +925,7 @@ class TDTestCase: check nchar length limit """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(7, "letters") input_sql = f'{stb_name} 1626006833640 f t2={tdCom.getLongName(1, "letters")}' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -949,7 +949,7 @@ class TDTestCase: test batch insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') @@ -976,7 +976,7 @@ class TDTestCase: test multi insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") sql_list = [] stb_name = tdCom.getLongName(8, "letters") tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 nchar(10))') @@ -992,7 +992,7 @@ class TDTestCase: test batch error insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") lines = ["st123456 1626006833640 3i 64 t1=3i64 t2=4f64 t3=\"t3\"", f"{stb_name} 1626056811823316532ns tRue t2=5f64 t3=L\"ste\""] @@ -1007,7 +1007,7 @@ class TDTestCase: test multi cols insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(c_multi_tag=True)[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -1020,7 +1020,7 @@ class TDTestCase: test blank col insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(c_blank_tag=True)[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -1033,7 +1033,7 @@ class TDTestCase: test blank tag insert """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(t_blank_tag=True)[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -1046,7 +1046,7 @@ class TDTestCase: check nchar ---> chinese """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(chinese_tag=True) self.resCmp(input_sql, stb_name) @@ -1055,7 +1055,7 @@ class TDTestCase: multi_field ''' tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(multi_field_tag=True)[0] try: self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -1065,7 +1065,7 @@ class TDTestCase: def spellCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") input_sql_list = [f'{stb_name}_1 1626006833640 127I8 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64', f'{stb_name}_2 1626006833640 32767I16 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64', @@ -1086,7 +1086,7 @@ class TDTestCase: metric value "." trans to "_" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(point_trans_tag=True, protocol=protocol)[0] if protocol == 'telnet-tcp': stb_name = f'`{input_sql.split(" ")[1]}`' @@ -1097,7 +1097,7 @@ class TDTestCase: def defaultTypeCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") stb_name = tdCom.getLongName(8, "letters") input_sql_list = [f'{stb_name}_1 1626006833640 9223372036854775807 t0=f t1=127 t2=32767i16 t3=2147483647i32 t4=9223372036854775807 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \ f'{stb_name}_2 1626006833641 22.123456789 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789 t7="vozamcts" t8=L"ncharTagValue"', \ @@ -1110,7 +1110,7 @@ class TDTestCase: def tbnameTagsColsNameCheckCase(self): tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") if self.smlChildTableName_value == "ID": input_sql = 'rFa$sta 1626006834 9223372036854775807 id=rFas$ta_1 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"' self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) @@ -1135,7 +1135,7 @@ class TDTestCase: stb = "put" """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genFullTypeSql(tcp_keyword_tag=True, protocol=protocol)[0] stb_name = f'`{input_sql.split(" ")[1]}`' self.resCmp(input_sql, stb_name, protocol=protocol) @@ -1204,7 +1204,7 @@ class TDTestCase: thread input different stb """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql = self.genSqlList()[0] print(input_sql) self.multiThreadRun(self.genMultiThreadSeq(input_sql)) @@ -1216,7 +1216,7 @@ class TDTestCase: thread input same stb tb, different data, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1235,7 +1235,7 @@ class TDTestCase: thread input same stb tb, different data, add columes and tags, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1254,7 +1254,7 @@ class TDTestCase: thread input same stb tb, different data, minus columes and tags, result keep first data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1273,7 +1273,7 @@ class TDTestCase: thread input same stb, different tb, different data """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4] @@ -1286,7 +1286,7 @@ class TDTestCase: thread input same stb, different tb, different data, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) s_stb_d_tb_m_tag_list = [(f'{stb_name} 1626006833640 "omfdhyom" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \ @@ -1303,7 +1303,7 @@ class TDTestCase: thread input same stb, different tb, different data, add tag, mul col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) s_stb_d_tb_a_tag_list = self.genSqlList(stb_name=stb_name)[6] @@ -1316,7 +1316,7 @@ class TDTestCase: thread input same stb tb, different ts """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1336,7 +1336,7 @@ class TDTestCase: thread input same stb tb, different ts, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1354,7 +1354,7 @@ class TDTestCase: thread input same stb tb, different ts, add tag, mul col """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") tb_name = tdCom.getLongName(7, "letters") input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) @@ -1377,7 +1377,7 @@ class TDTestCase: thread input same stb, different tb, data, ts """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10] @@ -1390,7 +1390,7 @@ class TDTestCase: thread input same stb, different tb, data, ts, add col, mul tag """ tdLog.info(f'{sys._getframe().f_code.co_name}() function is running') - tdCom.cleanTb() + tdCom.cleanTb(dbname="test") input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"") self.resCmp(input_sql, stb_name) s_stb_d_tb_d_ts_m_tag_list = [(f'{stb_name} 0 "mnpmtzul" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \ diff --git a/tests/system-test/2-query/function_diff.py b/tests/system-test/2-query/function_diff.py index fd5d6ea1cf1d42623443cbe13eb60aac6b9e80ac..946453bb23137d6ebbb67f8d588a67e054f5c2f1 100644 --- a/tests/system-test/2-query/function_diff.py +++ b/tests/system-test/2-query/function_diff.py @@ -193,43 +193,38 @@ class TDTestCase: # case17: only support normal table join case17 = { - "col": "t1.c1", - "table_expr": "t1, t2", - "condition": "where t1.ts=t2.ts" + "col": "table1.c1 ", + "table_expr": "db.t1 as table1, db.t2 as table2", + "condition": "where table1.ts=table2.ts" } self.checkdiff(**case17) - # case18~19: with group by - # case18 = { - # "table_expr": "db.t1", - # "condition": "group by c6" - # } - # self.checkdiff(**case18) + # case18~19: with group by , function diff not support group by + case19 = { - "table_expr": "db.stb1", + "table_expr": "db.stb1 where tbname =='t0' ", "condition": "partition by tbname order by tbname" # partition by tbname } self.checkdiff(**case19) - # # case20~21: with order by - # case20 = {"condition": "order by ts"} - # self.checkdiff(**case20) + # case20~21: with order by , Not a single-group group function - # # case22: with union + # case22: with union # case22 = { - # "condition": "union all select diff(c1) from t2" + # "condition": "union all select diff(c1) from db.t2 " # } # self.checkdiff(**case22) + tdSql.query("select count(c1) from db.t1 union all select count(c1) from db.t2") # case23: with limit/slimit case23 = { "condition": "limit 1" } self.checkdiff(**case23) - # case24 = { - # "table_expr": "db.stb1", - # "condition": "group by tbname slimit 1 soffset 1" - # } - # self.checkdiff(**case24) + case24 = { + "table_expr": "db.stb1", + "condition": "partition by tbname order by tbname slimit 1 soffset 1" + } + self.checkdiff(**case24) pass @@ -284,9 +279,9 @@ class TDTestCase: tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1 # tdSql.error(self.diff_query_form(table_expr="db.stb1")) # select stb directly stb_join = { - "col": "stb1.c1", - "table_expr": "stb1, stb2", - "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" + "col": "stable1.c1", + "table_expr": "db.stb1 as stable1, db.stb2 as stable2", + "condition": "where stable1.ts=stable2.ts and stable1.st1=stable2.st2 order by stable1.ts" } tdSql.query(self.diff_query_form(**stb_join)) # stb join interval_sql = { @@ -315,20 +310,20 @@ class TDTestCase: for i in range(tbnum): for j in range(data_row): tdSql.execute( - f"insert into t{i} values (" + f"insert into db.t{i} values (" f"{basetime + (j+1)*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, " f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, " f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )" ) tdSql.execute( - f"insert into t{i} values (" + f"insert into db.t{i} values (" f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, " f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, " f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )" ) tdSql.execute( - f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" + f"insert into db.tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" ) pass @@ -349,8 +344,8 @@ class TDTestCase: "create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)" ) for i in range(tbnum): - tdSql.execute(f"create table t{i} using db.stb1 tags({i})") - tdSql.execute(f"create table tt{i} using db.stb2 tags({i})") + tdSql.execute(f"create table db.t{i} using db.stb1 tags({i})") + tdSql.execute(f"create table db.tt{i} using db.stb2 tags({i})") pass def diff_support_stable(self): @@ -398,8 +393,8 @@ class TDTestCase: tdLog.printNoPrefix("######## insert only NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime - 5})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime + 5})") self.diff_current_query() self.diff_error_query() @@ -430,9 +425,9 @@ class TDTestCase: tdLog.printNoPrefix("######## insert data mix with NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") + tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") self.diff_current_query() self.diff_error_query() diff --git a/tests/system-test/2-query/join2.py b/tests/system-test/2-query/join2.py index 5533cb840e29d2e0b109687f2aa3189d2c26a381..5c8fe0f0f96e6c28aa1ef70240b3ef4d5b0598fa 100644 --- a/tests/system-test/2-query/join2.py +++ b/tests/system-test/2-query/join2.py @@ -52,12 +52,12 @@ class TDTestCase: return query_condition - def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): + def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False, alias_tb1="tb1", alias_tb2="tb2"): table_reference = tb_list[0] join_condition = table_reference join = "inner join" if INNER else "join" for i in range(len(tb_list[1:])): - join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}" + join_condition += f" as {alias_tb1} {join} {tb_list[i+1]} as {alias_tb2} on {alias_tb1}.{filter}={alias_tb2}.{filter}" return join_condition @@ -123,28 +123,28 @@ class TDTestCase: sqls = [] __join_tblist = self.__join_tblist for join_tblist in __join_tblist: - for join_tb in join_tblist: - select_claus_list = self.__query_condition(join_tb) - for select_claus in select_claus_list: - group_claus = self.__group_condition( col=select_claus) - where_claus = self.__where_condition( query_conditon=select_claus ) - having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" ) - sqls.extend( - ( - # self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, having_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus), - # self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist), having_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist)), - # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, having_claus), - self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, ), - self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), having_claus ), - # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ), - self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True) ), - ) + alias_tb = "tb1" + select_claus_list = self.__query_condition(alias_tb) + for select_claus in select_claus_list: + group_claus = self.__group_condition( col=select_claus) + where_claus = self.__where_condition( query_conditon=select_claus ) + having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" ) + sqls.extend( + ( + # self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus, having_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus), + # self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), having_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb)), + # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, having_claus), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, ), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), having_claus ), + # self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ), + self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True) ), ) + ) return list(filter(None, sqls)) def __join_check(self,): @@ -341,10 +341,8 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + tdSql.execute(f"flush database db") - tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() diff --git a/tests/system-test/2-query/last_row.py b/tests/system-test/2-query/last_row.py index f65744a0b7666a2fc9d0e60332fc20fb53ca6886..5d435b068fb12959fd2bdc6f02968b2a7ffe7c9d 100644 --- a/tests/system-test/2-query/last_row.py +++ b/tests/system-test/2-query/last_row.py @@ -638,13 +638,13 @@ class TDTestCase: tdSql.query(f"select ts , last_row(c1) ,c1 from (select ts , c1 ,t1 from {dbname}.stb1)") tdSql.checkData(0,1,None) - tdSql.query(f"select ts , last_row(c1) ,c1 from (select ts , max(c1) c1 ,t1 from {dbname}.stb1 where ts >now -1h and ts now -1h and ts now -1h and ts now -1h and ts now -1h and ts now -1h and ts 0: - elem = math.log(elem) - elif elem <=0: - elem = None - row_check.append(elem) - auto_result.append(row_check) - - check_status = True - for row_index , row in enumerate(log_result): - for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] != elem: - check_status = False - if not check_status: - tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) - sys.exit(1) - else: - tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - - def check_result_auto_log2(self ,origin_query , log_query): - - log_result = tdSql.getResult(log_query) - origin_result = tdSql.getResult(origin_query) - - auto_result =[] - - for row in origin_result: - row_check = [] - for elem in row: - if elem == None: - elem = None - elif elem >0: - elem = math.log(elem,2) - elif elem <=0: - elem = None - row_check.append(elem) - auto_result.append(row_check) - - check_status = True - for row_index , row in enumerate(log_result): - for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] != elem: - check_status = False - if not check_status: - tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) - sys.exit(1) - else: - tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - - def check_result_auto_log1(self ,origin_query , log_query): - log_result = tdSql.getResult(log_query) - origin_result = tdSql.getResult(origin_query) - - auto_result =[] - - for row in origin_result: - row_check = [] - for elem in row: - if elem == None: - elem = None - elif elem >0: - elem = None - elif elem <=0: - elem = None - row_check.append(elem) - auto_result.append(row_check) - - check_status = True - for row_index , row in enumerate(log_result): - for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] != elem: - check_status = False - if not check_status: - tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) - sys.exit(1) - else: - tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - def check_result_auto_log__10(self ,origin_query , log_query): log_result = tdSql.getResult(log_query) origin_result = tdSql.getResult(origin_query) @@ -163,26 +75,30 @@ class TDTestCase: for row in origin_result: row_check = [] for elem in row: - if elem == None: - elem = None - elif elem >0: - elem = None - elif elem <=0: + if base ==1: elem = None + else: + if elem == None: + elem = None + elif elem ==1: + elem = 0.0 + elif elem >0 and elem !=1 : + if base==None : + elem = math.log(elem ) + else: + print(base , elem) + elem = math.log(elem , base) + elif elem <=0: + elem = None + row_check.append(elem) auto_result.append(row_check) - check_status = True + tdSql.query(log_query) for row_index , row in enumerate(log_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] != elem: - check_status = False - if not check_status: - tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query ) - sys.exit(1) - else: - tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query ) - + tdSql.checkData(row_index , col_index ,auto_result[row_index][col_index]) + def test_errors(self, dbname="db"): error_sql_lists = [ f"select log from {dbname}.t1", @@ -328,10 +244,10 @@ class TDTestCase: tdSql.checkData(3 , 0, 1.098612289) tdSql.checkData(4 , 0, 1.386294361) - self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1") - self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1") - self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1") - self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,-10), log(c2 ,-10) ,log(c3, -10), log(c4 ,-10), log(c5 ,-10) from {dbname}.t1") + self.check_result_auto_log( None , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1") + self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1") + self.check_result_auto_log( 1, f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1") + self.check_result_auto_log( 10 ,f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,10), log(c2 ,10) ,log(c3, 10), log(c4 ,10), log(c5 ,10) from {dbname}.t1") # used for sub table tdSql.query(f"select c1 ,log(c1 ,3) from {dbname}.ct1") @@ -349,9 +265,9 @@ class TDTestCase: tdSql.checkData(3 , 2, 0.147315235) tdSql.checkData(4 , 2, None) - self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1") - self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1") - self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) from {dbname}.ct1") + self.check_result_auto_log( None ,f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1") + self.check_result_auto_log( 2, f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1") + self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) from {dbname}.ct1") # nest query for log functions tdSql.query(f"select c1 , log(c1,3) ,log(log(c1,3),3) , log(log(log(c1,3),3),3) from {dbname}.ct1;") @@ -585,15 +501,15 @@ class TDTestCase: tdSql.error( f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound") - self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound") - self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) ,log(c6,-10) from {dbname}.sub1_bound") + self.check_result_auto_log(None , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound") + self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound") + self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) ,log(c6,10) from {dbname}.sub1_bound") - self.check_result_auto_log2( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound") - self.check_result_auto_log( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound") + self.check_result_auto_log( 2 , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound") + self.check_result_auto_log( None , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound") - self.check_result_auto_log2(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" ) + self.check_result_auto_log(2 , f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" ) # check basic elem for table per row tdSql.query(f"select log(abs(c1),2) ,log(abs(c2),2) , log(abs(c3),2) , log(abs(c4),2), log(abs(c5),2), log(abs(c6),2) from {dbname}.sub1_bound ") @@ -647,15 +563,15 @@ class TDTestCase: def support_super_table_test(self, dbname="db"): - self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" ) - self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" ) - self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" ) + self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" ) - self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" ) - self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" ) + self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log( 2 ,f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() diff --git a/tests/system-test/2-query/lower.py b/tests/system-test/2-query/lower.py index 0917fb63fc638263849625aec5b907c05260f49f..0e33e3834ec9ecc50470f0793b29a3a4b84d4834 100644 --- a/tests/system-test/2-query/lower.py +++ b/tests/system-test/2-query/lower.py @@ -96,16 +96,16 @@ class TDTestCase: return sqls - def __test_current(self): + def __test_current(self, dbname="db"): tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: self.__lower_current_check(tb) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: for errsql in self.__lower_err_check(tb): @@ -113,22 +113,20 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -138,78 +136,78 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values - ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } ) - ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } ) + f'''insert into {dbname}.ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000} + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} ) ( { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000} + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} ) ''' ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, - { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, - { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, - "binary_{i}", "nchar_{i}", { now_time - 1000 * i } ) + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, - "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, - "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) @@ -227,10 +225,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) - - tdSql.execute("use db") + tdSql.execute("flush database db") tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() diff --git a/tests/system-test/2-query/ltrim.py b/tests/system-test/2-query/ltrim.py index 15f40a09c3db67e4324e75768532221f55f2e35f..330f688990d614c1a824fd25741f19966e227581 100644 --- a/tests/system-test/2-query/ltrim.py +++ b/tests/system-test/2-query/ltrim.py @@ -23,6 +23,7 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [ BOOL_COL, ] TS_TYPE_COL = [ TS_COL, ] +DBNAME = "db" class TDTestCase: @@ -120,16 +121,16 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname=DBNAME): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: self.__ltrim_check(tb) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname=DBNAME): tdLog.printNoPrefix("==========err sql condition check , must return error==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: for errsql in self.__ltrim_err_check(tb): @@ -142,17 +143,16 @@ class TDTestCase: self.__test_error() - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname=DBNAME): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -162,29 +162,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname=DBNAME): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -200,7 +200,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -216,13 +216,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -251,8 +251,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") diff --git a/tests/system-test/2-query/mavg.py b/tests/system-test/2-query/mavg.py index 0995dfc6ffedb28232c56d6f4826b8b2454249ff..b52217af9ac61e5a3c08d55b11e4219ec826b203 100644 --- a/tests/system-test/2-query/mavg.py +++ b/tests/system-test/2-query/mavg.py @@ -307,7 +307,7 @@ class TDTestCase: pass - def mavg_current_query(self) : + def mavg_current_query(self, dbname="db") : # table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool # c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16) @@ -325,17 +325,17 @@ class TDTestCase: case6 = {"col": "c9"} self.checkmavg(**case6) - # # case7~8: nested query - # case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"} - # self.checkmavg(**case7) - # case8 = {"table_expr": f"(select mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"} + # case7~8: nested query + case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"} + self.checkmavg(**case7) + # case8 = {"table_expr": f"(select _c0, mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"} # self.checkmavg(**case8) # case9~10: mix with tbname/ts/tag/col - # case9 = {"alias": ", tbname"} - # self.checkmavg(**case9) - # case10 = {"alias": ", _c0"} - # self.checkmavg(**case10) + case9 = {"alias": ", tbname"} + self.checkmavg(**case9) + case10 = {"alias": ", _c0"} + self.checkmavg(**case10) # case11 = {"alias": ", st1"} # self.checkmavg(**case11) # case12 = {"alias": ", c1"} @@ -356,7 +356,7 @@ class TDTestCase: # case17: only support normal table join case17 = { "col": "t1.c1", - "table_expr": "t1, t2", + "table_expr": f"{dbname}.t1 t1, {dbname}.t2 t2", "condition": "where t1.ts=t2.ts" } self.checkmavg(**case17) @@ -367,14 +367,14 @@ class TDTestCase: # } # self.checkmavg(**case19) - # case20~21: with order by + # # case20~21: with order by # case20 = {"condition": "order by ts"} # self.checkmavg(**case20) - #case21 = { - # "table_expr": f"{dbname}.stb1", - # "condition": "group by tbname order by tbname" - #} - #self.checkmavg(**case21) + case21 = { + "table_expr": f"{dbname}.stb1", + "condition": "group by tbname order by tbname" + } + self.checkmavg(**case21) # # case22: with union # case22 = { @@ -398,7 +398,7 @@ class TDTestCase: pass - def mavg_error_query(self) -> None : + def mavg_error_query(self, dbname="db") -> None : # unusual test # form test @@ -419,9 +419,9 @@ class TDTestCase: err8 = {"table_expr": ""} self.checkmavg(**err8) # no table_expr - # err9 = {"col": "st1"} + err9 = {"col": "st1"} # self.checkmavg(**err9) # col: tag - # err10 = {"col": 1} + err10 = {"col": 1} # self.checkmavg(**err10) # col: value err11 = {"col": "NULL"} self.checkmavg(**err11) # col: NULL @@ -496,7 +496,7 @@ class TDTestCase: # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" # } # self.checkmavg(**err44) # stb join - tdSql.query("select mavg( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;") + tdSql.query(f"select mavg( stb1.c1 , 1 ) from {dbname}.stb1 stb1, {dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;") err45 = { "condition": "where ts>0 and ts < now interval(1h) fill(next)" } diff --git a/tests/system-test/2-query/max.py b/tests/system-test/2-query/max.py index 34442a3725d69092535c02a509ba8cece4c10ed4..169b1c2c387c7158635483f8ce8868891e42e3c2 100644 --- a/tests/system-test/2-query/max.py +++ b/tests/system-test/2-query/max.py @@ -5,10 +5,7 @@ import numpy as np class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) @@ -17,60 +14,80 @@ class TDTestCase: self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def max_check_stb_and_tb_base(self): + def max_check_stb_and_tb_base(self, dbname="db"): tdSql.prepare() intData = [] floatData = [] - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + tdSql.execute(f'''create table {dbname}.stb(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)) tags(loc nchar(20))''') - tdSql.execute("create table stb_1 using stb tags('beijing')") + tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')") for i in range(self.rowNum): - tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) - for i in ['ts','col11','col12','col13']: - for j in ['db.stb','stb','db.stb_1','stb_1']: - tdSql.error(f'select max({i} from {j} )') + for i in ['col11','col12','col13']: + for j in ['stb','stb_1']: + tdSql.error(f'select max({i} from {dbname}.{j} )') for i in range(1,11): - for j in ['db.stb','stb','db.stb_1','stb_1']: - tdSql.query(f"select max(col{i}) from {j}") + for j in ['stb', 'stb_1']: + tdSql.query(f"select max(col{i}) from {dbname}.{j}") if i<9: tdSql.checkData(0, 0, np.max(intData)) elif i>=9: tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col1) from stb_1 where col2<=5") + + tdSql.query(f"select max(now()) from {dbname}.stb_1") + tdSql.checkRows(1) + + tdSql.query(f"select last(ts) from {dbname}.stb_1") + lastTs = tdSql.getData(0, 0) + tdSql.query(f"select max(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, lastTs) + + tdSql.query(f"select last(ts) from {dbname}.stb") + lastTs = tdSql.getData(0, 0) + tdSql.query(f"select max(ts) from {dbname}.stb") + tdSql.checkData(0, 0, lastTs) + + tdSql.query(f"select max(col1) from {dbname}.stb_1 where col2<=5") tdSql.checkData(0,0,5) - tdSql.query("select max(col1) from stb where col2<=5") + tdSql.query(f"select max(col1) from {dbname}.stb where col2<=5") tdSql.checkData(0,0,5) - tdSql.execute('drop database db') - def max_check_ntb_base(self): + def max_check_ntb_base(self, dbname="db"): tdSql.prepare() intData = [] floatData = [] - tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + tdSql.execute(f'''create table {dbname}.ntb(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))''') for i in range(self.rowNum): - tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) - for i in ['ts','col11','col12','col13']: - for j in ['db.ntb','ntb']: - tdSql.error(f'select max({i} from {j} )') + for i in ['col11','col12','col13']: + for j in ['ntb']: + tdSql.error(f'select max({i} from {dbname}.{j} )') for i in range(1,11): - for j in ['db.ntb','ntb']: - tdSql.query(f"select max(col{i}) from {j}") + for j in ['ntb']: + tdSql.query(f"select max(col{i}) from {dbname}.{j}") if i<9: tdSql.checkData(0, 0, np.max(intData)) elif i>=9: tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col1) from ntb where col2<=5") - tdSql.checkData(0,0,5) - tdSql.execute('drop database db') + tdSql.query(f"select max(now()) from {dbname}.ntb") + tdSql.checkRows(1) + + tdSql.query(f"select last(ts) from {dbname}.ntb") + lastTs = tdSql.getData(0, 0) + tdSql.query(f"select max(ts) from {dbname}.ntb") + tdSql.checkData(0, 0, lastTs) + + tdSql.query(f"select max(col1) from {dbname}.ntb where col2<=5") + tdSql.checkData(0,0,5) def check_max_functions(self, tbname , col_name): @@ -90,55 +107,55 @@ class TDTestCase: tdLog.info(" max function work as expected, sql : %s "% max_sql) - def support_distributed_aggregate(self): + def support_distributed_aggregate(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") + tdSql.execute(f"use {dbname} ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(20): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + 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): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) for i in range(1,21): if i ==1 or i == 4: continue else: - tbname = "ct"+f'{i}' + tbname = f"{dbname}.ct{i}" for j in range(9): tdSql.execute( f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -157,7 +174,7 @@ class TDTestCase: tdLog.info(" prepare data for distributed_aggregate done! ") # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -167,7 +184,7 @@ class TDTestCase: # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query("select * from information_schema.ins_tables where db_name = 'testdb' and table_name like 'ct%'") + tdSql.query(f"select * from information_schema.ins_tables where db_name = '{dbname}' and table_name like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -182,13 +199,13 @@ class TDTestCase: # check max function work status - tdSql.query("show tables like 'ct%'") + tdSql.query(f"show {dbname}.tables like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: tablenames.append(table_name[0]) - tdSql.query("desc stb1") + tdSql.query(f"desc {dbname}.stb1") col_names = tdSql.queryResult colnames = [] @@ -198,11 +215,7 @@ class TDTestCase: for tablename in tablenames: for colname in colnames: - self.check_max_functions(tablename,colname) - - # max function with basic filter - print(vnode_tables) - + self.check_max_functions(f"{dbname}.{tablename}", colname) def run(self): diff --git a/tests/system-test/2-query/max_partition.py b/tests/system-test/2-query/max_partition.py index 4b9996d9c3b1d45f52e184f1da4ec8e59714feaa..01c267724210591e639753c3566c4826a5218813 100644 --- a/tests/system-test/2-query/max_partition.py +++ b/tests/system-test/2-query/max_partition.py @@ -12,16 +12,15 @@ class TDTestCase: self.tb_nums = 10 self.ts = 1537146000000 - def prepare_datas(self, stb_name , tb_nums , row_nums ): - tdSql.execute(" use db ") - tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\ + def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ): + tdSql.execute(f" create stable {dbname}.{stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\ uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\ , t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ") for i in range(tb_nums): - tbname = f"sub_{stb_name}_{i}" + tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") for row in range(row_nums): ts = self.ts + row*1000 @@ -31,191 +30,192 @@ class TDTestCase: ts = self.ts + row_nums*1000 + null*1000 tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )") - def basic_query(self): - tdSql.query("select count(*) from stb") + def basic_query(self, dbname="db"): + tdSql.query(f"select count(*) from {dbname}.stb") tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums) - tdSql.query("select max(c1) from stb") + tdSql.query(f"select max(c1) from {dbname}.stb") tdSql.checkData(0,0,(self.row_nums -1)) - tdSql.query(" select tbname , max(c1) from stb partition by tbname ") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname ") tdSql.checkRows(self.tb_nums) - tdSql.query(" select max(c1) from stb group by t1 order by t1 ") + tdSql.query(f"select max(c1) from {dbname}.stb group by t1 order by t1 ") tdSql.checkRows(self.tb_nums) - tdSql.query(" select max(c1) from stb group by c1 order by t1 ") - tdSql.query(" select max(t2) from stb group by c1 order by t1 ") - tdSql.query(" select max(c1) from stb group by tbname order by tbname ") + tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by t1 ") + tdSql.query(f"select max(t2) from {dbname}.stb group by c1 order by t1 ") + tdSql.query(f"select max(c1) from {dbname}.stb group by tbname order by tbname ") tdSql.checkRows(self.tb_nums) # bug need fix - tdSql.query(" select max(t2) from stb group by t2 order by t2 ") + tdSql.query(f"select max(t2) from {dbname}.stb group by t2 order by t2 ") tdSql.checkRows(self.tb_nums) - tdSql.query(" select max(c1) from stb group by c1 order by c1 ") + tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by c1 ") tdSql.checkRows(self.row_nums+1) - tdSql.query(" select c1 , max(c1) from stb group by c1 order by c1 ") + tdSql.query(f"select c1 , max(c1) from {dbname}.stb group by c1 order by c1 ") tdSql.checkRows(self.row_nums+1) # support selective functions - tdSql.query(" select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ") + tdSql.query(f"select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ") tdSql.checkRows(self.row_nums+1) - tdSql.query(" select c1, tbname , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ") + tdSql.query(f"select c1, tbname , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ") tdSql.checkRows(self.row_nums+1) # bug need fix - # tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ") - # tdSql.checkRows(1) - # tdSql.checkData(0,0,"sub_stb_1") + tdSql.query(f"select tbname , max(c1) from {dbname}.sub_stb_1 where c1 is null group by c1 order by c1 desc ") + tdSql.checkRows(1) + tdSql.checkData(0,0,"sub_stb_1") - tdSql.query("select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)") + tdSql.query(f"select max(c1) ,c2 ,t2,tbname from {dbname}.stb group by abs(c1) order by abs(c1)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select abs(c1+c3), count(c1+c3) ,max(c1+t2) from stb group by abs(c1+c3) order by abs(c1+c3)") + tdSql.query(f"select abs(c1+c3), count(c1+c3) ,max(c1+t2) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select max(c1+c3)+min(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)") + tdSql.query(f"select max(c1+c3)+min(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)") tdSql.checkRows(self.row_nums+1) - tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from stb group by abs(c1) order by abs(t1)+c2") - tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2") - tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+max(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") + tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from {dbname}.stb group by abs(c1) order by abs(t1)+c2") + tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2") + tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+max(c2) from {dbname}.stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") tdSql.checkRows(self.row_nums+1) - tdSql.query(" select max(c1) , max(t2) from stb where abs(c1+t2)=1 partition by tbname ") + tdSql.query(f"select max(c1) , max(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ") tdSql.checkRows(2) - tdSql.query(" select max(c1) from stb where abs(c1+t2)=1 partition by tbname ") + tdSql.query(f"select max(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ") tdSql.checkRows(2) - tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname ") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname ") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,1,self.row_nums-1) - tdSql.query("select tbname , max(c2) from stb partition by t1 order by t1") - tdSql.query("select tbname , max(t2) from stb partition by t1 order by t1") - tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2") + tdSql.query(f"select tbname , max(c2) from {dbname}.stb partition by t1 order by t1") + tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t1 order by t1") + tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t2 order by t2") # # bug need fix - tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2") + tdSql.query(f"select t2 , max(t2) from {dbname}.stb partition by t2 order by t2") tdSql.checkRows(self.tb_nums) - tdSql.query("select tbname , max(c1) from stb partition by tbname order by tbname") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,1,self.row_nums-1) - tdSql.query("select tbname , max(c1) from stb partition by t2 order by t2") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by t2 order by t2") - tdSql.query("select c2, max(c1) from stb partition by c2 order by c2 desc") + tdSql.query(f"select c2, max(c1) from {dbname}.stb partition by c2 order by c2 desc") tdSql.checkRows(self.tb_nums+1) tdSql.checkData(0,1,self.row_nums-1) - tdSql.query("select tbname , max(c1) from stb partition by c1 order by c2") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by c1 order by c2") - tdSql.query("select tbname , abs(t2) from stb partition by c2 order by t2") + tdSql.query(f"select tbname , abs(t2) from {dbname}.stb partition by c2 order by t2") tdSql.checkRows(self.tb_nums*(self.row_nums+5)) - tdSql.query("select max(c1) , count(t2) from stb partition by c2 ") + tdSql.query(f"select max(c1) , count(t2) from {dbname}.stb partition by c2 ") tdSql.checkRows(self.row_nums+1) tdSql.checkData(0,1,self.row_nums) - tdSql.query("select count(c1) , max(t2) ,c2 from stb partition by c2 order by c2") + tdSql.query(f"select count(c1) , max(t2) ,c2 from {dbname}.stb partition by c2 order by c2") tdSql.checkRows(self.row_nums+1) - tdSql.query("select count(c1) , count(t1) ,max(c2) ,tbname from stb partition by tbname order by tbname") + tdSql.query(f"select count(c1) , count(t1) ,max(c2) ,tbname from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkCols(4) - tdSql.query("select count(c1) , max(t2) ,t1 from stb partition by t1 order by t1") + tdSql.query(f"select count(c1) , max(t2) ,t1 from {dbname}.stb partition by t1 order by t1") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,self.row_nums) # bug need fix - tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)") + tdSql.query(f"select count(c1) , max(t2) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)") + tdSql.query(f"select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)") tdSql.checkRows(self.row_nums+1) - tdSql.query("select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))") + tdSql.query(f"select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from {dbname}.stb partition by abs(floor(c1)) order by abs(floor(c1))") tdSql.checkRows(self.row_nums+1) - tdSql.query("select tbname , max(c1) ,c1 from stb partition by tbname order by tbname") + tdSql.query(f"select tbname , max(c1) ,c1 from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,'sub_stb_0') tdSql.checkData(0,1,9) tdSql.checkData(0,2,9) - tdSql.query("select tbname ,top(c1,1) ,c1 from stb partition by tbname order by tbname") + tdSql.query(f"select tbname ,top(c1,1) ,c1 from {dbname}.stb partition by tbname order by tbname") tdSql.checkRows(self.tb_nums) - tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ") + tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by tbname order by tbname ") tdSql.checkRows(self.tb_nums*2) # interval - tdSql.query("select max(c1) from stb interval(2s) sliding(1s)") + tdSql.query(f"select max(c1) from {dbname}.stb interval(2s) sliding(1s)") # bug need fix - tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') + tdSql.query(f'select max(c1) from {dbname}.stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') - tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ") + tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s) slimit 5 soffset 1 ") - tdSql.query("select tbname , max(c1) from stb partition by tbname interval(10s)") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname interval(10s)") tdSql.checkRows(self.row_nums*2) - tdSql.query("select unique(c1) from stb partition by tbname order by tbname") + tdSql.query(f"select unique(c1) from {dbname}.stb partition by tbname order by tbname") - tdSql.query("select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s)") + tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s)") tdSql.checkData(0,0,'sub_stb_1') tdSql.checkData(0,1,self.row_nums) - tdSql.query("select c1 , mavg(c1 ,2 ) from stb partition by c1") + tdSql.query(f"select c1 , mavg(c1 ,2 ) from {dbname}.stb partition by c1") tdSql.checkRows(90) - tdSql.query("select c1 , diff(c1 , 0) from stb partition by c1") + tdSql.query(f"select c1 , diff(c1 , 0) from {dbname}.stb partition by c1") tdSql.checkRows(90) - tdSql.query("select c1 , csum(c1) from stb partition by c1") + tdSql.query(f"select c1 , csum(c1) from {dbname}.stb partition by c1") tdSql.checkRows(100) - tdSql.query("select c1 , sample(c1,2) from stb partition by c1 order by c1") + tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by c1 order by c1") tdSql.checkRows(21) # bug need fix - # tdSql.checkData(0,1,None) + tdSql.checkData(0,1,None) - tdSql.query("select c1 , twa(c1) from stb partition by c1 order by c1") + tdSql.query(f"select c1 , twa(c1) from {dbname}.stb partition by c1 order by c1") tdSql.checkRows(11) tdSql.checkData(0,1,None) - tdSql.query("select c1 , irate(c1) from stb partition by c1 order by c1") + tdSql.query(f"select c1 , irate(c1) from {dbname}.stb partition by c1 order by c1") tdSql.checkRows(11) tdSql.checkData(0,1,None) - tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1") + tdSql.query(f"select c1 , DERIVATIVE(c1,2,1) from {dbname}.stb partition by c1 order by c1") tdSql.checkRows(90) # bug need fix tdSql.checkData(0,1,None) - tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") + tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ") tdSql.checkRows(10) - tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ") + tdSql.query(f"select tbname , max(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s) sliding(5s) ") - tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') - tdSql.query(f'select tbname , max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') + tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') + tdSql.query(f'select tbname , max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)') def run(self): + dbname = "db" tdSql.prepare() self.prepare_datas("stb",self.tb_nums,self.row_nums) self.basic_query() # # coverage case for taosd crash about bug fix - tdSql.query(" select sum(c1) from stb where t2+10 >1 ") - tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ") - tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ") - tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ") - tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ") + tdSql.query(f"select sum(c1) from {dbname}.stb where t2+10 >1 ") + tdSql.query(f"select count(c1),count(t1) from {dbname}.stb where -t2<1 ") + tdSql.query(f"select tbname ,max(ceil(c1)) from {dbname}.stb group by tbname ") + tdSql.query(f"select avg(abs(c1)) , tbname from {dbname}.stb group by tbname ") + tdSql.query(f"select t1,c1 from {dbname}.stb where abs(t2+c1)=1 ") def stop(self): diff --git a/tests/system-test/2-query/min.py b/tests/system-test/2-query/min.py index c27e9926ff52e178afe230872d70c6ab269d6983..3d46b7b2224f834360c17cdc311dbf1e0d5a4535 100644 --- a/tests/system-test/2-query/min.py +++ b/tests/system-test/2-query/min.py @@ -14,198 +14,159 @@ class TDTestCase: self.ts = 1537146000000 def run(self): + dbname = "db" tdSql.prepare() intData = [] floatData = [] - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table stb_1 using stb tags('beijing')") - tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')") + tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') for i in range(self.rowNum): - tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) for i in range(self.rowNum): - tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) # max verifacation - tdSql.error("select min(ts) from stb_1") - tdSql.error("select min(ts) from db.stb_1") - tdSql.error("select min(col7) from stb_1") - tdSql.error("select min(col7) from db.stb_1") - tdSql.error("select min(col8) from stb_1") - tdSql.error("select min(col8) from db.stb_1") - tdSql.error("select min(col9) from stb_1") - tdSql.error("select min(col9) from db.stb_1") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from stb_1") - tdSql.error("select min(count(c1),count(c2)) from stb_1") + tdSql.error(f"select min(col7) from {dbname}.stb_1") + tdSql.error(f"select min(col8) from {dbname}.stb_1") + tdSql.error(f"select min(col9) from {dbname}.stb_1") + tdSql.error(f"select min(a) from {dbname}.stb_1") + tdSql.query(f"select min(1) from {dbname}.stb_1") + tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1") - tdSql.query("select min(col1) from stb_1") + tdSql.query(f"select min(col1) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col1) from db.stb_1") + tdSql.query(f"select min(col2) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from stb_1") + tdSql.query(f"select min(col3) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from db.stb_1") + tdSql.query(f"select min(col4) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from stb_1") + tdSql.query(f"select min(col11) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from db.stb_1") + tdSql.query(f"select min(col12) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from stb_1") + tdSql.query(f"select min(col13) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from db.stb_1") + tdSql.query(f"select min(col14) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from db.stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from db.stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from db.stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from db.stb_1") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col5) from stb_1") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col5) from db.stb_1") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from stb_1") + tdSql.query(f"select min(col5) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from db.stb_1") + tdSql.query(f"select min(col6) from {dbname}.stb_1") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col1) from stb_1 where col2>=5") + tdSql.query(f"select min(col1) from {dbname}.stb_1 where col2>=5") tdSql.checkData(0,0,5) + tdSql.query(f"select min(now()) from {dbname}.stb_1") + tdSql.checkRows(1) - tdSql.error("select min(ts) from stb_1") - tdSql.error("select min(ts) from db.stb_1") - tdSql.error("select min(col7) from stb_1") - tdSql.error("select min(col7) from db.stb_1") - tdSql.error("select min(col8) from stb_1") - tdSql.error("select min(col8) from db.stb_1") - tdSql.error("select min(col9) from stb_1") - tdSql.error("select min(col9) from db.stb_1") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from stb_1") - tdSql.error("select min(count(c1),count(c2)) from stb_1") + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) - tdSql.query("select min(col1) from stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col1) from db.stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from db.stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from db.stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from db.stb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from stb") + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) + + + tdSql.error(f"select min(col7) from {dbname}.stb_1") + tdSql.error(f"select min(col8) from {dbname}.stb_1") + tdSql.error(f"select min(col9) from {dbname}.stb_1") + tdSql.error(f"select min(a) from {dbname}.stb_1") + tdSql.query(f"select min(1) from {dbname}.stb_1") + tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1") + + tdSql.query(f"select min(col1) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from db.stb") + tdSql.query(f"select min(col2) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from stb") + tdSql.query(f"select min(col3) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from db.stb") + tdSql.query(f"select min(col4) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from stb") + tdSql.query(f"select min(col11) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from db.stb") + tdSql.query(f"select min(col12) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from stb") + tdSql.query(f"select min(col13) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from db.stb") + tdSql.query(f"select min(col14) from {dbname}.stb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col5) from stb") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col5) from db.stb") + tdSql.query(f"select min(col5) from {dbname}.stb") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from stb") + tdSql.query(f"select min(col6) from {dbname}.stb") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from db.stb") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col1) from stb where col2>=5") + tdSql.query(f"select min(col1) from {dbname}.stb where col2>=5") tdSql.checkData(0,0,5) + tdSql.query(f"select min(now()) from {dbname}.stb_1") + tdSql.checkRows(1) - tdSql.error("select min(ts) from ntb") - tdSql.error("select min(ts) from db.ntb") - tdSql.error("select min(col7) from ntb") - tdSql.error("select min(col7) from db.ntb") - tdSql.error("select min(col8) from ntb") - tdSql.error("select min(col8) from db.ntb") - tdSql.error("select min(col9) from ntb") - tdSql.error("select min(col9) from db.ntb") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from ntb") - tdSql.error("select min(count(c1),count(c2)) from ntb") + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) - tdSql.query("select min(col1) from ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col1) from db.ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col2) from db.ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col3) from db.ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col4) from db.ntb") - tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from ntb") + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) + + tdSql.error(f"select min(col7) from {dbname}.ntb") + tdSql.error(f"select min(col8) from {dbname}.ntb") + tdSql.error(f"select min(col9) from {dbname}.ntb") + tdSql.error(f"select min(a) from {dbname}.ntb") + tdSql.query(f"select min(1) from {dbname}.ntb") + tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.ntb") + + tdSql.query(f"select min(col1) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col11) from db.ntb") + tdSql.query(f"select min(col2) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from ntb") + tdSql.query(f"select min(col3) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col12) from db.ntb") + tdSql.query(f"select min(col4) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from ntb") + tdSql.query(f"select min(col11) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col13) from db.ntb") + tdSql.query(f"select min(col12) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from ntb") + tdSql.query(f"select min(col13) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col14) from db.ntb") + tdSql.query(f"select min(col14) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(intData)) - tdSql.query("select min(col5) from ntb") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col5) from db.ntb") + tdSql.query(f"select min(col5) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from ntb") + tdSql.query(f"select min(col6) from {dbname}.ntb") tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col6) from db.ntb") - tdSql.checkData(0, 0, np.min(floatData)) - tdSql.query("select min(col1) from ntb where col2>=5") + tdSql.query(f"select min(col1) from {dbname}.ntb where col2>=5") tdSql.checkData(0,0,5) + tdSql.query(f"select min(now()) from {dbname}.stb_1") + tdSql.checkRows(1) + + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) + + tdSql.query(f"select first(ts) from {dbname}.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query(f"select min(ts) from {dbname}.stb_1") + tdSql.checkData(0, 0, firstTs) + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/nestedQuery_str.py b/tests/system-test/2-query/nestedQuery_str.py index 0d40ef8147eabe133973a15607c340243b69db92..931ff873dcce279d8ddff018549beb648c5cfbc4 100755 --- a/tests/system-test/2-query/nestedQuery_str.py +++ b/tests/system-test/2-query/nestedQuery_str.py @@ -24,9 +24,6 @@ from util.dnodes import tdDnodes from util.dnodes import * class TDTestCase: - updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) diff --git a/tests/system-test/2-query/pow.py b/tests/system-test/2-query/pow.py index 1af8bd3839beafe37f690abf14d85f3c0e224cb2..0702d05c0b7bf0989046ab1cfdfaa0d812c78407 100644 --- a/tests/system-test/2-query/pow.py +++ b/tests/system-test/2-query/pow.py @@ -9,48 +9,46 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} + def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - - def prepare_datas(self): + + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) - + tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -65,257 +63,182 @@ class TDTestCase: ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ''' ) - - def check_result_auto_pow2(self ,origin_query , pow_query): + def check_result_auto_pow(self ,base , origin_query , pow_query): pow_result = tdSql.getResult(pow_query) origin_result = tdSql.getResult(origin_query) auto_result =[] - - for row in origin_result: - row_check = [] - for elem in row: - if elem == None: - elem = None - else: - elem = math.pow(elem,2) - row_check.append(elem) - auto_result.append(row_check) - - check_status = True - for row_index , row in enumerate(pow_result): - for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("pow value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def check_result_auto_pow1(self ,origin_query , pow_query): - pow_result = tdSql.getResult(pow_query) - origin_result = tdSql.getResult(origin_query) - - auto_result =[] - for row in origin_result: row_check = [] for elem in row: if elem == None: elem = None else : - elem = pow(elem ,1) + elem = float(pow(elem ,base)) row_check.append(elem) auto_result.append(row_check) - check_status = True + tdSql.query(pow_query) for row_index , row in enumerate(pow_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("pow value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def check_result_auto_pow__10(self ,origin_query , pow_query): - pow_result = tdSql.getResult(pow_query) - origin_result = tdSql.getResult(origin_query) + tdSql.checkData(row_index,col_index ,auto_result[row_index][col_index]) + - auto_result =[] - - for row in origin_result: - row_check = [] - for elem in row: - if elem == None: - elem = None - elif elem == 0: - elem = None - else: - elem = pow(elem ,-10) - row_check.append(elem) - auto_result.append(row_check) - - check_status = True - for row_index , row in enumerate(pow_result): - for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("pow value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def test_errors(self): + def test_errors(self, dbname="db"): error_sql_lists = [ - "select pow from t1", - # "select pow(-+--+c1 ,2) from t1", - # "select +-pow(c1,2) from t1", - # "select ++-pow(c1,2) from t1", - # "select ++--pow(c1,2) from t1", - # "select - -pow(c1,2)*0 from t1", - # "select pow(tbname+1,2) from t1 ", - "select pow(123--123,2)==1 from t1", - "select pow(c1,2) as 'd1' from t1", - "select pow(c1 ,c2 ,2) from t1", - "select pow(c1 ,NULL ,2) from t1", - "select pow(, 2) from t1;", - "select pow(pow(c1, 2) ab from t1)", - "select pow(c1 ,2 ) as int from t1", - "select pow from stb1", - # "select pow(-+--+c1) from stb1", - # "select +-pow(c1) from stb1", - # "select ++-pow(c1) from stb1", - # "select ++--pow(c1) from stb1", - # "select - -pow(c1)*0 from stb1", - # "select pow(tbname+1) from stb1 ", - "select pow(123--123 ,2)==1 from stb1", - "select pow(c1 ,2) as 'd1' from stb1", - "select pow(c1 ,c2 ,2 ) from stb1", - "select pow(c1 ,NULL,2) from stb1", - "select pow(,) from stb1;", - "select pow(pow(c1 , 2) ab from stb1)", - "select pow(c1 , 2) as int from stb1" + f"select pow from {dbname}.t1", + # f"select pow(-+--+c1 ,2) from {dbname}.t1", + # f"select +-pow(c1,2) from {dbname}.t1", + # f"select ++-pow(c1,2) from {dbname}.t1", + # f"select ++--pow(c1,2) from {dbname}.t1", + # f"select - -pow(c1,2)*0 from {dbname}.t1", + # f"select pow(tbname+1,2) from {dbname}.t1 ", + f"select pow(123--123,2)==1 from {dbname}.t1", + f"select pow(c1,2) as 'd1' from {dbname}.t1", + f"select pow(c1 ,c2 ,2) from {dbname}.t1", + f"select pow(c1 ,NULL ,2) from {dbname}.t1", + f"select pow(, 2) from {dbname}.t1;", + f"select pow(pow(c1, 2) ab from {dbname}.t1)", + f"select pow(c1 ,2 ) as int from {dbname}.t1", + f"select pow from {dbname}.stb1", + # f"select pow(-+--+c1) from {dbname}.stb1", + # f"select +-pow(c1) from {dbname}.stb1", + # f"select ++-pow(c1) from {dbname}.stb1", + # f"select ++--pow(c1) from {dbname}.stb1", + # f"select - -pow(c1)*0 from {dbname}.stb1", + # f"select pow(tbname+1) from {dbname}.stb1 ", + f"select pow(123--123 ,2)==1 from {dbname}.stb1", + f"select pow(c1 ,2) as 'd1' from {dbname}.stb1", + f"select pow(c1 ,c2 ,2 ) from {dbname}.stb1", + f"select pow(c1 ,NULL,2) from {dbname}.stb1", + f"select pow(,) from {dbname}.stb1;", + f"select pow(pow(c1 , 2) ab from {dbname}.stb1)", + f"select pow(c1 , 2) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - - def support_types(self): + + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select pow(ts ,2 ) from t1" , - "select pow(c7,c1 ) from t1", - "select pow(c8,c2) from t1", - "select pow(c9,c3 ) from t1", - "select pow(ts,c4 ) from ct1" , - "select pow(c7,c5 ) from ct1", - "select pow(c8,c6 ) from ct1", - "select pow(c9,c8 ) from ct1", - "select pow(ts,2 ) from ct3" , - "select pow(c7,2 ) from ct3", - "select pow(c8,2 ) from ct3", - "select pow(c9,2 ) from ct3", - "select pow(ts,2 ) from ct4" , - "select pow(c7,2 ) from ct4", - "select pow(c8,2 ) from ct4", - "select pow(c9,2 ) from ct4", - "select pow(ts,2 ) from stb1" , - "select pow(c7,2 ) from stb1", - "select pow(c8,2 ) from stb1", - "select pow(c9,2 ) from stb1" , - - "select pow(ts,2 ) from stbbb1" , - "select pow(c7,2 ) from stbbb1", - - "select pow(ts,2 ) from tbname", - "select pow(c9,2 ) from tbname" + f"select pow(ts ,2 ) from {dbname}.t1" , + f"select pow(c7,c1 ) from {dbname}.t1", + f"select pow(c8,c2) from {dbname}.t1", + f"select pow(c9,c3 ) from {dbname}.t1", + f"select pow(ts,c4 ) from {dbname}.ct1" , + f"select pow(c7,c5 ) from {dbname}.ct1", + f"select pow(c8,c6 ) from {dbname}.ct1", + f"select pow(c9,c8 ) from {dbname}.ct1", + f"select pow(ts,2 ) from {dbname}.ct3" , + f"select pow(c7,2 ) from {dbname}.ct3", + f"select pow(c8,2 ) from {dbname}.ct3", + f"select pow(c9,2 ) from {dbname}.ct3", + f"select pow(ts,2 ) from {dbname}.ct4" , + f"select pow(c7,2 ) from {dbname}.ct4", + f"select pow(c8,2 ) from {dbname}.ct4", + f"select pow(c9,2 ) from {dbname}.ct4", + f"select pow(ts,2 ) from {dbname}.stb1" , + f"select pow(c7,2 ) from {dbname}.stb1", + f"select pow(c8,2 ) from {dbname}.stb1", + f"select pow(c9,2 ) from {dbname}.stb1" , + + f"select pow(ts,2 ) from {dbname}.stbbb1" , + f"select pow(c7,2 ) from {dbname}.stbbb1", + + f"select pow(ts,2 ) from {dbname}.tbname", + f"select pow(c9,2 ) from {dbname}.tbname" ] - + for type_sql in type_error_sql_lists: tdSql.error(type_sql) - - + + type_sql_lists = [ - "select pow(c1,2 ) from t1", - "select pow(c2,2 ) from t1", - "select pow(c3,2 ) from t1", - "select pow(c4,2 ) from t1", - "select pow(c5,2 ) from t1", - "select pow(c6,2 ) from t1", - - "select pow(c1,2 ) from ct1", - "select pow(c2,2 ) from ct1", - "select pow(c3,2 ) from ct1", - "select pow(c4,2 ) from ct1", - "select pow(c5,2 ) from ct1", - "select pow(c6,2 ) from ct1", - - "select pow(c1,2 ) from ct3", - "select pow(c2,2 ) from ct3", - "select pow(c3,2 ) from ct3", - "select pow(c4,2 ) from ct3", - "select pow(c5,2 ) from ct3", - "select pow(c6,2 ) from ct3", - - "select pow(c1,2 ) from stb1", - "select pow(c2,2 ) from stb1", - "select pow(c3,2 ) from stb1", - "select pow(c4,2 ) from stb1", - "select pow(c5,2 ) from stb1", - "select pow(c6,2 ) from stb1", - - "select pow(c6,2) as alisb from stb1", - "select pow(c6,2) alisb from stb1", + f"select pow(c1,2 ) from {dbname}.t1", + f"select pow(c2,2 ) from {dbname}.t1", + f"select pow(c3,2 ) from {dbname}.t1", + f"select pow(c4,2 ) from {dbname}.t1", + f"select pow(c5,2 ) from {dbname}.t1", + f"select pow(c6,2 ) from {dbname}.t1", + + f"select pow(c1,2 ) from {dbname}.ct1", + f"select pow(c2,2 ) from {dbname}.ct1", + f"select pow(c3,2 ) from {dbname}.ct1", + f"select pow(c4,2 ) from {dbname}.ct1", + f"select pow(c5,2 ) from {dbname}.ct1", + f"select pow(c6,2 ) from {dbname}.ct1", + + f"select pow(c1,2 ) from {dbname}.ct3", + f"select pow(c2,2 ) from {dbname}.ct3", + f"select pow(c3,2 ) from {dbname}.ct3", + f"select pow(c4,2 ) from {dbname}.ct3", + f"select pow(c5,2 ) from {dbname}.ct3", + f"select pow(c6,2 ) from {dbname}.ct3", + + f"select pow(c1,2 ) from {dbname}.stb1", + f"select pow(c2,2 ) from {dbname}.stb1", + f"select pow(c3,2 ) from {dbname}.stb1", + f"select pow(c4,2 ) from {dbname}.stb1", + f"select pow(c5,2 ) from {dbname}.stb1", + f"select pow(c6,2 ) from {dbname}.stb1", + + f"select pow(c6,2) as alisb from {dbname}.stb1", + f"select pow(c6,2) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - - def basic_pow_function(self): - # basic query - tdSql.query("select c1 from ct3") + def basic_pow_function(self, dbname="db"): + + # basic query + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select pow(c1 ,2) from ct3") + tdSql.query(f"select pow(c1 ,2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select pow(c2 ,2) from ct3") + tdSql.query(f"select pow(c2 ,2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select pow(c3 ,2) from ct3") + tdSql.query(f"select pow(c3 ,2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select pow(c4 ,2) from ct3") + tdSql.query(f"select pow(c4 ,2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select pow(c5 ,2) from ct3") + tdSql.query(f"select pow(c5 ,2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select pow(c6 ,2) from ct3") + tdSql.query(f"select pow(c6 ,2) from {dbname}.ct3") tdSql.checkRows(0) # # used for regular table - tdSql.query("select pow(c1 ,2) from t1") + tdSql.query(f"select pow(c1 ,2) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 1.000000000) tdSql.checkData(3 , 0, 9.000000000) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto_pow2( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,2), pow(c2 ,2) ,pow(c3, 2), pow(c4 ,2), pow(c5 ,2) from t1") - self.check_result_auto_pow1( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,1), pow(c2 ,1) ,pow(c3, 1), pow(c4 ,1), pow(c5 ,1) from t1") - self.check_result_auto_pow__10( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,-10), pow(c2 ,-10) ,pow(c3, -10), pow(c4 ,-10), pow(c5 ,-10) from t1") - + self.check_result_auto_pow( 2, f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,2) , pow(c3, 2), pow(c4 ,2), pow(c5 ,2) from {dbname}.t1") + self.check_result_auto_pow( 1,f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,1) , pow(c3, 1), pow(c4 ,1), pow(c5 ,1) from {dbname}.t1") + self.check_result_auto_pow( 10,f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,10) ,pow(c3, 10), pow(c4 ,10), pow(c5 ,10) from {dbname}.t1") + # used for sub table - tdSql.query("select c1 ,pow(c1 ,2) from ct1") + tdSql.query(f"select c1 ,pow(c1 ,2) from {dbname}.ct1") tdSql.checkData(0, 1, 64.000000000) tdSql.checkData(1 , 1, 49.000000000) tdSql.checkData(3 , 1, 25.000000000) @@ -323,7 +246,7 @@ class TDTestCase: # # test bug fix for pow(c1,c2) - tdSql.query("select c1, c5 ,pow(c1,c5) from ct4") + tdSql.query(f"select c1, c5 ,pow(c1,c5) from {dbname}.ct4") tdSql.checkData(0 , 2, None) tdSql.checkData(1 , 2, 104577724.506799981) tdSql.checkData(2 , 2, 3684781.623933245) @@ -331,11 +254,11 @@ class TDTestCase: tdSql.checkData(4 , 2, 7573.273783071) - self.check_result_auto_pow2( "select c1, c2, c3 , c4, c5 from ct1", "select pow(c1,2), pow(c2,2) ,pow(c3,2), pow(c4,2), pow(c5,2) from ct1") - self.check_result_auto_pow__10( "select c1, c2, c3 , c4, c5 from ct1", "select pow(c1,-10), pow(c2,-10) ,pow(c3,-10), pow(c4,-10), pow(c5,-10) from ct1") + self.check_result_auto_pow( 2, f"select c1, c3 , c4, c5 from {dbname}.ct1", f"select pow(c1,2), pow(c3,2), pow(c4,2), pow(c5,2) from {dbname}.ct1") + self.check_result_auto_pow( 10, f"select c1, c3 , c4, c5 from {dbname}.ct1", f"select pow(c1,10), pow(c3,10), pow(c4,10), pow(c5,10) from {dbname}.ct1") # nest query for pow functions - tdSql.query("select c1 , pow(c1,2) ,pow(pow(c1,2),2) , pow(pow(pow(c1,2),2),2) from ct1;") + tdSql.query(f"select c1 , pow(c1,2) ,pow(pow(c1,2),2) , pow(pow(pow(c1,2),2),2) from {dbname}.ct1;") tdSql.checkData(0 , 0 , 8) tdSql.checkData(0 , 1 , 64.000000000) tdSql.checkData(0 , 2 , 4096.000000000) @@ -351,24 +274,24 @@ class TDTestCase: tdSql.checkData(4 , 2 , 0.000000000) tdSql.checkData(4 , 3 , 0.000000000) - # # used for stable table - - tdSql.query("select pow(c1, 2) from stb1") + # # used for stable table + + tdSql.query(f"select pow(c1, 2) from {dbname}.stb1") tdSql.checkRows(25) - + # used for not exists table - tdSql.error("select pow(c1, 2) from stbbb1") - tdSql.error("select pow(c1, 2) from tbname") - tdSql.error("select pow(c1, 2) from ct5") + tdSql.error(f"select pow(c1, 2) from {dbname}.stbbb1") + tdSql.error(f"select pow(c1, 2) from {dbname}.tbname") + tdSql.error(f"select pow(c1, 2) from {dbname}.ct5") - # mix with common col - tdSql.query("select c1, pow(c1 ,2) from ct1") + # mix with common col + tdSql.query(f"select c1, pow(c1 ,2) from {dbname}.ct1") tdSql.checkData(0 , 0 ,8) tdSql.checkData(0 , 1 ,64.000000000) tdSql.checkData(4 , 0 ,0) tdSql.checkData(4 , 1 ,0.000000000) - tdSql.query("select c1, pow(c1,2) from ct4") + tdSql.query(f"select c1, pow(c1,2) from {dbname}.ct4") tdSql.checkData(0 , 0 , None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(4 , 0 ,5) @@ -377,45 +300,45 @@ class TDTestCase: tdSql.checkData(5 , 1 ,None) # mix with common functions - tdSql.query("select c1, pow(c1 ,2),pow(c1,2), log(pow(c1,2) ,2) from ct4 ") + tdSql.query(f"select c1, pow(c1 ,2),pow(c1,2), log(pow(c1,2) ,2) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) tdSql.checkData(0 , 3 ,None) - + tdSql.checkData(3 , 0 , 6) tdSql.checkData(3 , 1 ,36.000000000) tdSql.checkData(3 , 2 ,36.000000000) tdSql.checkData(3 , 3 ,5.169925001) - tdSql.query("select c1, pow(c1,1),c5, floor(c5 ) from stb1 ") + tdSql.query(f"select c1, pow(c1,1),c5, floor(c5 ) from {dbname}.stb1 ") # # mix with agg functions , not support - tdSql.error("select c1, pow(c1 ,2),c5, count(c5) from stb1 ") - tdSql.error("select c1, pow(c1 ,2),c5, count(c5) from ct1 ") - tdSql.error("select pow(c1 ,2), count(c5) from stb1 ") - tdSql.error("select pow(c1 ,2), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, pow(c1 ,2),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, pow(c1 ,2),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select pow(c1 ,2), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select pow(c1 ,2), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") + - # bug fix for count - tdSql.query("select count(c1) from ct4 ") + tdSql.query(f"select count(c1) from {dbname}.ct4 ") tdSql.checkData(0,0,9) - tdSql.query("select count(*) from ct4 ") + tdSql.query(f"select count(*) from {dbname}.ct4 ") tdSql.checkData(0,0,12) - tdSql.query("select count(c1) from stb1 ") + tdSql.query(f"select count(c1) from {dbname}.stb1 ") tdSql.checkData(0,0,22) - tdSql.query("select count(*) from stb1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 ") tdSql.checkData(0,0,25) - # # bug fix for compute - tdSql.query("select c1, pow(c1 ,2) -0 ,pow(c1-4 ,2)-0 from ct4 ") + # # bug fix for compute + tdSql.query(f"select c1, pow(c1 ,2) -0 ,pow(c1-4 ,2)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -423,7 +346,7 @@ class TDTestCase: tdSql.checkData(1, 1, 64.000000000) tdSql.checkData(1, 2, 16.000000000) - tdSql.query(" select c1, pow(c1 ,2) -0 ,pow(c1-0.1 ,2)-0.1 from ct4") + tdSql.query(f"select c1, pow(c1 ,2) -0 ,pow(c1-0.1 ,2)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -431,87 +354,86 @@ class TDTestCase: tdSql.checkData(1, 1, 64.000000000) tdSql.checkData(1, 2, 62.310000000) - tdSql.query("select c1, pow(c1, -10), c2, pow(c2, -10), c3, pow(c3, -10) from ct1") + tdSql.query(f"select c1, pow(c1, -10), c2, pow(c2, -10), c3, pow(c3, -10) from {dbname}.ct1") - def test_big_number(self): + def test_big_number(self, dbname="db"): - tdSql.query("select c1, pow(c1, 100000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 100000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(0, 1, None) tdSql.checkData(1, 1, None) tdSql.checkData(4, 1, 0.000000000) - tdSql.query("select c1, pow(c1, 10000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 10000000000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(0, 1, None) tdSql.checkData(1, 1, None) tdSql.checkData(4, 1, 0.000000000) - tdSql.query("select c1, pow(c1, 10000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, pow(c1, 10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(0, 1, None) tdSql.checkData(1, 1, None) tdSql.checkData(4, 1, 0.000000000) - tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(0, 1, None) tdSql.checkData(1, 1, None) tdSql.checkData(4, 1, 0.000000000) - tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(0, 1, None) tdSql.checkData(1, 1, None) tdSql.checkData(4, 1, 0.000000000) - tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow - def pow_base_test(self): + def pow_base_test(self, dbname="db"): # base is an regular number ,int or double - tdSql.query("select c1, pow(c1, 2) from ct1") + tdSql.query(f"select c1, pow(c1, 2) from {dbname}.ct1") tdSql.checkData(0, 1,64.000000000) - tdSql.query("select c1, pow(c1, 2.0) from ct1") + tdSql.query(f"select c1, pow(c1, 2.0) from {dbname}.ct1") tdSql.checkData(0, 1, 64.000000000) - tdSql.query("select c1, pow(1, 2.0) from ct1") + tdSql.query(f"select c1, pow(1, 2.0) from {dbname}.ct1") tdSql.checkData(0, 1, 1.000000000) tdSql.checkRows(13) # # bug for compute in functions - # tdSql.query("select c1, abs(1/0) from ct1") + # tdSql.query(f"select c1, abs(1/0) from {dbname}.ct1") # tdSql.checkData(0, 0, 8) # tdSql.checkData(0, 1, 1) - tdSql.query("select c1, pow(1, 2.0) from ct1") + tdSql.query(f"select c1, pow(1, 2.0) from {dbname}.ct1") tdSql.checkData(0, 1, 1.000000000) tdSql.checkRows(13) # two cols start pow(x,y) - tdSql.query("select c1,c2, pow(c1,c2) from ct1") + tdSql.query(f"select c1,c2, pow(c1,c2) from {dbname}.ct1") tdSql.checkData(0, 2, None) tdSql.checkData(1, 2, None) tdSql.checkData(4, 2, 1.000000000) - tdSql.query("select c1,c2, pow(c2,c1) from ct1") + tdSql.query(f"select c1,c2, pow(c2,c1) from {dbname}.ct1") tdSql.checkData(0, 2, 3897131646727578700481513520437089271808.000000000) tdSql.checkData(1, 2, 17217033054561120738612297152331776.000000000) tdSql.checkData(4, 2, 1.000000000) - tdSql.query("select c1, pow(2.0 , c1) from ct1") + tdSql.query(f"select c1, pow(2.0 , c1) from {dbname}.ct1") tdSql.checkData(0, 1, 256.000000000) tdSql.checkData(1, 1, 128.000000000) tdSql.checkData(4, 1, 1.000000000) - tdSql.query("select c1, pow(2.0 , c1) from ct1") + tdSql.query(f"select c1, pow(2.0 , c1) from {dbname}.ct1") tdSql.checkData(0, 1, 256.000000000) tdSql.checkData(1, 1, 128.000000000) tdSql.checkData(4, 1, 1.000000000) - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -519,7 +441,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,64.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -527,7 +449,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,25.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -535,7 +457,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,25.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_pow2( " select t1,c5 from stb1 order by ts " , "select pow(t1,2), pow(c5,2) from stb1 order by ts" ) - self.check_result_auto_pow2( " select t1,c5 from stb1 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 order by tbname" ) - self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) , pow(c5,2) from stb1 where c1 > 0 order by tbname" ) - pass - - + def support_super_table_test(self, dbname="db"): + self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 order by ts " , f"select pow(c5,2) from {dbname}.stb1 order by ts" ) + self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 order by ts " , f"select pow(t1,2), pow(c5,2) from {dbname}.stb1 order by ts" ) + self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select pow(t1,2) ,pow(c5,2) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(t1,2) ,pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(t1,2) , pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" ) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: pow basic query ============") + tdLog.printNoPrefix("==========step4: pow basic query ============") self.basic_pow_function() - tdLog.printNoPrefix("==========step5: big number pow query ============") + tdLog.printNoPrefix("==========step5: big number pow query ============") self.test_big_number() - tdLog.printNoPrefix("==========step6: base number for pow query ============") + tdLog.printNoPrefix("==========step6: base number for pow query ============") self.pow_base_test() - tdLog.printNoPrefix("==========step7: pow boundary query ============") + tdLog.printNoPrefix("==========step7: pow boundary query ============") self.check_boundary_values() - tdLog.printNoPrefix("==========step8: pow filter query ============") + tdLog.printNoPrefix("==========step8: pow filter query ============") self.abs_func_filter() tdLog.printNoPrefix("==========step9: check pow result of stable query ============") - self.support_super_table_test() + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/qnodeCluster.py b/tests/system-test/2-query/qnodeCluster.py index f68eb58a7a0820333b50258cf7cd29d860153cac..9e49bff9389deeb83839477c98e194c014a2a87f 100644 --- a/tests/system-test/2-query/qnodeCluster.py +++ b/tests/system-test/2-query/qnodeCluster.py @@ -13,9 +13,9 @@ from util.common import * sys.path.append("./6-cluster/") from clusterCommonCreate import * -from clusterCommonCheck import clusterComCheck +from clusterCommonCheck import clusterComCheck -import threading +import threading class TDTestCase: @@ -28,7 +28,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): tsql.execute("use %s" %dbName) @@ -47,7 +47,7 @@ class TDTestCase: sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -55,7 +55,7 @@ class TDTestCase: dbname="db_tsbs" stabname1="readings" stabname2="diagnostics" - ctbnamePre1="rct" + ctbnamePre1="rct" ctbnamePre2="dct" ctbNums=40 self.ctbNums=ctbNums @@ -73,7 +73,7 @@ class TDTestCase: self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums) - for j in range(ctbNums): + for j in range(ctbNums): for i in range(rowNUms): tdSql.execute( f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )" @@ -109,19 +109,19 @@ class TDTestCase: def tsbsIotQuery(self,tdSql): tdSql.execute("use db_tsbs") - + # test interval and partition tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") # print(tdSql.queryResult) parRows=tdSql.queryRows tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") tdSql.checkRows(parRows) - - - # # test insert into + + + # # test insert into # tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") # tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") - + # tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") @@ -141,7 +141,7 @@ class TDTestCase: tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;") - # 2 stationary-trucks + # 2 stationary-trucks tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)") tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name") @@ -156,7 +156,7 @@ class TDTestCase: tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;") - # # 6. avg-daily-driving-session + # # 6. avg-daily-driving-session # #taosc core dumped # tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))") # tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;") @@ -166,7 +166,7 @@ class TDTestCase: # 7. avg-load tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;") - # 8. daily-activity + # 8. daily-activity tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") @@ -184,7 +184,7 @@ class TDTestCase: tdSql.query(" SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;") - + #it's already supported: # last-loc tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;") @@ -192,7 +192,7 @@ class TDTestCase: #2. low-fuel tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;") - + # 3. avg-vs-projected-fuel-consumption tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet") @@ -213,16 +213,16 @@ class TDTestCase: 'ctbPrefix': 'ctb', 'ctbNum': 1, } - + dnodeNumbers=int(dnodeNumbers) mnodeNums=int(mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums) - + tdSql.query("select * from information_schema.ins_dnodes;") tdLog.debug(tdSql.queryResult) clusterComCheck.checkDnodes(dnodeNumbers) - tdLog.info("create database and stable") + tdLog.info("create database and stable") tdDnodes=cluster.dnodes stopcount =0 threads=[] @@ -234,7 +234,7 @@ class TDTestCase: for tr in threads: tr.start() - tdLog.info("Take turns stopping %s "%stopRole) + tdLog.info("Take turns stopping %s "%stopRole) while stopcount < restartNumbers: tdLog.info(" restart loop: %d"%stopcount ) if stopRole == "mnode": @@ -242,7 +242,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) elif stopRole == "vnode": for i in range(vnodeNumbers): tdDnodes[i+mnodeNums].stoptaosd() @@ -254,7 +254,7 @@ class TDTestCase: tdDnodes[i].stoptaosd() # sleep(10) tdDnodes[i].starttaosd() - # sleep(10) + # sleep(10) # dnodeNumbers don't include database of schema if clusterComCheck.checkDnodes(dnodeNumbers): @@ -265,12 +265,12 @@ class TDTestCase: tdLog.exit("one or more of dnodes failed to start ") # self.check3mnode() stopcount+=1 - + for tr in threads: tr.join() - def run(self): + def run(self): tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") self.createCluster() self.prepareData() diff --git a/tests/system-test/2-query/query_cols_tags_and_or.py b/tests/system-test/2-query/query_cols_tags_and_or.py index e0fb986d79d8491bf2bd23e82ccde85914c76541..af3fbb83c070202368f317b119377035ac133e16 100644 --- a/tests/system-test/2-query/query_cols_tags_and_or.py +++ b/tests/system-test/2-query/query_cols_tags_and_or.py @@ -19,7 +19,7 @@ class TDTestCase: def init(self, conn, logSql): ## add for TD-6672 tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) + tdSql.init(conn.cursor(), False) def insertData(self, tb_name): insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1, 2, 3, 4)', @@ -37,17 +37,17 @@ class TDTestCase: for sql in insert_sql_list: tdSql.execute(sql) - def initTb(self): - tdCom.cleanTb() - tb_name = tdCom.getLongName(8, "letters") + def initTb(self, dbname="db"): + tdCom.cleanTb(dbname) + tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}' tdSql.execute( f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned)") self.insertData(tb_name) return tb_name - def initStb(self, count=5): - tdCom.cleanTb() - tb_name = tdCom.getLongName(8, "letters") + def initStb(self, count=5, dbname="db"): + tdCom.cleanTb(dbname) + tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}' tdSql.execute( f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 tinyint unsigned, t11 smallint unsigned, t12 int unsigned, t13 bigint unsigned)") for i in range(1, count+1): @@ -56,9 +56,10 @@ class TDTestCase: self.insertData(f'{tb_name}_sub_{i}') return tb_name - def initTwoStb(self): - tdCom.cleanTb() - tb_name = tdCom.getLongName(8, "letters") + def initTwoStb(self, dbname="db"): + tdCom.cleanTb(dbname) + tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}' + # tb_name = tdCom.getLongName(8, "letters") tb_name1 = f'{tb_name}1' tb_name2 = f'{tb_name}2' tdSql.execute( diff --git a/tests/system-test/2-query/round.py b/tests/system-test/2-query/round.py index 551e225a4d02025780b4238e2079b70249dcdd5a..1d69d3c9afa1d7fffc3b8eac80c2b648a54bc74e 100644 --- a/tests/system-test/2-query/round.py +++ b/tests/system-test/2-query/round.py @@ -8,49 +8,46 @@ from util.sql import * from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - def prepare_datas(self): + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -94,68 +91,68 @@ class TDTestCase: else: tdLog.info("round value check pass , it work as expected ,sql is \"%s\" "%round_query ) - def test_errors(self): + def test_errors(self, dbname="db"): error_sql_lists = [ - "select round from t1", - # "select round(-+--+c1) from t1", - # "select +-round(c1) from t1", - # "select ++-round(c1) from t1", - # "select ++--round(c1) from t1", - # "select - -round(c1)*0 from t1", - # "select round(tbname+1) from t1 ", - "select round(123--123)==1 from t1", - "select round(c1) as 'd1' from t1", - "select round(c1 ,c2 ) from t1", - "select round(c1 ,NULL) from t1", - "select round(,) from t1;", - "select round(round(c1) ab from t1)", - "select round(c1) as int from t1", - "select round from stb1", - # "select round(-+--+c1) from stb1", - # "select +-round(c1) from stb1", - # "select ++-round(c1) from stb1", - # "select ++--round(c1) from stb1", - # "select - -round(c1)*0 from stb1", - # "select round(tbname+1) from stb1 ", - "select round(123--123)==1 from stb1", - "select round(c1) as 'd1' from stb1", - "select round(c1 ,c2 ) from stb1", - "select round(c1 ,NULL) from stb1", - "select round(,) from stb1;", - "select round(round(c1) ab from stb1)", - "select round(c1) as int from stb1" + f"select round from {dbname}.t1", + # f"select round(-+--+c1) from {dbname}.t1", + # f"select +-round(c1) from {dbname}.t1", + # f"select ++-round(c1) from {dbname}.t1", + # f"select ++--round(c1) from {dbname}.t1", + # f"select - -round(c1)*0 from {dbname}.t1", + # f"select round(tbname+1) from {dbname}.t1 ", + f"select round(123--123)==1 from {dbname}.t1", + f"select round(c1) as 'd1' from {dbname}.t1", + f"select round(c1 ,c2 ) from {dbname}.t1", + f"select round(c1 ,NULL) from {dbname}.t1", + f"select round(,) from {dbname}.t1;", + f"select round(round(c1) ab from {dbname}.t1)", + f"select round(c1) as int from {dbname}.t1", + f"select round from {dbname}.stb1", + # f"select round(-+--+c1) from {dbname}.stb1", + # f"select +-round(c1) from {dbname}.stb1", + # f"select ++-round(c1) from {dbname}.stb1", + # f"select ++--round(c1) from {dbname}.stb1", + # f"select - -round(c1)*0 from {dbname}.stb1", + # f"select round(tbname+1) from {dbname}.stb1 ", + f"select round(123--123)==1 from {dbname}.stb1", + f"select round(c1) as 'd1' from {dbname}.stb1", + f"select round(c1 ,c2 ) from {dbname}.stb1", + f"select round(c1 ,NULL) from {dbname}.stb1", + f"select round(,) from {dbname}.stb1;", + f"select round(round(c1) ab from {dbname}.stb1)", + f"select round(c1) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - def support_types(self): + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select round(ts) from t1" , - "select round(c7) from t1", - "select round(c8) from t1", - "select round(c9) from t1", - "select round(ts) from ct1" , - "select round(c7) from ct1", - "select round(c8) from ct1", - "select round(c9) from ct1", - "select round(ts) from ct3" , - "select round(c7) from ct3", - "select round(c8) from ct3", - "select round(c9) from ct3", - "select round(ts) from ct4" , - "select round(c7) from ct4", - "select round(c8) from ct4", - "select round(c9) from ct4", - "select round(ts) from stb1" , - "select round(c7) from stb1", - "select round(c8) from stb1", - "select round(c9) from stb1" , - - "select round(ts) from stbbb1" , - "select round(c7) from stbbb1", - - "select round(ts) from tbname", - "select round(c9) from tbname" + f"select round(ts) from {dbname}.t1" , + f"select round(c7) from {dbname}.t1", + f"select round(c8) from {dbname}.t1", + f"select round(c9) from {dbname}.t1", + f"select round(ts) from {dbname}.ct1" , + f"select round(c7) from {dbname}.ct1", + f"select round(c8) from {dbname}.ct1", + f"select round(c9) from {dbname}.ct1", + f"select round(ts) from {dbname}.ct3" , + f"select round(c7) from {dbname}.ct3", + f"select round(c8) from {dbname}.ct3", + f"select round(c9) from {dbname}.ct3", + f"select round(ts) from {dbname}.ct4" , + f"select round(c7) from {dbname}.ct4", + f"select round(c8) from {dbname}.ct4", + f"select round(c9) from {dbname}.ct4", + f"select round(ts) from {dbname}.stb1" , + f"select round(c7) from {dbname}.stb1", + f"select round(c8) from {dbname}.stb1", + f"select round(c9) from {dbname}.stb1" , + + f"select round(ts) from {dbname}.stbbb1" , + f"select round(c7) from {dbname}.stbbb1", + + f"select round(ts) from {dbname}.tbname", + f"select round(c9) from {dbname}.tbname" ] @@ -164,127 +161,127 @@ class TDTestCase: type_sql_lists = [ - "select round(c1) from t1", - "select round(c2) from t1", - "select round(c3) from t1", - "select round(c4) from t1", - "select round(c5) from t1", - "select round(c6) from t1", - - "select round(c1) from ct1", - "select round(c2) from ct1", - "select round(c3) from ct1", - "select round(c4) from ct1", - "select round(c5) from ct1", - "select round(c6) from ct1", - - "select round(c1) from ct3", - "select round(c2) from ct3", - "select round(c3) from ct3", - "select round(c4) from ct3", - "select round(c5) from ct3", - "select round(c6) from ct3", - - "select round(c1) from stb1", - "select round(c2) from stb1", - "select round(c3) from stb1", - "select round(c4) from stb1", - "select round(c5) from stb1", - "select round(c6) from stb1", - - "select round(c6) as alisb from stb1", - "select round(c6) alisb from stb1", + f"select round(c1) from {dbname}.t1", + f"select round(c2) from {dbname}.t1", + f"select round(c3) from {dbname}.t1", + f"select round(c4) from {dbname}.t1", + f"select round(c5) from {dbname}.t1", + f"select round(c6) from {dbname}.t1", + + f"select round(c1) from {dbname}.ct1", + f"select round(c2) from {dbname}.ct1", + f"select round(c3) from {dbname}.ct1", + f"select round(c4) from {dbname}.ct1", + f"select round(c5) from {dbname}.ct1", + f"select round(c6) from {dbname}.ct1", + + f"select round(c1) from {dbname}.ct3", + f"select round(c2) from {dbname}.ct3", + f"select round(c3) from {dbname}.ct3", + f"select round(c4) from {dbname}.ct3", + f"select round(c5) from {dbname}.ct3", + f"select round(c6) from {dbname}.ct3", + + f"select round(c1) from {dbname}.stb1", + f"select round(c2) from {dbname}.stb1", + f"select round(c3) from {dbname}.stb1", + f"select round(c4) from {dbname}.stb1", + f"select round(c5) from {dbname}.stb1", + f"select round(c6) from {dbname}.stb1", + + f"select round(c6) as alisb from {dbname}.stb1", + f"select round(c6) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - def basic_round_function(self): + def basic_round_function(self, dbname="db"): # basic query - tdSql.query("select c1 from ct3") + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select round(c1) from ct3") + tdSql.query(f"select round(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select round(c2) from ct3") + tdSql.query(f"select round(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select round(c3) from ct3") + tdSql.query(f"select round(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select round(c4) from ct3") + tdSql.query(f"select round(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select round(c5) from ct3") + tdSql.query(f"select round(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select round(c6) from ct3") + tdSql.query(f"select round(c6) from {dbname}.ct3") # used for regular table - tdSql.query("select round(c1) from t1") + tdSql.query(f"select round(c1) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 1) tdSql.checkData(3 , 0, 3) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto( "select c1, c2, c3 , c4, c5 from t1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from t1") + self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.t1") # used for sub table - tdSql.query("select round(c1) from ct1") + tdSql.query(f"select round(c1) from {dbname}.ct1") tdSql.checkData(0, 0, 8) tdSql.checkData(1 , 0, 7) tdSql.checkData(3 , 0, 5) tdSql.checkData(5 , 0, 4) - tdSql.query("select round(c1) from ct1") - self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct1") - self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct1;","select c1 from ct1" ) + tdSql.query(f"select round(c1) from {dbname}.ct1") + self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct1") + self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct1;",f"select c1 from {dbname}.ct1" ) # used for stable table - tdSql.query("select round(c1) from stb1") + tdSql.query(f"select round(c1) from {dbname}.stb1") tdSql.checkRows(25) - self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct4 ", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct4") - self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct4;" , "select c1 from ct4" ) + self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct4 ", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct4") + self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct4;" , f"select c1 from {dbname}.ct4" ) # used for not exists table - tdSql.error("select round(c1) from stbbb1") - tdSql.error("select round(c1) from tbname") - tdSql.error("select round(c1) from ct5") + tdSql.error(f"select round(c1) from {dbname}.stbbb1") + tdSql.error(f"select round(c1) from {dbname}.tbname") + tdSql.error(f"select round(c1) from {dbname}.ct5") # mix with common col - tdSql.query("select c1, round(c1) from ct1") + tdSql.query(f"select c1, round(c1) from {dbname}.ct1") tdSql.checkData(0 , 0 ,8) tdSql.checkData(0 , 1 ,8) tdSql.checkData(4 , 0 ,0) tdSql.checkData(4 , 1 ,0) - tdSql.query("select c1, round(c1) from ct4") + tdSql.query(f"select c1, round(c1) from {dbname}.ct4") tdSql.checkData(0 , 0 , None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(4 , 0 ,5) tdSql.checkData(4 , 1 ,5) tdSql.checkData(5 , 0 ,None) tdSql.checkData(5 , 1 ,None) - tdSql.query("select c1, round(c1) from ct4 ") + tdSql.query(f"select c1, round(c1) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(4 , 0 ,5) tdSql.checkData(4 , 1 ,5) # mix with common functions - tdSql.query("select c1, round(c1),c5, round(c5) from ct4 ") + tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) @@ -300,34 +297,34 @@ class TDTestCase: tdSql.checkData(6 , 2 ,4.44000) tdSql.checkData(6 , 3 ,4.00000) - tdSql.query("select c1, round(c1),c5, round(c5) from stb1 ") + tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.stb1 ") # mix with agg functions , not support - tdSql.error("select c1, round(c1),c5, count(c5) from stb1 ") - tdSql.error("select c1, round(c1),c5, count(c5) from ct1 ") - tdSql.error("select round(c1), count(c5) from stb1 ") - tdSql.error("select round(c1), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select round(c1), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select round(c1), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") # bug fix for count - tdSql.query("select count(c1) from ct4 ") + tdSql.query(f"select count(c1) from {dbname}.ct4 ") tdSql.checkData(0,0,9) - tdSql.query("select count(*) from ct4 ") + tdSql.query(f"select count(*) from {dbname}.ct4 ") tdSql.checkData(0,0,12) - tdSql.query("select count(c1) from stb1 ") + tdSql.query(f"select count(c1) from {dbname}.stb1 ") tdSql.checkData(0,0,22) - tdSql.query("select count(*) from stb1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 ") tdSql.checkData(0,0,25) # bug fix for compute - tdSql.query("select c1, abs(c1) -0 ,round(c1)-0 from ct4 ") + tdSql.query(f"select c1, abs(c1) -0 ,round(c1)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -335,7 +332,7 @@ class TDTestCase: tdSql.checkData(1, 1, 8.000000000) tdSql.checkData(1, 2, 8.000000000) - tdSql.query(" select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from ct4") + tdSql.query(f"select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -343,9 +340,8 @@ class TDTestCase: tdSql.checkData(1, 1, 8.000000000) tdSql.checkData(1, 2, 7.900000000) - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -353,7 +349,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,3.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -361,7 +357,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,2.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -369,7 +365,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,2.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from ct4 where c1>log(c1,2) limit 1 ") + tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from {dbname}.ct4 where c1>log(c1,2) limit 1 ") tdSql.checkRows(1) tdSql.checkData(0,0,8) tdSql.checkData(0,1,88888) @@ -382,44 +378,42 @@ class TDTestCase: def round_Arithmetic(self): pass - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - time.sleep(3) - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from sub1_bound") - self.check_result_auto( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from sub1_bound") - self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from sub1_bound;" , "select round(c1) from sub1_bound" ) + self.check_result_auto( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from {dbname}.sub1_bound") + self.check_result_auto( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from {dbname}.sub1_bound") + self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.sub1_bound;" , f"select round(c1) from {dbname}.sub1_bound" ) # check basic elem for table per row - tdSql.query("select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from sub1_bound ") + tdSql.query(f"select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from {dbname}.sub1_bound ") tdSql.checkData(0, 0, 2147483647.000000000) tdSql.checkData(0, 2, 32767.000000000) tdSql.checkData(0, 3, 127.000000000) @@ -430,19 +424,18 @@ class TDTestCase: tdSql.checkData(4, 3, -123.000000000) tdSql.checkData(4, 4, -169499995645668991474575059260979281920.000000000) - self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from sub1_bound ") + self.check_result_auto(f"select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from {dbname}.sub1_bound" ,f"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from {dbname}.sub1_bound ") - def support_super_table_test(self): - tdSql.execute(" use db ") - self.check_result_auto( " select c5 from stb1 order by ts " , "select round(c5) from stb1 order by ts" ) - self.check_result_auto( " select c5 from stb1 order by tbname " , "select round(c5) from stb1 order by tbname" ) - self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) + def support_super_table_test(self, dbname="db"): + self.check_result_auto( f"select c5 from {dbname}.stb1 order by ts " , f"select round(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto( f"select c5 from {dbname}.stb1 order by tbname " , f"select round(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) - self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select round(t1), round(c5) from stb1 order by ts" ) - self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select round(t1) ,round(c5) from stb1 order by tbname" ) - self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) ,round(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) , round(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select round(t1), round(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) , round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) pass diff --git a/tests/system-test/2-query/rtrim.py b/tests/system-test/2-query/rtrim.py index 30624792cc33866a19c0ec1a31594cdfa438ffcf..80307e8534787889b080baa0c25a32b638c49461 100644 --- a/tests/system-test/2-query/rtrim.py +++ b/tests/system-test/2-query/rtrim.py @@ -120,16 +120,16 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: self.__rtrim_check(tb) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: for errsql in self.__rtrim_err_check(tb): @@ -142,17 +142,15 @@ class TDTestCase: self.__test_error() - def __create_tb(self): - tdSql.prepare() - + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -162,29 +160,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -200,7 +198,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -216,13 +214,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -251,8 +249,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") diff --git a/tests/system-test/2-query/sample.py b/tests/system-test/2-query/sample.py index 45be0ef8abc8e32c1dbe904fb2dcd225f3db5f94..7f1d7ab8c0d62fb4db7386caf3b4eeca4b3f8cba 100644 --- a/tests/system-test/2-query/sample.py +++ b/tests/system-test/2-query/sample.py @@ -11,21 +11,17 @@ # -*- coding: utf-8 -*- -from pstats import Stats import sys -import subprocess import random -import math -import numpy as np -import inspect import re -import taos from util.log import * from util.cases import * from util.sql import * from util.dnodes import * +DBNAME = "db" + class TDTestCase: def init(self, conn, logSql): @@ -33,11 +29,11 @@ class TDTestCase: tdSql.init(conn.cursor()) self.ts = 1537146000000 - def sample_query_form(self, sel="select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""): + def sample_query_form(self, sel=f"select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""): ''' sample function: - :param sel: string, must be "select", required parameters; + :param sel: string, must be f"select", required parameters; :param func: string, in this case must be "sample(", otherwise return other function, required parameters; :param col: string, column name, required parameters; :param m_comm: string, comma between col and k , required parameters; @@ -47,12 +43,12 @@ class TDTestCase: :param fr: string, must be "from", required parameters; :param table_expr: string or expression, data source(eg,table/stable name, result set), required parameters; :param condition: expression; - :return: sample query statement,default: select sample(c1, 1) from t1 + :return: sample query statement,default: select sample(c1, 1) from {dbname}.t1 ''' return f"{sel} {func} {col} {m_comm} {k} {r_comm} {alias} {fr} {table_expr} {condition}" - def checksample(self,sel="select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr="t1", condition=""): + def checksample(self,sel=f"select", func="sample(", col="c1", m_comm =",", k=1,r_comm=")", alias="", fr="from",table_expr=f"{DBNAME}.t1", condition=""): # print(self.sample_query_form(sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr, # table_expr=table_expr, condition=condition)) line = sys._getframe().f_back.f_lineno @@ -65,7 +61,7 @@ class TDTestCase: )) - sql = "select * from t1" + sql = f"select * from {table_expr}" collist = tdSql.getColNameList(sql) if not isinstance(col, str): @@ -125,7 +121,7 @@ class TDTestCase: # table_expr=table_expr, condition=condition # )) - if any( [func != "sample(" , r_comm != ")" , fr != "from", sel != "select"]): + if any( [func != "sample(" , r_comm != ")" , fr != "from", sel != f"select"]): print(f"case in {line}: ", end='') return tdSql.error(self.sample_query_form( sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr, @@ -286,14 +282,14 @@ class TDTestCase: return else: - if "where" in condition: - condition = re.sub('where', f"where {col} is not null and ", condition) - else: - condition = f"where {col} is not null" + condition - print(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") - tdSql.query(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") + # if "where" in condition: + # condition = re.sub('where', f"where {col} is not null and ", condition) + # else: + # condition = f"where {col} is not null" + condition + # print(f"select ts, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") + # tdSql.query(f"select _c0, {col} {alias} from {table_expr} {re.sub('limit [0-9]*|offset [0-9]*','',condition)}") # offset_val = condition.split("offset")[1].split(" ")[1] if "offset" in condition else 0 - pre_sample = tdSql.queryResult + # pre_sample = tdSql.queryResult # pre_len = tdSql.queryRows # for i in range(sample_len): # if sample_result[pre_row:pre_row + step][i] not in pre_sample: @@ -301,7 +297,7 @@ class TDTestCase: # else: # tdLog.info(f"case in {line} is success: sample data is in {group_name}") - pass + pass def sample_current_query(self) : @@ -322,24 +318,24 @@ class TDTestCase: self.checksample(**case6) # # case7~8: nested query - # case7 = {"table_expr": "(select c1 from stb1)"} - # self.checksample(**case7) - # case8 = {"table_expr": "(select sample(c1, 1) c1 from stb1 group by tbname)"} - # self.checksample(**case8) + case7 = {"table_expr": f"(select c1 from {DBNAME}.stb1)"} + self.checksample(**case7) + case8 = {"table_expr": f"(select sample(c1, 1) c1 from {DBNAME}.stb1 group by tbname)"} + self.checksample(**case8) # case9~10: mix with tbname/ts/tag/col - # case9 = {"alias": ", tbname"} - # self.checksample(**case9) - # case10 = {"alias": ", _c0"} - # self.checksample(**case10) - # case11 = {"alias": ", st1"} + case9 = {"alias": ", tbname"} + self.checksample(**case9) + case10 = {"alias": ", _c0"} + self.checksample(**case10) + case11 = {"alias": ", st1"} # self.checksample(**case11) - tdSql.query("select sample( c1 , 1 ) , st1 from t1") + tdSql.query(f"select sample( c1 , 1 ) , st1 from {DBNAME}.t1") - # case12 = {"alias": ", c1"} + case12 = {"alias": ", c1"} # self.checksample(**case12) - tdSql.query("select sample( c1 , 1 ) , c1 from t1") + tdSql.query(f"select sample( c1 , 1 ) , c1 from {DBNAME}.t1") # case13~15: with single condition case13 = {"condition": "where c1 <= 10"} @@ -353,32 +349,31 @@ class TDTestCase: case16 = {"condition": "where c6=1 or c6 =0"} self.checksample(**case16) - # # case17: only support normal table join - # case17 = { - # "col": "t1.c1", - # "table_expr": "t1, t2", - # "condition": "where t1.ts=t2.ts" - # } - # self.checksample(**case17) - # # case18~19: with group by - # case19 = { - # "table_expr": "stb1", - # "condition": "partition by tbname" - # } + # case17: only support normal table join + case17 = { + "col": "t1.c1", + "table_expr": f"{DBNAME}.t1 t1 join {DBNAME}.t2 t2 on t1.ts = t2.ts", + } + self.checksample(**case17) + # case18~19: with group by + case19 = { + "table_expr": f"{DBNAME}.stb1", + "condition": "partition by tbname" + } # self.checksample(**case19) - # # case20~21: with order by - # case20 = {"condition": "order by ts"} + # case20~21: with order by + case20 = {"condition": "order by ts"} # self.checksample(**case20) - # case21 = { - # "table_expr": "stb1", - # "condition": "partition by tbname order by tbname" - # } + case21 = { + "table_expr": f"{DBNAME}.stb1", + "condition": "partition by tbname order by tbname" + } # self.checksample(**case21) # case22: with union case22 = { - "condition": "union all select sample( c1 , 1 ) from t2" + "condition": f"union all select sample( c1 , 1 ) from {DBNAME}.t2" } self.checksample(**case22) @@ -396,12 +391,12 @@ class TDTestCase: case26 = {"k": 1000} self.checksample(**case26) case27 = { - "table_expr": "stb1", + "table_expr": f"{DBNAME}.stb1", "condition": "group by tbname slimit 1 " } self.checksample(**case27) # with slimit case28 = { - "table_expr": "stb1", + "table_expr": f"{DBNAME}.stb1", "condition": "group by tbname slimit 1 soffset 1" } self.checksample(**case28) # with soffset @@ -431,7 +426,7 @@ class TDTestCase: # err9 = {"col": "st1"} # self.checksample(**err9) # col: tag - tdSql.query(" select sample(st1 ,1) from t1 ") + tdSql.query(f"select sample(st1 ,1) from {DBNAME}.t1 ") # err10 = {"col": 1} # self.checksample(**err10) # col: value # err11 = {"col": "NULL"} @@ -494,13 +489,13 @@ class TDTestCase: self.checksample(**err39) # mix with calculation function 2 # err40 = {"alias": "+ 2"} # self.checksample(**err40) # mix with arithmetic 1 - # tdSql.query(" select sample(c1 , 1) + 2 from t1 ") + # tdSql.query(f"select sample(c1 , 1) + 2 from {dbname}.t1 ") err41 = {"alias": "+ avg(c1)"} # self.checksample(**err41) # mix with arithmetic 2 # err42 = {"alias": ", c1"} # self.checksample(**err42) - tdSql.query("select sample( c1 , 1 ) , c1 from t1") + tdSql.query(f"select sample( c1 , 1 ) , c1 from {DBNAME}.t1") # mix with other col # err43 = {"table_expr": "stb1"} # self.checksample(**err43) # select stb directly @@ -510,14 +505,14 @@ class TDTestCase: # "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts" # } # self.checksample(**err44) # stb join - tdSql.query("select sample( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts") + tdSql.query(f"select sample( stb1.c1 , 1 ) from {DBNAME}.stb1 stb1, {DBNAME}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts") # err45 = { # "condition": "where ts>0 and ts < now interval(1h) fill(next)" # } # self.checksample(**err45) # interval - tdSql.error("select sample( c1 , 1 ) from t1 where ts>0 and ts < now interval(1h) fill(next)") + tdSql.error(f"select sample( c1 , 1 ) from {DBNAME}.t1 where ts>0 and ts < now interval(1h) fill(next)") err46 = { - "table_expr": "t1", + "table_expr": f"{DBNAME}.t1", "condition": "group by c6" } # self.checksample(**err46) # group by normal col @@ -563,49 +558,45 @@ class TDTestCase: pass - def sample_test_data(self, tbnum:int, data_row:int, basetime:int) -> None : + def sample_test_data(self, tbnum:int, data_row:int, basetime:int, dbname="db") -> None : for i in range(tbnum): for j in range(data_row): tdSql.execute( - f"insert into t{i} values (" + f"insert into {dbname}.t{i} values (" f"{basetime + (j+1)*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, " f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, " f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )" ) tdSql.execute( - f"insert into t{i} values (" + f"insert into {dbname}.t{i} values (" f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, " f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, " f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )" ) tdSql.execute( - f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" + f"insert into {dbname}.tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )" ) pass - def sample_test_table(self,tbnum: int) -> None : - tdSql.execute("drop database if exists db") - tdSql.execute("create database if not exists db keep 3650") - tdSql.execute("use db") + def sample_test_table(self,tbnum: int, dbname="db") -> None : + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname} keep 3650") tdSql.execute( - "create stable db.stb1 (\ + f"create stable {dbname}.stb1 (\ ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool, \ c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16)\ ) \ tags(st1 int)" ) tdSql.execute( - "create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)" + f"create stable {dbname}.stb2 (ts timestamp, c1 int) tags(st2 int)" ) for i in range(tbnum): - tdSql.execute(f"create table t{i} using stb1 tags({i})") - tdSql.execute(f"create table tt{i} using stb2 tags({i})") - - pass - + tdSql.execute(f"create table {dbname}.t{i} using {dbname}.stb1 tags({i})") + tdSql.execute(f"create table {dbname}.tt{i} using {dbname}.stb2 tags({i})") def check_sample(self , sample_query , origin_query ): @@ -626,45 +617,43 @@ class TDTestCase: else: tdLog.exit(" sample data is not in datas groups ,failed sql is : %s" % sample_query ) - - def basic_sample_query(self): - tdSql.execute(" drop database if exists db ") - tdSql.execute(" create database if not exists db duration 300d ") - tdSql.execute(" use db ") + def basic_sample_query(self, dbname="db"): + tdSql.execute(f" drop database if exists {dbname} ") + tdSql.execute(f" create database if not exists {dbname} duration 300d ") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -683,116 +672,116 @@ class TDTestCase: # basic query for sample # params test for all - tdSql.error(" select sample(c1,c1) from t1 ") - tdSql.error(" select sample(c1,now) from t1 ") - tdSql.error(" select sample(c1,tbname) from t1 ") - tdSql.error(" select sample(c1,ts) from t1 ") - tdSql.error(" select sample(c1,false) from t1 ") - tdSql.query(" select sample(123,1) from t1 ") - - tdSql.query(" select sample(c1,2) from t1 ") + tdSql.error(f"select sample(c1,c1) from {dbname}.t1 ") + tdSql.error(f"select sample(c1,now) from {dbname}.t1 ") + tdSql.error(f"select sample(c1,tbname) from {dbname}.t1 ") + tdSql.error(f"select sample(c1,ts) from {dbname}.t1 ") + tdSql.error(f"select sample(c1,false) from {dbname}.t1 ") + tdSql.query(f"select sample(123,1) from {dbname}.t1 ") + + tdSql.query(f"select sample(c1,2) from {dbname}.t1 ") tdSql.checkRows(2) - tdSql.query(" select sample(c1,10) from t1 ") + tdSql.query(f"select sample(c1,10) from {dbname}.t1 ") tdSql.checkRows(9) - tdSql.query(" select sample(c8,10) from t1 ") + tdSql.query(f"select sample(c8,10) from {dbname}.t1 ") tdSql.checkRows(9) - tdSql.query(" select sample(c1,999) from t1 ") + tdSql.query(f"select sample(c1,999) from {dbname}.t1 ") tdSql.checkRows(9) - tdSql.query(" select sample(c1,1000) from t1 ") + tdSql.query(f"select sample(c1,1000) from {dbname}.t1 ") tdSql.checkRows(9) - tdSql.query(" select sample(c8,1000) from t1 ") + tdSql.query(f"select sample(c8,1000) from {dbname}.t1 ") tdSql.checkRows(9) - tdSql.error(" select sample(c1,-1) from t1 ") + tdSql.error(f"select sample(c1,-1) from {dbname}.t1 ") # bug need fix - # tdSql.query("select sample(c1 ,2) , 123 from stb1;") + # tdSql.query(f"select sample(c1 ,2) , 123 from {dbname}.stb1;") # all type support - tdSql.query(" select sample(c1 , 20 ) from ct4 ") + tdSql.query(f"select sample(c1 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c2 , 20 ) from ct4 ") + tdSql.query(f"select sample(c2 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c3 , 20 ) from ct4 ") + tdSql.query(f"select sample(c3 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c4 , 20 ) from ct4 ") + tdSql.query(f"select sample(c4 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c5 , 20 ) from ct4 ") + tdSql.query(f"select sample(c5 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c6 , 20 ) from ct4 ") + tdSql.query(f"select sample(c6 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c7 , 20 ) from ct4 ") + tdSql.query(f"select sample(c7 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c8 , 20 ) from ct4 ") + tdSql.query(f"select sample(c8 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c9 , 20 ) from ct4 ") + tdSql.query(f"select sample(c9 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - tdSql.query(" select sample(c10 , 20 ) from ct4 ") + tdSql.query(f"select sample(c10 , 20 ) from {dbname}.ct4 ") tdSql.checkRows(9) - # tdSql.query(" select sample(t1 , 20 ) from ct1 ") + # tdSql.query(f"select sample(t1 , 20 ) from {dbname}.ct1 ") # tdSql.checkRows(13) # filter data - tdSql.query(" select sample(c1, 20 ) from t1 where c1 is null ") + tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 is null ") tdSql.checkRows(1) - tdSql.query(" select sample(c1, 20 ) from t1 where c1 =6 ") + tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 =6 ") tdSql.checkRows(1) - tdSql.query(" select sample(c1, 20 ) from t1 where c1 > 6 ") + tdSql.query(f"select sample(c1, 20 ) from {dbname}.t1 where c1 > 6 ") tdSql.checkRows(3) - self.check_sample("select sample(c1, 20 ) from t1 where c1 > 6" , "select c1 from t1 where c1 > 6") + self.check_sample(f"select sample(c1, 20 ) from {dbname}.t1 where c1 > 6" , f"select c1 from {dbname}.t1 where c1 > 6") - tdSql.query(" select sample( c1 , 1 ) from t1 where c1 in (0, 1,2) ") + tdSql.query(f"select sample( c1 , 1 ) from {dbname}.t1 where c1 in (0, 1,2) ") tdSql.checkRows(1) - tdSql.query("select sample( c1 ,3 ) from t1 where c1 between 1 and 10 ") + tdSql.query(f"select sample( c1 ,3 ) from {dbname}.t1 where c1 between 1 and 10 ") tdSql.checkRows(3) - self.check_sample("select sample( c1 ,3 ) from t1 where c1 between 1 and 10" ,"select c1 from t1 where c1 between 1 and 10") + self.check_sample(f"select sample( c1 ,3 ) from {dbname}.t1 where c1 between 1 and 10" ,f"select c1 from {dbname}.t1 where c1 between 1 and 10") # join - tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts") + tdSql.query(f"select sample( ct4.c1 , 1 ) from {dbname}.ct1 ct1, {dbname}.ct4 ct4 where ct4.ts=ct1.ts") # partition by tbname - tdSql.query("select sample(c1,2) from stb1 partition by tbname") + tdSql.query(f"select sample(c1,2) from {dbname}.stb1 partition by tbname") tdSql.checkRows(4) - self.check_sample("select sample(c1,2) from stb1 partition by tbname" , "select c1 from stb1 partition by tbname") + self.check_sample(f"select sample(c1,2) from {dbname}.stb1 partition by tbname" , f"select c1 from {dbname}.stb1 partition by tbname") # nest query - # tdSql.query("select sample(c1,2) from (select c1 from t1); ") + # tdSql.query(f"select sample(c1,2) from (select c1 from {dbname}.t1); ") # tdSql.checkRows(2) # union all - tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1") + tdSql.query(f"select sample(c1,2) from {dbname}.t1 union all select sample(c1,3) from {dbname}.t1") tdSql.checkRows(5) # fill interval # not support mix with other function - tdSql.error("select top(c1,2) , sample(c1,2) from ct1") - tdSql.error("select max(c1) , sample(c1,2) from ct1") - tdSql.query("select c1 , sample(c1,2) from ct1") + tdSql.error(f"select top(c1,2) , sample(c1,2) from {dbname}.ct1") + tdSql.error(f"select max(c1) , sample(c1,2) from {dbname}.ct1") + tdSql.query(f"select c1 , sample(c1,2) from {dbname}.ct1") # bug for mix with scalar - tdSql.query("select 123 , sample(c1,100) from ct1") - tdSql.query("select sample(c1,100)+2 from ct1") - tdSql.query("select abs(sample(c1,100)) from ct1") + tdSql.query(f"select 123 , sample(c1,100) from {dbname}.ct1") + tdSql.query(f"select sample(c1,100)+2 from {dbname}.ct1") + tdSql.query(f"select abs(sample(c1,100)) from {dbname}.ct1") - def sample_test_run(self) : + def sample_test_run(self, dbname="db") : tdLog.printNoPrefix("==========support sample function==========") tbnum = 10 nowtime = int(round(time.time() * 1000)) @@ -805,28 +794,28 @@ class TDTestCase: tdLog.printNoPrefix("######## insert only NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})") + tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime - 5})") + tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime + 5})") self.sample_current_query() self.sample_error_query() tdLog.printNoPrefix("######## insert data in the range near the max(bigint/double):") - # self.sample_test_table(tbnum) - # tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " - # f"({nowtime - (per_table_rows + 1) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") - # tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " - # f"({nowtime - (per_table_rows + 2) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") - # self.sample_current_query() - # self.sample_error_query() + self.sample_test_table(tbnum) + tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values " + f"({nowtime - (per_table_rows + 1) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") + tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values " + f"({nowtime - (per_table_rows + 2) * 10}, {2**31-1}, {3.4*10**38}, {1.7*10**308}, {2**63-1})") + self.sample_current_query() + self.sample_error_query() tdLog.printNoPrefix("######## insert data in the range near the min(bigint/double):") - # self.sample_test_table(tbnum) - # tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " - # f"({nowtime - (per_table_rows + 1) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {1-2**63})") - # tdSql.execute(f"insert into t1(ts, c1,c2,c5,c7) values " - # f"({nowtime - (per_table_rows + 2) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {512-2**63})") - # self.sample_current_query() - # self.sample_error_query() + self.sample_test_table(tbnum) + tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values " + f"({nowtime - (per_table_rows + 1) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {1-2**63})") + tdSql.execute(f"insert into {dbname}.t1(ts, c1,c2,c5,c7) values " + f"({nowtime - (per_table_rows + 2) * 10}, {1-2**31}, {-3.4*10**38}, {-1.7*10**308}, {512-2**63})") + self.sample_current_query() + self.sample_error_query() tdLog.printNoPrefix("######## insert data without NULL data test:") self.sample_test_table(tbnum) @@ -837,16 +826,16 @@ class TDTestCase: tdLog.printNoPrefix("######## insert data mix with NULL test:") for i in range(tbnum): - tdSql.execute(f"insert into t{i}(ts) values ({nowtime})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") - tdSql.execute(f"insert into t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") + tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime})") + tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})") + tdSql.execute(f"insert into {dbname}.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})") self.sample_current_query() self.sample_error_query() tdLog.printNoPrefix("######## check after WAL test:") - tdSql.query("select * from information_schema.ins_dnodes") + tdSql.query(f"select * from information_schema.ins_dnodes") index = tdSql.getData(0, 0) tdDnodes.stop(index) tdDnodes.start(index) @@ -855,19 +844,19 @@ class TDTestCase: self.basic_sample_query() - def sample_big_data(self): - tdSql.execute("create database sample_db") + def sample_big_data(self, dbname="sample_db"): + tdSql.execute(f"create database {dbname}") tdSql.execute("use sample_db") - tdSql.execute("create stable st (ts timestamp ,c1 int ) tags(ind int)" ) - tdSql.execute("create table sub_tb using st tags(1)") + tdSql.execute(f"create stable {dbname}.st (ts timestamp ,c1 int ) tags(ind int)" ) + tdSql.execute(f"create table {dbname}.sub_tb using {dbname}.st tags(1)") for i in range(2000): ts = self.ts+i*10 - tdSql.execute(f"insert into sub_tb values({ts} ,{i})") + tdSql.execute(f"insert into {dbname}.sub_tb values({ts} ,{i})") - tdSql.query("select count(*) from st") + tdSql.query(f"select count(*) from {dbname}.st") tdSql.checkData(0,0,2000) - tdSql.query("select sample(c1 ,1000) from st") + tdSql.query(f"select sample(c1 ,1000) from {dbname}.st") tdSql.checkRows(1000) # bug need fix diff --git a/tests/system-test/2-query/sin.py b/tests/system-test/2-query/sin.py index 7cb559c510f637c25fef6e7573ea44c92a2051bc..a1ba3354879eb9e1e0abe66ae445f7604734ad66 100644 --- a/tests/system-test/2-query/sin.py +++ b/tests/system-test/2-query/sin.py @@ -9,48 +9,46 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} + def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - - def prepare_datas(self): + + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) - + tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -65,14 +63,15 @@ class TDTestCase: ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ''' ) - + def check_result_auto_sin(self ,origin_query , pow_query): pow_result = tdSql.getResult(pow_query) + origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -82,190 +81,179 @@ class TDTestCase: elem = math.sin(elem) row_check.append(elem) auto_result.append(row_check) - - check_status = True - + tdSql.query(pow_query) for row_index , row in enumerate(pow_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("sin function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("sin value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def test_errors(self): + tdSql.checkData(row_index ,col_index ,auto_result[row_index][col_index]) + + + def test_errors(self, dbname="db"): error_sql_lists = [ - "select sin from t1", - # "select sin(-+--+c1 ) from t1", - # "select +-sin(c1) from t1", - # "select ++-sin(c1) from t1", - # "select ++--sin(c1) from t1", - # "select - -sin(c1)*0 from t1", - # "select sin(tbname+1) from t1 ", - "select sin(123--123)==1 from t1", - "select sin(c1) as 'd1' from t1", - "select sin(c1 ,c2) from t1", - "select sin(c1 ,NULL ) from t1", - "select sin(,) from t1;", - "select sin(sin(c1) ab from t1)", - "select sin(c1 ) as int from t1", - "select sin from stb1", - # "select sin(-+--+c1) from stb1", - # "select +-sin(c1) from stb1", - # "select ++-sin(c1) from stb1", - # "select ++--sin(c1) from stb1", - # "select - -sin(c1)*0 from stb1", - # "select sin(tbname+1) from stb1 ", - "select sin(123--123)==1 from stb1", - "select sin(c1) as 'd1' from stb1", - "select sin(c1 ,c2 ) from stb1", - "select sin(c1 ,NULL) from stb1", - "select sin(,) from stb1;", - "select sin(sin(c1) ab from stb1)", - "select sin(c1) as int from stb1" + f"select sin from {dbname}.t1", + # f"select sin(-+--+c1 ) from {dbname}.t1", + # f"select +-sin(c1) from {dbname}.t1", + # f"select ++-sin(c1) from {dbname}.t1", + # f"select ++--sin(c1) from {dbname}.t1", + # f"select - -sin(c1)*0 from {dbname}.t1", + # f"select sin(tbname+1) from {dbname}.t1 ", + f"select sin(123--123)==1 from {dbname}.t1", + f"select sin(c1) as 'd1' from {dbname}.t1", + f"select sin(c1 ,c2) from {dbname}.t1", + f"select sin(c1 ,NULL ) from {dbname}.t1", + f"select sin(,) from {dbname}.t1;", + f"select sin(sin(c1) ab from {dbname}.t1)", + f"select sin(c1 ) as int from {dbname}.t1", + f"select sin from {dbname}.stb1", + # f"select sin(-+--+c1) from {dbname}.stb1", + # f"select +-sin(c1) from {dbname}.stb1", + # f"select ++-sin(c1) from {dbname}.stb1", + # f"select ++--sin(c1) from {dbname}.stb1", + # f"select - -sin(c1)*0 from {dbname}.stb1", + # f"select sin(tbname+1) from {dbname}.stb1 ", + f"select sin(123--123)==1 from {dbname}.stb1", + f"select sin(c1) as 'd1' from {dbname}.stb1", + f"select sin(c1 ,c2 ) from {dbname}.stb1", + f"select sin(c1 ,NULL) from {dbname}.stb1", + f"select sin(,) from {dbname}.stb1;", + f"select sin(sin(c1) ab from {dbname}.stb1)", + f"select sin(c1) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - - def support_types(self): + + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select sin(ts) from t1" , - "select sin(c7) from t1", - "select sin(c8) from t1", - "select sin(c9) from t1", - "select sin(ts) from ct1" , - "select sin(c7) from ct1", - "select sin(c8) from ct1", - "select sin(c9) from ct1", - "select sin(ts) from ct3" , - "select sin(c7) from ct3", - "select sin(c8) from ct3", - "select sin(c9) from ct3", - "select sin(ts) from ct4" , - "select sin(c7) from ct4", - "select sin(c8) from ct4", - "select sin(c9) from ct4", - "select sin(ts) from stb1" , - "select sin(c7) from stb1", - "select sin(c8) from stb1", - "select sin(c9) from stb1" , - - "select sin(ts) from stbbb1" , - "select sin(c7) from stbbb1", - - "select sin(ts) from tbname", - "select sin(c9) from tbname" + f"select sin(ts) from {dbname}.t1" , + f"select sin(c7) from {dbname}.t1", + f"select sin(c8) from {dbname}.t1", + f"select sin(c9) from {dbname}.t1", + f"select sin(ts) from {dbname}.ct1" , + f"select sin(c7) from {dbname}.ct1", + f"select sin(c8) from {dbname}.ct1", + f"select sin(c9) from {dbname}.ct1", + f"select sin(ts) from {dbname}.ct3" , + f"select sin(c7) from {dbname}.ct3", + f"select sin(c8) from {dbname}.ct3", + f"select sin(c9) from {dbname}.ct3", + f"select sin(ts) from {dbname}.ct4" , + f"select sin(c7) from {dbname}.ct4", + f"select sin(c8) from {dbname}.ct4", + f"select sin(c9) from {dbname}.ct4", + f"select sin(ts) from {dbname}.stb1" , + f"select sin(c7) from {dbname}.stb1", + f"select sin(c8) from {dbname}.stb1", + f"select sin(c9) from {dbname}.stb1" , + + f"select sin(ts) from {dbname}.stbbb1" , + f"select sin(c7) from {dbname}.stbbb1", + + f"select sin(ts) from {dbname}.tbname", + f"select sin(c9) from {dbname}.tbname" ] - + for type_sql in type_error_sql_lists: tdSql.error(type_sql) - - + + type_sql_lists = [ - "select sin(c1) from t1", - "select sin(c2) from t1", - "select sin(c3) from t1", - "select sin(c4) from t1", - "select sin(c5) from t1", - "select sin(c6) from t1", - - "select sin(c1) from ct1", - "select sin(c2) from ct1", - "select sin(c3) from ct1", - "select sin(c4) from ct1", - "select sin(c5) from ct1", - "select sin(c6) from ct1", - - "select sin(c1) from ct3", - "select sin(c2) from ct3", - "select sin(c3) from ct3", - "select sin(c4) from ct3", - "select sin(c5) from ct3", - "select sin(c6) from ct3", - - "select sin(c1) from stb1", - "select sin(c2) from stb1", - "select sin(c3) from stb1", - "select sin(c4) from stb1", - "select sin(c5) from stb1", - "select sin(c6) from stb1", - - "select sin(c6) as alisb from stb1", - "select sin(c6) alisb from stb1", + f"select sin(c1) from {dbname}.t1", + f"select sin(c2) from {dbname}.t1", + f"select sin(c3) from {dbname}.t1", + f"select sin(c4) from {dbname}.t1", + f"select sin(c5) from {dbname}.t1", + f"select sin(c6) from {dbname}.t1", + + f"select sin(c1) from {dbname}.ct1", + f"select sin(c2) from {dbname}.ct1", + f"select sin(c3) from {dbname}.ct1", + f"select sin(c4) from {dbname}.ct1", + f"select sin(c5) from {dbname}.ct1", + f"select sin(c6) from {dbname}.ct1", + + f"select sin(c1) from {dbname}.ct3", + f"select sin(c2) from {dbname}.ct3", + f"select sin(c3) from {dbname}.ct3", + f"select sin(c4) from {dbname}.ct3", + f"select sin(c5) from {dbname}.ct3", + f"select sin(c6) from {dbname}.ct3", + + f"select sin(c1) from {dbname}.stb1", + f"select sin(c2) from {dbname}.stb1", + f"select sin(c3) from {dbname}.stb1", + f"select sin(c4) from {dbname}.stb1", + f"select sin(c5) from {dbname}.stb1", + f"select sin(c6) from {dbname}.stb1", + + f"select sin(c6) as alisb from {dbname}.stb1", + f"select sin(c6) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - - def basic_sin_function(self): - # basic query - tdSql.query("select c1 from ct3") + def basic_sin_function(self, dbname="db"): + + # basic query + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select sin(c1) from ct3") + tdSql.query(f"select sin(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sin(c2) from ct3") + tdSql.query(f"select sin(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sin(c3) from ct3") + tdSql.query(f"select sin(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sin(c4) from ct3") + tdSql.query(f"select sin(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sin(c5) from ct3") + tdSql.query(f"select sin(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sin(c6) from ct3") + tdSql.query(f"select sin(c6) from {dbname}.ct3") tdSql.checkRows(0) # # used for regular table - tdSql.query("select sin(c1) from t1") + tdSql.query(f"select sin(c1) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 0.841470985) tdSql.checkData(3 , 0, 0.141120008) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto_sin( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select sin(abs(c1)), sin(abs(c2)) ,sin(abs(c3)), sin(abs(c4)), sin(abs(c5)) from t1") - + self.check_result_auto_sin( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select sin(abs(c1)), sin(abs(c2)) ,sin(abs(c3)), sin(abs(c4)), sin(abs(c5)) from {dbname}.t1") + # used for sub table - tdSql.query("select c2 ,sin(c2) from ct1") + tdSql.query(f"select c2 ,sin(c2) from {dbname}.ct1") tdSql.checkData(0, 1, -0.220708349) tdSql.checkData(1 , 1, -0.556921845) tdSql.checkData(3 , 1, -0.798311364) tdSql.checkData(4 , 1, 0.000000000) - tdSql.query("select c1, c5 ,sin(c5) from ct4") + tdSql.query(f"select c1, c5 ,sin(c5) from {dbname}.ct4") tdSql.checkData(0 , 2, None) tdSql.checkData(1 , 2, 0.518228108) tdSql.checkData(2 , 2, 0.996475613) tdSql.checkData(3 , 2, 0.367960369) tdSql.checkData(5 , 2, None) - self.check_result_auto_sin( "select c1, c2, c3 , c4, c5 from ct1", "select sin(c1), sin(c2) ,sin(c3), sin(c4), sin(c5) from ct1") - + self.check_result_auto_sin( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select sin(c1), sin(c2) ,sin(c3), sin(c4), sin(c5) from {dbname}.ct1") + # nest query for sin functions - tdSql.query("select c4 , sin(c4) ,sin(sin(c4)) , sin(sin(sin(c4))) from ct1;") + tdSql.query(f"select c4 , sin(c4) ,sin(sin(c4)) , sin(sin(sin(c4))) from {dbname}.ct1;") tdSql.checkData(0 , 0 , 88) tdSql.checkData(0 , 1 , 0.035398303) tdSql.checkData(0 , 2 , 0.035390911) @@ -281,52 +269,52 @@ class TDTestCase: tdSql.checkData(11 , 2 , 0.841042171) tdSql.checkData(11 , 3 , 0.745338326) - # used for stable table - - tdSql.query("select sin(c1) from stb1") + # used for stable table + + tdSql.query(f"select sin(c1) from {dbname}.stb1") tdSql.checkRows(25) - + # used for not exists table - tdSql.error("select sin(c1) from stbbb1") - tdSql.error("select sin(c1) from tbname") - tdSql.error("select sin(c1) from ct5") + tdSql.error(f"select sin(c1) from {dbname}.stbbb1") + tdSql.error(f"select sin(c1) from {dbname}.tbname") + tdSql.error(f"select sin(c1) from {dbname}.ct5") + + # mix with common col + tdSql.query(f"select c1, sin(c1) from {dbname}.ct1") + tdSql.query(f"select c2, sin(c2) from {dbname}.ct4") - # mix with common col - tdSql.query("select c1, sin(c1) from ct1") - tdSql.query("select c2, sin(c2) from ct4") - # mix with common functions - tdSql.query("select c1, sin(c1),sin(c1), sin(sin(c1)) from ct4 ") + tdSql.query(f"select c1, sin(c1),sin(c1), sin(sin(c1)) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) tdSql.checkData(0 , 3 ,None) - + tdSql.checkData(3 , 0 , 6) tdSql.checkData(3 , 1 ,-0.279415498) tdSql.checkData(3 , 2 ,-0.279415498) tdSql.checkData(3 , 3 ,-0.275793863) - tdSql.query("select c1, sin(c1),c5, floor(c5) from stb1 ") + tdSql.query(f"select c1, sin(c1),c5, floor(c5) from {dbname}.stb1 ") # # mix with agg functions , not support - tdSql.error("select c1, sin(c1),c5, count(c5) from stb1 ") - tdSql.error("select c1, sin(c1),c5, count(c5) from ct1 ") - tdSql.error("select sin(c1), count(c5) from stb1 ") - tdSql.error("select sin(c1), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, sin(c1),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, sin(c1),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select sin(c1), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select sin(c1), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") - - # # bug fix for compute - tdSql.query("select c1, sin(c1) -0 ,sin(c1-4)-0 from ct4 ") + + # # bug fix for compute + tdSql.query(f"select c1, sin(c1) -0 ,sin(c1-4)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -334,7 +322,7 @@ class TDTestCase: tdSql.checkData(1, 1, 0.989358247) tdSql.checkData(1, 2, -0.756802495) - tdSql.query(" select c1, sin(c1) -0 ,sin(c1-0.1)-0.1 from ct4") + tdSql.query(f"select c1, sin(c1) -0 ,sin(c1-0.1)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -342,35 +330,34 @@ class TDTestCase: tdSql.checkData(1, 1, 0.989358247) tdSql.checkData(1, 2, 0.898941342) - tdSql.query("select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1") + tdSql.query(f"select c1, sin(c1), c2, sin(c2), c3, sin(c3) from {dbname}.ct1") - def test_big_number(self): + def test_big_number(self, dbname="db"): - tdSql.query("select c1, sin(100000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(100000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.sin(100000000)) - tdSql.query("select c1, sin(10000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(10000000000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.sin(10000000000000)) - tdSql.query("select c1, sin(10000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sin(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sin(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(1, 1, math.sin(10000000000000000000000000.0)) - tdSql.query("select c1, sin(10000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sin(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sin(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.sin(10000000000000000000000000000000000.0)) - tdSql.query("select c1, sin(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sin(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sin(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.sin(10000000000000000000000000000000000000000.0)) - tdSql.query("select c1, sin(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sin(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -378,7 +365,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,1.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -386,7 +373,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,-1.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from ct4 where c1=sin(c1) limit 1 ") + tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from {dbname}.ct4 where c1=sin(c1) limit 1 ") tdSql.checkRows(1) tdSql.checkData(0,0,0) tdSql.checkData(0,1,0) @@ -394,45 +381,40 @@ class TDTestCase: tdSql.checkData(0,3,0.000000000) tdSql.checkData(0,4,-0.100000000) tdSql.checkData(0,5,0.000000000) - - def pow_Arithmetic(self): - pass - - def check_boundary_values(self): + + def check_boundary_values(self, dbname="testdb"): PI=3.1415926 - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - time.sleep(3) - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto_sin( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select sin(abs(c1)), sin(abs(c2)) ,sin(abs(c3)), sin(abs(c4)), sin(abs(c5)) from sub1_bound") - - self.check_result_auto_sin( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select sin(c1), sin(c2) ,sin(c3), sin(c3), sin(c2) ,sin(c1) from sub1_bound") + self.check_result_auto_sin( f"select abs(c1), abs(c2), abs(c3) , abs(c4) from {dbname}.sub1_bound ", f"select sin(abs(c1)), sin(abs(c2)) ,sin(abs(c3)), sin(abs(c4)) from {dbname}.sub1_bound") + + self.check_result_auto_sin( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select sin(c1), sin(c2) ,sin(c3), sin(c3), sin(c2) ,sin(c1) from {dbname}.sub1_bound") + + self.check_result_auto_sin(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select sin(abs(c1)) from {dbname}.sub1_bound" ) - self.check_result_auto_sin("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select sin(abs(c1)) from sub1_bound" ) - # check basic elem for table per row - tdSql.query("select sin(abs(c1)) ,sin(abs(c2)) , sin(abs(c3)) , sin(abs(c4)), sin(abs(c5)), sin(abs(c6)) from sub1_bound ") + tdSql.query(f"select sin(abs(c1)) ,sin(abs(c2)) , sin(abs(c3)) , sin(abs(c4)), sin(abs(c5)), sin(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.sin(2147483647)) tdSql.checkData(0,1,math.sin(9223372036854775807)) tdSql.checkData(0,2,math.sin(32767)) @@ -450,83 +432,79 @@ class TDTestCase: tdSql.checkData(3,4,math.sin(339999995214436424907732413799364296704.00000)) # check + - * / in functions - tdSql.query("select sin(abs(c1+1)) ,sin(abs(c2)) , sin(abs(c3*1)) , sin(abs(c4/2)), sin(abs(c5))/2, sin(abs(c6)) from sub1_bound ") + tdSql.query(f"select sin(abs(c1+1)) ,sin(abs(c2)) , sin(abs(c3*1)) , sin(abs(c4/2)), sin(abs(c5))/2, sin(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.sin(2147483648.000000000)) tdSql.checkData(0,1,math.sin(9223372036854775807)) tdSql.checkData(0,2,math.sin(32767.000000000)) tdSql.checkData(0,3,math.sin(63.500000000)) - tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);") - tdSql.execute(f'create table tb1 using st tags (1)') - tdSql.execute(f'create table tb2 using st tags (2)') - tdSql.execute(f'create table tb3 using st tags (3)') - tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) - - tdSql.execute('insert into tb2 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb2 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) - - for i in range(100): - tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) - - self.check_result_auto_sin("select num1,num2 from tb3;" , "select sin(num1),sin(num2) from tb3") - - def support_super_table_test(self): - tdSql.execute(" use db ") - self.check_result_auto_sin( " select c5 from stb1 order by ts " , "select sin(c5) from stb1 order by ts" ) - self.check_result_auto_sin( " select c5 from stb1 order by tbname " , "select sin(c5) from stb1 order by tbname" ) - self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) - - self.check_result_auto_sin( " select t1,c5 from stb1 order by ts " , "select sin(t1), sin(c5) from stb1 order by ts" ) - self.check_result_auto_sin( " select t1,c5 from stb1 order by tbname " , "select sin(t1) ,sin(c5) from stb1 order by tbname" ) - self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) ,sin(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) , sin(c5) from stb1 where c1 > 0 order by tbname" ) - pass - + tdSql.execute(f"create stable {dbname}.st (ts timestamp, num1 float, num2 double) tags (t1 int);") + tdSql.execute(f'create table {dbname}.tb1 using {dbname}.st tags (1)') + tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)') + tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now(), {PI*2.5}, {PI*2.5})') + + tdSql.execute(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now(), {PI*2.5}, {PI*2.5})') + + self.check_result_auto_sin(f"select num1,num2 from {dbname}.tb3;" , f"select sin(num1),sin(num2) from {dbname}.tb3") + + def support_super_table_test(self, dbname="db"): + self.check_result_auto_sin( f"select c5 from {dbname}.stb1 order by ts " , f"select sin(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_sin( f"select c5 from {dbname}.stb1 order by tbname " , f"select sin(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_sin( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sin( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select sin(t1), sin(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_sin( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select sin(t1) ,sin(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_sin( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sin(t1) ,sin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sin(t1) , sin(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: sin basic query ============") + tdLog.printNoPrefix("==========step4: sin basic query ============") self.basic_sin_function() - tdLog.printNoPrefix("==========step5: big number sin query ============") - - self.test_big_number() + tdLog.printNoPrefix("==========step5: sin filter query ============") + self.abs_func_filter() - tdLog.printNoPrefix("==========step6: sin boundary query ============") + tdLog.printNoPrefix("==========step6: big number sin query ============") - self.check_boundary_values() + self.test_big_number() + - tdLog.printNoPrefix("==========step7: sin filter query ============") + tdLog.printNoPrefix("==========step7: sin boundary query ============") - self.abs_func_filter() + self.check_boundary_values() + tdLog.printNoPrefix("==========step8: check sin result of stable query ============") self.support_super_table_test() - + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/smaTest.py b/tests/system-test/2-query/smaTest.py index 67824cc3a3c372821c5014d48f6d2dbbc9ee9066..0217b6c28c2f44deb87c032957ef749fc329742e 100644 --- a/tests/system-test/2-query/smaTest.py +++ b/tests/system-test/2-query/smaTest.py @@ -30,14 +30,6 @@ class TDTestCase: # updatecfgDict = {'debugFlag': 135} # updatecfgDict = {'fqdn': 135} - def caseDescription(self): - ''' - limit and offset keyword function test cases; - case1: limit offset base function test - case2: offset return valid - ''' - return - # init def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -47,11 +39,12 @@ class TDTestCase: self.ts = 1500000000000 - # run case + # run case def run(self): # insert data - self.insert_data1("t1", self.ts, 1000*10000) - self.insert_data1("t4", self.ts, 1000*10000) + dbname = "db" + self.insert_data1(f"{dbname}.t1", self.ts, 1000*10000) + self.insert_data1(f"{dbname}.t4", self.ts, 1000*10000) # test base case # self.test_case1() tdLog.debug(" LIMIT test_case1 ............ [OK]") @@ -60,7 +53,7 @@ class TDTestCase: tdLog.debug(" LIMIT test_case2 ............ [OK]") - # stop + # stop def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) @@ -70,16 +63,16 @@ class TDTestCase: # # create table - def create_tables(self): + def create_tables(self, dbname="db"): # super table - tdSql.execute("create table st(ts timestamp, i1 int,i2 int) tags(area int)"); + tdSql.execute(f"create table {dbname}.st(ts timestamp, i1 int,i2 int) tags(area int)") # child table - tdSql.execute("create table t1 using st tags(1)"); + tdSql.execute(f"create table {dbname}.t1 using {dbname}.st tags(1)") - tdSql.execute("create table st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) "); - tdSql.execute("create table t4 using st1 tags(1)"); + tdSql.execute(f"create table {dbname}.st1(ts timestamp, i1 int ,i2 int) tags(area int) sma(i2) ") + tdSql.execute(f"create table {dbname}.t4 using {dbname}.st1 tags(1)") - return + return # insert data1 def insert_data(self, tbname, ts_start, count): @@ -91,7 +84,7 @@ class TDTestCase: if i >0 and i%30000 == 0: tdSql.execute(sql) sql = pre_insert - # end sql + # end sql if sql != pre_insert: tdSql.execute(sql) @@ -107,16 +100,16 @@ class TDTestCase: if i >0 and i%30000 == 0: tdSql.execute(sql) sql = pre_insert - # end sql + # end sql if sql != pre_insert: tdSql.execute(sql) tdLog.debug("INSERT TABLE DATA ............ [OK]") return - # test case1 base + # test case1 base # def test_case1(self): - # # + # # # # limit base function # # # # base no where diff --git a/tests/system-test/2-query/sml.py b/tests/system-test/2-query/sml.py index 5d74c568ce516b5b336f06b044513e600a0eb993..4dae2ad6c0ec289e034929e6a949eed8b665c899 100644 --- a/tests/system-test/2-query/sml.py +++ b/tests/system-test/2-query/sml.py @@ -20,7 +20,7 @@ class TDTestCase: tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - def checkFileContent(self): + def checkFileContent(self, dbname="sml_db"): buildPath = tdCom.getBuildPath() cmdStr = '%s/build/bin/sml_test'%(buildPath) tdLog.info(cmdStr) @@ -28,8 +28,8 @@ class TDTestCase: if ret != 0: tdLog.exit("sml_test failed") - tdSql.execute('use sml_db') - tdSql.query("select * from t_b7d815c9222ca64cdf2614c61de8f211") + # tdSql.execute('use sml_db') + tdSql.query(f"select * from {dbname}.t_b7d815c9222ca64cdf2614c61de8f211") tdSql.checkRows(1) tdSql.checkData(0, 0, '2016-01-01 08:00:07.000') @@ -44,35 +44,35 @@ class TDTestCase: tdSql.checkData(0, 9, 0) tdSql.checkData(0, 10, 25) - tdSql.query("select * from readings") + tdSql.query(f"select * from {dbname}.readings") tdSql.checkRows(9) - tdSql.query("select distinct tbname from readings") + tdSql.query(f"select distinct tbname from {dbname}.readings") tdSql.checkRows(4) - tdSql.query("select * from t_0799064f5487946e5d22164a822acfc8 order by _ts") + tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts") tdSql.checkRows(2) tdSql.checkData(0, 3, "kk") - tdSql.checkData(1, 3, None) + tdSql.checkData(1, 3, "") - tdSql.query("select distinct tbname from `sys.if.bytes.out`") + tdSql.query(f"select distinct tbname from {dbname}.`sys.if.bytes.out`") tdSql.checkRows(2) - tdSql.query("select * from t_fc70dec6677d4277c5d9799c4da806da order by _ts") + tdSql.query(f"select * from {dbname}.t_fc70dec6677d4277c5d9799c4da806da order by _ts") tdSql.checkRows(2) tdSql.checkData(0, 1, 1.300000000) tdSql.checkData(1, 1,13.000000000) - tdSql.query("select * from `sys.procs.running`") + tdSql.query(f"select * from {dbname}.`sys.procs.running`") tdSql.checkRows(1) tdSql.checkData(0, 1, 42.000000000) tdSql.checkData(0, 2, "web01") - tdSql.query("select distinct tbname from `sys.cpu.nice`") + tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`") tdSql.checkRows(2) - tdSql.query("select * from `sys.cpu.nice` order by _ts") + tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts") tdSql.checkRows(2) tdSql.checkData(0, 1, 9.000000000) tdSql.checkData(0, 2, "lga") @@ -83,10 +83,10 @@ class TDTestCase: tdSql.checkData(1, 3, "web01") tdSql.checkData(1, 4, "t1") - tdSql.query("select * from macylr") + tdSql.query(f"select * from {dbname}.macylr") tdSql.checkRows(2) - tdSql.query("desc macylr") + tdSql.query(f"desc {dbname}.macylr") tdSql.checkRows(25) return diff --git a/tests/system-test/2-query/spread.py b/tests/system-test/2-query/spread.py index 51c569e56567fc7fdf1e2399008eaca5acc4059d..ffe86ff36304224e2d5f776f5088a16b445a5231 100644 --- a/tests/system-test/2-query/spread.py +++ b/tests/system-test/2-query/spread.py @@ -26,6 +26,8 @@ TS_TYPE_COL = [ TS_COL, ] ALL_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BOOL_COL, BINARY_COL, NCHAR_COL, TS_COL ] +DBNAME = "db" + class TDTestCase: def init(self, conn, logSql): @@ -88,6 +90,7 @@ class TDTestCase: return join_condition def __where_condition(self, col=None, tbname=None, query_conditon=None): + # tbname = tbname.split(".")[-1] if tbname else None if query_conditon and isinstance(query_conditon, str): if query_conditon.startswith("count"): query_conditon = query_conditon[6:-1] @@ -129,32 +132,33 @@ class TDTestCase: return f"select spread({select_clause}) from {from_clause} {where_condition} {group_condition}" @property - def __tb_list(self): + def __tb_list(self, dbname=DBNAME): return [ - "ct1", - "ct4", - "t1", - "ct2", - "stb1", + f"{dbname}.ct1", + f"{dbname}.ct4", + f"{dbname}.t1", + f"{dbname}.ct2", + f"{dbname}.stb1", ] def sql_list(self): sqls = [] __no_join_tblist = self.__tb_list for tb in __no_join_tblist: - select_claus_list = self.__query_condition(tb) - for select_claus in select_claus_list: - group_claus = self.__group_condition(col=select_claus) - where_claus = self.__where_condition(query_conditon=select_claus) - having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null") - sqls.extend( - ( - self.__single_sql(select_claus, tb, where_claus, having_claus), - self.__single_sql(select_claus, tb,), - self.__single_sql(select_claus, tb, where_condition=where_claus), - self.__single_sql(select_claus, tb, group_condition=group_claus), - ) + tbname = tb.split(".")[-1] + select_claus_list = self.__query_condition(tbname) + for select_claus in select_claus_list: + group_claus = self.__group_condition(col=select_claus) + where_claus = self.__where_condition(query_conditon=select_claus) + having_claus = self.__group_condition(col=select_claus, having=f"{select_claus} is not null") + sqls.extend( + ( + self.__single_sql(select_claus, tb, where_claus, having_claus), + self.__single_sql(select_claus, tb,), + self.__single_sql(select_claus, tb, where_condition=where_claus), + self.__single_sql(select_claus, tb, group_condition=group_claus), ) + ) # return filter(None, sqls) return list(filter(None, sqls)) @@ -166,28 +170,28 @@ class TDTestCase: tdLog.info(f"sql: {sqls[i]}") tdSql.query(sqls[i]) - def __test_current(self): - tdSql.query("select spread(ts) from ct1") + def __test_current(self, dbname=DBNAME): + tdSql.query(f"select spread(ts) from {dbname}.ct1") tdSql.checkRows(1) - tdSql.query("select spread(c1) from ct2") + tdSql.query(f"select spread(c1) from {dbname}.ct2") tdSql.checkRows(1) - tdSql.query("select spread(c1) from ct4 group by c1") + tdSql.query(f"select spread(c1) from {dbname}.ct4 group by c1") tdSql.checkRows(self.rows + 3) - tdSql.query("select spread(c1) from ct4 group by c7") + tdSql.query(f"select spread(c1) from {dbname}.ct4 group by c7") tdSql.checkRows(3) - tdSql.query("select spread(ct2.c1) from ct4 join ct2 on ct4.ts=ct2.ts") + tdSql.query(f"select spread(ct2.c1) from {dbname}.ct4 ct4 join {dbname}.ct2 ct2 on ct4.ts=ct2.ts") tdSql.checkRows(1) self.spread_check() - def __test_error(self): + def __test_error(self, dbname=DBNAME): tdLog.printNoPrefix("===step 0: err case, must return err") - tdSql.error( "select spread() from ct1" ) - tdSql.error( "select spread(1, 2) from ct2" ) - tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from ct4" ) - tdSql.error( f"select spread({BOOLEAN_COL[0]}) from t1" ) - tdSql.error( f"select spread({CHAR_COL[0]}) from stb1" ) + tdSql.error( f"select spread() from {dbname}.ct1" ) + tdSql.error( f"select spread(1, 2) from {dbname}.ct2" ) + tdSql.error( f"select spread({NUM_COL[0]}, {NUM_COL[1]}) from {dbname}.ct4" ) + tdSql.error( f"select spread({BOOLEAN_COL[0]}) from {dbname}.t1" ) + tdSql.error( f"select spread({CHAR_COL[0]}) from {dbname}.stb1" ) # tdSql.error( ''' select spread(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']) # from ct1 @@ -196,20 +200,20 @@ class TDTestCase: # having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null ''' ) # tdSql.error( "select c1 from ct1 union select c1 from ct2 union select c1 from ct4 ") - def all_test(self): - self.__test_error() - self.__test_current() + def all_test(self, dbname=DBNAME): + self.__test_error(dbname) + self.__test_current(dbname) - def __create_tb(self): + def __create_tb(self, dbname=DBNAME): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (t1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -219,30 +223,30 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} - def __insert_data(self, rows): + def __insert_data(self, rows, dbname=DBNAME): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -258,7 +262,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -274,13 +278,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) diff --git a/tests/system-test/2-query/sqrt.py b/tests/system-test/2-query/sqrt.py index 425d59f1186615467f4aac8a085949029422b760..9597375885cf5fdedf1d52a547d7558430cb46e4 100644 --- a/tests/system-test/2-query/sqrt.py +++ b/tests/system-test/2-query/sqrt.py @@ -9,48 +9,46 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} + def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - def prepare_datas(self): + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -85,84 +83,74 @@ class TDTestCase: row_check.append(elem) auto_result.append(row_check) - check_status = True - + tdSql.query(pow_query) for row_index , row in enumerate(pow_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("sqrt function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("sqrt value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def test_errors(self): + tdSql.checkData(row_index ,col_index ,auto_result[row_index][col_index]) + + + def test_errors(self, dbname="db"): error_sql_lists = [ - "select sqrt from t1", - # "select sqrt(-+--+c1 ) from t1", - # "select +-sqrt(c1) from t1", - # "select ++-sqrt(c1) from t1", - # "select ++--sqrt(c1) from t1", - # "select - -sqrt(c1)*0 from t1", - # "select sqrt(tbname+1) from t1 ", - "select sqrt(123--123)==1 from t1", - "select sqrt(c1) as 'd1' from t1", - "select sqrt(c1 ,c2) from t1", - "select sqrt(c1 ,NULL ) from t1", - "select sqrt(,) from t1;", - "select sqrt(sqrt(c1) ab from t1)", - "select sqrt(c1 ) as int from t1", - "select sqrt from stb1", - # "select sqrt(-+--+c1) from stb1", - # "select +-sqrt(c1) from stb1", - # "select ++-sqrt(c1) from stb1", - # "select ++--sqrt(c1) from stb1", - # "select - -sqrt(c1)*0 from stb1", - # "select sqrt(tbname+1) from stb1 ", - "select sqrt(123--123)==1 from stb1", - "select sqrt(c1) as 'd1' from stb1", - "select sqrt(c1 ,c2 ) from stb1", - "select sqrt(c1 ,NULL) from stb1", - "select sqrt(,) from stb1;", - "select sqrt(sqrt(c1) ab from stb1)", - "select sqrt(c1) as int from stb1" + f"select sqrt from {dbname}.t1", + # f"select sqrt(-+--+c1 ) from {dbname}.t1", + # f"select +-sqrt(c1) from {dbname}.t1", + # f"select ++-sqrt(c1) from {dbname}.t1", + # f"select ++--sqrt(c1) from {dbname}.t1", + # f"select - -sqrt(c1)*0 from {dbname}.t1", + # f"select sqrt(tbname+1) from {dbname}.t1 ", + f"select sqrt(123--123)==1 from {dbname}.t1", + f"select sqrt(c1) as 'd1' from {dbname}.t1", + f"select sqrt(c1 ,c2) from {dbname}.t1", + f"select sqrt(c1 ,NULL ) from {dbname}.t1", + f"select sqrt(,) from {dbname}.t1;", + f"select sqrt(sqrt(c1) ab from {dbname}.t1)", + f"select sqrt(c1 ) as int from {dbname}.t1", + f"select sqrt from {dbname}.stb1", + # f"select sqrt(-+--+c1) from {dbname}.stb1", + # f"select +-sqrt(c1) from {dbname}.stb1", + # f"select ++-sqrt(c1) from {dbname}.stb1", + # f"select ++--sqrt(c1) from {dbname}.stb1", + # f"select - -sqrt(c1)*0 from {dbname}.stb1", + # f"select sqrt(tbname+1) from {dbname}.stb1 ", + f"select sqrt(123--123)==1 from {dbname}.stb1", + f"select sqrt(c1) as 'd1' from {dbname}.stb1", + f"select sqrt(c1 ,c2 ) from {dbname}.stb1", + f"select sqrt(c1 ,NULL) from {dbname}.stb1", + f"select sqrt(,) from {dbname}.stb1;", + f"select sqrt(sqrt(c1) ab from {dbname}.stb1)", + f"select sqrt(c1) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - def support_types(self): + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select sqrt(ts) from t1" , - "select sqrt(c7) from t1", - "select sqrt(c8) from t1", - "select sqrt(c9) from t1", - "select sqrt(ts) from ct1" , - "select sqrt(c7) from ct1", - "select sqrt(c8) from ct1", - "select sqrt(c9) from ct1", - "select sqrt(ts) from ct3" , - "select sqrt(c7) from ct3", - "select sqrt(c8) from ct3", - "select sqrt(c9) from ct3", - "select sqrt(ts) from ct4" , - "select sqrt(c7) from ct4", - "select sqrt(c8) from ct4", - "select sqrt(c9) from ct4", - "select sqrt(ts) from stb1" , - "select sqrt(c7) from stb1", - "select sqrt(c8) from stb1", - "select sqrt(c9) from stb1" , - - "select sqrt(ts) from stbbb1" , - "select sqrt(c7) from stbbb1", - - "select sqrt(ts) from tbname", - "select sqrt(c9) from tbname" + f"select sqrt(ts) from {dbname}.t1" , + f"select sqrt(c7) from {dbname}.t1", + f"select sqrt(c8) from {dbname}.t1", + f"select sqrt(c9) from {dbname}.t1", + f"select sqrt(ts) from {dbname}.ct1" , + f"select sqrt(c7) from {dbname}.ct1", + f"select sqrt(c8) from {dbname}.ct1", + f"select sqrt(c9) from {dbname}.ct1", + f"select sqrt(ts) from {dbname}.ct3" , + f"select sqrt(c7) from {dbname}.ct3", + f"select sqrt(c8) from {dbname}.ct3", + f"select sqrt(c9) from {dbname}.ct3", + f"select sqrt(ts) from {dbname}.ct4" , + f"select sqrt(c7) from {dbname}.ct4", + f"select sqrt(c8) from {dbname}.ct4", + f"select sqrt(c9) from {dbname}.ct4", + f"select sqrt(ts) from {dbname}.stb1" , + f"select sqrt(c7) from {dbname}.stb1", + f"select sqrt(c8) from {dbname}.stb1", + f"select sqrt(c9) from {dbname}.stb1" , + + f"select sqrt(ts) from {dbname}.stbbb1" , + f"select sqrt(c7) from {dbname}.stbbb1", + + f"select sqrt(ts) from {dbname}.tbname", + f"select sqrt(c9) from {dbname}.tbname" ] @@ -171,103 +159,103 @@ class TDTestCase: type_sql_lists = [ - "select sqrt(c1) from t1", - "select sqrt(c2) from t1", - "select sqrt(c3) from t1", - "select sqrt(c4) from t1", - "select sqrt(c5) from t1", - "select sqrt(c6) from t1", - - "select sqrt(c1) from ct1", - "select sqrt(c2) from ct1", - "select sqrt(c3) from ct1", - "select sqrt(c4) from ct1", - "select sqrt(c5) from ct1", - "select sqrt(c6) from ct1", - - "select sqrt(c1) from ct3", - "select sqrt(c2) from ct3", - "select sqrt(c3) from ct3", - "select sqrt(c4) from ct3", - "select sqrt(c5) from ct3", - "select sqrt(c6) from ct3", - - "select sqrt(c1) from stb1", - "select sqrt(c2) from stb1", - "select sqrt(c3) from stb1", - "select sqrt(c4) from stb1", - "select sqrt(c5) from stb1", - "select sqrt(c6) from stb1", - - "select sqrt(c6) as alisb from stb1", - "select sqrt(c6) alisb from stb1", + f"select sqrt(c1) from {dbname}.t1", + f"select sqrt(c2) from {dbname}.t1", + f"select sqrt(c3) from {dbname}.t1", + f"select sqrt(c4) from {dbname}.t1", + f"select sqrt(c5) from {dbname}.t1", + f"select sqrt(c6) from {dbname}.t1", + + f"select sqrt(c1) from {dbname}.ct1", + f"select sqrt(c2) from {dbname}.ct1", + f"select sqrt(c3) from {dbname}.ct1", + f"select sqrt(c4) from {dbname}.ct1", + f"select sqrt(c5) from {dbname}.ct1", + f"select sqrt(c6) from {dbname}.ct1", + + f"select sqrt(c1) from {dbname}.ct3", + f"select sqrt(c2) from {dbname}.ct3", + f"select sqrt(c3) from {dbname}.ct3", + f"select sqrt(c4) from {dbname}.ct3", + f"select sqrt(c5) from {dbname}.ct3", + f"select sqrt(c6) from {dbname}.ct3", + + f"select sqrt(c1) from {dbname}.stb1", + f"select sqrt(c2) from {dbname}.stb1", + f"select sqrt(c3) from {dbname}.stb1", + f"select sqrt(c4) from {dbname}.stb1", + f"select sqrt(c5) from {dbname}.stb1", + f"select sqrt(c6) from {dbname}.stb1", + + f"select sqrt(c6) as alisb from {dbname}.stb1", + f"select sqrt(c6) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - def basic_sqrt_function(self): + def basic_sqrt_function(self, dbname="db"): # basic query - tdSql.query("select c1 from ct3") + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select sqrt(c1) from ct3") + tdSql.query(f"select sqrt(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sqrt(c2) from ct3") + tdSql.query(f"select sqrt(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sqrt(c3) from ct3") + tdSql.query(f"select sqrt(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sqrt(c4) from ct3") + tdSql.query(f"select sqrt(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sqrt(c5) from ct3") + tdSql.query(f"select sqrt(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select sqrt(c6) from ct3") + tdSql.query(f"select sqrt(c6) from {dbname}.ct3") tdSql.checkRows(0) # # used for regular table - tdSql.query("select sqrt(c1) from t1") + tdSql.query(f"select sqrt(c1) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 1.000000000) tdSql.checkData(3 , 0, 1.732050808) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto_sqrt( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select sqrt(abs(c1)), sqrt(abs(c2)) ,sqrt(abs(c3)), sqrt(abs(c4)), sqrt(abs(c5)) from t1") + self.check_result_auto_sqrt( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select sqrt(abs(c1)), sqrt(abs(c2)) ,sqrt(abs(c3)), sqrt(abs(c4)), sqrt(abs(c5)) from {dbname}.t1") # used for sub table - tdSql.query("select c2 ,sqrt(c2) from ct1") + tdSql.query(f"select c2 ,sqrt(c2) from {dbname}.ct1") tdSql.checkData(0, 1, 298.140906284) tdSql.checkData(1 , 1, 278.885281074) tdSql.checkData(3 , 1, 235.701081881) tdSql.checkData(4 , 1, 0.000000000) - tdSql.query("select c1, c5 ,sqrt(c5) from ct4") + tdSql.query(f"select c1, c5 ,sqrt(c5) from {dbname}.ct4") tdSql.checkData(0 , 2, None) tdSql.checkData(1 , 2, 2.979932904) tdSql.checkData(2 , 2, 2.787471970) tdSql.checkData(3 , 2, 2.580697551) tdSql.checkData(5 , 2, None) - self.check_result_auto_sqrt( "select c1, c2, c3 , c4, c5 from ct1", "select sqrt(c1), sqrt(c2) ,sqrt(c3), sqrt(c4), sqrt(c5) from ct1") + self.check_result_auto_sqrt( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select sqrt(c1), sqrt(c2) ,sqrt(c3), sqrt(c4), sqrt(c5) from {dbname}.ct1") # nest query for sqrt functions - tdSql.query("select c4 , sqrt(c4) ,sqrt(sqrt(c4)) , sqrt(sqrt(sqrt(c4))) from ct1;") + tdSql.query(f"select c4 , sqrt(c4) ,sqrt(sqrt(c4)) , sqrt(sqrt(sqrt(c4))) from {dbname}.ct1;") tdSql.checkData(0 , 0 , 88) tdSql.checkData(0 , 1 , 9.380831520) tdSql.checkData(0 , 2 , 3.062814314) @@ -285,22 +273,22 @@ class TDTestCase: # used for stable table - tdSql.query("select sqrt(c1) from stb1") + tdSql.query(f"select sqrt(c1) from {dbname}.stb1") tdSql.checkRows(25) # used for not exists table - tdSql.error("select sqrt(c1) from stbbb1") - tdSql.error("select sqrt(c1) from tbname") - tdSql.error("select sqrt(c1) from ct5") + tdSql.error(f"select sqrt(c1) from {dbname}.stbbb1") + tdSql.error(f"select sqrt(c1) from {dbname}.tbname") + tdSql.error(f"select sqrt(c1) from {dbname}.ct5") # mix with common col - tdSql.query("select c1, sqrt(c1) from ct1") + tdSql.query(f"select c1, sqrt(c1) from {dbname}.ct1") tdSql.checkData(0 , 0 ,8) tdSql.checkData(0 , 1 ,2.828427125) tdSql.checkData(4 , 0 ,0) tdSql.checkData(4 , 1 ,0.000000000) - tdSql.query("select c2, sqrt(c2) from ct4") + tdSql.query(f"select c2, sqrt(c2) from {dbname}.ct4") tdSql.checkData(0 , 0 , None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(4 , 0 ,55555) @@ -309,7 +297,7 @@ class TDTestCase: tdSql.checkData(5 , 1 ,None) # mix with common functions - tdSql.query("select c1, sqrt(c1),sqrt(c1), sqrt(sqrt(c1)) from ct4 ") + tdSql.query(f"select c1, sqrt(c1),sqrt(c1), sqrt(sqrt(c1)) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) @@ -320,34 +308,34 @@ class TDTestCase: tdSql.checkData(3 , 2 ,2.449489743) tdSql.checkData(3 , 3 ,1.565084580) - tdSql.query("select c1, sqrt(c1),c5, floor(c5) from stb1 ") + tdSql.query(f"select c1, sqrt(c1),c5, floor(c5) from {dbname}.stb1 ") # # mix with agg functions , not support - tdSql.error("select c1, sqrt(c1),c5, count(c5) from stb1 ") - tdSql.error("select c1, sqrt(c1),c5, count(c5) from ct1 ") - tdSql.error("select sqrt(c1), count(c5) from stb1 ") - tdSql.error("select sqrt(c1), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, sqrt(c1),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, sqrt(c1),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select sqrt(c1), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select sqrt(c1), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") # bug fix for count - tdSql.query("select count(c1) from ct4 ") + tdSql.query(f"select count(c1) from {dbname}.ct4 ") tdSql.checkData(0,0,9) - tdSql.query("select count(*) from ct4 ") + tdSql.query(f"select count(*) from {dbname}.ct4 ") tdSql.checkData(0,0,12) - tdSql.query("select count(c1) from stb1 ") + tdSql.query(f"select count(c1) from {dbname}.stb1 ") tdSql.checkData(0,0,22) - tdSql.query("select count(*) from stb1 ") + tdSql.query(f"select count(*) from {dbname}.stb1 ") tdSql.checkData(0,0,25) # # bug fix for compute - tdSql.query("select c1, sqrt(c1) -0 ,sqrt(c1-4)-0 from ct4 ") + tdSql.query(f"select c1, sqrt(c1) -0 ,sqrt(c1-4)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -355,7 +343,7 @@ class TDTestCase: tdSql.checkData(1, 1, 2.828427125) tdSql.checkData(1, 2, 2.000000000) - tdSql.query(" select c1, sqrt(c1) -0 ,sqrt(c1-0.1)-0.1 from ct4") + tdSql.query(f"select c1, sqrt(c1) -0 ,sqrt(c1-0.1)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -363,57 +351,56 @@ class TDTestCase: tdSql.checkData(1, 1, 2.828427125) tdSql.checkData(1, 2, 2.710693865) - tdSql.query("select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ct1") + tdSql.query(f"select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from {dbname}.ct1") - def test_big_number(self): + def test_big_number(self, dbname="db"): - tdSql.query("select c1, sqrt(100000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(100000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, 10000.000000000) - tdSql.query("select c1, sqrt(10000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(10000000000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, 3162277.660168380) - tdSql.query("select c1, sqrt(c1) + sqrt(10000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sqrt(c1) + sqrt(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sqrt(c1) + sqrt(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(c1) + sqrt(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(1, 1, 3162277660171.025390625) - tdSql.query("select c1, sqrt(10000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sqrt(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sqrt(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, 100000000000000000.000000000) - tdSql.query("select c1, sqrt(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, sqrt(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, sqrt(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, 100000000000000000000.000000000) - tdSql.query("select c1, sqrt(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, sqrt(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow - def pow_base_test(self): + def pow_base_test(self, dbname="db"): # base is an regular number ,int or double - tdSql.query("select c1, sqrt(c1) from ct1") + tdSql.query(f"select c1, sqrt(c1) from {dbname}.ct1") tdSql.checkData(0, 1,2.828427125) tdSql.checkRows(13) # # bug for compute in functions - # tdSql.query("select c1, abs(1/0) from ct1") + # tdSql.query(f"select c1, abs(1/0) from {dbname}.ct1") # tdSql.checkData(0, 0, 8) # tdSql.checkData(0, 1, 1) - tdSql.query("select c1, sqrt(1) from ct1") + tdSql.query(f"select c1, sqrt(1) from {dbname}.ct1") tdSql.checkData(0, 1, 1.000000000) tdSql.checkRows(13) # two cols start sqrt(x,y) - tdSql.query("select c1,c2, sqrt(c2) from ct1") + tdSql.query(f"select c1,c2, sqrt(c2) from {dbname}.ct1") tdSql.checkData(0, 2, 298.140906284) tdSql.checkData(1, 2, 278.885281074) tdSql.checkData(4, 2, 0.000000000) - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -421,7 +408,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,3.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -429,7 +416,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,2.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -437,7 +424,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,2.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from ct4 where c1=sqrt(c1) limit 1 ") + tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sqrt(c1)-0.5) from {dbname}.ct4 where c1=sqrt(c1) limit 1 ") tdSql.checkRows(1) tdSql.checkData(0,0,1) tdSql.checkData(0,1,11111) @@ -446,42 +433,37 @@ class TDTestCase: tdSql.checkData(0,4,0.900000000) tdSql.checkData(0,5,1.000000000) - def pow_Arithmetic(self): - pass - - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - time.sleep(3) - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto_sqrt( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select sqrt(abs(c1)), sqrt(abs(c2)) ,sqrt(abs(c3)), sqrt(abs(c4)), sqrt(abs(c5)) from sub1_bound") + self.check_result_auto_sqrt( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select sqrt(abs(c1)), sqrt(abs(c2)) ,sqrt(abs(c3)), sqrt(abs(c4)), sqrt(abs(c5)) from {dbname}.sub1_bound") - self.check_result_auto_sqrt( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select sqrt(c1), sqrt(c2) ,sqrt(c3), sqrt(c3), sqrt(c2) ,sqrt(c1) from sub1_bound") + self.check_result_auto_sqrt( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select sqrt(c1), sqrt(c2) ,sqrt(c3), sqrt(c3), sqrt(c2) ,sqrt(c1) from {dbname}.sub1_bound") - self.check_result_auto_sqrt("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select sqrt(abs(c1)) from sub1_bound" ) + self.check_result_auto_sqrt(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select sqrt(abs(c1)) from {dbname}.sub1_bound" ) # check basic elem for table per row - tdSql.query("select sqrt(abs(c1)) ,sqrt(abs(c2)) , sqrt(abs(c3)) , sqrt(abs(c4)), sqrt(abs(c5)), sqrt(abs(c6)) from sub1_bound ") + tdSql.query(f"select sqrt(abs(c1)) ,sqrt(abs(c2)) , sqrt(abs(c3)) , sqrt(abs(c4)), sqrt(abs(c5)), sqrt(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.sqrt(2147483647)) tdSql.checkData(0,1,math.sqrt(9223372036854775807)) tdSql.checkData(0,2,math.sqrt(32767)) @@ -499,23 +481,22 @@ class TDTestCase: tdSql.checkData(3,4,math.sqrt(339999995214436424907732413799364296704.00000)) # check + - * / in functions - tdSql.query("select sqrt(abs(c1+1)) ,sqrt(abs(c2)) , sqrt(abs(c3*1)) , sqrt(abs(c4/2)), sqrt(abs(c5))/2, sqrt(abs(c6)) from sub1_bound ") + tdSql.query(f"select sqrt(abs(c1+1)) ,sqrt(abs(c2)) , sqrt(abs(c3*1)) , sqrt(abs(c4/2)), sqrt(abs(c5))/2, sqrt(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.sqrt(2147483648.000000000)) tdSql.checkData(0,1,math.sqrt(9223372036854775807)) tdSql.checkData(0,2,math.sqrt(32767.000000000)) tdSql.checkData(0,3,math.sqrt(63.500000000)) - def support_super_table_test(self): - tdSql.execute(" use db ") - self.check_result_auto_sqrt( " select c5 from stb1 order by ts " , "select sqrt(c5) from stb1 order by ts" ) - self.check_result_auto_sqrt( " select c5 from stb1 order by tbname " , "select sqrt(c5) from stb1 order by tbname" ) - self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) - - self.check_result_auto_sqrt( " select t1,c5 from stb1 order by ts " , "select sqrt(t1), sqrt(c5) from stb1 order by ts" ) - self.check_result_auto_sqrt( " select t1,c5 from stb1 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 order by tbname" ) - self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) , sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + def support_super_table_test(self, dbname="db"): + self.check_result_auto_sqrt( f"select c5 from {dbname}.stb1 order by ts " , f"select sqrt(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_sqrt( f"select c5 from {dbname}.stb1 order by tbname " , f"select sqrt(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_sqrt( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sqrt(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sqrt(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sqrt( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select sqrt(t1), sqrt(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_sqrt( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select sqrt(t1) ,sqrt(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_sqrt( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sqrt(t1) ,sqrt(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select sqrt(t1) , sqrt(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring diff --git a/tests/system-test/2-query/statecount.py b/tests/system-test/2-query/statecount.py index a88c4aef9fdad7580d4d10a642093c80750b1c57..c73c955de405ee54e6924c25cd219aa8b8a7f4eb 100644 --- a/tests/system-test/2-query/statecount.py +++ b/tests/system-test/2-query/statecount.py @@ -11,50 +11,47 @@ from util.sql import * from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record - def prepare_datas(self): + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -70,68 +67,68 @@ class TDTestCase: ''' ) - def test_errors(self): + def test_errors(self, dbname="db"): error_sql_lists = [ - # "select statecount(c1,'GT',5) from t1" - "select statecount from t1", - "select statecount(123--123)==1 from t1", - "select statecount(123,123) from t1", - "select statecount(c1,ts) from t1", - "select statecount(c1,c1,ts) from t1", - "select statecount(c1 ,c2 ) from t1", - "select statecount(c1 ,NULL) from t1", - #"select statecount(c1 ,'NULL',1.0) from t1", - "select statecount(c1 ,'GT','1') from t1", - "select statecount(c1 ,'GT','tbname') from t1", - "select statecount(c1 ,'GT','*') from t1", - "select statecount(c1 ,'GT',ts) from t1", - "select statecount(c1 ,'GT',max(c1)) from t1", - # "select statecount(abs(c1) ,'GT',1) from t1", - # "select statecount(c1+2 ,'GT',1) from t1", - "select statecount(c1 ,'GT',1,1u) from t1", - "select statecount(c1 ,'GT',1,now) from t1", - "select statecount(c1 ,'GT','1') from t1", - "select statecount(c1 ,'GT','1',True) from t1", - "select statecount(statecount(c1) ab from t1)", - "select statecount(c1 ,'GT',1,,)int from t1", - "select statecount('c1','GT',1) from t1", - "select statecount('c1','GT' , NULL) from t1", - "select statecount('c1','GT', 1 , '') from t1", - "select statecount('c1','GT', 1 ,c%) from t1", - "select statecount(c1 ,'GT',1,t1) from t1", - "select statecount(c1 ,'GT',1,True) from t1", - "select statecount(c1 ,'GT',1) , count(c1) from t1", - "select statecount(c1 ,'GT',1) , avg(c1) from t1", - "select statecount(c1 ,'GT',1) , min(c1) from t1", - "select statecount(c1 ,'GT',1) , spread(c1) from t1", - "select statecount(c1 ,'GT',1) , diff(c1) from t1", + # f"select statecount(c1,'GT',5) from {dbname}.t1" + f"select statecount from {dbname}.t1", + f"select statecount(123--123)==1 from {dbname}.t1", + f"select statecount(123,123) from {dbname}.t1", + f"select statecount(c1,ts) from {dbname}.t1", + f"select statecount(c1,c1,ts) from {dbname}.t1", + f"select statecount(c1 ,c2 ) from {dbname}.t1", + f"select statecount(c1 ,NULL) from {dbname}.t1", + #f"select statecount(c1 ,'NULL',1.0) from {dbname}.t1", + f"select statecount(c1 ,'GT','1') from {dbname}.t1", + f"select statecount(c1 ,'GT','tbname') from {dbname}.t1", + f"select statecount(c1 ,'GT','*') from {dbname}.t1", + f"select statecount(c1 ,'GT',ts) from {dbname}.t1", + f"select statecount(c1 ,'GT',max(c1)) from {dbname}.t1", + # f"select statecount(abs(c1) ,'GT',1) from {dbname}.t1", + # f"select statecount(c1+2 ,'GT',1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1,1u) from {dbname}.t1", + f"select statecount(c1 ,'GT',1,now) from {dbname}.t1", + f"select statecount(c1 ,'GT','1') from {dbname}.t1", + f"select statecount(c1 ,'GT','1',True) from {dbname}.t1", + f"select statecount(statecount(c1) ab from {dbname}.t1)", + f"select statecount(c1 ,'GT',1,,)int from {dbname}.t1", + f"select statecount('c1','GT',1) from {dbname}.t1", + f"select statecount('c1','GT' , NULL) from {dbname}.t1", + f"select statecount('c1','GT', 1 , '') from {dbname}.t1", + f"select statecount('c1','GT', 1 ,c%) from {dbname}.t1", + f"select statecount(c1 ,'GT',1,t1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1,True) from {dbname}.t1", + f"select statecount(c1 ,'GT',1) , count(c1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1) , avg(c1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1) , min(c1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1) , spread(c1) from {dbname}.t1", + f"select statecount(c1 ,'GT',1) , diff(c1) from {dbname}.t1", ] for error_sql in error_sql_lists: tdSql.error(error_sql) pass - def support_types(self): + def support_types(self, dbname="db"): other_no_value_types = [ - "select statecount(ts,'GT',1) from t1" , - "select statecount(c7,'GT',1) from t1", - "select statecount(c8,'GT',1) from t1", - "select statecount(c9,'GT',1) from t1", - "select statecount(ts,'GT',1) from ct1" , - "select statecount(c7,'GT',1) from ct1", - "select statecount(c8,'GT',1) from ct1", - "select statecount(c9,'GT',1) from ct1", - "select statecount(ts,'GT',1) from ct3" , - "select statecount(c7,'GT',1) from ct3", - "select statecount(c8,'GT',1) from ct3", - "select statecount(c9,'GT',1) from ct3", - "select statecount(ts,'GT',1) from ct4" , - "select statecount(c7,'GT',1) from ct4", - "select statecount(c8,'GT',1) from ct4", - "select statecount(c9,'GT',1) from ct4", - "select statecount(ts,'GT',1) from stb1 partition by tbname" , - "select statecount(c7,'GT',1) from stb1 partition by tbname", - "select statecount(c8,'GT',1) from stb1 partition by tbname", - "select statecount(c9,'GT',1) from stb1 partition by tbname" + f"select statecount(ts,'GT',1) from {dbname}.t1" , + f"select statecount(c7,'GT',1) from {dbname}.t1", + f"select statecount(c8,'GT',1) from {dbname}.t1", + f"select statecount(c9,'GT',1) from {dbname}.t1", + f"select statecount(ts,'GT',1) from {dbname}.ct1" , + f"select statecount(c7,'GT',1) from {dbname}.ct1", + f"select statecount(c8,'GT',1) from {dbname}.ct1", + f"select statecount(c9,'GT',1) from {dbname}.ct1", + f"select statecount(ts,'GT',1) from {dbname}.ct3" , + f"select statecount(c7,'GT',1) from {dbname}.ct3", + f"select statecount(c8,'GT',1) from {dbname}.ct3", + f"select statecount(c9,'GT',1) from {dbname}.ct3", + f"select statecount(ts,'GT',1) from {dbname}.ct4" , + f"select statecount(c7,'GT',1) from {dbname}.ct4", + f"select statecount(c8,'GT',1) from {dbname}.ct4", + f"select statecount(c9,'GT',1) from {dbname}.ct4", + f"select statecount(ts,'GT',1) from {dbname}.stb1 partition by tbname" , + f"select statecount(c7,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c8,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c9,'GT',1) from {dbname}.stb1 partition by tbname" ] for type_sql in other_no_value_types: @@ -139,224 +136,222 @@ class TDTestCase: tdLog.info("support type ok , sql is : %s"%type_sql) type_sql_lists = [ - "select statecount(c1,'GT',1) from t1", - "select statecount(c2,'GT',1) from t1", - "select statecount(c3,'GT',1) from t1", - "select statecount(c4,'GT',1) from t1", - "select statecount(c5,'GT',1) from t1", - "select statecount(c6,'GT',1) from t1", - - "select statecount(c1,'GT',1) from ct1", - "select statecount(c2,'GT',1) from ct1", - "select statecount(c3,'GT',1) from ct1", - "select statecount(c4,'GT',1) from ct1", - "select statecount(c5,'GT',1) from ct1", - "select statecount(c6,'GT',1) from ct1", - - "select statecount(c1,'GT',1) from ct3", - "select statecount(c2,'GT',1) from ct3", - "select statecount(c3,'GT',1) from ct3", - "select statecount(c4,'GT',1) from ct3", - "select statecount(c5,'GT',1) from ct3", - "select statecount(c6,'GT',1) from ct3", - - "select statecount(c1,'GT',1) from stb1 partition by tbname", - "select statecount(c2,'GT',1) from stb1 partition by tbname", - "select statecount(c3,'GT',1) from stb1 partition by tbname", - "select statecount(c4,'GT',1) from stb1 partition by tbname", - "select statecount(c5,'GT',1) from stb1 partition by tbname", - "select statecount(c6,'GT',1) from stb1 partition by tbname", - - "select statecount(c6,'GT',1) as alisb from stb1 partition by tbname", - "select statecount(c6,'GT',1) alisb from stb1 partition by tbname", + f"select statecount(c1,'GT',1) from {dbname}.t1", + f"select statecount(c2,'GT',1) from {dbname}.t1", + f"select statecount(c3,'GT',1) from {dbname}.t1", + f"select statecount(c4,'GT',1) from {dbname}.t1", + f"select statecount(c5,'GT',1) from {dbname}.t1", + f"select statecount(c6,'GT',1) from {dbname}.t1", + + f"select statecount(c1,'GT',1) from {dbname}.ct1", + f"select statecount(c2,'GT',1) from {dbname}.ct1", + f"select statecount(c3,'GT',1) from {dbname}.ct1", + f"select statecount(c4,'GT',1) from {dbname}.ct1", + f"select statecount(c5,'GT',1) from {dbname}.ct1", + f"select statecount(c6,'GT',1) from {dbname}.ct1", + + f"select statecount(c1,'GT',1) from {dbname}.ct3", + f"select statecount(c2,'GT',1) from {dbname}.ct3", + f"select statecount(c3,'GT',1) from {dbname}.ct3", + f"select statecount(c4,'GT',1) from {dbname}.ct3", + f"select statecount(c5,'GT',1) from {dbname}.ct3", + f"select statecount(c6,'GT',1) from {dbname}.ct3", + + f"select statecount(c1,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c2,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c3,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c4,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c5,'GT',1) from {dbname}.stb1 partition by tbname", + f"select statecount(c6,'GT',1) from {dbname}.stb1 partition by tbname", + + f"select statecount(c6,'GT',1) as alisb from {dbname}.stb1 partition by tbname", + f"select statecount(c6,'GT',1) alisb from {dbname}.stb1 partition by tbname", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - def support_opers(self): + def support_opers(self, dbname="db"): oper_lists = ['LT','lt','Lt','lT','GT','gt','Gt','gT','LE','le','Le','lE','GE','ge','Ge','gE','NE','ne','Ne','nE','EQ','eq','Eq','eQ'] oper_errors = [",","*","NULL","tbname","ts","sum","_c0"] for oper in oper_lists: - tdSql.query(f"select statecount(c1 ,'{oper}',1) as col from t1") + tdSql.query(f"select statecount(c1 ,'{oper}',1) as col from {dbname}.t1") tdSql.checkRows(12) for oper in oper_errors: - tdSql.error(f"select statecount(c1 ,'{oper}',1) as col from t1") - + tdSql.error(f"select statecount(c1 ,'{oper}',1) as col from {dbname}.t1") - def basic_statecount_function(self): + def basic_statecount_function(self, dbname="db"): # basic query - tdSql.query("select c1 from ct3") + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select statecount(c6,'GT',1) from ct3") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct3") # will support _rowts mix with - # tdSql.query("select (c6,'GT',1),_rowts from ct3") + # tdSql.query(f"select (c6,'GT',1),_rowts from {dbname}.ct3") # auto check for t1 table # used for regular table - tdSql.query("select statecount(c6,'GT',1) from t1") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.t1") # unique with super tags - tdSql.query("select statecount(c6,'GT',1) from ct1") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select statecount(c6,'GT',1) from ct4") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct4") tdSql.checkRows(12) - tdSql.query("select statecount(c6,'GT',1),tbname from ct1") + tdSql.query(f"select statecount(c6,'GT',1),tbname from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select statecount(c6,'GT',1),t1 from ct1") + tdSql.query(f"select statecount(c6,'GT',1),t1 from {dbname}.ct1") tdSql.checkRows(13) # unique with common col - tdSql.query("select statecount(c6,'GT',1) ,ts from ct1") + tdSql.query(f"select statecount(c6,'GT',1) ,ts from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, statecount(c6,'GT',1) from ct1") + tdSql.query(f"select ts, statecount(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select statecount(c6,'GT',1) ,c1 from ct1") + tdSql.query(f"select statecount(c6,'GT',1) ,c1 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select c1, statecount(c6,'GT',1) from ct1") + tdSql.query(f"select c1, statecount(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, c1, c2, c3, statecount(c6,'GT',1) from ct1") + tdSql.query(f"select ts, c1, c2, c3, statecount(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select statecount(c6,'GT',1), ts, c1, c2, c3 from ct1") + tdSql.query(f"select statecount(c6,'GT',1), ts, c1, c2, c3 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, c1, c2, c3, statecount(c6,'GT',1), ts, c4, c5, c6 from ct1") + tdSql.query(f"select ts, c1, c2, c3, statecount(c6,'GT',1), ts, c4, c5, c6 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select stateduration(c6,'GT',1) ,ts from ct1") + tdSql.query(f"select stateduration(c6,'GT',1) ,ts from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, stateduration(c6,'GT',1) from ct1") + tdSql.query(f"select ts, stateduration(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select stateduration(c6,'GT',1) ,c1 from ct1") + tdSql.query(f"select stateduration(c6,'GT',1) ,c1 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select c1, stateduration(c6,'GT',1) from ct1") + tdSql.query(f"select c1, stateduration(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, c1, c2, c3, stateduration(c6,'GT',1) from ct1") + tdSql.query(f"select ts, c1, c2, c3, stateduration(c6,'GT',1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select stateduration(c6,'GT',1), ts, c1, c2, c3 from ct1") + tdSql.query(f"select stateduration(c6,'GT',1), ts, c1, c2, c3 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select ts, c1, c2, c3, stateduration(c6,'GT',1), ts, c4, c5, c6 from ct1") + tdSql.query(f"select ts, c1, c2, c3, stateduration(c6,'GT',1), ts, c4, c5, c6 from {dbname}.ct1") tdSql.checkRows(13) # unique with scalar function - tdSql.query("select statecount(c6,'GT',1) , abs(c1) from ct1") + tdSql.query(f"select statecount(c6,'GT',1) , abs(c1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select statecount(c6,'GT',1) , abs(c2)+2 from ct1") + tdSql.query(f"select statecount(c6,'GT',1) , abs(c2)+2 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.error("select statecount(c6,'GT',1) , unique(c2) from ct1") + tdSql.error(f"select statecount(c6,'GT',1) , unique(c2) from {dbname}.ct1") - tdSql.query("select stateduration(c6,'GT',1) , abs(c1) from ct1") + tdSql.query(f"select stateduration(c6,'GT',1) , abs(c1) from {dbname}.ct1") tdSql.checkRows(13) - tdSql.query("select stateduration(c6,'GT',1) , abs(c2)+2 from ct1") + tdSql.query(f"select stateduration(c6,'GT',1) , abs(c2)+2 from {dbname}.ct1") tdSql.checkRows(13) - tdSql.error("select stateduration(c6,'GT',1) , unique(c2) from ct1") + tdSql.error(f"select stateduration(c6,'GT',1) , unique(c2) from {dbname}.ct1") # unique with aggregate function - tdSql.error("select statecount(c6,'GT',1) ,sum(c1) from ct1") - tdSql.error("select statecount(c6,'GT',1) ,max(c1) from ct1") - tdSql.error("select statecount(c6,'GT',1) ,csum(c1) from ct1") - tdSql.error("select statecount(c6,'GT',1) ,count(c1) from ct1") + tdSql.error(f"select statecount(c6,'GT',1) ,sum(c1) from {dbname}.ct1") + tdSql.error(f"select statecount(c6,'GT',1) ,max(c1) from {dbname}.ct1") + tdSql.error(f"select statecount(c6,'GT',1) ,csum(c1) from {dbname}.ct1") + tdSql.error(f"select statecount(c6,'GT',1) ,count(c1) from {dbname}.ct1") # unique with filter where - tdSql.query("select statecount(c6,'GT',1) from ct4 where c1 is null") + tdSql.query(f"select statecount(c6,'GT',1) from {dbname}.ct4 where c1 is null") tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query("select statecount(c1,'GT',1) from t1 where c1 >2 ") + tdSql.query(f"select statecount(c1,'GT',1) from {dbname}.t1 where c1 >2 ") tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, 2) tdSql.checkData(2, 0, 3) tdSql.checkData(4, 0, 5) tdSql.checkData(5, 0, 6) - tdSql.query("select statecount(c2,'GT',1) from t1 where c2 between 0 and 99999") + tdSql.query(f"select statecount(c2,'GT',1) from {dbname}.t1 where c2 between 0 and 99999") tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, 2) tdSql.checkData(6, 0, -1) # unique with union all - tdSql.query("select statecount(c1,'GT',1) from ct4 union all select statecount(c1,'GT',1) from ct1") + tdSql.query(f"select statecount(c1,'GT',1) from {dbname}.ct4 union all select statecount(c1,'GT',1) from {dbname}.ct1") tdSql.checkRows(25) - tdSql.query("select statecount(c1,'GT',1) from ct4 union all select distinct(c1) from ct4") + tdSql.query(f"select statecount(c1,'GT',1) from {dbname}.ct4 union all select distinct(c1) from {dbname}.ct4") tdSql.checkRows(22) # unique with join # prepare join datas with same ts - tdSql.execute(" use db ") - tdSql.execute(" create stable st1 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table tb1 using st1 tags(1)") - tdSql.execute(" create table tb2 using st1 tags(2)") + tdSql.execute(f"create stable {dbname}.st1 (ts timestamp , num int) tags(ind int)") + tdSql.execute(f"create table {dbname}.tb1 using {dbname}.st1 tags(1)") + tdSql.execute(f"create table {dbname}.tb2 using {dbname}.st1 tags(2)") - tdSql.execute(" create stable st2 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table ttb1 using st2 tags(1)") - tdSql.execute(" create table ttb2 using st2 tags(2)") + tdSql.execute(f"create stable {dbname}.st2 (ts timestamp , num int) tags(ind int)") + tdSql.execute(f"create table {dbname}.ttb1 using {dbname}.st2 tags(1)") + tdSql.execute(f"create table {dbname}.ttb2 using {dbname}.st2 tags(2)") start_ts = 1622369635000 # 2021-05-30 18:13:55 for i in range(10): ts_value = start_ts+i*1000 - tdSql.execute(f" insert into tb1 values({ts_value} , {i})") - tdSql.execute(f" insert into tb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb2 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb1 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb2 values({ts_value} , {i})") - tdSql.query("select statecount(tb1.num,'GT',1) from tb1, tb2 where tb1.ts=tb2.ts ") + tdSql.query(f"select statecount(tb1.num,'GT',1) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts ") tdSql.checkRows(10) tdSql.checkData(0,0,-1) tdSql.checkData(1,0,-1) tdSql.checkData(2,0,1) tdSql.checkData(9,0,8) - tdSql.query("select statecount(tb1.num,'GT',1) from tb1, tb2 where tb1.ts=tb2.ts union all select statecount(tb2.num,'GT',1) from tb1, tb2 where tb1.ts=tb2.ts ") + tdSql.query(f"select statecount(tb1.num,'GT',1) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts union all select statecount(tb2.num,'GT',1) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts ") tdSql.checkRows(20) # nest query - # tdSql.query("select unique(c1) from (select c1 from ct1)") - tdSql.query("select c1 from (select statecount(c1,'GT',1) c1 from t1)") + # tdSql.query(f"select unique(c1) from (select c1 from {dbname}.ct1)") + tdSql.query(f"select c1 from (select statecount(c1,'GT',1) c1 from {dbname}.t1)") tdSql.checkRows(12) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, -1) tdSql.checkData(2, 0, 1) tdSql.checkData(10, 0, 8) - tdSql.query("select sum(c1) from (select statecount(c1,'GT',1) c1 from t1)") + tdSql.query(f"select sum(c1) from (select statecount(c1,'GT',1) c1 from {dbname}.t1)") tdSql.checkRows(1) tdSql.checkData(0, 0, 35) - tdSql.query("select sum(c1) from (select distinct(c1) c1 from ct1) union all select sum(c1) from (select statecount(c1,'GT',1) c1 from ct1)") + tdSql.query(f"select sum(c1) from (select distinct(c1) c1 from {dbname}.ct1) union all select sum(c1) from (select statecount(c1,'GT',1) c1 from {dbname}.ct1)") tdSql.checkRows(2) - tdSql.query("select 1-abs(c1) from (select statecount(c1,'GT',1) c1 from t1)") + tdSql.query(f"select 1-abs(c1) from (select statecount(c1,'GT',1) c1 from {dbname}.t1)") tdSql.checkRows(12) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, 0.000000000) @@ -365,43 +360,41 @@ class TDTestCase: # bug for stable #partition by tbname - # tdSql.query(" select unique(c1) from stb1 partition by tbname ") + # tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ") # tdSql.checkRows(21) - # tdSql.query(" select unique(c1) from stb1 partition by tbname ") + # tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ") # tdSql.checkRows(21) # group by - tdSql.error("select statecount(c1,'GT',1) from ct1 group by c1") - tdSql.error("select statecount(c1,'GT',1) from ct1 group by tbname") - - # super table - - def check_unit_time(self): - tdSql.execute(" use db ") - tdSql.error("select stateduration(c1,'GT',1,1b) from ct1") - tdSql.error("select stateduration(c1,'GT',1,1u) from ct1") - tdSql.error("select stateduration(c1,'GT',1,1000s) from t1") - tdSql.error("select stateduration(c1,'GT',1,10m) from t1") - tdSql.error("select stateduration(c1,'GT',1,10d) from t1") - tdSql.query("select stateduration(c1,'GT',1,1s) from t1") + tdSql.error(f"select statecount(c1,'GT',1) from {dbname}.ct1 group by c1") + tdSql.error(f"select statecount(c1,'GT',1) from {dbname}.ct1 group by tbname") + + def check_unit_time(self, dbname="db"): + tdSql.error(f"select stateduration(c1,'GT',1,1b) from {dbname}.ct1") + tdSql.error(f"select stateduration(c1,'GT',1,1u) from {dbname}.ct1") + tdSql.error(f"select stateduration(c1,'GT',1,1000s) from {dbname}.t1") + tdSql.error(f"select stateduration(c1,'GT',1,10m) from {dbname}.t1") + tdSql.error(f"select stateduration(c1,'GT',1,10d) from {dbname}.t1") + tdSql.query(f"select stateduration(c1,'GT',1,1s) from {dbname}.t1") tdSql.checkData(10,0,63072035) - tdSql.query("select stateduration(c1,'GT',1,1m) from t1") + tdSql.query(f"select stateduration(c1,'GT',1,1m) from {dbname}.t1") tdSql.checkData(10,0,int(63072035/60)) - tdSql.query("select stateduration(c1,'GT',1,1h) from t1") + tdSql.query(f"select stateduration(c1,'GT',1,1h) from {dbname}.t1") tdSql.checkData(10,0,int(63072035/60/60)) - tdSql.query("select stateduration(c1,'GT',1,1d) from t1") + tdSql.query(f"select stateduration(c1,'GT',1,1d) from {dbname}.t1") tdSql.checkData(10,0,int(63072035/60/24/60)) - tdSql.query("select stateduration(c1,'GT',1,1w) from t1") + tdSql.query(f"select stateduration(c1,'GT',1,1w) from {dbname}.t1") tdSql.checkData(10,0,int(63072035/60/7/24/60)) def query_precision(self): def generate_data(precision="ms"): - tdSql.execute("create database if not exists db_%s precision '%s';" %(precision, precision)) + dbname = f"db_{precision}" + tdSql.execute(f"create database if not exists db_%s precision '%s';" %(precision, precision)) tdSql.execute("use db_%s;" %precision) - tdSql.execute("create stable db_%s.st (ts timestamp , id int) tags(ind int);"%precision) - tdSql.execute("create table db_%s.tb1 using st tags(1);"%precision) - tdSql.execute("create table db_%s.tb2 using st tags(2);"%precision) + tdSql.execute(f"create stable db_%s.st (ts timestamp , id int) tags(ind int);"%precision) + tdSql.execute(f"create table db_%s.tb1 using {dbname}.st tags(1);"%precision) + tdSql.execute(f"create table db_%s.tb2 using {dbname}.st tags(2);"%precision) if precision == "ms": start_ts = self.ts @@ -432,55 +425,54 @@ class TDTestCase: if pres == "ms": if unit in ["1u","1b"]: - tdSql.error("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) + tdSql.error(f"select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) pass else: - tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) + tdSql.query(f"select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) elif pres == "us" and unit in ["1b"]: if unit in ["1b"]: - tdSql.error("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) + tdSql.error(f"select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) pass else: - tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) + tdSql.query(f"select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) else: - tdSql.query("select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) + tdSql.query(f"select stateduration(id,'GT',1,%s) from db_%s.tb1 "%(unit,pres)) basic_result = 70 tdSql.checkData(9,0,basic_result*pow(1000,index)) - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - tdSql.query("select statecount(c1,'GT',1) from sub1_bound") + tdSql.query(f"select statecount(c1,'GT',1) from {dbname}.sub1_bound") tdSql.checkRows(5) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring diff --git a/tests/system-test/2-query/substr.py b/tests/system-test/2-query/substr.py index f833a42b574aac2cf8cfcab1bae7035b8273c427..ea55c5e44e780c5acdd86b8be29e8654b8d1251e 100644 --- a/tests/system-test/2-query/substr.py +++ b/tests/system-test/2-query/substr.py @@ -127,16 +127,16 @@ class TDTestCase: return sqls - def __test_current(self): # sourcery skip: use-itertools-product + def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: self.__substr_check(tb, CURRENT_POS, LENS) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: for errsql in self.__substr_err_check(tb): @@ -145,22 +145,21 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp ) tags (tag1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -170,29 +169,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -208,7 +207,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -224,13 +223,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -259,10 +258,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) - - tdSql.execute("use db") + tdSql.execute("flush database db") tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() diff --git a/tests/system-test/2-query/sum.py b/tests/system-test/2-query/sum.py index 4f5ed34419082d49990f14b6e8518b516c4e7df8..dbc79e25f5ba230723f54507f47da91514698c69 100644 --- a/tests/system-test/2-query/sum.py +++ b/tests/system-test/2-query/sum.py @@ -89,14 +89,14 @@ class TDTestCase: return sqls - def __test_current(self): + def __test_current(self, dbname="db"): tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = ["ct1", "ct2", "ct4", "t1"] for tb in tbname: self.__sum_current_check(tb) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") tbname = ["ct1", "ct2", "ct4", "t1"] @@ -106,21 +106,21 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - def __create_tb(self): + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table {DBNAME}.stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' - create_ntb_sql = f'''create table {DBNAME}.t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -130,83 +130,82 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table {DBNAME}.ct{i+1} using {DBNAME}.stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into {DBNAME}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into {DBNAME}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into {DBNAME}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into {DBNAME}.ct1 values - ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } ) - ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } ) + f'''insert into {dbname}.ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into {DBNAME}.ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000} + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} ) ( { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000} + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} ) ''' ) tdSql.execute( - f'''insert into {DBNAME}.ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, - { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, - { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) for i in range(rows): - insert_data = f'''insert into {DBNAME}.t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, - "binary_{i}", "nchar_{i}", { now_time - 1000 * i } ) + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into {DBNAME}.t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, - "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, - "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) - def run(self): tdSql.prepare() @@ -219,12 +218,8 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - # tdDnodes.stop(1) - # tdDnodes.start(1) - tdSql.execute("flush database db") - tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index d708873d6ff608581a64120a054c81f0b3a8da1f..687023f57ec833248c2c7c472b751019a90f930f 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -10,49 +10,46 @@ from util.sql import * from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - - def prepare_datas(self): + + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) - + tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -67,115 +64,115 @@ class TDTestCase: ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ''' ) - - def test_errors(self): + + def test_errors(self, dbname="db"): error_sql_lists = [ - "select tail from t1", - "select tail(123--123)==1 from t1", - "select tail(123,123) from t1", - "select tail(c1,ts) from t1", - "select tail(c1,c1,ts) from t1", - "select tail(c1) as 'd1' from t1", - "select tail(c1 ,c2 ) from t1", - "select tail(c1 ,NULL) from t1", - "select tail(,) from t1;", - "select tail(tail(c1) ab from t1)", - "select tail(c1) as int from t1", - "select tail('c1') from t1", - "select tail(NULL) from t1", - "select tail('') from t1", - "select tail(c%) from t1", - "select tail(t1) from t1", - "select tail(True) from t1", - "select tail(c1,1) , count(c1) from t1", - "select tail(c1,1) , avg(c1) from t1", - "select tail(c1,1) , min(c1) from t1", - "select tail(c1,1) , spread(c1) from t1", - "select tail(c1,1) , diff(c1) from t1", - "select tail from stb1 partition by tbname", - "select tail(123--123)==1 from stb1 partition by tbname", - "select tail(123,123) from stb1 partition by tbname", - "select tail(c1,ts) from stb1 partition by tbname", - "select tail(c1,c1,ts) from stb1 partition by tbname", - "select tail(c1) as 'd1' from stb1 partition by tbname", - "select tail(c1 ,c2 ) from stb1 partition by tbname", - "select tail(c1 ,NULL) from stb1 partition by tbname", - "select tail(,) from stb1 partition by tbname;", - "select tail(tail(c1) ab from stb1 partition by tbname)", - "select tail(c1) as int from stb1 partition by tbname", - "select tail('c1') from stb1 partition by tbname", - "select tail(NULL) from stb1 partition by tbname", - "select tail('') from stb1 partition by tbname", - "select tail(c%) from stb1 partition by tbname", - "select tail(t1) from stb1 partition by tbname", - "select tail(True) from stb1 partition by tbname", - "select tail(c1,1) , count(c1) from stb1 partition by tbname", - "select tail(c1,1) , avg(c1) from stb1 partition by tbname", - "select tail(c1,1) , min(c1) from stb1 partition by tbname", - "select tail(c1,1) , spread(c1) from stb1 partition by tbname", - "select tail(c1,1) , diff(c1) from stb1 partition by tbname", + f"select tail from {dbname}.t1", + f"select tail(123--123)==1 from {dbname}.t1", + f"select tail(123,123) from {dbname}.t1", + f"select tail(c1,ts) from {dbname}.t1", + f"select tail(c1,c1,ts) from {dbname}.t1", + f"select tail(c1) as 'd1' from {dbname}.t1", + f"select tail(c1 ,c2 ) from {dbname}.t1", + f"select tail(c1 ,NULL) from {dbname}.t1", + f"select tail(,) from {dbname}.t1;", + f"select tail(tail(c1) ab from {dbname}.t1)", + f"select tail(c1) as int from {dbname}.t1", + f"select tail('c1') from {dbname}.t1", + f"select tail(NULL) from {dbname}.t1", + f"select tail('') from {dbname}.t1", + f"select tail(c%) from {dbname}.t1", + f"select tail(t1) from {dbname}.t1", + f"select tail(True) from {dbname}.t1", + f"select tail(c1,1) , count(c1) from {dbname}.t1", + f"select tail(c1,1) , avg(c1) from {dbname}.t1", + f"select tail(c1,1) , min(c1) from {dbname}.t1", + f"select tail(c1,1) , spread(c1) from {dbname}.t1", + f"select tail(c1,1) , diff(c1) from {dbname}.t1", + f"select tail from {dbname}.stb1 partition by tbname", + f"select tail(123--123)==1 from {dbname}.stb1 partition by tbname", + f"select tail(123,123) from {dbname}.stb1 partition by tbname", + f"select tail(c1,ts) from {dbname}.stb1 partition by tbname", + f"select tail(c1,c1,ts) from {dbname}.stb1 partition by tbname", + f"select tail(c1) as 'd1' from {dbname}.stb1 partition by tbname", + f"select tail(c1 ,c2 ) from {dbname}.stb1 partition by tbname", + f"select tail(c1 ,NULL) from {dbname}.stb1 partition by tbname", + f"select tail(,) from {dbname}.stb1 partition by tbname;", + f"select tail(tail(c1) ab from {dbname}.stb1 partition by tbname)", + f"select tail(c1) as int from {dbname}.stb1 partition by tbname", + f"select tail('c1') from {dbname}.stb1 partition by tbname", + f"select tail(NULL) from {dbname}.stb1 partition by tbname", + f"select tail('') from {dbname}.stb1 partition by tbname", + f"select tail(c%) from {dbname}.stb1 partition by tbname", + f"select tail(t1) from {dbname}.stb1 partition by tbname", + f"select tail(True) from {dbname}.stb1 partition by tbname", + f"select tail(c1,1) , count(c1) from {dbname}.stb1 partition by tbname", + f"select tail(c1,1) , avg(c1) from {dbname}.stb1 partition by tbname", + f"select tail(c1,1) , min(c1) from {dbname}.stb1 partition by tbname", + f"select tail(c1,1) , spread(c1) from {dbname}.stb1 partition by tbname", + f"select tail(c1,1) , diff(c1) from {dbname}.stb1 partition by tbname", ] for error_sql in error_sql_lists: tdSql.error(error_sql) - - def support_types(self): + + def support_types(self, dbname="db"): other_no_value_types = [ - "select tail(ts,1) from t1" , - "select tail(c7,1) from t1", - "select tail(c8,1) from t1", - "select tail(c9,1) from t1", - "select tail(ts,1) from ct1" , - "select tail(c7,1) from ct1", - "select tail(c8,1) from ct1", - "select tail(c9,1) from ct1", - "select tail(ts,1) from ct3" , - "select tail(c7,1) from ct3", - "select tail(c8,1) from ct3", - "select tail(c9,1) from ct3", - "select tail(ts,1) from ct4" , - "select tail(c7,1) from ct4", - "select tail(c8,1) from ct4", - "select tail(c9,1) from ct4", - "select tail(ts,1) from stb1 partition by tbname" , - "select tail(c7,1) from stb1 partition by tbname", - "select tail(c8,1) from stb1 partition by tbname", - "select tail(c9,1) from stb1 partition by tbname" + f"select tail(ts,1) from {dbname}.t1" , + f"select tail(c7,1) from {dbname}.t1", + f"select tail(c8,1) from {dbname}.t1", + f"select tail(c9,1) from {dbname}.t1", + f"select tail(ts,1) from {dbname}.ct1" , + f"select tail(c7,1) from {dbname}.ct1", + f"select tail(c8,1) from {dbname}.ct1", + f"select tail(c9,1) from {dbname}.ct1", + f"select tail(ts,1) from {dbname}.ct3" , + f"select tail(c7,1) from {dbname}.ct3", + f"select tail(c8,1) from {dbname}.ct3", + f"select tail(c9,1) from {dbname}.ct3", + f"select tail(ts,1) from {dbname}.ct4" , + f"select tail(c7,1) from {dbname}.ct4", + f"select tail(c8,1) from {dbname}.ct4", + f"select tail(c9,1) from {dbname}.ct4", + f"select tail(ts,1) from {dbname}.stb1 partition by tbname" , + f"select tail(c7,1) from {dbname}.stb1 partition by tbname", + f"select tail(c8,1) from {dbname}.stb1 partition by tbname", + f"select tail(c9,1) from {dbname}.stb1 partition by tbname" ] - + for type_sql in other_no_value_types: tdSql.query(type_sql) - + type_sql_lists = [ - "select tail(c1,1) from t1", - "select tail(c2,1) from t1", - "select tail(c3,1) from t1", - "select tail(c4,1) from t1", - "select tail(c5,1) from t1", - "select tail(c6,1) from t1", - - "select tail(c1,1) from ct1", - "select tail(c2,1) from ct1", - "select tail(c3,1) from ct1", - "select tail(c4,1) from ct1", - "select tail(c5,1) from ct1", - "select tail(c6,1) from ct1", - - "select tail(c1,1) from ct3", - "select tail(c2,1) from ct3", - "select tail(c3,1) from ct3", - "select tail(c4,1) from ct3", - "select tail(c5,1) from ct3", - "select tail(c6,1) from ct3", - - "select tail(c1,1) from stb1 partition by tbname", - "select tail(c2,1) from stb1 partition by tbname", - "select tail(c3,1) from stb1 partition by tbname", - "select tail(c4,1) from stb1 partition by tbname", - "select tail(c5,1) from stb1 partition by tbname", - "select tail(c6,1) from stb1 partition by tbname", - - "select tail(c6,1) as alisb from stb1 partition by tbname", - "select tail(c6,1) alisb from stb1 partition by tbname", + f"select tail(c1,1) from {dbname}.t1", + f"select tail(c2,1) from {dbname}.t1", + f"select tail(c3,1) from {dbname}.t1", + f"select tail(c4,1) from {dbname}.t1", + f"select tail(c5,1) from {dbname}.t1", + f"select tail(c6,1) from {dbname}.t1", + + f"select tail(c1,1) from {dbname}.ct1", + f"select tail(c2,1) from {dbname}.ct1", + f"select tail(c3,1) from {dbname}.ct1", + f"select tail(c4,1) from {dbname}.ct1", + f"select tail(c5,1) from {dbname}.ct1", + f"select tail(c6,1) from {dbname}.ct1", + + f"select tail(c1,1) from {dbname}.ct3", + f"select tail(c2,1) from {dbname}.ct3", + f"select tail(c3,1) from {dbname}.ct3", + f"select tail(c4,1) from {dbname}.ct3", + f"select tail(c5,1) from {dbname}.ct3", + f"select tail(c6,1) from {dbname}.ct3", + + f"select tail(c1,1) from {dbname}.stb1 partition by tbname", + f"select tail(c2,1) from {dbname}.stb1 partition by tbname", + f"select tail(c3,1) from {dbname}.stb1 partition by tbname", + f"select tail(c4,1) from {dbname}.stb1 partition by tbname", + f"select tail(c5,1) from {dbname}.stb1 partition by tbname", + f"select tail(c6,1) from {dbname}.stb1 partition by tbname", + + f"select tail(c6,1) as alisb from {dbname}.stb1 partition by tbname", + f"select tail(c6,1) alisb from {dbname}.stb1 partition by tbname", ] for type_sql in type_sql_lists: @@ -189,7 +186,6 @@ class TDTestCase: tail_result = tdSql.queryResult tdSql.query(equal_sql) - print(equal_sql) equal_result = tdSql.queryResult @@ -198,257 +194,255 @@ class TDTestCase: else: tdLog.exit(" tail query check fail , tail sql is: %s " %tail_sql) - def basic_tail_function(self): + def basic_tail_function(self, dbname="db"): - # basic query - tdSql.query("select c1 from ct3") + # basic query + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select tail(c1,1) from ct3") + tdSql.query(f"select tail(c1,1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tail(c2,1) from ct3") + tdSql.query(f"select tail(c2,1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tail(c3,1) from ct3") + tdSql.query(f"select tail(c3,1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tail(c4,1) from ct3") + tdSql.query(f"select tail(c4,1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tail(c5,1) from ct3") + tdSql.query(f"select tail(c5,1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tail(c6,1) from ct3") - + tdSql.query(f"select tail(c6,1) from {dbname}.ct3") + # auto check for t1 table # used for regular table - tdSql.query("select tail(c1,1) from t1") - - tdSql.query("desc t1") + tdSql.query(f"select tail(c1,1) from {dbname}.t1") + + tdSql.query(f"desc {dbname}.t1") col_lists_rows = tdSql.queryResult col_lists = [] for col_name in col_lists_rows: if col_name[0] =="ts": continue - + col_lists.append(col_name[0]) - + for col in col_lists: - for loop in range(100): + for loop in range(100): limit = randint(1,100) offset = randint(0,100) - self.check_tail_table("t1" , col , limit , offset) + self.check_tail_table(f"{dbname}.t1" , col , limit , offset) # tail for invalid params - - tdSql.error("select tail(c1,-10,10) from ct1") - tdSql.error("select tail(c1,10,10000) from ct1") - tdSql.error("select tail(c1,10,-100) from ct1") - tdSql.error("select tail(c1,100/2,10) from ct1") - tdSql.error("select tail(c1,5,10*2) from ct1") - tdSql.query("select tail(c1,100,100) from ct1") + + tdSql.error(f"select tail(c1,-10,10) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,10000) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,-100) from {dbname}.ct1") + tdSql.error(f"select tail(c1,100/2,10) from {dbname}.ct1") + tdSql.error(f"select tail(c1,5,10*2) from {dbname}.ct1") + tdSql.query(f"select tail(c1,100,100) from {dbname}.ct1") tdSql.checkRows(0) - tdSql.query("select tail(c1,10,100) from ct1") + tdSql.query(f"select tail(c1,10,100) from {dbname}.ct1") tdSql.checkRows(0) - tdSql.error("select tail(c1,10,101) from ct1") - tdSql.query("select tail(c1,10,0) from ct1") - tdSql.query("select tail(c1,100,10) from ct1") + tdSql.error(f"select tail(c1,10,101) from {dbname}.ct1") + tdSql.query(f"select tail(c1,10,0) from {dbname}.ct1") + tdSql.query(f"select tail(c1,100,10) from {dbname}.ct1") tdSql.checkRows(3) - + # tail with super tags - tdSql.query("select tail(c1,10,10) from ct1") + tdSql.query(f"select tail(c1,10,10) from {dbname}.ct1") tdSql.checkRows(3) - tdSql.query("select tail(c1,10,10),tbname from ct1") - tdSql.query("select tail(c1,10,10),t1 from ct1") + tdSql.query(f"select tail(c1,10,10),tbname from {dbname}.ct1") + tdSql.query(f"select tail(c1,10,10),t1 from {dbname}.ct1") + + # tail with common col + tdSql.query(f"select tail(c1,10,10) ,ts from {dbname}.ct1") + tdSql.query(f"select tail(c1,10,10) ,c1 from {dbname}.ct1") - # tail with common col - tdSql.query("select tail(c1,10,10) ,ts from ct1") - tdSql.query("select tail(c1,10,10) ,c1 from ct1") + # tail with scalar function + tdSql.query(f"select tail(c1,10,10) ,abs(c1) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,10) , tail(c2,10,10) from {dbname}.ct1") + tdSql.query(f"select tail(c1,10,10) , abs(c2)+2 from {dbname}.ct1") - # tail with scalar function - tdSql.query("select tail(c1,10,10) ,abs(c1) from ct1") - tdSql.error("select tail(c1,10,10) , tail(c2,10,10) from ct1") - tdSql.query("select tail(c1,10,10) , abs(c2)+2 from ct1") - # bug need fix for scalar value or compute again - # tdSql.error(" select tail(c1,10,10) , 123 from ct1") - # tdSql.error(" select abs(tail(c1,10,10)) from ct1") - # tdSql.error(" select abs(tail(c1,10,10)) + 2 from ct1") + # tdSql.error(f"select tail(c1,10,10) , 123 from {dbname}.ct1") + # tdSql.error(f"select abs(tail(c1,10,10)) from {dbname}.ct1") + # tdSql.error(f"select abs(tail(c1,10,10)) + 2 from {dbname}.ct1") - # tail with aggregate function - tdSql.error("select tail(c1,10,10) ,sum(c1) from ct1") - tdSql.error("select tail(c1,10,10) ,max(c1) from ct1") - tdSql.error("select tail(c1,10,10) ,csum(c1) from ct1") - tdSql.error("select tail(c1,10,10) ,count(c1) from ct1") + # tail with aggregate function + tdSql.error(f"select tail(c1,10,10) ,sum(c1) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,10) ,max(c1) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,10) ,csum(c1) from {dbname}.ct1") + tdSql.error(f"select tail(c1,10,10) ,count(c1) from {dbname}.ct1") # tail with filter where - tdSql.query("select tail(c1,3,1) from ct4 where c1 is null") + tdSql.query(f"select tail(c1,3,1) from {dbname}.ct4 where c1 is null") tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) - tdSql.query("select tail(c1,3,2) from ct4 where c1 >2 order by 1") + tdSql.query(f"select tail(c1,3,2) from {dbname}.ct4 where c1 >2 order by 1") tdSql.checkData(0, 0, 5) tdSql.checkData(1, 0, 6) tdSql.checkData(2, 0, 7) - tdSql.query("select tail(c1,2,1) from ct4 where c2 between 0 and 99999 order by 1") + tdSql.query(f"select tail(c1,2,1) from {dbname}.ct4 where c2 between 0 and 99999 order by 1") tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, 2) - # tail with union all - tdSql.query("select tail(c1,2,1) from ct4 union all select c1 from ct1") + # tail with union all + tdSql.query(f"select tail(c1,2,1) from {dbname}.ct4 union all select c1 from {dbname}.ct1") tdSql.checkRows(15) - tdSql.query("select tail(c1,2,1) from ct4 union all select c1 from ct2 order by 1") + tdSql.query(f"select tail(c1,2,1) from {dbname}.ct4 union all select c1 from {dbname}.ct2 order by 1") tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(1, 0, 1) - tdSql.query("select tail(c2,2,1) from ct4 union all select abs(c2)/2 from ct4") + tdSql.query(f"select tail(c2,2,1) from {dbname}.ct4 union all select abs(c2)/2 from {dbname}.ct4") tdSql.checkRows(14) - # tail with join - # prepare join datas with same ts + # tail with join + # prepare join datas with same ts - tdSql.execute(" use db ") - tdSql.execute(" create stable st1 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table tb1 using st1 tags(1)") - tdSql.execute(" create table tb2 using st1 tags(2)") + tdSql.execute(f" create stable {dbname}.st1 (ts timestamp , num int) tags(ind int)") + tdSql.execute(f" create table {dbname}.tb1 using {dbname}.st1 tags(1)") + tdSql.execute(f" create table {dbname}.tb2 using {dbname}.st1 tags(2)") - tdSql.execute(" create stable st2 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table ttb1 using st2 tags(1)") - tdSql.execute(" create table ttb2 using st2 tags(2)") + tdSql.execute(f" create stable {dbname}.st2 (ts timestamp , num int) tags(ind int)") + tdSql.execute(f" create table {dbname}.ttb1 using {dbname}.st2 tags(1)") + tdSql.execute(f" create table {dbname}.ttb2 using {dbname}.st2 tags(2)") start_ts = 1622369635000 # 2021-05-30 18:13:55 for i in range(10): ts_value = start_ts+i*1000 - tdSql.execute(f" insert into tb1 values({ts_value} , {i})") - tdSql.execute(f" insert into tb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb2 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb1 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb2 values({ts_value} , {i})") - tdSql.query("select tail(tb2.num,3,2) from tb1, tb2 where tb1.ts=tb2.ts order by 1 desc") + tdSql.query(f"select tail(tb2.num,3,2) from {dbname}.tb1 tb1, {dbname}.tb2 tb2 where tb1.ts=tb2.ts order by 1 desc") tdSql.checkRows(3) tdSql.checkData(0,0,7) tdSql.checkData(1,0,6) tdSql.checkData(2,0,5) # nest query - # tdSql.query("select tail(c1,2) from (select _rowts , c1 from ct1)") - tdSql.query("select c1 from (select tail(c1,2) c1 from ct4) order by 1 nulls first") + # tdSql.query(f"select tail(c1,2) from (select _rowts , c1 from {dbname}.ct1)") + tdSql.query(f"select c1 from (select tail(c1,2) c1 from {dbname}.ct4) order by 1 nulls first") tdSql.checkRows(2) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, 0) - tdSql.query("select sum(c1) from (select tail(c1,2) c1 from ct1)") + tdSql.query(f"select sum(c1) from (select tail(c1,2) c1 from {dbname}.ct1)") tdSql.checkRows(1) tdSql.checkData(0, 0, 18) - tdSql.query("select abs(c1) from (select tail(c1,2) c1 from ct1)") + tdSql.query(f"select abs(c1) from (select tail(c1,2) c1 from {dbname}.ct1)") tdSql.checkRows(2) tdSql.checkData(0, 0, 9) - + #partition by tbname - tdSql.query(" select tail(c1,5) from stb1 partition by tbname ") + tdSql.query(f"select tail(c1,5) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(10) - tdSql.query(" select tail(c1,3) from stb1 partition by tbname ") + tdSql.query(f"select tail(c1,3) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(6) - - # group by - tdSql.error("select tail(c1,2) from ct1 group by c1") - tdSql.error("select tail(c1,2) from ct1 group by tbname") + + # group by + tdSql.error(f"select tail(c1,2) from {dbname}.ct1 group by c1") + tdSql.error(f"select tail(c1,2) from {dbname}.ct1 group by tbname") # super table - tdSql.error("select tbname , tail(c1,2) from stb1 group by tbname") - tdSql.query("select tail(c1,2) from stb1 partition by tbname") + tdSql.error(f"select tbname , tail(c1,2) from {dbname}.stb1 group by tbname") + tdSql.query(f"select tail(c1,2) from {dbname}.stb1 partition by tbname") tdSql.checkRows(4) - # bug need fix - # tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname") + # bug need fix + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 partition by tbname") # tdSql.checkRows(4) - # tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname order by tbname") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 partition by tbname order by tbname") # tdSql.checkRows(4) - # tdSql.query(" select tbname , count(c1) from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , count(c1) from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , max(c1) ,c1 from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , max(c1) ,c1 from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname ,first(c1) from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname ,first(c1) from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - tdSql.query("select tail(c1,2) from stb1 partition by tbname") + tdSql.query(f"select tail(c1,2) from {dbname}.stb1 partition by tbname") tdSql.checkRows(4) - # # bug need fix - # tdSql.query(" select tbname , tail(c1,2) from stb1 where t1 = 0 partition by tbname ") + # # bug need fix + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 where t1 = 0 partition by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , tail(c1,2) from stb1 where t1 = 0 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 where t1 = 0 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 where c1 = 0 partition by tbname order by tbname ") # tdSql.checkRows(3) - # tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname ") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 where c1 = 0 partition by tbname ") # tdSql.checkRows(3) - # tdSql.query(" select tbname , tail(c1,2) from stb1 where c1 = 0 partition by tbname ") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 where c1 = 0 partition by tbname ") # tdSql.checkRows(3) - tdSql.query(" select tail(t1,2) from stb1 ") + tdSql.query(f"select tail(t1,2) from {dbname}.stb1 ") tdSql.checkRows(2) - tdSql.query(" select tail(t1+c1,2) from stb1 ") + tdSql.query(f"select tail(t1+c1,2) from {dbname}.stb1 ") tdSql.checkRows(2) - tdSql.query(" select tail(t1+c1,2) from stb1 partition by tbname ") + tdSql.query(f"select tail(t1+c1,2) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(4) - tdSql.query(" select tail(t1,2) from stb1 partition by tbname ") + tdSql.query(f"select tail(t1,2) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(4) - # nest query - tdSql.query(" select tail(c1,2) from (select _rowts , t1 ,c1 , tbname from stb1 ) ") + # nest query + tdSql.query(f"select tail(c1,2) from (select _rowts , t1 ,c1 , tbname from {dbname}.stb1 ) ") tdSql.checkRows(2) tdSql.checkData(0,0,None) tdSql.checkData(1,0,9) - tdSql.query("select tail(t1,2) from (select _rowts , t1 , tbname from stb1 )") + tdSql.query(f"select tail(t1,2) from (select _rowts , t1 , tbname from {dbname}.stb1 )") tdSql.checkRows(2) tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - + tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - - tdSql.query("select tail(c2,2) from sub1_bound order by 1 desc") + + tdSql.query(f"select tail(c2,2) from {dbname}.sub1_bound order by 1 desc") tdSql.checkRows(2) tdSql.checkData(0,0,9223372036854775803) @@ -456,22 +450,22 @@ class TDTestCase: tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: tail basic query ============") + tdLog.printNoPrefix("==========step4: tail basic query ============") self.basic_tail_function() - tdLog.printNoPrefix("==========step5: tail boundary query ============") + tdLog.printNoPrefix("==========step5: tail boundary query ============") self.check_boundary_values() diff --git a/tests/system-test/2-query/tan.py b/tests/system-test/2-query/tan.py index da47c1c2b2560bf617681df10e8788f518b11ac1..683cee37ff7c81ca45b628852134ddbab6e342cf 100644 --- a/tests/system-test/2-query/tan.py +++ b/tests/system-test/2-query/tan.py @@ -9,48 +9,46 @@ from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} + def init(self, conn, powSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - - def prepare_datas(self): + + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) - + tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -61,18 +59,18 @@ class TDTestCase: ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) - ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + ( '2022-12-31 01:01:36.000', 9, -99999, -999, -99, -9.99, -99999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ''' ) - + def check_result_auto_tan(self ,origin_query , pow_query): pow_result = tdSql.getResult(pow_query) origin_result = tdSql.getResult(origin_query) auto_result =[] - + for row in origin_result: row_check = [] for elem in row: @@ -82,190 +80,178 @@ class TDTestCase: elem = math.tan(elem) row_check.append(elem) auto_result.append(row_check) - - check_status = True - + tdSql.query(pow_query) for row_index , row in enumerate(pow_result): for col_index , elem in enumerate(row): - if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None): - check_status = False - elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001): - check_status = False - else: - pass - if not check_status: - tdLog.notice("tan function value has not as expected , sql is \"%s\" "%pow_query ) - sys.exit(1) - else: - tdLog.info("tan value check pass , it work as expected ,sql is \"%s\" "%pow_query ) - - def test_errors(self): + tdSql.checkData(row_index , col_index ,auto_result[row_index][col_index] ) + + def test_errors(self, dbname="db"): error_sql_lists = [ - "select tan from t1", - # "select tan(-+--+c1 ) from t1", - # "select +-tan(c1) from t1", - # "select ++-tan(c1) from t1", - # "select ++--tan(c1) from t1", - # "select - -tan(c1)*0 from t1", - # "select tan(tbname+1) from t1 ", - "select tan(123--123)==1 from t1", - "select tan(c1) as 'd1' from t1", - "select tan(c1 ,c2) from t1", - "select tan(c1 ,NULL ) from t1", - "select tan(,) from t1;", - "select tan(tan(c1) ab from t1)", - "select tan(c1 ) as int from t1", - "select tan from stb1", - # "select tan(-+--+c1) from stb1", - # "select +-tan(c1) from stb1", - # "select ++-tan(c1) from stb1", - # "select ++--tan(c1) from stb1", - # "select - -tan(c1)*0 from stb1", - # "select tan(tbname+1) from stb1 ", - "select tan(123--123)==1 from stb1", - "select tan(c1) as 'd1' from stb1", - "select tan(c1 ,c2 ) from stb1", - "select tan(c1 ,NULL) from stb1", - "select tan(,) from stb1;", - "select tan(tan(c1) ab from stb1)", - "select tan(c1) as int from stb1" + f"select tan from {dbname}.t1", + # f"select tan(-+--+c1 ) from {dbname}.t1", + # f"select +-tan(c1) from {dbname}.t1", + # f"select ++-tan(c1) from {dbname}.t1", + # f"select ++--tan(c1) from {dbname}.t1", + # f"select - -tan(c1)*0 from {dbname}.t1", + # f"select tan(tbname+1) from {dbname}.t1 ", + f"select tan(123--123)==1 from {dbname}.t1", + f"select tan(c1) as 'd1' from {dbname}.t1", + f"select tan(c1 ,c2) from {dbname}.t1", + f"select tan(c1 ,NULL ) from {dbname}.t1", + f"select tan(,) from {dbname}.t1;", + f"select tan(tan(c1) ab from {dbname}.t1)", + f"select tan(c1 ) as int from {dbname}.t1", + f"select tan from {dbname}.stb1", + # f"select tan(-+--+c1) from {dbname}.stb1", + # f"select +-tan(c1) from {dbname}.stb1", + # f"select ++-tan(c1) from {dbname}.stb1", + # f"select ++--tan(c1) from {dbname}.stb1", + # f"select - -tan(c1)*0 from {dbname}.stb1", + # f"select tan(tbname+1) from {dbname}.stb1 ", + f"select tan(123--123)==1 from {dbname}.stb1", + f"select tan(c1) as 'd1' from {dbname}.stb1", + f"select tan(c1 ,c2 ) from {dbname}.stb1", + f"select tan(c1 ,NULL) from {dbname}.stb1", + f"select tan(,) from {dbname}.stb1;", + f"select tan(tan(c1) ab from {dbname}.stb1)", + f"select tan(c1) as int from {dbname}.stb1" ] for error_sql in error_sql_lists: tdSql.error(error_sql) - - def support_types(self): + + def support_types(self, dbname="db"): type_error_sql_lists = [ - "select tan(ts) from t1" , - "select tan(c7) from t1", - "select tan(c8) from t1", - "select tan(c9) from t1", - "select tan(ts) from ct1" , - "select tan(c7) from ct1", - "select tan(c8) from ct1", - "select tan(c9) from ct1", - "select tan(ts) from ct3" , - "select tan(c7) from ct3", - "select tan(c8) from ct3", - "select tan(c9) from ct3", - "select tan(ts) from ct4" , - "select tan(c7) from ct4", - "select tan(c8) from ct4", - "select tan(c9) from ct4", - "select tan(ts) from stb1" , - "select tan(c7) from stb1", - "select tan(c8) from stb1", - "select tan(c9) from stb1" , - - "select tan(ts) from stbbb1" , - "select tan(c7) from stbbb1", - - "select tan(ts) from tbname", - "select tan(c9) from tbname" + f"select tan(ts) from {dbname}.t1" , + f"select tan(c7) from {dbname}.t1", + f"select tan(c8) from {dbname}.t1", + f"select tan(c9) from {dbname}.t1", + f"select tan(ts) from {dbname}.ct1" , + f"select tan(c7) from {dbname}.ct1", + f"select tan(c8) from {dbname}.ct1", + f"select tan(c9) from {dbname}.ct1", + f"select tan(ts) from {dbname}.ct3" , + f"select tan(c7) from {dbname}.ct3", + f"select tan(c8) from {dbname}.ct3", + f"select tan(c9) from {dbname}.ct3", + f"select tan(ts) from {dbname}.ct4" , + f"select tan(c7) from {dbname}.ct4", + f"select tan(c8) from {dbname}.ct4", + f"select tan(c9) from {dbname}.ct4", + f"select tan(ts) from {dbname}.stb1" , + f"select tan(c7) from {dbname}.stb1", + f"select tan(c8) from {dbname}.stb1", + f"select tan(c9) from {dbname}.stb1" , + + f"select tan(ts) from {dbname}.stbbb1" , + f"select tan(c7) from {dbname}.stbbb1", + + f"select tan(ts) from {dbname}.tbname", + f"select tan(c9) from {dbname}.tbname" ] - + for type_sql in type_error_sql_lists: tdSql.error(type_sql) - - + + type_sql_lists = [ - "select tan(c1) from t1", - "select tan(c2) from t1", - "select tan(c3) from t1", - "select tan(c4) from t1", - "select tan(c5) from t1", - "select tan(c6) from t1", - - "select tan(c1) from ct1", - "select tan(c2) from ct1", - "select tan(c3) from ct1", - "select tan(c4) from ct1", - "select tan(c5) from ct1", - "select tan(c6) from ct1", - - "select tan(c1) from ct3", - "select tan(c2) from ct3", - "select tan(c3) from ct3", - "select tan(c4) from ct3", - "select tan(c5) from ct3", - "select tan(c6) from ct3", - - "select tan(c1) from stb1", - "select tan(c2) from stb1", - "select tan(c3) from stb1", - "select tan(c4) from stb1", - "select tan(c5) from stb1", - "select tan(c6) from stb1", - - "select tan(c6) as alisb from stb1", - "select tan(c6) alisb from stb1", + f"select tan(c1) from {dbname}.t1", + f"select tan(c2) from {dbname}.t1", + f"select tan(c3) from {dbname}.t1", + f"select tan(c4) from {dbname}.t1", + f"select tan(c5) from {dbname}.t1", + f"select tan(c6) from {dbname}.t1", + + f"select tan(c1) from {dbname}.ct1", + f"select tan(c2) from {dbname}.ct1", + f"select tan(c3) from {dbname}.ct1", + f"select tan(c4) from {dbname}.ct1", + f"select tan(c5) from {dbname}.ct1", + f"select tan(c6) from {dbname}.ct1", + + f"select tan(c1) from {dbname}.ct3", + f"select tan(c2) from {dbname}.ct3", + f"select tan(c3) from {dbname}.ct3", + f"select tan(c4) from {dbname}.ct3", + f"select tan(c5) from {dbname}.ct3", + f"select tan(c6) from {dbname}.ct3", + + f"select tan(c1) from {dbname}.stb1", + f"select tan(c2) from {dbname}.stb1", + f"select tan(c3) from {dbname}.stb1", + f"select tan(c4) from {dbname}.stb1", + f"select tan(c5) from {dbname}.stb1", + f"select tan(c6) from {dbname}.stb1", + + f"select tan(c6) as alisb from {dbname}.stb1", + f"select tan(c6) alisb from {dbname}.stb1", ] for type_sql in type_sql_lists: tdSql.query(type_sql) - - def basic_tan_function(self): - # basic query - tdSql.query("select c1 from ct3") + def basic_tan_function(self, dbname="db"): + + # basic query + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select tan(c1) from ct3") + tdSql.query(f"select tan(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tan(c2) from ct3") + tdSql.query(f"select tan(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tan(c3) from ct3") + tdSql.query(f"select tan(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tan(c4) from ct3") + tdSql.query(f"select tan(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tan(c5) from ct3") + tdSql.query(f"select tan(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select tan(c6) from ct3") + tdSql.query(f"select tan(c6) from {dbname}.ct3") tdSql.checkRows(0) # # used for regular table - tdSql.query("select tan(c1) from t1") + tdSql.query(f"select tan(c1) from {dbname}.t1") tdSql.checkData(0, 0, None) tdSql.checkData(1 , 0, 1.557407725) tdSql.checkData(3 , 0, -0.142546543) tdSql.checkData(5 , 0, None) - tdSql.query("select c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 4, 1.11000) tdSql.checkData(3, 3, 33) tdSql.checkData(5, 4, None) - tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1") + tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1") tdSql.checkData(1, 5, 1.11000) tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto_tan( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select tan(abs(c1)), tan(abs(c2)) ,tan(abs(c3)), tan(abs(c4)), tan(abs(c5)) from t1") - + self.check_result_auto_tan( f"select abs(c1), abs(c2), abs(c3) , abs(c4) from {dbname}.t1", f"select tan(abs(c1)), tan(abs(c2)) ,tan(abs(c3)), tan(abs(c4)) from {dbname}.t1") + # used for sub table - tdSql.query("select c2 ,tan(c2) from ct1") + tdSql.query(f"select c2 ,tan(c2) from {dbname}.ct1") tdSql.checkData(0, 1, -0.226288661) tdSql.checkData(1 , 1, 0.670533806) tdSql.checkData(3 , 1, -1.325559275) tdSql.checkData(4 , 1, 0.000000000) - tdSql.query("select c1, c5 ,tan(c5) from ct4") + tdSql.query(f"select c1, c5 ,tan(c5) from {dbname}.ct4") tdSql.checkData(0 , 2, None) tdSql.checkData(1 , 2, -0.605942929) tdSql.checkData(2 , 2, 11.879355609) tdSql.checkData(3 , 2, 0.395723765) tdSql.checkData(5 , 2, None) - self.check_result_auto_tan( "select c1, c2, c3 , c4, c5 from ct1", "select tan(c1), tan(c2) ,tan(c3), tan(c4), tan(c5) from ct1") - + self.check_result_auto_tan( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select tan(c1), tan(c2) ,tan(c3), tan(c4), tan(c5) from {dbname}.ct1") + # nest query for tan functions - tdSql.query("select c4 , tan(c4) ,tan(tan(c4)) , tan(tan(tan(c4))) from ct1;") + tdSql.query(f"select c4 , tan(c4) ,tan(tan(c4)) , tan(tan(tan(c4))) from {dbname}.ct1;") tdSql.checkData(0 , 0 , 88) tdSql.checkData(0 , 1 , 0.035420501) tdSql.checkData(0 , 2 , 0.035435322) @@ -281,52 +267,52 @@ class TDTestCase: tdSql.checkData(11 , 2 , -0.040227928) tdSql.checkData(11 , 3 , -0.040249642) - # used for stable table - - tdSql.query("select tan(c1) from stb1") + # used for stable table + + tdSql.query(f"select tan(c1) from {dbname}.stb1") tdSql.checkRows(25) - + # used for not exists table - tdSql.error("select tan(c1) from stbbb1") - tdSql.error("select tan(c1) from tbname") - tdSql.error("select tan(c1) from ct5") + tdSql.error(f"select tan(c1) from {dbname}.stbbb1") + tdSql.error(f"select tan(c1) from {dbname}.tbname") + tdSql.error(f"select tan(c1) from {dbname}.ct5") + + # mix with common col + tdSql.query(f"select c1, tan(c1) from {dbname}.ct1") + tdSql.query(f"select c2, tan(c2) from {dbname}.ct4") - # mix with common col - tdSql.query("select c1, tan(c1) from ct1") - tdSql.query("select c2, tan(c2) from ct4") - # mix with common functions - tdSql.query("select c1, tan(c1),tan(c1), tan(tan(c1)) from ct4 ") + tdSql.query(f"select c1, tan(c1),tan(c1), tan(tan(c1)) from {dbname}.ct4 ") tdSql.checkData(0 , 0 ,None) tdSql.checkData(0 , 1 ,None) tdSql.checkData(0 , 2 ,None) tdSql.checkData(0 , 3 ,None) - + tdSql.checkData(3 , 0 , 6) tdSql.checkData(3 , 1 ,-0.291006191) tdSql.checkData(3 , 2 ,-0.291006191) tdSql.checkData(3 , 3 ,-0.299508909) - tdSql.query("select c1, tan(c1),c5, floor(c5) from stb1 ") + tdSql.query(f"select c1, tan(c1),c5, floor(c5) from {dbname}.stb1 ") # # mix with agg functions , not support - tdSql.error("select c1, tan(c1),c5, count(c5) from stb1 ") - tdSql.error("select c1, tan(c1),c5, count(c5) from ct1 ") - tdSql.error("select tan(c1), count(c5) from stb1 ") - tdSql.error("select tan(c1), count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from ct1 ") - tdSql.error("select c1, count(c5) from stb1 ") + tdSql.error(f"select c1, tan(c1),c5, count(c5) from {dbname}.stb1 ") + tdSql.error(f"select c1, tan(c1),c5, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select tan(c1), count(c5) from {dbname}.stb1 ") + tdSql.error(f"select tan(c1), count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ") + tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ") # agg functions mix with agg functions - tdSql.query("select max(c5), count(c5) from stb1") - tdSql.query("select max(c5), count(c5) from ct1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1") + tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1") + - - # # bug fix for compute - tdSql.query("select c1, tan(c1) -0 ,tan(c1-4)-0 from ct4 ") + # # bug fix for compute + tdSql.query(f"select c1, tan(c1) -0 ,tan(c1-4)-0 from {dbname}.ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -334,7 +320,7 @@ class TDTestCase: tdSql.checkData(1, 1, -6.799711455) tdSql.checkData(1, 2, 1.157821282) - tdSql.query(" select c1, tan(c1) -0 ,tan(c1-0.1)-0.1 from ct4") + tdSql.query(f"select c1, tan(c1) -0 ,tan(c1-0.1)-0.1 from {dbname}.ct4") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) tdSql.checkData(0, 2, None) @@ -342,35 +328,33 @@ class TDTestCase: tdSql.checkData(1, 1, -6.799711455) tdSql.checkData(1, 2, -21.815112681) - tdSql.query("select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ct1") + tdSql.query(f"select c1, tan(c1), c2, tan(c2), c3, tan(c3) from {dbname}.ct1") - def test_big_number(self): + def test_big_number(self, dbname="db"): - tdSql.query("select c1, tan(100000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(100000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.tan(100000000)) - - tdSql.query("select c1, tan(10000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(10000000000000) from {dbname}.ct1") # bigint to double data overflow tdSql.checkData(4, 1, math.tan(10000000000000)) - tdSql.query("select c1, tan(10000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, tan(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, tan(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(1, 1, math.tan(10000000000000000000000000.0)) - tdSql.query("select c1, tan(10000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, tan(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, tan(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.tan(10000000000000000000000000000000000.0)) - tdSql.query("select c1, tan(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow - tdSql.query("select c1, tan(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value + tdSql.query(f"select c1, tan(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value tdSql.checkData(4, 1, math.tan(10000000000000000000000000000000000000000.0)) - tdSql.query("select c1, tan(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow + tdSql.query(f"select c1, tan(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow - def abs_func_filter(self): - tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from ct4 where c1>5 ") + def abs_func_filter(self, dbname="db"): + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from {dbname}.ct4 where c1>5 ") tdSql.checkRows(3) tdSql.checkData(0,0,8) tdSql.checkData(0,1,8.000000000) @@ -378,7 +362,7 @@ class TDTestCase: tdSql.checkData(0,3,7.900000000) tdSql.checkData(0,4,-7.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from ct4 where c1=5 ") + tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from {dbname}.ct4 where c1=5 ") tdSql.checkRows(1) tdSql.checkData(0,0,5) tdSql.checkData(0,1,5.000000000) @@ -386,7 +370,7 @@ class TDTestCase: tdSql.checkData(0,3,4.900000000) tdSql.checkData(0,4,-3.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from ct4 where c1>tan(c1) limit 1 ") + tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(tan(c1)-0.5) from {dbname}.ct4 where c1>tan(c1) limit 1 ") tdSql.checkRows(1) tdSql.checkData(0,0,8) tdSql.checkData(0,1,88888) @@ -394,45 +378,40 @@ class TDTestCase: tdSql.checkData(0,3,8.000000000) tdSql.checkData(0,4,7.900000000) tdSql.checkData(0,5,-7.000000000) - - def pow_Arithmetic(self): - pass - - def check_boundary_values(self): + + def check_boundary_values(self, dbname="bound_test"): PI=3.1415926 - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - time.sleep(3) - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - self.check_result_auto_tan( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select tan(abs(c1)), tan(abs(c2)) ,tan(abs(c3)), tan(abs(c4)), tan(abs(c5)) from sub1_bound") - - self.check_result_auto_tan( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select tan(c1), tan(c2) ,tan(c3), tan(c3), tan(c2) ,tan(c1) from sub1_bound") + self.check_result_auto_tan( f"select abs(c1), abs(c2), abs(c3) , abs(c4) from {dbname}.sub1_bound ", f"select tan(abs(c1)), tan(abs(c2)) ,tan(abs(c3)), tan(abs(c4)) from {dbname}.sub1_bound") + + self.check_result_auto_tan( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select tan(c1), tan(c2) ,tan(c3), tan(c3), tan(c2) ,tan(c1) from {dbname}.sub1_bound") + + self.check_result_auto_tan(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select tan(abs(c1)) from {dbname}.sub1_bound" ) - self.check_result_auto_tan("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select tan(abs(c1)) from sub1_bound" ) - # check basic elem for table per row - tdSql.query("select tan(abs(c1)) ,tan(abs(c2)) , tan(abs(c3)) , tan(abs(c4)), tan(abs(c5)), tan(abs(c6)) from sub1_bound ") + tdSql.query(f"select tan(abs(c1)) ,tan(abs(c2)) , tan(abs(c3)) , tan(abs(c4)), tan(abs(c5)), tan(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.tan(2147483647)) tdSql.checkData(0,1,math.tan(9223372036854775807)) tdSql.checkData(0,2,math.tan(32767)) @@ -450,76 +429,71 @@ class TDTestCase: tdSql.checkData(3,4,math.tan(339999995214436424907732413799364296704.00000)) # check + - * / in functions - tdSql.query("select tan(abs(c1+1)) ,tan(abs(c2)) , tan(abs(c3*1)) , tan(abs(c4/2)), tan(abs(c5))/2, tan(abs(c6)) from sub1_bound ") + tdSql.query(f"select tan(abs(c1+1)) ,tan(abs(c2)) , tan(abs(c3*1)) , tan(abs(c4/2)), tan(abs(c5))/2, tan(abs(c6)) from {dbname}.sub1_bound ") tdSql.checkData(0,0,math.tan(2147483648.000000000)) tdSql.checkData(0,1,math.tan(9223372036854775807)) tdSql.checkData(0,2,math.tan(32767.000000000)) tdSql.checkData(0,3,math.tan(63.500000000)) - tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);") - tdSql.execute(f'create table tb1 using st tags (1)') - tdSql.execute(f'create table tb2 using st tags (2)') - tdSql.execute(f'create table tb3 using st tags (3)') - tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) - - tdSql.execute('insert into tb2 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 )) - tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI )) - tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5)) - tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2)) - tdSql.execute('insert into tb2 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5)) - - for i in range(100): - tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) - - self.check_result_auto_tan("select num1,num2 from tb3;" , "select tan(num1),tan(num2) from tb3") - - def support_super_table_test(self): - tdSql.execute(" use db ") - self.check_result_auto_tan( " select c5 from stb1 order by ts " , "select tan(c5) from stb1 order by ts" ) - self.check_result_auto_tan( " select c5 from stb1 order by tbname " , "select tan(c5) from stb1 order by tbname" ) - self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) - - self.check_result_auto_tan( " select t1,c5 from stb1 order by ts " , "select tan(t1), tan(c5) from stb1 order by ts" ) - self.check_result_auto_tan( " select t1,c5 from stb1 order by tbname " , "select tan(t1) ,tan(c5) from stb1 order by tbname" ) - self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) ,tan(c5) from stb1 where c1 > 0 order by tbname" ) - self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) , tan(c5) from stb1 where c1 > 0 order by tbname" ) + tdSql.execute(f"create stable {dbname}.st (ts timestamp, num1 float, num2 double) tags (t1 int);") + tdSql.execute(f'create table {dbname}.tb1 using {dbname}.st tags (1)') + tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)') + tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb1 values (now(), {PI*2.5}, {PI*2.5})') + + tdSql.execute(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})') + tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {PI*2}, {PI*2})') + tdSql.execute(f'insert into {dbname}.tb2 values (now(), {PI*2.5}, {PI*2.5})') + + self.check_result_auto_tan(f"select num1,num2 from {dbname}.tb3;" , f"select tan(num1),tan(num2) from {dbname}.tb3") + + def support_super_table_test(self, dbname="db"): + self.check_result_auto_tan( f"select c5 from {dbname}.stb1 order by ts " , f"select tan(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_tan( f"select c5 from {dbname}.stb1 order by tbname " , f"select tan(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_tan( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select tan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select tan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_tan( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select tan(t1), tan(c5) from {dbname}.stb1 order by ts" ) + self.check_result_auto_tan( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select tan(t1) ,tan(c5) from {dbname}.stb1 order by tbname" ) + self.check_result_auto_tan( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select tan(t1) ,tan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select tan(t1) , tan(c5) from {dbname}.stb1 where c1 > 0 order by tbname" ) pass - - + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: tan basic query ============") + tdLog.printNoPrefix("==========step4: tan basic query ============") self.basic_tan_function() - tdLog.printNoPrefix("==========step5: big number tan query ============") + tdLog.printNoPrefix("==========step5: big number tan query ============") self.test_big_number() - - tdLog.printNoPrefix("==========step6: tan boundary query ============") + tdLog.printNoPrefix("==========step6: tan boundary query ============") self.check_boundary_values() - tdLog.printNoPrefix("==========step7: tan filter query ============") + tdLog.printNoPrefix("==========step7: tan filter query ============") self.abs_func_filter() diff --git a/tests/system-test/2-query/timetruncate.py b/tests/system-test/2-query/timetruncate.py index 3551d8ee2cfb0669c23ed1754ebcb65c69e48daa..d773114c3c3d84bb6b102852d84223d68e0c0a2f 100644 --- a/tests/system-test/2-query/timetruncate.py +++ b/tests/system-test/2-query/timetruncate.py @@ -25,6 +25,7 @@ class TDTestCase: self.ntbname = f'{self.dbname}.ntb' self.stbname = f'{self.dbname}.stb' self.ctbname = f'{self.dbname}.ctb' + def check_ms_timestamp(self,unit,date_time): if unit.lower() == '1a': for i in range(len(self.ts_str)): @@ -45,11 +46,12 @@ class TDTestCase: elif unit.lower() == '1d': for i in range(len(self.ts_str)): ts_result = self.get_time.get_ms_timestamp(str(tdSql.queryResult[i][0])) - tdSql.checkEqual(ts_result,int(date_time[i]/1000/60/60/24)*24*60*60*1000) + tdSql.checkEqual(ts_result,int(date_time[i]/1000/60/60/24)*24*60*60*1000) elif unit.lower() == '1w': for i in range(len(self.ts_str)): ts_result = self.get_time.get_ms_timestamp(str(tdSql.queryResult[i][0])) tdSql.checkEqual(ts_result,int(date_time[i]/1000/60/60/24/7)*7*24*60*60*1000) + def check_us_timestamp(self,unit,date_time): if unit.lower() == '1u': for i in range(len(self.ts_str)): @@ -74,11 +76,12 @@ class TDTestCase: elif unit.lower() == '1d': for i in range(len(self.ts_str)): ts_result = self.get_time.get_us_timestamp(str(tdSql.queryResult[i][0])) - tdSql.checkEqual(ts_result,int(date_time[i]/1000/1000/60/60/24)*24*60*60*1000*1000 ) + tdSql.checkEqual(ts_result,int(date_time[i]/1000/1000/60/60/24)*24*60*60*1000*1000 ) elif unit.lower() == '1w': for i in range(len(self.ts_str)): ts_result = self.get_time.get_us_timestamp(str(tdSql.queryResult[i][0])) tdSql.checkEqual(ts_result,int(date_time[i]/1000/1000/60/60/24/7)*7*24*60*60*1000*1000) + def check_ns_timestamp(self,unit,date_time): if unit.lower() == '1b': for i in range(len(self.ts_str)): @@ -100,21 +103,23 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60)*60*60*1000*1000*1000 ) elif unit.lower() == '1d': for i in range(len(self.ts_str)): - tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60/24)*24*60*60*1000*1000*1000 ) + tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60/24)*24*60*60*1000*1000*1000 ) elif unit.lower() == '1w': for i in range(len(self.ts_str)): tdSql.checkEqual(tdSql.queryResult[i][0],int(date_time[i]*1000/1000/1000/1000/1000/60/60/24/7)*7*24*60*60*1000*1000*1000) + def check_tb_type(self,unit,tb_type): - if tb_type.lower() == 'ntb': + if tb_type.lower() == 'ntb': tdSql.query(f'select timetruncate(ts,{unit}) from {self.ntbname}') elif tb_type.lower() == 'ctb': tdSql.query(f'select timetruncate(ts,{unit}) from {self.ctbname}') elif tb_type.lower() == 'stb': tdSql.query(f'select timetruncate(ts,{unit}) from {self.stbname}') + def data_check(self,date_time,precision,tb_type): for unit in self.time_unit: if (unit.lower() == '1u' and precision.lower() == 'ms') or (unit.lower() == '1b' and precision.lower() == 'us') or (unit.lower() == '1b' and precision.lower() == 'ms'): - if tb_type.lower() == 'ntb': + if tb_type.lower() == 'ntb': tdSql.error(f'select timetruncate(ts,{unit}) from {self.ntbname}') elif tb_type.lower() == 'ctb': tdSql.error(f'select timetruncate(ts,{unit}) from {self.ctbname}') @@ -139,16 +144,19 @@ class TDTestCase: tdSql.error(f'select timetruncate(ts,{unit}) from {self.ctbname}') elif tb_type.lower() == 'stb': tdSql.error(f'select timetruncate(ts,{unit}) from {self.stbname}') + def function_check_ntb(self): for precision in self.db_param_precision: tdSql.execute(f'drop database if exists {self.dbname}') tdSql.execute(f'create database {self.dbname} precision "{precision}"') + tdLog.info(f"=====now is in a {precision} database=====") tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create table {self.ntbname} (ts timestamp,c0 int)') for ts in self.ts_str: tdSql.execute(f'insert into {self.ntbname} values("{ts}",1)') date_time = self.get_time.time_transform(self.ts_str,precision) self.data_check(date_time,precision,'ntb') + def function_check_stb(self): for precision in self.db_param_precision: tdSql.execute(f'drop database if exists {self.dbname}') @@ -161,9 +169,11 @@ class TDTestCase: date_time = self.get_time.time_transform(self.ts_str,precision) self.data_check(date_time,precision,'ctb') self.data_check(date_time,precision,'stb') + def run(self): self.function_check_ntb() self.function_check_stb() + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 617f7e74643c9b1dbb24834e3535b4bac669e4bb..04a80a74ad2d6ec21a97dc17bba05fb02df3830b 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -22,7 +22,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def create_ctable(self,tsql=None, dbName='db',stbName='stb',ctbPrefix='ctb',ctbNum=1): tsql.execute("use %s" %dbName) @@ -32,16 +32,16 @@ class TDTestCase: for i in range(ctbNum): tagValue = 'beijing' if (i % 10 == 0): - sql += " %s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i)) + sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i)) else: model = 'H-%d'%i - sql += " %s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i)) + sql += f" {dbName}.%s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i)) if (i > 0) and (i%1000 == 0): tsql.execute(sql) sql = pre_create if sql != pre_create: tsql.execute(sql) - + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) return @@ -54,32 +54,32 @@ class TDTestCase: startTs = int(round(t * 1000)) for i in range(ctbNum): - sql += " %s%d values "%(ctbPrefix,i) + sql += f" {dbName}.%s%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): if(ctbPrefix=="rct"): sql += f"({startTs+j*60000}, {80+j}, {90+j}, {85+j}, {30+j*10}, {1.2*j}, {221+j*2}, {20+j*0.2}) " elif ( ctbPrefix=="dct"): status= random.randint(0,1) - sql += f"( {startTs+j*60000}, {1+j*0.1},{1400+j*15}, {status} ) " + sql += f"( {startTs+j*60000}, {1+j*0.1},{1400+j*15}, {status} ) " # tdLog.debug("1insert sql:%s"%sql) if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): # tdLog.debug("2insert sql:%s"%sql) tsql.execute(sql) if j < rowsPerTbl - 1: - sql = "insert into %s%d values " %(ctbPrefix,i) + sql = f"insert into {dbName}.%s%d values " %(ctbPrefix,i) else: sql = "insert into " if sql != pre_insert: # tdLog.debug("3insert sql:%s"%sql) - tsql.execute(sql) + tsql.execute(sql) tdLog.debug("insert data ............ [OK]") return def prepareData(self): dbname="db_tsbs" - stabname1="readings" - stabname2="diagnostics" - ctbnamePre1="rct" + stabname1=f"{dbname}.readings" + stabname2=f"{dbname}.diagnostics" + ctbnamePre1="rct" ctbnamePre2="dct" ctbNums=50 self.ctbNums=ctbNums @@ -107,7 +107,7 @@ class TDTestCase: # tdSql.execute(f"create table dct{i} using diagnostics (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}',NULL ,'v2.3')") # else: # tdSql.execute(f"create table dct{i} using diagnostics (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}','H-{i}','v2.3')") - # for j in range(ctbNums): + # for j in range(ctbNums): # for i in range(rowNUms): # tdSql.execute( # f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )" @@ -133,106 +133,106 @@ class TDTestCase: # tdLog.info("avg value check pass , it work as expected ,sql is \"%s\" "%check_query ) - def tsbsIotQuery(self,insertinto=True): - + def tsbsIotQuery(self,insertinto=True, dbname="db_tsbs"): + tdSql.execute("use db_tsbs") - + # test interval and partition - tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") + tdSql.query(f"select avg(velocity) as mean_velocity ,name,driver,fleet from {dbname}.readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ") parRows=tdSql.queryRows - tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") + tdSql.query(f"select avg(velocity) as mean_velocity ,name,driver,fleet from {dbname}.readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ") tdSql.checkRows(parRows) - - - # test insert into + + + # test insert into if insertinto == True : - tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") - tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") - - tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") + tdSql.execute(f"create table {dbname}.testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;") + tdSql.query(f"insert into {dbname}.testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet from {dbname}.readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") + + tdSql.query(f"insert into {dbname}.testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet from {dbname}.readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);") # test paitition interval fill - tdSql.query("SELECT name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0) ;") + tdSql.query(f"select name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv from {dbname}.readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0) ;") # test partition interval limit (PRcore-TD-17410) - tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings partition BY name,driver,fleet interval (10m) limit 1);") + tdSql.query(f"select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity from {dbname}.readings partition BY name,driver,fleet interval (10m) limit 1);") tdSql.checkRows(self.ctbNums) # test partition interval Pseudo time-column - tdSql.query("SELECT count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") + tdSql.query(f"select count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") # 1 high-load: - tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name desc, ts DESC;") + tdSql.query(f"select ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity from {dbname}.diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name desc, ts DESC;") - tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;") + tdSql.query(f"select ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity from {dbname}.diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;") - # 2 stationary-trucks - tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)") - tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name") + # 2 stationary-trucks + tdSql.query(f"select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity from {dbname}.readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)") + tdSql.query(f"select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity from {dbname}.readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name") # 3 long-driving-sessions - tdSql.query("SELECT name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT _wstart as ts,name,driver,avg(velocity) as mean_velocity FROM readings where ts > '2016-01-01T00:00:34Z' AND ts <= '2016-01-01T04:00:34Z' partition BY name,driver interval(10m)) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 22 ;") + tdSql.query(f"select name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT _wstart as ts,name,driver,avg(velocity) as mean_velocity from {dbname}.readings where ts > '2016-01-01T00:00:34Z' AND ts <= '2016-01-01T04:00:34Z' partition BY name,driver interval(10m)) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 22 ;") #4 long-daily-sessions - tdSql.query("SELECT name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT name,driver,avg(velocity) as mean_velocity FROM readings WHERE fleet ='West' AND ts > '2016-01-01T12:31:37Z' AND ts <= '2016-01-05T12:31:37Z' partition BY name,driver interval(10m) ) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 60") + tdSql.query(f"select name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT name,driver,avg(velocity) as mean_velocity from {dbname}.readings WHERE fleet ='West' AND ts > '2016-01-01T12:31:37Z' AND ts <= '2016-01-05T12:31:37Z' partition BY name,driver interval(10m) ) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 60") # 5. avg-daily-driving-duration - tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;") + tdSql.query(f"select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from {dbname}.readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;") - # # 6. avg-daily-driving-session + # # 6. avg-daily-driving-session # #taosc core dumped - tdSql.query(" SELECT _wstart as ts,name,floor(avg(velocity)/5) AS mv FROM readings WHERE name is not null AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0);") - # tdSql.query("select name,diff(mv) AS difka FROM (SELECT ts,name,mv FROM (SELECT _wstart as ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0))) group BY name ;") - # tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)") + tdSql.query(f"select _wstart as ts,name,floor(avg(velocity)/5) AS mv from {dbname}.readings WHERE name is not null AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0);") + # tdSql.query(f"select name,diff(mv) AS difka FROM (SELECT ts,name,mv FROM (SELECT _wstart as ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv from {dbname}.readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0))) group BY name ;") + # tdSql.query(f"select _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv from {dbname}.readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)") # 7. avg-load - tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;") + tdSql.query(f"select fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml from {dbname}.diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;") - # 8. daily-activity - tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") + # 8. daily-activity + tdSql.query(f"select model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") - tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") + tdSql.query(f"select model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;") - tdSql.query("SELECT _wstart,model,fleet,count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1 partition by model, fleet interval(1d) ;") + tdSql.query(f"select _wstart,model,fleet,count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1 partition by model, fleet interval(1d) ;") - tdSql.query("SELECT _wstart as ts,model,fleet,count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1 partition by model, fleet interval(1d) ;") + tdSql.query(f"select _wstart as ts,model,fleet,count(ms1)/144 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1 partition by model, fleet interval(1d) ;") # 9. breakdown-frequency # NULL ---count(NULL)=0 expect count(NULL)= 100 - tdSql.query("SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where model is null partition BY model,state_changed ") + tdSql.query(f"select model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where model is null partition BY model,state_changed ") parRows=tdSql.queryRows assert parRows != 0 , "query result is wrong, query rows %d but expect > 0 " %parRows - tdSql.query(" SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;") - sql="select model,ctc from (SELECT model,count(state_changed) as ctc FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= 1451606400000 AND ts < 1451952001000 ) WHERE ts >= 1451606400000 AND ts < 1451952001000 partition BY model interval(10m)) partition BY model) WHERE state_changed = 1 partition BY model )where model is null;" + tdSql.query(f"select model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;") + sql=f"select model,ctc from (SELECT model,count(state_changed) as ctc FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs from {dbname}.diagnostics WHERE ts >= 1451606400000 AND ts < 1451952001000 ) WHERE ts >= 1451606400000 AND ts < 1451952001000 partition BY model interval(10m)) partition BY model) WHERE state_changed = 1 partition BY model )where model is null;" # for i in range(2): # tdSql.query("%s"%sql) - # quertR1=tdSql.queryResult + # quertR1=tdSql.queryResult # for j in range(50): # tdSql.query("%s"%sql) # quertR2=tdSql.queryResult - # assert quertR1 == quertR2 , "%s != %s ,The results of multiple queries are different" %(quertR1,quertR2) + # assert quertR1 == quertR2 , "%s != %s ,The results of multiple queries are different" %(quertR1,quertR2) + - #it's already supported: # last-loc - tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;") + tdSql.query(f"select last_row(ts),latitude,longitude,name,driver from {dbname}.readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;") #2. low-fuel - tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;") - + tdSql.query(f"select last_row(ts),name,driver,fuel_state,driver from {dbname}.diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;") + # 3. avg-vs-projected-fuel-consumption - tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet") - - def run(self): + tdSql.query(f"select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from {dbname}.readings where velocity > 1 group by fleet") + + def run(self): tdLog.printNoPrefix("==========step1:create database and table,insert data ==============") self.prepareData() self.tsbsIotQuery() diff --git a/tests/system-test/2-query/ttl_comment.py b/tests/system-test/2-query/ttl_comment.py index 33bd61b66c85a2519513b9eee10bfcdaff8e8925..c26393158cefe46fb054d7bd3e28a621cab73199 100644 --- a/tests/system-test/2-query/ttl_comment.py +++ b/tests/system-test/2-query/ttl_comment.py @@ -26,20 +26,21 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) + tdSql.init(conn.cursor(), False) def run(self): + dbname="db" tdSql.prepare() - tdSql.error("create table ttl_table1(ts timestamp, i int) ttl 1.1") - tdSql.error("create table ttl_table2(ts timestamp, i int) ttl 1e1") - tdSql.error("create table ttl_table3(ts timestamp, i int) ttl -1") + tdSql.error(f"create table {dbname}.ttl_table1(ts timestamp, i int) ttl 1.1") + tdSql.error(f"create table {dbname}.ttl_table2(ts timestamp, i int) ttl 1e1") + tdSql.error(f"create table {dbname}.ttl_table3(ts timestamp, i int) ttl -1") print("============== STEP 1 ===== test normal table") - tdSql.execute("create table normal_table1(ts timestamp, i int)") - tdSql.execute("create table normal_table2(ts timestamp, i int) comment '' ttl 3") - tdSql.execute("create table normal_table3(ts timestamp, i int) ttl 2100000000020 comment 'hello'") + tdSql.execute(f"create table {dbname}.normal_table1(ts timestamp, i int)") + tdSql.execute(f"create table {dbname}.normal_table2(ts timestamp, i int) comment '' ttl 3") + tdSql.execute(f"create table {dbname}.normal_table3(ts timestamp, i int) ttl 2100000000020 comment 'hello'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') @@ -58,32 +59,32 @@ class TDTestCase: tdSql.checkData(0, 7, 2147483647) tdSql.checkData(0, 8, 'hello') - tdSql.execute("alter table normal_table1 comment 'nihao'") + tdSql.execute(f"alter table {dbname}.normal_table1 comment 'nihao'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') tdSql.checkData(0, 8, 'nihao') - tdSql.execute("alter table normal_table1 comment ''") + tdSql.execute(f"alter table {dbname}.normal_table1 comment ''") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') tdSql.checkData(0, 8, '') - tdSql.execute("alter table normal_table2 comment 'fly'") + tdSql.execute(f"alter table {dbname}.normal_table2 comment 'fly'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table2'") tdSql.checkData(0, 0, 'normal_table2') tdSql.checkData(0, 8, 'fly') - tdSql.execute("alter table normal_table3 comment 'fly'") + tdSql.execute(f"alter table {dbname}.normal_table3 comment 'fly'") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table3'") tdSql.checkData(0, 0, 'normal_table3') tdSql.checkData(0, 8, 'fly') - tdSql.execute("alter table normal_table1 ttl 1") + tdSql.execute(f"alter table {dbname}.normal_table1 ttl 1") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table1'") tdSql.checkData(0, 0, 'normal_table1') tdSql.checkData(0, 7, 1) - tdSql.execute("alter table normal_table3 ttl 0") + tdSql.execute(f"alter table {dbname}.normal_table3 ttl 0") tdSql.query("select * from information_schema.ins_tables where table_name like 'normal_table3'") tdSql.checkData(0, 0, 'normal_table3') tdSql.checkData(0, 7, 0) @@ -91,9 +92,9 @@ class TDTestCase: print("============== STEP 2 ===== test super table") - tdSql.execute("create table super_table1(ts timestamp, i int) tags(t int)") - tdSql.execute("create table super_table2(ts timestamp, i int) tags(t int) comment ''") - tdSql.execute("create table super_table3(ts timestamp, i int) tags(t int) comment 'super'") + tdSql.execute(f"create table {dbname}.super_table1(ts timestamp, i int) tags(t int)") + tdSql.execute(f"create table {dbname}.super_table2(ts timestamp, i int) tags(t int) comment ''") + tdSql.execute(f"create table {dbname}.super_table3(ts timestamp, i int) tags(t int) comment 'super'") tdSql.query("select * from information_schema.ins_stables where stable_name like 'super_table1'") tdSql.checkData(0, 0, 'super_table1') @@ -110,32 +111,32 @@ class TDTestCase: tdSql.checkData(0, 6, 'super') - tdSql.execute("alter table super_table1 comment 'nihao'") + tdSql.execute(f"alter table {dbname}.super_table1 comment 'nihao'") tdSql.query("select * from information_schema.ins_stables where stable_name like 'super_table1'") tdSql.checkData(0, 0, 'super_table1') tdSql.checkData(0, 6, 'nihao') - tdSql.execute("alter table super_table1 comment ''") + tdSql.execute(f"alter table {dbname}.super_table1 comment ''") tdSql.query("select * from information_schema.ins_stables where stable_name like 'super_table1'") tdSql.checkData(0, 0, 'super_table1') tdSql.checkData(0, 6, '') - tdSql.execute("alter table super_table2 comment 'fly'") + tdSql.execute(f"alter table {dbname}.super_table2 comment 'fly'") tdSql.query("select * from information_schema.ins_stables where stable_name like 'super_table2'") tdSql.checkData(0, 0, 'super_table2') tdSql.checkData(0, 6, 'fly') - tdSql.execute("alter table super_table3 comment 'tdengine'") + tdSql.execute(f"alter table {dbname}.super_table3 comment 'tdengine'") tdSql.query("select * from information_schema.ins_stables where stable_name like 'super_table3'") tdSql.checkData(0, 0, 'super_table3') tdSql.checkData(0, 6, 'tdengine') print("============== STEP 3 ===== test child table") - tdSql.execute("create table child_table1 using super_table1 tags(1) ttl 10") - tdSql.execute("create table child_table2 using super_table1 tags(1) comment ''") - tdSql.execute("create table child_table3 using super_table1 tags(1) comment 'child'") - tdSql.execute("insert into child_table4 using super_table1 tags(1) values(now, 1)") + tdSql.execute(f"create table {dbname}.child_table1 using {dbname}.super_table1 tags(1) ttl 10") + tdSql.execute(f"create table {dbname}.child_table2 using {dbname}.super_table1 tags(1) comment ''") + tdSql.execute(f"create table {dbname}.child_table3 using {dbname}.super_table1 tags(1) comment 'child'") + tdSql.execute(f"insert into {dbname}.child_table4 using {dbname}.super_table1 tags(1) values(now, 1)") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'") @@ -160,38 +161,38 @@ class TDTestCase: tdSql.checkData(0, 8, None) - tdSql.execute("alter table child_table1 comment 'nihao'") + tdSql.execute(f"alter table {dbname}.child_table1 comment 'nihao'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'") tdSql.checkData(0, 0, 'child_table1') tdSql.checkData(0, 8, 'nihao') - tdSql.execute("alter table child_table1 comment ''") + tdSql.execute(f"alter table {dbname}.child_table1 comment ''") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table1'") tdSql.checkData(0, 0, 'child_table1') tdSql.checkData(0, 8, '') - tdSql.execute("alter table child_table2 comment 'fly'") + tdSql.execute(f"alter table {dbname}.child_table2 comment 'fly'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table2'") tdSql.checkData(0, 0, 'child_table2') tdSql.checkData(0, 8, 'fly') - tdSql.execute("alter table child_table3 comment 'tdengine'") + tdSql.execute(f"alter table {dbname}.child_table3 comment 'tdengine'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table3'") tdSql.checkData(0, 0, 'child_table3') tdSql.checkData(0, 8, 'tdengine') - tdSql.execute("alter table child_table4 comment 'tdengine'") + tdSql.execute(f"alter table {dbname}.child_table4 comment 'tdengine'") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table4'") tdSql.checkData(0, 0, 'child_table4') tdSql.checkData(0, 8, 'tdengine') - tdSql.execute("alter table child_table4 ttl 9") + tdSql.execute(f"alter table {dbname}.child_table4 ttl 9") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table4'") tdSql.checkData(0, 0, 'child_table4') tdSql.checkData(0, 7, 9) - tdSql.execute("alter table child_table3 ttl 9") + tdSql.execute(f"alter table {dbname}.child_table3 ttl 9") tdSql.query("select * from information_schema.ins_tables where table_name like 'child_table3'") tdSql.checkData(0, 0, 'child_table3') tdSql.checkData(0, 7, 9) @@ -203,4 +204,3 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) - diff --git a/tests/system-test/2-query/twa.py b/tests/system-test/2-query/twa.py index 8281527bd46be8f1b14d6ee2098a2888c20a737a..62940477cf701d69e8c8e7568ae4b56d68518d81 100644 --- a/tests/system-test/2-query/twa.py +++ b/tests/system-test/2-query/twa.py @@ -7,10 +7,7 @@ import platform import math class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143, - "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -21,46 +18,45 @@ class TDTestCase: self.row_nums = 100 self.time_step = 1000 - def prepare_datas_of_distribute(self): + def prepare_datas_of_distribute(self, dbname="testdb"): # prepate datas for 20 tables distributed at different vgroups - tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") - tdSql.execute(" use testdb ") + tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) ''' ) for i in range(self.tb_nums): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + 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}" )') ts = self.ts for j in range(self.row_nums): ts+=j*self.time_step tdSql.execute( - f"insert into ct{i+1} values({ts}, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary{j}', 'nchar{j}', now()+{1*j}a )" + f"insert into {dbname}.ct{i+1} values({ts}, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary{j}', 'nchar{j}', now()+{1*j}a )" ) - tdSql.execute("insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdLog.info(" prepare data for distributed_aggregate done! ") - def twa_support_types(self): - tdSql.query("desc stb1 ") + def twa_support_types(self, dbname="testdb"): + tdSql.query(f"desc {dbname}.stb1 ") schema_list = tdSql.queryResult for col_type in schema_list: if col_type[1] in ["TINYINT" ,"SMALLINT","BIGINT" ,"INT","FLOAT","DOUBLE"]: - tdSql.query(f" select twa({col_type[0]}) from stb1 partition by tbname ") + tdSql.query(f"select twa({col_type[0]}) from {dbname}.stb1 partition by tbname ") else: - tdSql.error(f" select twa({col_type[0]}) from stb1 partition by tbname ") + tdSql.error(f"select twa({col_type[0]}) from {dbname}.stb1 partition by tbname ") - def check_distribute_datas(self): + def check_distribute_datas(self, dbname="testdb"): # get vgroup_ids of all - tdSql.query("show vgroups ") + tdSql.query(f"show {dbname}.vgroups ") vgroups = tdSql.queryResult vnode_tables={} @@ -69,7 +65,7 @@ class TDTestCase: vnode_tables[vgroup_id[0]]=[] # check sub_table of per vnode ,make sure sub_table has been distributed - tdSql.query(f"select * from information_schema.ins_tables where db_name = 'testdb' and table_name like 'ct%'") + tdSql.query(f"select * from information_schema.ins_tables where db_name = '{dbname}' and table_name like 'ct%'") table_names = tdSql.queryResult tablenames = [] for table_name in table_names: @@ -83,28 +79,28 @@ class TDTestCase: if count < 2: tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") - def distribute_twa_query(self): + def distribute_twa_query(self, dbname="testdb"): # basic filter - tdSql.query(" select twa(c1) from ct1 ") + tdSql.query(f"select twa(c1) from {dbname}.ct1 ") tdSql.checkData(0,0,1.000000000) - tdSql.query(" select twa(c1) from stb1 partition by tbname ") + tdSql.query(f"select twa(c1) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,1.000000000) - tdSql.query(" select twa(c2) from stb1 group by tbname ") + tdSql.query(f"select twa(c2) from {dbname}.stb1 group by tbname ") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,11111.000000000) - tdSql.query("select twa(c1+c2) from stb1 partition by tbname ") + tdSql.query(f"select twa(c1+c2) from {dbname}.stb1 partition by tbname ") tdSql.checkData(0,0,11112.000000000) - tdSql.query("select twa(c1) from stb1 partition by t1") + tdSql.query(f"select twa(c1) from {dbname}.stb1 partition by t1") tdSql.checkRows(self.tb_nums) tdSql.checkData(0,0,1.000000000) # union all - tdSql.query(" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname ") + tdSql.query(f"select twa(c1) from {dbname}.stb1 partition by tbname union all select twa(c1) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(40) tdSql.checkData(0,0,1.000000000) @@ -112,26 +108,23 @@ class TDTestCase: tdSql.execute(" create database if not exists db ") tdSql.execute(" use db ") - tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") - tdSql.execute(" create table tb1 using st tags(1) ") - tdSql.execute(" create table tb2 using st tags(2) ") + tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table db.tb1 using db.st tags(1) ") + tdSql.execute(" create table db.tb2 using db.st tags(2) ") for i in range(10): ts = i*10 + self.ts - tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") - tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)") - tdSql.query(" select twa(tb1.c1), twa(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts ") + tdSql.query(f"select twa(tb1.c1), twa(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts ") tdSql.checkRows(1) tdSql.checkData(0,0,4.500000000) tdSql.checkData(0,1,4.500000000) - # group by - tdSql.execute(" use testdb ") - # mixup with other functions - tdSql.query(" select twa(c1),twa(c2),max(c1),elapsed(ts) from stb1 ") + tdSql.query(f"select twa(c1),twa(c2),max(c1),elapsed(ts) from {dbname}.stb1 ") tdSql.checkData(0,0,1.000000000) tdSql.checkData(0,1,11111.000000000) tdSql.checkData(0,2,1) diff --git a/tests/system-test/2-query/union.py b/tests/system-test/2-query/union.py index 88767ab888c9bfe11c329eecd41f78442436cafb..4040bb71cbb92849dd63d11627c93a2954a4a0d1 100644 --- a/tests/system-test/2-query/union.py +++ b/tests/system-test/2-query/union.py @@ -58,10 +58,10 @@ class TDTestCase: def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False): table_reference = tb_list[0] - join_condition = table_reference + join_condition = f'{table_reference} {table_reference.split(".")[-1]}' join = "inner join" if INNER else "join" for i in range(len(tb_list[1:])): - join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}" + join_condition += f" {join} {tb_list[i+1]} {tb_list[i+1].split('.')[-1]} on {table_reference.split('.')[-1]}.{filter}={tb_list[i+1].split('.')[-1]}.{filter}" return join_condition @@ -76,7 +76,6 @@ class TDTestCase: elif query_conditon.startswith("min"): query_conditon = query_conditon[4:-1] - if query_conditon: return f" where {query_conditon} is not null" if col in NUM_COL: @@ -108,10 +107,10 @@ class TDTestCase: return f"select {select_clause} from {from_clause} {where_condition} {group_condition}" @property - def __join_tblist(self): + def __join_tblist(self, dbname="db"): return [ - ["ct1", "t1"], - ["ct4", "t1"], + [f"{dbname}.ct1", f"{dbname}.t1"], + [f"{dbname}.ct4", f"{dbname}.t1"], # ["ct1", "ct2", "ct4"], # ["ct1", "ct2", "t1"], # ["ct1", "ct4", "t1"], @@ -120,10 +119,10 @@ class TDTestCase: ] @property - def __tb_liast(self): + def __tb_list(self, dbname="db"): return [ - "ct1", - "ct4", + f"{dbname}.ct1", + f"{dbname}.ct4", ] def sql_list(self): @@ -131,7 +130,8 @@ class TDTestCase: __join_tblist = self.__join_tblist for join_tblist in __join_tblist: for join_tb in join_tblist: - select_claus_list = self.__query_condition(join_tb) + join_tb_name = join_tb.split(".")[-1] + select_claus_list = self.__query_condition(join_tb_name) for select_claus in select_claus_list: group_claus = self.__group_condition( col=select_claus) where_claus = self.__where_condition(query_conditon=select_claus) @@ -141,9 +141,10 @@ class TDTestCase: self.__single_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, having_claus), ) ) - __no_join_tblist = self.__tb_liast + __no_join_tblist = self.__tb_list for tb in __no_join_tblist: - select_claus_list = self.__query_condition(tb) + tb_name = join_tb.split(".")[-1] + select_claus_list = self.__query_condition(tb_name) for select_claus in select_claus_list: group_claus = self.__group_condition(col=select_claus) where_claus = self.__where_condition(query_conditon=select_claus) @@ -230,31 +231,29 @@ class TDTestCase: else: tdSql.error(f"{sqls[i]} union {sqls[j+i]}") - def __test_error(self): + def __test_error(self, dbname="db"): - tdSql.error( "show tables union show tables" ) - tdSql.error( "create table errtb1 union all create table errtb2" ) - tdSql.error( "drop table ct1 union all drop table ct3" ) - tdSql.error( "select c1 from ct1 union all drop table ct3" ) - tdSql.error( "select c1 from ct1 union all '' " ) - tdSql.error( " '' union all select c1 from ct1 " ) - # tdSql.error( "select c1 from ct1 union select c1 from ct2 union select c1 from ct4 ") + tdSql.error( f"show {dbname}.tables union show {dbname}.tables" ) + tdSql.error( f"create table {dbname}.errtb1 union all create table {dbname}.errtb2" ) + tdSql.error( f"drop table {dbname}.ct1 union all drop table {dbname}.ct3" ) + tdSql.error( f"select c1 from {dbname}.ct1 union all drop table {dbname}.ct3" ) + tdSql.error( f"select c1 from {dbname}.ct1 union all '' " ) + tdSql.error( f" '' union all select c1 from{dbname}. ct1 " ) def all_test(self): self.__test_error() self.union_check() - - def __create_tb(self): + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -264,30 +263,29 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values + f'''insert into {dbname}.ct1 values ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -303,7 +301,7 @@ class TDTestCase: ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -319,13 +317,13 @@ class TDTestCase: ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) @@ -341,7 +339,6 @@ class TDTestCase: ''' ) - def run(self): tdSql.prepare() @@ -355,8 +352,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index ccf7e287e27d7768acedc17b55969d1fab6d30cd..ec77cbbcdc9d83d0a63b54fbe377c14d8645ce52 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -11,49 +11,46 @@ from util.sql import * from util.cases import * class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) - def prepare_datas(self): + def prepare_datas(self, dbname="db"): tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') for i in range(9): tdSql.execute( - f"insert into 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 )" + 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 )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) @@ -69,84 +66,84 @@ class TDTestCase: ''' ) - def test_errors(self): + def test_errors(self, dbname="db"): error_sql_lists = [ - "select unique from t1", - "select unique(123--123)==1 from t1", - "select unique(123,123) from t1", - "select unique(c1,ts) from t1", - "select unique(c1,c1,ts) from t1", - "select unique(c1) as 'd1' from t1", - "select unique(c1 ,c2 ) from t1", - "select unique(c1 ,NULL) from t1", - "select unique(,) from t1;", - "select unique(floor(c1) ab from t1)", - "select unique(c1) as int from t1", - "select unique('c1') from t1", - "select unique(NULL) from t1", - "select unique('') from t1", - "select unique(c%) from t1", - "select unique(t1) from t1", - "select unique(True) from t1", - "select unique(c1) , count(c1) from t1", - "select unique(c1) , avg(c1) from t1", - "select unique(c1) , min(c1) from t1", - "select unique(c1) , spread(c1) from t1", - "select unique(c1) , diff(c1) from t1", - #"select unique(c1) , abs(c1) from t1", # support - #"select unique(c1) , c1 from t1", - "select unique from stb1 partition by tbname", - "select unique(123--123)==1 from stb1 partition by tbname", - "select unique(123) from stb1 partition by tbname", - "select unique(c1,ts) from stb1 partition by tbname", - "select unique(c1,c1,ts) from stb1 partition by tbname", - "select unique(c1) as 'd1' from stb1 partition by tbname", - "select unique(c1 ,c2 ) from stb1 partition by tbname", - "select unique(c1 ,NULL) from stb1 partition by tbname", - "select unique(,) from stb1 partition by tbname;", - #"select unique(floor(c1) ab from stb1 partition by tbname)", # support - #"select unique(c1) as int from stb1 partition by tbname", - "select unique('c1') from stb1 partition by tbname", - "select unique(NULL) from stb1 partition by tbname", - "select unique('') from stb1 partition by tbname", - "select unique(c%) from stb1 partition by tbname", - #"select unique(t1) from stb1 partition by tbname", # support - "select unique(True) from stb1 partition by tbname", - "select unique(c1) , count(c1) from stb1 partition by tbname", - "select unique(c1) , avg(c1) from stb1 partition by tbname", - "select unique(c1) , min(c1) from stb1 partition by tbname", - "select unique(c1) , spread(c1) from stb1 partition by tbname", - "select unique(c1) , diff(c1) from stb1 partition by tbname", - #"select unique(c1) , abs(c1) from stb1 partition by tbname", # support - #"select unique(c1) , c1 from stb1 partition by tbname" # support + f"select unique from {dbname}.t1", + f"select unique(123--123)==1 from {dbname}.t1", + f"select unique(123,123) from {dbname}.t1", + f"select unique(c1,ts) from {dbname}.t1", + f"select unique(c1,c1,ts) from {dbname}.t1", + f"select unique(c1) as 'd1' from {dbname}.t1", + f"select unique(c1 ,c2 ) from {dbname}.t1", + f"select unique(c1 ,NULL) from {dbname}.t1", + f"select unique(,) from {dbname}.t1;", + f"select unique(floor(c1) ab from {dbname}.t1)", + f"select unique(c1) as int from {dbname}.t1", + f"select unique('c1') from {dbname}.t1", + f"select unique(NULL) from {dbname}.t1", + f"select unique('') from {dbname}.t1", + f"select unique(c%) from {dbname}.t1", + f"select unique(t1) from {dbname}.t1", + f"select unique(True) from {dbname}.t1", + f"select unique(c1) , count(c1) from {dbname}.t1", + f"select unique(c1) , avg(c1) from {dbname}.t1", + f"select unique(c1) , min(c1) from {dbname}.t1", + f"select unique(c1) , spread(c1) from {dbname}.t1", + f"select unique(c1) , diff(c1) from {dbname}.t1", + #f"select unique(c1) , abs(c1) from {dbname}.t1", # support + #f"select unique(c1) , c1 from {dbname}.t1", + f"select unique from {dbname}.stb1 partition by tbname", + f"select unique(123--123)==1 from {dbname}.stb1 partition by tbname", + f"select unique(123) from {dbname}.stb1 partition by tbname", + f"select unique(c1,ts) from {dbname}.stb1 partition by tbname", + f"select unique(c1,c1,ts) from {dbname}.stb1 partition by tbname", + f"select unique(c1) as 'd1' from {dbname}.stb1 partition by tbname", + f"select unique(c1 ,c2 ) from {dbname}.stb1 partition by tbname", + f"select unique(c1 ,NULL) from {dbname}.stb1 partition by tbname", + f"select unique(,) from {dbname}.stb1 partition by tbname;", + #f"select unique(floor(c1) ab from {dbname}.stb1 partition by tbname)", # support + #f"select unique(c1) as int from {dbname}.stb1 partition by tbname", + f"select unique('c1') from {dbname}.stb1 partition by tbname", + f"select unique(NULL) from {dbname}.stb1 partition by tbname", + f"select unique('') from {dbname}.stb1 partition by tbname", + f"select unique(c%) from {dbname}.stb1 partition by tbname", + #f"select unique(t1) from {dbname}.stb1 partition by tbname", # support + f"select unique(True) from {dbname}.stb1 partition by tbname", + f"select unique(c1) , count(c1) from {dbname}.stb1 partition by tbname", + f"select unique(c1) , avg(c1) from {dbname}.stb1 partition by tbname", + f"select unique(c1) , min(c1) from {dbname}.stb1 partition by tbname", + f"select unique(c1) , spread(c1) from {dbname}.stb1 partition by tbname", + f"select unique(c1) , diff(c1) from {dbname}.stb1 partition by tbname", + #f"select unique(c1) , abs(c1) from {dbname}.stb1 partition by tbname", # support + #f"select unique(c1) , c1 from {dbname}.stb1 partition by tbname" # support ] for error_sql in error_sql_lists: tdSql.error(error_sql) pass - def support_types(self): + def support_types(self, dbname="db"): other_no_value_types = [ - "select unique(ts) from t1" , - "select unique(c7) from t1", - "select unique(c8) from t1", - "select unique(c9) from t1", - "select unique(ts) from ct1" , - "select unique(c7) from ct1", - "select unique(c8) from ct1", - "select unique(c9) from ct1", - "select unique(ts) from ct3" , - "select unique(c7) from ct3", - "select unique(c8) from ct3", - "select unique(c9) from ct3", - "select unique(ts) from ct4" , - "select unique(c7) from ct4", - "select unique(c8) from ct4", - "select unique(c9) from ct4", - "select unique(ts) from stb1 partition by tbname" , - "select unique(c7) from stb1 partition by tbname", - "select unique(c8) from stb1 partition by tbname", - "select unique(c9) from stb1 partition by tbname" + f"select unique(ts) from {dbname}.t1" , + f"select unique(c7) from {dbname}.t1", + f"select unique(c8) from {dbname}.t1", + f"select unique(c9) from {dbname}.t1", + f"select unique(ts) from {dbname}.ct1" , + f"select unique(c7) from {dbname}.ct1", + f"select unique(c8) from {dbname}.ct1", + f"select unique(c9) from {dbname}.ct1", + f"select unique(ts) from {dbname}.ct3" , + f"select unique(c7) from {dbname}.ct3", + f"select unique(c8) from {dbname}.ct3", + f"select unique(c9) from {dbname}.ct3", + f"select unique(ts) from {dbname}.ct4" , + f"select unique(c7) from {dbname}.ct4", + f"select unique(c8) from {dbname}.ct4", + f"select unique(c9) from {dbname}.ct4", + f"select unique(ts) from {dbname}.stb1 partition by tbname" , + f"select unique(c7) from {dbname}.stb1 partition by tbname", + f"select unique(c8) from {dbname}.stb1 partition by tbname", + f"select unique(c9) from {dbname}.stb1 partition by tbname" ] for type_sql in other_no_value_types: @@ -154,43 +151,43 @@ class TDTestCase: tdLog.info("support type ok , sql is : %s"%type_sql) type_sql_lists = [ - "select unique(c1) from t1", - "select unique(c2) from t1", - "select unique(c3) from t1", - "select unique(c4) from t1", - "select unique(c5) from t1", - "select unique(c6) from t1", - - "select unique(c1) from ct1", - "select unique(c2) from ct1", - "select unique(c3) from ct1", - "select unique(c4) from ct1", - "select unique(c5) from ct1", - "select unique(c6) from ct1", - - "select unique(c1) from ct3", - "select unique(c2) from ct3", - "select unique(c3) from ct3", - "select unique(c4) from ct3", - "select unique(c5) from ct3", - "select unique(c6) from ct3", - - "select unique(c1) from stb1 partition by tbname", - "select unique(c2) from stb1 partition by tbname", - "select unique(c3) from stb1 partition by tbname", - "select unique(c4) from stb1 partition by tbname", - "select unique(c5) from stb1 partition by tbname", - "select unique(c6) from stb1 partition by tbname", - - "select unique(c6) as alisb from stb1 partition by tbname", - "select unique(c6) alisb from stb1 partition by tbname", + f"select unique(c1) from {dbname}.t1", + f"select unique(c2) from {dbname}.t1", + f"select unique(c3) from {dbname}.t1", + f"select unique(c4) from {dbname}.t1", + f"select unique(c5) from {dbname}.t1", + f"select unique(c6) from {dbname}.t1", + + f"select unique(c1) from {dbname}.ct1", + f"select unique(c2) from {dbname}.ct1", + f"select unique(c3) from {dbname}.ct1", + f"select unique(c4) from {dbname}.ct1", + f"select unique(c5) from {dbname}.ct1", + f"select unique(c6) from {dbname}.ct1", + + f"select unique(c1) from {dbname}.ct3", + f"select unique(c2) from {dbname}.ct3", + f"select unique(c3) from {dbname}.ct3", + f"select unique(c4) from {dbname}.ct3", + f"select unique(c5) from {dbname}.ct3", + f"select unique(c6) from {dbname}.ct3", + + f"select unique(c1) from {dbname}.stb1 partition by tbname", + f"select unique(c2) from {dbname}.stb1 partition by tbname", + f"select unique(c3) from {dbname}.stb1 partition by tbname", + f"select unique(c4) from {dbname}.stb1 partition by tbname", + f"select unique(c5) from {dbname}.stb1 partition by tbname", + f"select unique(c6) from {dbname}.stb1 partition by tbname", + + f"select unique(c6) as alisb from {dbname}.stb1 partition by tbname", + f"select unique(c6) alisb from {dbname}.stb1 partition by tbname", ] for type_sql in type_sql_lists: tdSql.query(type_sql) def check_unique_table(self , unique_sql): - # unique_sql = "select unique(c1) from ct1" + # unique_sql = f"select unique(c1) from {dbname}.ct1" origin_sql = unique_sql.replace("unique(","").replace(")","") tdSql.query(unique_sql) unique_result = tdSql.queryResult @@ -219,83 +216,83 @@ class TDTestCase: else: tdLog.exit(" unique query check fail , unique sql is: %s " %unique_sql) - def basic_unique_function(self): + def basic_unique_function(self, dbname="db"): # basic query - tdSql.query("select c1 from ct3") + tdSql.query(f"select c1 from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select c1 from t1") + tdSql.query(f"select c1 from {dbname}.t1") tdSql.checkRows(12) - tdSql.query("select c1 from stb1") + tdSql.query(f"select c1 from {dbname}.stb1") tdSql.checkRows(25) # used for empty table , ct3 is empty - tdSql.query("select unique(c1) from ct3") + tdSql.query(f"select unique(c1) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select unique(c2) from ct3") + tdSql.query(f"select unique(c2) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select unique(c3) from ct3") + tdSql.query(f"select unique(c3) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select unique(c4) from ct3") + tdSql.query(f"select unique(c4) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select unique(c5) from ct3") + tdSql.query(f"select unique(c5) from {dbname}.ct3") tdSql.checkRows(0) - tdSql.query("select unique(c6) from ct3") + tdSql.query(f"select unique(c6) from {dbname}.ct3") # will support _rowts mix with - # tdSql.query("select unique(c6),_rowts from ct3") + # tdSql.query(f"select unique(c6),_rowts from {dbname}.ct3") # auto check for t1 table # used for regular table - tdSql.query("select unique(c1) from t1") + tdSql.query(f"select unique(c1) from {dbname}.t1") - tdSql.query("desc t1") + tdSql.query(f"desc {dbname}.t1") col_lists_rows = tdSql.queryResult col_lists = [] for col_name in col_lists_rows: col_lists.append(col_name[0]) for col in col_lists: - self.check_unique_table(f"select unique({col}) from t1") + self.check_unique_table(f"select unique({col}) from {dbname}.t1") # unique with super tags - tdSql.query("select unique(c1) from ct1") + tdSql.query(f"select unique(c1) from {dbname}.ct1") tdSql.checkRows(10) - tdSql.query("select unique(c1) from ct4") + tdSql.query(f"select unique(c1) from {dbname}.ct4") tdSql.checkRows(10) - #tdSql.error("select unique(c1),tbname from ct1") #support - #tdSql.error("select unique(c1),t1 from ct1") #support + #tdSql.error(f"select unique(c1),tbname from {dbname}.ct1") #support + #tdSql.error(f"select unique(c1),t1 from {dbname}.ct1") #support # unique with common col - #tdSql.error("select unique(c1) ,ts from ct1") - #tdSql.error("select unique(c1) ,c1 from ct1") + #tdSql.error(f"select unique(c1) ,ts from {dbname}.ct1") + #tdSql.error(f"select unique(c1) ,c1 from {dbname}.ct1") # unique with scalar function - #tdSql.error("select unique(c1) ,abs(c1) from ct1") - tdSql.error("select unique(c1) , unique(c2) from ct1") - #tdSql.error("select unique(c1) , abs(c2)+2 from ct1") + #tdSql.error(f"select unique(c1) ,abs(c1) from {dbname}.ct1") + tdSql.error(f"select unique(c1) , unique(c2) from {dbname}.ct1") + #tdSql.error(f"select unique(c1) , abs(c2)+2 from {dbname}.ct1") # unique with aggregate function - tdSql.error("select unique(c1) ,sum(c1) from ct1") - tdSql.error("select unique(c1) ,max(c1) from ct1") - tdSql.error("select unique(c1) ,csum(c1) from ct1") - tdSql.error("select unique(c1) ,count(c1) from ct1") + tdSql.error(f"select unique(c1) ,sum(c1) from {dbname}.ct1") + tdSql.error(f"select unique(c1) ,max(c1) from {dbname}.ct1") + tdSql.error(f"select unique(c1) ,csum(c1) from {dbname}.ct1") + tdSql.error(f"select unique(c1) ,count(c1) from {dbname}.ct1") # unique with filter where - tdSql.query("select unique(c1) from ct4 where c1 is null") + tdSql.query(f"select unique(c1) from {dbname}.ct4 where c1 is null") tdSql.checkData(0, 0, None) - tdSql.query("select unique(c1) from ct4 where c1 >2 order by 1") + tdSql.query(f"select unique(c1) from {dbname}.ct4 where c1 >2 order by 1") tdSql.checkData(0, 0, 3) tdSql.checkData(1, 0, 4) tdSql.checkData(2, 0, 5) tdSql.checkData(5, 0, 8) - tdSql.query("select unique(c1) from ct4 where c2 between 0 and 99999 order by 1 desc") + tdSql.query(f"select unique(c1) from {dbname}.ct4 where c2 between 0 and 99999 order by 1 desc") tdSql.checkData(0, 0, 8) tdSql.checkData(1, 0, 7) tdSql.checkData(2, 0, 6) @@ -307,43 +304,43 @@ class TDTestCase: tdSql.checkData(8, 0, 0) # unique with union all - tdSql.query("select unique(c1) from ct4 union all select c1 from ct1") + tdSql.query(f"select unique(c1) from {dbname}.ct4 union all select c1 from {dbname}.ct1") tdSql.checkRows(23) - tdSql.query("select unique(c1) from ct4 union all select distinct(c1) from ct4") + tdSql.query(f"select unique(c1) from {dbname}.ct4 union all select distinct(c1) from {dbname}.ct4") tdSql.checkRows(20) - tdSql.query("select unique(c2) from ct4 union all select abs(c2)/2 from ct4") + tdSql.query(f"select unique(c2) from {dbname}.ct4 union all select abs(c2)/2 from {dbname}.ct4") tdSql.checkRows(22) # unique with join # prepare join datas with same ts tdSql.execute(" use db ") - tdSql.execute(" create stable st1 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table tb1 using st1 tags(1)") - tdSql.execute(" create table tb2 using st1 tags(2)") + tdSql.execute(" create stable db.st1 (ts timestamp , num int) tags(ind int)") + tdSql.execute(" create table db.tb1 using db.st1 tags(1)") + tdSql.execute(" create table db.tb2 using db.st1 tags(2)") - tdSql.execute(" create stable st2 (ts timestamp , num int) tags(ind int)") - tdSql.execute(" create table ttb1 using st2 tags(1)") - tdSql.execute(" create table ttb2 using st2 tags(2)") + tdSql.execute(" create stable db.st2 (ts timestamp , num int) tags(ind int)") + tdSql.execute(" create table db.ttb1 using db.st2 tags(1)") + tdSql.execute(" create table db.ttb2 using db.st2 tags(2)") start_ts = 1622369635000 # 2021-05-30 18:13:55 for i in range(10): ts_value = start_ts+i*1000 - tdSql.execute(f" insert into tb1 values({ts_value} , {i})") - tdSql.execute(f" insert into tb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.tb2 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb1 values({ts_value} , {i})") - tdSql.execute(f" insert into ttb2 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb1 values({ts_value} , {i})") + tdSql.execute(f" insert into {dbname}.ttb2 values({ts_value} , {i})") - tdSql.query("select unique(tb2.num) from tb1, tb2 where tb1.ts=tb2.ts order by 1") + tdSql.query(f"select unique(tb2.num) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts order by 1") tdSql.checkRows(10) tdSql.checkData(0,0,0) tdSql.checkData(1,0,1) tdSql.checkData(2,0,2) tdSql.checkData(9,0,9) - tdSql.query("select unique(tb2.num) from tb1, tb2 where tb1.ts=tb2.ts union all select unique(tb1.num) from tb1, tb2 where tb1.ts=tb2.ts order by 1") + tdSql.query(f"select unique(tb2.num) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts union all select unique(tb1.num) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts order by 1") tdSql.checkRows(20) tdSql.checkData(0,0,0) tdSql.checkData(2,0,1) @@ -351,23 +348,23 @@ class TDTestCase: tdSql.checkData(18,0,9) # nest query - # tdSql.query("select unique(c1) from (select c1 from ct1)") - tdSql.query("select c1 from (select unique(c1) c1 from ct4) order by 1 desc nulls first") + # tdSql.query(f"select unique(c1) from (select c1 from {dbname}.ct1)") + tdSql.query(f"select c1 from (select unique(c1) c1 from {dbname}.ct4) order by 1 desc nulls first") tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, 8) tdSql.checkData(9, 0, 0) - tdSql.query("select sum(c1) from (select unique(c1) c1 from ct1)") + tdSql.query(f"select sum(c1) from (select unique(c1) c1 from {dbname}.ct1)") tdSql.checkRows(1) tdSql.checkData(0, 0, 45) - tdSql.query("select sum(c1) from (select distinct(c1) c1 from ct1) union all select sum(c1) from (select unique(c1) c1 from ct1)") + tdSql.query(f"select sum(c1) from (select distinct(c1) c1 from {dbname}.ct1) union all select sum(c1) from (select unique(c1) c1 from {dbname}.ct1)") tdSql.checkRows(2) tdSql.checkData(0, 0, 45) tdSql.checkData(1, 0, 45) - tdSql.query("select 1-abs(c1) from (select unique(c1) c1 from ct4) order by 1 nulls first") + tdSql.query(f"select 1-abs(c1) from (select unique(c1) c1 from {dbname}.ct4) order by 1 nulls first") tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, -7.000000000) @@ -375,104 +372,103 @@ class TDTestCase: # bug for stable #partition by tbname - # tdSql.query(" select unique(c1) from stb1 partition by tbname ") + # tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ") # tdSql.checkRows(21) - # tdSql.query(" select unique(c1) from stb1 partition by tbname ") + # tdSql.query(f"select unique(c1) from {dbname}.stb1 partition by tbname ") # tdSql.checkRows(21) # group by - tdSql.error("select unique(c1) from ct1 group by c1") - tdSql.error("select unique(c1) from ct1 group by tbname") + tdSql.error(f"select unique(c1) from {dbname}.ct1 group by c1") + tdSql.error(f"select unique(c1) from {dbname}.ct1 group by tbname") # super table # super table - tdSql.error("select tbname , tail(c1,2) from stb1 group by tbname") - tdSql.query("select tail(c1,2) from stb1 partition by tbname") + tdSql.error(f"select tbname , tail(c1,2) from {dbname}.stb1 group by tbname") + tdSql.query(f"select tail(c1,2) from {dbname}.stb1 partition by tbname") tdSql.checkRows(4) # bug need fix - # tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 partition by tbname") # tdSql.checkRows(4) - # tdSql.query("select tbname , tail(c1,2) from stb1 partition by tbname order by tbname") + # tdSql.query(f"select tbname , tail(c1,2) from {dbname}.stb1 partition by tbname order by tbname") # tdSql.checkRows(4) - # tdSql.query(" select tbname , count(c1) from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , count(c1) from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , max(c1) ,c1 from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , max(c1) ,c1 from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname ,first(c1) from stb1 partition by tbname order by tbname ") + # tdSql.query(f"select tbname ,first(c1) from {dbname}.stb1 partition by tbname order by tbname ") # tdSql.checkRows(2) - tdSql.query("select tail(c1,2) from stb1 partition by tbname") + tdSql.query(f"select tail(c1,2) from {dbname}.stb1 partition by tbname") tdSql.checkRows(4) # # bug need fix - # tdSql.query(" select tbname , unique(c1) from stb1 where t1 = 0 partition by tbname ") + # tdSql.query(f"select tbname , unique(c1) from {dbname}.stb1 where t1 = 0 partition by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , unique(c1) from stb1 where t1 = 0 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , unique(c1) from {dbname}.stb1 where t1 = 0 partition by tbname order by tbname ") # tdSql.checkRows(2) - # tdSql.query(" select tbname , unique(c1) from stb1 where c1 = 0 partition by tbname order by tbname ") + # tdSql.query(f"select tbname , unique(c1) from {dbname}.stb1 where c1 = 0 partition by tbname order by tbname ") # tdSql.checkRows(3) - # tdSql.query(" select tbname , unique(c1) from stb1 where c1 = 0 partition by tbname ") + # tdSql.query(f"select tbname , unique(c1) from {dbname}.stb1 where c1 = 0 partition by tbname ") # tdSql.checkRows(3) - tdSql.query(" select unique(t1) from stb1 ") + tdSql.query(f"select unique(t1) from {dbname}.stb1 ") tdSql.checkRows(2) - tdSql.query(" select unique(t1+c1) from stb1 ") + tdSql.query(f"select unique(t1+c1) from {dbname}.stb1 ") tdSql.checkRows(13) - tdSql.query(" select unique(t1+c1) from stb1 partition by tbname ") + tdSql.query(f"select unique(t1+c1) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(20) - tdSql.query(" select unique(t1) from stb1 partition by tbname ") + tdSql.query(f"select unique(t1) from {dbname}.stb1 partition by tbname ") tdSql.checkRows(2) # nest query - tdSql.query(" select unique(c1) from (select _rowts , t1 ,c1 , tbname from stb1 ) ") + tdSql.query(f"select unique(c1) from (select _rowts , t1 ,c1 , tbname from {dbname}.stb1 ) ") tdSql.checkRows(11) tdSql.checkData(0,0,6) tdSql.checkData(10,0,3) - tdSql.query("select unique(t1) from (select _rowts , t1 , tbname from stb1 )") + tdSql.query(f"select unique(t1) from (select _rowts , t1 , tbname from {dbname}.stb1 )") tdSql.checkRows(2) tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) - def check_boundary_values(self): + def check_boundary_values(self, dbname="bound_test"): - tdSql.execute("drop database if exists bound_test") - tdSql.execute("create database if not exists bound_test") - tdSql.execute("use bound_test") + tdSql.execute(f"drop database if exists {dbname}") + tdSql.execute(f"create database if not exists {dbname}") tdSql.execute( - "create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" + f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);" ) - tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') + tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()+1s, -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()+2s, 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+2s, 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.execute( - f"insert into sub1_bound values ( now()+3s, -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+3s, -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + f"insert into {dbname}.sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" ) - tdSql.query("select unique(c2) from sub1_bound order by 1 desc") + tdSql.query(f"select unique(c2) from {dbname}.sub1_bound order by 1 desc") tdSql.checkRows(5) tdSql.checkData(0,0,9223372036854775807) diff --git a/tests/system-test/2-query/upper.py b/tests/system-test/2-query/upper.py index bb485161dd12885175c470e8b5542b1ab011f186..f15a6f3ba76d3acb5645f443cf068d4cce7d9755 100644 --- a/tests/system-test/2-query/upper.py +++ b/tests/system-test/2-query/upper.py @@ -95,16 +95,16 @@ class TDTestCase: return sqls - def __test_current(self): + def __test_current(self, dbname="db"): tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: self.__upper_current_check(tb) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") - def __test_error(self): + def __test_error(self, dbname="db"): tdLog.printNoPrefix("==========err sql condition check , must return error==========") - tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] + tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"] for tb in tbname: for errsql in self.__upper_err_check(tb): @@ -112,22 +112,20 @@ class TDTestCase: tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") - def all_test(self): - self.__test_current() - self.__test_error() + def all_test(self, dbname="db"): + self.__test_current(dbname) + self.__test_error(dbname) - - def __create_tb(self): - tdSql.prepare() + def __create_tb(self, dbname="db"): tdLog.printNoPrefix("==========step1:create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {dbname}.stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {dbname}.t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp @@ -137,83 +135,82 @@ class TDTestCase: tdSql.execute(create_ntb_sql) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') - def __insert_data(self, rows): + def __insert_data(self, rows, dbname="db"): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) for i in range(rows): tdSql.execute( - f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar{i}', { now_time + 1 * i } )" + f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" ) tdSql.execute( - f'''insert into ct1 values - ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } ) - ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } ) + f'''insert into {dbname}.ct1 values + ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) + ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ''' ) tdSql.execute( - f'''insert into ct4 values + f'''insert into {dbname}.ct4 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000} + { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000} ) ( { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000} + { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000} ) ''' ) tdSql.execute( - f'''insert into ct2 values + f'''insert into {dbname}.ct2 values ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000+ 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, - { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + { -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, - { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + { - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) for i in range(rows): - insert_data = f'''insert into t1 values + insert_data = f'''insert into {dbname}.t1 values ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, - "binary_{i}", "nchar_{i}", { now_time - 1000 * i } ) + "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) ''' tdSql.execute(insert_data) tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, - "binary_limit-1", "nchar_limit-1", { now_time - 86400000 } + "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 } ) ( { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, - "binary_limit-2", "nchar_limit-2", { now_time - 172800000 } + "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 } ) ''' ) - def run(self): tdSql.prepare() @@ -226,8 +223,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3:all check") self.all_test() - tdDnodes.stop(1) - tdDnodes.start(1) + tdSql.execute("flush database db") tdSql.execute("use db") diff --git a/tests/system-test/2-query/varchar.py b/tests/system-test/2-query/varchar.py index 5cc6c8e39965453c646cb267774564af1a66f42d..17c3ea633357cf16a8b17e52c180192d07e52a87 100644 --- a/tests/system-test/2-query/varchar.py +++ b/tests/system-test/2-query/varchar.py @@ -14,43 +14,44 @@ class TDTestCase: tdSql.init(conn.cursor()) def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + dbname = "db" tdSql.prepare() tdLog.printNoPrefix("==========step1:create table") tdSql.execute( - '''create table stb1 + f'''create table {dbname}.stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 varchar(16),c9 nchar(32), c10 timestamp) tags (t1 int) ''' ) tdSql.execute( - ''' - create table t1 + f''' + create table {dbname}.t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 varchar(16),c9 nchar(32), c10 timestamp) ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )') tdLog.printNoPrefix("==========step2:insert data") for i in range(9): tdSql.execute( - f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'varchar{i}', 'nchar{i}', now()+{1*i}a )" + 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}, 'varchar{i}', 'nchar{i}', now()+{1*i}a )" ) tdSql.execute( - f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'varchar{i}', 'nchar{i}', now()+{1*i}a )" + f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'varchar{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'varchar0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'varchar9', 'nchar9', now()+9a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'varchar0', 'nchar0', now()+8a )") + tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'varchar9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( - f'''insert into t1 values + f'''insert into {dbname}.t1 values ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "varchar1", "nchar1", now()+1a ) ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "varchar2", "nchar2", now()+2a ) @@ -70,7 +71,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step3: cast on varchar") - tdSql.query("select c8 from ct1") + tdSql.query(f"select c8 from {dbname}.ct1") for i in range(tdSql.queryRows): tdSql.checkData(i,0, data_ct1_c8[i]) diff --git a/tests/system-test/7-tmq/tmqShow.py b/tests/system-test/7-tmq/tmqShow.py index 6f8183bf06cfa501f62c22c82c2915638ea7414b..c0f33d92049efe6eceffd01353e3bedc2c406ee9 100644 --- a/tests/system-test/7-tmq/tmqShow.py +++ b/tests/system-test/7-tmq/tmqShow.py @@ -19,6 +19,11 @@ class TDTestCase: tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file + def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,offset=1,cdbName='cdb'): + sql = "insert into %s.consumeinfo values "%cdbName + sql += "(now+%ds, %d, '%s', '%s', %d, %d, %d)"%(offset,consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) + tdLog.info("consume info sql: %s"%sql) + tdSql.query(sql) def tmqCase1(self): tdLog.printNoPrefix("======== test case 1: ") @@ -95,19 +100,23 @@ class TDTestCase: ifcheckdata = 0 ifManualCommit = 0 keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0] - tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + tsOffset=1 + self.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit,tsOffset) topicList = topicNameList[1] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1] - tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + tsOffset=2 + self.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit,tsOffset) topicList = topicNameList[2] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2] - tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + tsOffset=3 + self.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit,tsOffset) topicList = topicNameList[3] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3] - tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + tsOffset=4 + self.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit,tsOffset) tdLog.info("start consume processor") tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index d38e509d269beb265f9a7701f88954e71b064de2..07602ec29f69f9fbd0dab90935e0922996c80f80 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -20,15 +20,9 @@ class TDTestCase: tdSql.init(conn.cursor()) #tdSql.init(conn.cursor(), logSql) # output sql.txt file - def checkFileContent(self): - buildPath = tdCom.getBuildPath() - cfgPath = tdCom.getClientCfgPath() - cmdStr = '%s/build/bin/tmq_taosx_ci -c %s'%(buildPath, cfgPath) - tdLog.info(cmdStr) - os.system(cmdStr) - - srcFile = '%s/../log/tmq_taosx_tmp.source'%(cfgPath) - dstFile = '%s/../log/tmq_taosx_tmp.result'%(cfgPath) + def checkJson(self, cfgPath, name): + srcFile = '%s/../log/%s.source'%(cfgPath, name) + dstFile = '%s/../log/%s.result'%(cfgPath, name) tdLog.info("compare file: %s, %s"%(srcFile, dstFile)) consumeFile = open(srcFile, mode='r') @@ -43,7 +37,31 @@ class TDTestCase: tdLog.exit("compare error: %s != %s"%src, dst) else: break + return + + def checkDropData(self): + tdSql.execute('use db_taosx') + tdSql.query("show tables") + tdSql.checkRows(2) + tdSql.query("select * from jt order by i") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 11) + tdSql.checkData(0, 2, '{"k1":1,"k2":"hello"}') + tdSql.checkData(1, 2, None) + + tdSql.execute('use abc1') + tdSql.query("show tables") + tdSql.checkRows(2) + tdSql.query("select * from jt order by i") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 11) + tdSql.checkData(0, 2, '{"k1":1,"k2":"hello"}') + tdSql.checkData(1, 2, None) + return + def checkData(self): tdSql.execute('use db_taosx') tdSql.query("select * from ct3 order by c1 desc") tdSql.checkRows(2) @@ -116,113 +134,82 @@ class TDTestCase: tdSql.checkData(0, 2, None) tdSql.checkData(1, 1, 1) tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}') - - tdSql.execute('drop topic if exists topic_ctb_column') return - def checkFileContentSnapshot(self): + def checkWal1Vgroup(self): buildPath = tdCom.getBuildPath() cfgPath = tdCom.getClientCfgPath() - cmdStr = '%s/build/bin/tmq_taosx_snapshot_ci -c %s'%(buildPath, cfgPath) + cmdStr = '%s/build/bin/tmq_taosx_ci -c %s -sv 1 -dv 1'%(buildPath, cfgPath) tdLog.info(cmdStr) os.system(cmdStr) - srcFile = '%s/../log/tmq_taosx_tmp_snapshot.source'%(cfgPath) - dstFile = '%s/../log/tmq_taosx_tmp_snapshot.result'%(cfgPath) - tdLog.info("compare file: %s, %s"%(srcFile, dstFile)) - - consumeFile = open(srcFile, mode='r') - queryFile = open(dstFile, mode='r') - - while True: - dst = queryFile.readline() - src = consumeFile.readline() + self.checkJson(cfgPath, "tmq_taosx_tmp") + self.checkData() - if dst: - if dst != src: - tdLog.exit("compare error: %s != %s"%src, dst) - else: - break + return - tdSql.execute('use db_taosx') - tdSql.query("select * from ct3 order by c1 desc") - tdSql.checkRows(2) - tdSql.checkData(0, 1, 51) - tdSql.checkData(0, 4, 940) - tdSql.checkData(1, 1, 23) - tdSql.checkData(1, 4, None) + def checkWalMultiVgroups(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -sv 3 -dv 5'%(buildPath) + tdLog.info(cmdStr) + os.system(cmdStr) - tdSql.query("select * from st1 order by ts") - tdSql.checkRows(8) - tdSql.checkData(0, 1, 1) - tdSql.checkData(1, 1, 3) - tdSql.checkData(4, 1, 4) - tdSql.checkData(6, 1, 23) + self.checkData() - tdSql.checkData(0, 2, 2) - tdSql.checkData(1, 2, 4) - tdSql.checkData(4, 2, 3) - tdSql.checkData(6, 2, 32) + return - tdSql.checkData(0, 3, 'a') - tdSql.checkData(1, 3, 'b') - tdSql.checkData(4, 3, 'hwj') - tdSql.checkData(6, 3, 's21ds') + def checkWalMultiVgroupsWithDropTable(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -sv 3 -dv 5 -d'%(buildPath) + tdLog.info(cmdStr) + os.system(cmdStr) - tdSql.checkData(0, 4, None) - tdSql.checkData(1, 4, None) - tdSql.checkData(5, 4, 940) - tdSql.checkData(6, 4, None) + self.checkDropData() - tdSql.checkData(0, 5, 1000) - tdSql.checkData(1, 5, 2000) - tdSql.checkData(4, 5, 1000) - tdSql.checkData(6, 5, 5000) + return - tdSql.checkData(0, 6, 'ttt') - tdSql.checkData(1, 6, None) - tdSql.checkData(4, 6, 'ttt') - tdSql.checkData(6, 6, None) + def checkSnapshot1Vgroup(self): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -c %s -sv 1 -dv 1 -s'%(buildPath, cfgPath) + tdLog.info(cmdStr) + os.system(cmdStr) - tdSql.checkData(0, 7, True) - tdSql.checkData(1, 7, None) - tdSql.checkData(4, 7, True) - tdSql.checkData(6, 7, None) + self.checkJson(cfgPath, "tmq_taosx_tmp_snapshot") + self.checkData() - tdSql.checkData(0, 8, None) - tdSql.checkData(1, 8, None) - tdSql.checkData(4, 8, None) - tdSql.checkData(6, 8, None) + return - tdSql.query("select * from ct1") - tdSql.checkRows(4) + def checkSnapshotMultiVgroups(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -sv 2 -dv 4 -s'%(buildPath) + tdLog.info(cmdStr) + os.system(cmdStr) - tdSql.query("select * from ct2") - tdSql.checkRows(0) + self.checkData() - tdSql.query("select * from ct0 order by c1") - tdSql.checkRows(2) - tdSql.checkData(0, 3, "a") - tdSql.checkData(1, 4, None) + return - tdSql.query("select * from n1 order by cc3 desc") - tdSql.checkRows(2) - tdSql.checkData(0, 1, "eeee") - tdSql.checkData(1, 2, 940) + def checkSnapshotMultiVgroupsWithDropTable(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/tmq_taosx_ci -sv 2 -dv 4 -s -d'%(buildPath) + tdLog.info(cmdStr) + os.system(cmdStr) - tdSql.query("select * from jt order by i desc") - tdSql.checkRows(2) - tdSql.checkData(0, 1, 11) - tdSql.checkData(0, 2, None) - tdSql.checkData(1, 1, 1) - tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}') + self.checkDropData() return def run(self): tdSql.prepare() - self.checkFileContent() - self.checkFileContentSnapshot() + self.checkWal1Vgroup() + self.checkSnapshot1Vgroup() + + self.checkWalMultiVgroups() + self.checkSnapshotMultiVgroups() + + self.checkWalMultiVgroupsWithDropTable() + self.checkSnapshotMultiVgroupsWithDropTable() def stop(self): tdSql.close() diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 1e958bdb298507113f51b4ce717314df634dea17..11df13d451f1d63a116fdceea4757da032e1a9ec 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -124,44 +124,97 @@ python3 ./test.py -f 2-query/leastsquares.py python3 ./test.py -f 2-query/leastsquares.py -R python3 ./test.py -f 2-query/length.py python3 ./test.py -f 2-query/length.py -R +python3 ./test.py -f 2-query/log.py +# python3 ./test.py -f 2-query/log.py -R +python3 ./test.py -f 2-query/lower.py +python3 ./test.py -f 2-query/lower.py -R +python3 ./test.py -f 2-query/ltrim.py +python3 ./test.py -f 2-query/ltrim.py -R +python3 ./test.py -f 2-query/mavg.py +python3 ./test.py -f 2-query/mavg.py -R +python3 ./test.py -f 2-query/max_partition.py +python3 ./test.py -f 2-query/max_partition.py -R +python3 ./test.py -f 2-query/max.py +python3 ./test.py -f 2-query/max.py -R +python3 ./test.py -f 2-query/min.py +python3 ./test.py -f 2-query/min.py -R +python3 ./test.py -f 2-query/Now.py +python3 ./test.py -f 2-query/Now.py -R +python3 ./test.py -f 2-query/percentile.py +python3 ./test.py -f 2-query/percentile.py -R +python3 ./test.py -f 2-query/pow.py +python3 ./test.py -f 2-query/pow.py -R +python3 ./test.py -f 2-query/query_cols_tags_and_or.py +python3 ./test.py -f 2-query/query_cols_tags_and_or.py -R +python3 ./test.py -f 2-query/round.py +python3 ./test.py -f 2-query/round.py -R +python3 ./test.py -f 2-query/rtrim.py +python3 ./test.py -f 2-query/rtrim.py -R +python3 ./test.py -f 2-query/sample.py +python3 ./test.py -f 2-query/sample.py -R +python3 ./test.py -f 2-query/sin.py +python3 ./test.py -f 2-query/sin.py -R +python3 ./test.py -f 2-query/smaTest.py +python3 ./test.py -f 2-query/smaTest.py -R +#python3 ./test.py -f 2-query/sml.py +#python3 ./test.py -f 2-query/sml.py -R +python3 ./test.py -f 2-query/spread.py +python3 ./test.py -f 2-query/spread.py -R +python3 ./test.py -f 2-query/sqrt.py +python3 ./test.py -f 2-query/sqrt.py -R +python3 ./test.py -f 2-query/statecount.py +python3 ./test.py -f 2-query/statecount.py -R +python3 ./test.py -f 2-query/stateduration.py +python3 ./test.py -f 2-query/stateduration.py -R +python3 ./test.py -f 2-query/substr.py +python3 ./test.py -f 2-query/substr.py -R +python3 ./test.py -f 2-query/sum.py +python3 ./test.py -f 2-query/sum.py -R +python3 ./test.py -f 2-query/tail.py +python3 ./test.py -f 2-query/tail.py -R +python3 ./test.py -f 2-query/tan.py +# python3 ./test.py -f 2-query/tan.py -R +python3 ./test.py -f 2-query/Timediff.py +python3 ./test.py -f 2-query/Timediff.py -R +python3 ./test.py -f 2-query/timetruncate.py +# python3 ./test.py -f 2-query/timetruncate.py -R +python3 ./test.py -f 2-query/timezone.py +python3 ./test.py -f 2-query/timezone.py -R +python3 ./test.py -f 2-query/To_iso8601.py +python3 ./test.py -f 2-query/To_iso8601.py -R +python3 ./test.py -f 2-query/To_unixtimestamp.py +python3 ./test.py -f 2-query/To_unixtimestamp.py -R +python3 ./test.py -f 2-query/Today.py +# python3 ./test.py -f 2-query/Today.py -R +python3 ./test.py -f 2-query/top.py +python3 ./test.py -f 2-query/top.py -R +python3 ./test.py -f 2-query/tsbsQuery.py +python3 ./test.py -f 2-query/tsbsQuery.py -R +python3 ./test.py -f 2-query/ttl_comment.py +python3 ./test.py -f 2-query/ttl_comment.py -R +python3 ./test.py -f 2-query/twa.py +python3 ./test.py -f 2-query/twa.py -R +python3 ./test.py -f 2-query/union.py +python3 ./test.py -f 2-query/union.py -R +python3 ./test.py -f 2-query/unique.py +python3 ./test.py -f 2-query/unique.py -R +python3 ./test.py -f 2-query/upper.py +python3 ./test.py -f 2-query/upper.py -R +python3 ./test.py -f 2-query/varchar.py +python3 ./test.py -f 2-query/varchar.py -R + python3 ./test.py -f 1-insert/update_data.py python3 ./test.py -f 1-insert/delete_data.py -python3 ./test.py -f 2-query/varchar.py -python3 ./test.py -f 2-query/ltrim.py -python3 ./test.py -f 2-query/rtrim.py -python3 ./test.py -f 2-query/upper.py -python3 ./test.py -f 2-query/lower.py python3 ./test.py -f 2-query/join2.py -python3 ./test.py -f 2-query/substr.py -python3 ./test.py -f 2-query/union.py python3 ./test.py -f 2-query/union1.py python3 ./test.py -f 2-query/concat2.py -python3 ./test.py -f 2-query/spread.py -python3 ./test.py -f 2-query/timezone.py -python3 ./test.py -f 2-query/Now.py -python3 ./test.py -f 2-query/Today.py -python3 ./test.py -f 2-query/max.py -python3 ./test.py -f 2-query/min.py -python3 ./test.py -f 2-query/To_iso8601.py -python3 ./test.py -f 2-query/To_unixtimestamp.py -python3 ./test.py -f 2-query/timetruncate.py -python3 ./test.py -f 2-query/Timediff.py python3 ./test.py -f 2-query/json_tag.py -python3 ./test.py -f 2-query/top.py -python3 ./test.py -f 2-query/percentile.py -python3 ./test.py -f 2-query/round.py -python3 ./test.py -f 2-query/log.py -python3 ./test.py -f 2-query/pow.py -python3 ./test.py -f 2-query/sqrt.py -python3 ./test.py -f 2-query/sin.py -python3 ./test.py -f 2-query/tan.py -python3 ./test.py -f 2-query/query_cols_tags_and_or.py # python3 ./test.py -f 2-query/nestedQuery.py # TD-15983 subquery output duplicate name column. # Please Xiangyang Guo modify the following script @@ -169,18 +222,8 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/csum.py -python3 ./test.py -f 2-query/mavg.py -python3 ./test.py -f 2-query/sample.py python3 ./test.py -f 2-query/function_diff.py -python3 ./test.py -f 2-query/unique.py -python3 ./test.py -f 2-query/stateduration.py -python3 ./test.py -f 2-query/statecount.py -python3 ./test.py -f 2-query/tail.py -python3 ./test.py -f 2-query/ttl_comment.py -python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 2-query/queryQnode.py -python3 ./test.py -f 2-query/max_partition.py -python3 ./test.py -f 2-query/tsbsQuery.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 @@ -271,8 +314,8 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py -#python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py -#python3 ./test.py -f 7-tmq/tmqDnodeRestart.py +python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py +python3 ./test.py -f 7-tmq/tmqDnodeRestart.py python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py @@ -358,7 +401,7 @@ python3 ./test.py -f 2-query/interp.py -Q 2 python3 ./test.py -f 2-query/avg.py -Q 2 # python3 ./test.py -f 2-query/elapsed.py -Q 2 python3 ./test.py -f 2-query/csum.py -Q 2 -python3 ./test.py -f 2-query/mavg.py -Q 2 +#python3 ./test.py -f 2-query/mavg.py -Q 2 python3 ./test.py -f 2-query/sample.py -Q 2 python3 ./test.py -f 2-query/function_diff.py -Q 2 python3 ./test.py -f 2-query/unique.py -Q 2 @@ -445,7 +488,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 # python3 ./test.py -f 2-query/avg.py -Q 3 # python3 ./test.py -f 2-query/elapsed.py -Q 3 python3 ./test.py -f 2-query/csum.py -Q 3 -python3 ./test.py -f 2-query/mavg.py -Q 3 +#python3 ./test.py -f 2-query/mavg.py -Q 3 python3 ./test.py -f 2-query/sample.py -Q 3 python3 ./test.py -f 2-query/function_diff.py -Q 3 python3 ./test.py -f 2-query/unique.py -Q 3 @@ -469,5 +512,6 @@ python3 ./test.py -f 2-query/count_partition.py -Q 3 python3 ./test.py -f 2-query/max_partition.py -Q 3 python3 ./test.py -f 2-query/last_row.py -Q 3 python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 -python3 ./test.py -f 2-query/sml.py -Q 3 +#python3 ./test.py -f 2-query/sml.py -Q 3 python3 ./test.py -f 2-query/interp.py -Q 3 + diff --git a/tests/test/c/tmq_taosx_snapshot_ci.c b/tests/test/c/tmq_taosx_snapshot_ci.c deleted file mode 100644 index e3a52f7cad7bf4c3125fc0c023795a4d86fcdd5e..0000000000000000000000000000000000000000 --- a/tests/test/c/tmq_taosx_snapshot_ci.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include "taos.h" -#include "types.h" - -static int running = 1; -TdFilePtr g_fp = NULL; -char dir[64]={0}; - -static TAOS* use_db(){ - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - if (pConn == NULL) { - return NULL; - } - - TAOS_RES* pRes = taos_query(pConn, "use db_taosx"); - if (taos_errno(pRes) != 0) { - printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes)); - return NULL; - } - taos_free_result(pRes); - return pConn; -} - -static void msg_process(TAOS_RES* msg) { - /*memset(buf, 0, 1024);*/ - printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg)); - printf("db: %s\n", tmq_get_db_name(msg)); - printf("vg: %d\n", tmq_get_vgroup_id(msg)); - TAOS *pConn = use_db(); - if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) { - char* result = tmq_get_json_meta(msg); - if (result) { - printf("meta result: %s\n", result); - } - taosFprintfFile(g_fp, result); - taosFprintfFile(g_fp, "\n"); - tmq_free_json_meta(result); - } - - tmq_raw_data raw = {0}; - tmq_get_raw(msg, &raw); - int32_t ret = tmq_write_raw(pConn, raw); - printf("write raw data: %s\n", tmq_err2str(ret)); - -// else{ -// while(1){ -// int numOfRows = 0; -// void *pData = NULL; -// taos_fetch_raw_block(msg, &numOfRows, &pData); -// if(numOfRows == 0) break; -// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows); -// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg)); -// printf("write raw data: %s\n", tmq_err2str(ret)); -// } -// } - - taos_close(pConn); -} - -int32_t init_env() { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - if (pConn == NULL) { - return -1; - } - - TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx"); - if (taos_errno(pRes) != 0) { - printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 1"); - if (taos_errno(pRes) != 0) { - printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "drop database if exists abc1"); - if (taos_errno(pRes) != 0) { - printf("error in drop db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); - if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, - "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " - "nchar(8), t4 bool)"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)"); - if (taos_errno(pRes) != 0) { - printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table st1 add column c4 bigint"); - if (taos_errno(pRes) != 0) { - printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)"); - if (taos_errno(pRes) != 0) { - printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into ct3 select * from ct1"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)"); - if (taos_errno(pRes) != 0) { - printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table ct3 set tag t1=5000"); - if (taos_errno(pRes) != 0) { - printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); - if (taos_errno(pRes) != 0) { - printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table n1 add column c3 bigint"); - if (taos_errno(pRes) != 0) { - printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)"); - if (taos_errno(pRes) != 0) { - printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table n1 rename column c3 cc3"); - if (taos_errno(pRes) != 0) { - printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table n1 comment 'hello'"); - if (taos_errno(pRes) != 0) { - printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "alter table n1 drop column c1"); - if (taos_errno(pRes) != 0) { - printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)"); - if (taos_errno(pRes) != 0) { - printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table jt2 using jt tags('')"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into jt1 values(now, 1)"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table jt1, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "insert into jt2 values(now, 11)"); - if (taos_errno(pRes) != 0) { - printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - taos_close(pConn); - return 0; -} - -int32_t create_topic() { - printf("create topic\n"); - TAOS_RES* pRes; - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - if (pConn == NULL) { - return -1; - } - - pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); - if (taos_errno(pRes) != 0) { - printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - taos_close(pConn); - return 0; -} - -void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { - printf("commit %d tmq %p param %p\n", code, tmq, param); -} - -tmq_t* build_consumer() { -#if 0 - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - assert(pConn != NULL); - - TAOS_RES* pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - } - taos_free_result(pRes); -#endif - - tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "group.id", "tg2"); - tmq_conf_set(conf, "client.id", "my app 1"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "enable.heartbeat.background", "true"); - tmq_conf_set(conf, "experimental.snapshot.enable", "true"); - /*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/ - - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); - tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); - assert(tmq); - tmq_conf_destroy(conf); - return tmq; -} - -tmq_list_t* build_topic_list() { - tmq_list_t* topic_list = tmq_list_new(); - tmq_list_append(topic_list, "topic_ctb_column"); - /*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/ - return topic_list; -} - -void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) { - int32_t code; - - if ((code = tmq_subscribe(tmq, topics))) { - fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); - printf("subscribe err\n"); - return; - } - int32_t cnt = 0; - while (running) { - TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000); - if (tmqmessage) { - cnt++; - msg_process(tmqmessage); - /*if (cnt >= 2) break;*/ - /*printf("get data\n");*/ - taos_free_result(tmqmessage); - /*} else {*/ - /*break;*/ - /*tmq_commit_sync(tmq, NULL);*/ - }else{ - break; - } - } - - code = tmq_consumer_close(tmq); - if (code) - fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code)); - else - fprintf(stderr, "%% Consumer closed\n"); -} - -void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) { - static const int MIN_COMMIT_COUNT = 1; - - int msg_count = 0; - int32_t code; - - if ((code = tmq_subscribe(tmq, topics))) { - fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); - return; - } - - tmq_list_t* subList = NULL; - tmq_subscription(tmq, &subList); - char** subTopics = tmq_list_to_c_array(subList); - int32_t sz = tmq_list_get_size(subList); - printf("subscribed topics: "); - for (int32_t i = 0; i < sz; i++) { - printf("%s, ", subTopics[i]); - } - printf("\n"); - tmq_list_destroy(subList); - - while (running) { - TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000); - if (tmqmessage) { - msg_process(tmqmessage); - taos_free_result(tmqmessage); - - /*tmq_commit_sync(tmq, NULL);*/ - /*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/ - } - } - - code = tmq_consumer_close(tmq); - if (code) - fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code)); - else - fprintf(stderr, "%% Consumer closed\n"); -} - -void initLogFile() { - char f1[256] = {0}; - char f2[256] = {0}; - - sprintf(f1, "%s/../log/tmq_taosx_tmp_snapshot.source", dir); - sprintf(f2, "%s/../log/tmq_taosx_tmp_snapshot.result", dir); - TdFilePtr pFile = taosOpenFile(f1, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM); - if (NULL == pFile) { - fprintf(stderr, "Failed to open %s for save result\n", f1); - exit(-1); - } - g_fp = pFile; - - TdFilePtr pFile2 = taosOpenFile(f2, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM); - if (NULL == pFile2) { - fprintf(stderr, "Failed to open %s for save result\n", f2); - exit(-1); - } - char *result[] = { - "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":64},{\"name\":\"c4\",\"type\":5}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1},{\"name\":\"t2\",\"type\":8,\"length\":64}]}", - "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", - "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":5000}]}", - "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c2\",\"type\":10,\"length\":8},{\"name\":\"cc3\",\"type\":5}],\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", - "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}", - }; - - for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ - taosFprintfFile(pFile2, result[i]); - taosFprintfFile(pFile2, "\n"); - } - taosCloseFile(&pFile2); -} - -int main(int argc, char* argv[]) { - if(argc == 3 && strcmp(argv[1], "-c") == 0) { - strcpy(dir, argv[2]); - }else{ -// strcpy(dir, "../../../sim/psim/cfg"); - strcpy(dir, "/var/log"); - } - - printf("env init\n"); - initLogFile(); - - if (init_env() < 0) { - return -1; - } - create_topic(); - - tmq_t* tmq = build_consumer(); - tmq_list_t* topic_list = build_topic_list(); - basic_consume_loop(tmq, topic_list); - /*sync_consume_loop(tmq, topic_list);*/ - taosCloseFile(&g_fp); -} diff --git a/tools/shell/inc/shellInt.h b/tools/shell/inc/shellInt.h index 26ca6895ace188257ad9b16642cfe1f09bc792b4..15f6f6dc6a362c8c94994727fe19fa090ca94c57 100644 --- a/tools/shell/inc/shellInt.h +++ b/tools/shell/inc/shellInt.h @@ -113,7 +113,7 @@ int32_t shellExecute(); int32_t shellCalcColWidth(TAOS_FIELD *field, int32_t precision); void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields); void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t length, int32_t precision); -void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision); +void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision); // shellUtil.c int32_t shellCheckIntSize(); void shellPrintVersion(); diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index d87e10fd0897aaeea8a203d7b3d26e1fa02425cf..b73317e991042f6ce96a470ca9325cc2754fe47a 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -510,7 +510,10 @@ int32_t shellReadCommand(char *command) { shellClearLineAfter(&cmd); break; case 12: // Ctrl + L; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" system("clear"); +#pragma GCC diagnostic pop shellShowOnScreen(&cmd); break; case 21: // Ctrl + U; diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 68e3a272c33d2b97da02d5a27561de2b8dd5fa6f..45d5489803fb5a0f7ec5506320d9e21257c8281b 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -62,7 +62,10 @@ int32_t shellRunSingleCommand(char *command) { } if (shellRegexMatch(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - system("clear"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + system("clear"); +#pragma GCC diagnostic pop return 0; } @@ -266,7 +269,6 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision) { if (val == NULL) { - taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR); return; } @@ -314,13 +316,34 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_JSON: - memcpy(buf, val, length); - buf[length] = 0; - taosFprintfFile(pFile, "\'%s\'", buf); + { + char quotationStr[2]; + int32_t bufIndex = 0; + quotationStr[0] = 0; + quotationStr[1] = 0; + for (int32_t i = 0; i < length; i++) { + buf[bufIndex] = val[i]; + bufIndex++; + if (val[i] == '\"') { + buf[bufIndex] = val[i]; + bufIndex++; + quotationStr[0] = '\"'; + } + if (val[i] == ',') { + quotationStr[0] = '\"'; + } + } + buf[bufIndex] = 0; + if (length == 0) { + quotationStr[0] = '\"'; + } + + taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr); + } break; case TSDB_DATA_TYPE_TIMESTAMP: shellFormatTimestamp(buf, *(int64_t *)val, precision); - taosFprintfFile(pFile, "'%s'", buf); + taosFprintfFile(pFile, "%s", buf); break; default: break; diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index 2dcab04b3f4bfd072d766ff1e25c015cf609466f..b8b8392b961a92263f791ee4b480e61a8c148efd 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -18,19 +18,19 @@ #include "shellInt.h" int shell_conn_ws_server(bool first) { - shell.ws_conn = ws_connect_with_dsn(shell.args.dsn); - if (!shell.ws_conn) { - fprintf(stderr, "failed to connect %s, reason: %s\n", - shell.args.dsn, ws_errstr(NULL)); - return -1; - } - if (first && shell.args.restful) { - fprintf(stdout, "successfully connect to %s\n\n", - shell.args.dsn); - } else if (first && shell.args.cloud) { - fprintf(stdout, "successfully connect to cloud service\n"); - } - return 0; + shell.ws_conn = ws_connect_with_dsn(shell.args.dsn); + if (!shell.ws_conn) { + fprintf(stderr, "failed to connect %s, reason: %s\n", + shell.args.dsn, ws_errstr(NULL)); + return -1; + } + if (first && shell.args.restful) { + fprintf(stdout, "successfully connect to %s\n\n", + shell.args.dsn); + } else if (first && shell.args.cloud) { + fprintf(stdout, "successfully connect to cloud service\n"); + } + return 0; } static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) { @@ -39,7 +39,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) { ws_fetch_block(wres, &data, &rows); *execute_time += (double)(ws_take_timing(wres)/1E6); if (!rows) { - return 0; + return 0; } int num_fields = ws_field_count(wres); TAOS_FIELD* fields = (TAOS_FIELD*)ws_fetch_fields(wres); @@ -64,7 +64,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) { putchar(' '); putchar('|'); } - putchar('\r'); + putchar('\r'); putchar('\n'); } numOfRows += rows; @@ -79,7 +79,7 @@ static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) { ws_fetch_block(wres, &data, &rows); *pexecute_time += (double)(ws_take_timing(wres)/1E6); if (!rows) { - return 0; + return 0; } int num_fields = ws_field_count(wres); TAOS_FIELD* fields = (TAOS_FIELD*)ws_fetch_fields(wres); @@ -98,7 +98,7 @@ static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) { uint32_t len; for (int i = 0; i < rows; i++) { printf("*************************** %d.row ***************************\n", - numOfRows + 1); + numOfRows + 1); for (int j = 0; j < num_fields; j++) { TAOS_FIELD* field = fields + j; int padding = (int)(maxColNameLen - strlen(field->name)); @@ -121,7 +121,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute } TdFilePtr pFile = taosOpenFile(fullname, - TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); + TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); if (pFile == NULL) { fprintf(stderr, "failed to open file: %s\r\n", fullname); return -1; @@ -132,7 +132,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute *pexecute_time += (double)(ws_take_timing(wres)/1E6); if (!rows) { taosCloseFile(&pFile); - return 0; + return 0; } int numOfRows = 0; TAOS_FIELD* fields = (TAOS_FIELD*)ws_fetch_fields(wres); @@ -207,7 +207,7 @@ void shellRunSingleCommandWebsocketImp(char *command) { } if (!shell.ws_conn && shell_conn_ws_server(0)) { - return; + return; } shell.stop_query = false; @@ -216,16 +216,16 @@ void shellRunSingleCommandWebsocketImp(char *command) { WS_RES* res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout); int code = ws_errno(res); if (code != 0) { - et = taosGetTimestampUs(); - fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); - if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { - fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); - } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) { - fprintf(stderr, "TDengine server is down, will try to reconnect\n"); - shell.ws_conn = NULL; - } - ws_free_result(res); - return; + et = taosGetTimestampUs(); + fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); + if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { + fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); + } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) { + fprintf(stderr, "TDengine server is down, will try to reconnect\n"); + shell.ws_conn = NULL; + } + ws_free_result(res); + return; } double execute_time = ws_take_timing(res)/1E6; @@ -233,36 +233,36 @@ void shellRunSingleCommandWebsocketImp(char *command) { if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) { fprintf(stdout, "Database changed.\r\n\r\n"); fflush(stdout); - ws_free_result(res); + ws_free_result(res); return; } int numOfRows = 0; if (ws_is_update_query(res)) { - numOfRows = ws_affected_rows(res); - et = taosGetTimestampUs(); + numOfRows = ws_affected_rows(res); + et = taosGetTimestampUs(); double total_time = (et - st)/1E3; double net_time = total_time - (double)execute_time; - printf("Query Ok, %d of %d row(s) in database\n", numOfRows, numOfRows); + printf("Query Ok, %d of %d row(s) in database\n", numOfRows, numOfRows); printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); } else { - int error_no = 0; - numOfRows = shellDumpWebsocket(res, fname, &error_no, printMode, &execute_time); - if (numOfRows < 0) { - ws_free_result(res); - return; - } - et = taosGetTimestampUs(); + int error_no = 0; + numOfRows = shellDumpWebsocket(res, fname, &error_no, printMode, &execute_time); + if (numOfRows < 0) { + ws_free_result(res); + return; + } + et = taosGetTimestampUs(); double total_time = (et - st) / 1E3; double net_time = total_time - execute_time; - if (error_no == 0 && !shell.stop_query) { - printf("Query OK, %d row(s) in set\n", numOfRows); - printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); - } else { - printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows, - (et - st)/1E6); - printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); - } + if (error_no == 0 && !shell.stop_query) { + printf("Query OK, %d row(s) in set\n", numOfRows); + printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); + } else { + printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows, + (et - st)/1E6); + printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); + } } printf("\n"); ws_free_result(res); diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..59cbbb31471acc377dd614610aa715ae72c9ec31 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,4 @@ +#ADD_SUBDIRECTORY(examples/c) +ADD_SUBDIRECTORY(tsim) +ADD_SUBDIRECTORY(test/c) +#ADD_SUBDIRECTORY(comparisonTest/tdengine) diff --git a/tests/test/c/CMakeLists.txt b/utils/test/c/CMakeLists.txt similarity index 85% rename from tests/test/c/CMakeLists.txt rename to utils/test/c/CMakeLists.txt index 0fb80e69c264852a1fa7abc8b666d036c36a50d7..839c65b633b17872051075be33ce291fbeaefd5a 100644 --- a/tests/test/c/CMakeLists.txt +++ b/utils/test/c/CMakeLists.txt @@ -1,8 +1,8 @@ add_executable(tmq_demo tmqDemo.c) +add_dependencies(tmq_demo taos) add_executable(tmq_sim tmqSim.c) add_executable(create_table createTable.c) add_executable(tmq_taosx_ci tmq_taosx_ci.c) -add_executable(tmq_taosx_snapshot_ci tmq_taosx_snapshot_ci.c) add_executable(sml_test sml_test.c) target_link_libraries( create_table @@ -32,13 +32,6 @@ target_link_libraries( PUBLIC common PUBLIC os ) -target_link_libraries( - tmq_taosx_snapshot_ci - PUBLIC taos_static - PUBLIC util - PUBLIC common - PUBLIC os -) target_link_libraries( sml_test diff --git a/tests/test/c/createTable.c b/utils/test/c/createTable.c similarity index 100% rename from tests/test/c/createTable.c rename to utils/test/c/createTable.c diff --git a/tests/test/c/sdbDump.c b/utils/test/c/sdbDump.c similarity index 99% rename from tests/test/c/sdbDump.c rename to utils/test/c/sdbDump.c index aef50560316c87ca91d766a99bc7acc0509e0866..b90b781e4469f004df742b047d046ff7574601ba 100644 --- a/tests/test/c/sdbDump.c +++ b/utils/test/c/sdbDump.c @@ -20,6 +20,9 @@ #include "tconfig.h" #include "tjson.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + #define TMP_DNODE_DIR TD_TMP_DIR_PATH "dumpsdb" #define TMP_MNODE_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" #define TMP_SDB_DATA_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" @@ -429,6 +432,7 @@ int32_t parseArgs(int32_t argc, char *argv[]) { char cmd[PATH_MAX * 2] = {0}; snprintf(cmd, sizeof(cmd), "rm -rf %s", TMP_DNODE_DIR); + system(cmd); #ifdef WINDOWS taosMulMkDir(TMP_SDB_DATA_DIR); @@ -467,3 +471,5 @@ int32_t main(int32_t argc, char *argv[]) { return dumpSdb(); } + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/tests/test/c/sml_test.c b/utils/test/c/sml_test.c similarity index 96% rename from tests/test/c/sml_test.c rename to utils/test/c/sml_test.c index 18181d2073e154c7f3fe183d164e1f858fddcb4f..1fd1def263fb9a142ca7df4be1a8bed839ea098e 100644 --- a/tests/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -63,6 +63,7 @@ int smlProcess_influx_Test() { printf("%s result:%s\n", __FUNCTION__, taos_errstr(pRes)); int code = taos_errno(pRes); taos_free_result(pRes); + return code; } @@ -1100,34 +1101,91 @@ int sml_add_tag_col_Test() { return code; } +int smlProcess_18784_Test() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0); + + TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1"); + taos_free_result(pRes); + + pRes = taos_query(taos, "use sml_db"); + taos_free_result(pRes); + + const char *sql[] = { + "disk,device=sdc inodes_used=176059i,total=1081101176832i 1661943960000000000", + "disk,device=sdc inodes_free=66932805i 1661943960000000000", + }; + pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); + printf("%s result:%s, rows:%d\n", __FUNCTION__, taos_errstr(pRes), taos_affected_rows(pRes)); + int code = taos_errno(pRes); + ASSERT(!code); + ASSERT(taos_affected_rows(pRes) == 2); + taos_free_result(pRes); + + pRes = taos_query(taos, "select * from disk"); + ASSERT(pRes); + int fieldNum = taos_field_count(pRes); + ASSERT(fieldNum == 5); + printf("fieldNum:%d\n", fieldNum); + TAOS_ROW row = NULL; + int32_t rowIndex = 0; + while((row = taos_fetch_row(pRes)) != NULL) { + int64_t ts = *(int64_t*)row[0]; + int64_t used = *(int64_t*)row[1]; + int64_t total = *(int64_t*)row[2]; + int64_t freed = *(int64_t*)row[3]; + if(rowIndex == 0){ + ASSERT(ts == 1661943960000); + ASSERT(used == 176059); + ASSERT(total == 1081101176832); + ASSERT(freed == 66932805); +// ASSERT_EQ(latitude, 24.5208); +// ASSERT_EQ(longitude, 28.09377); +// ASSERT_EQ(elevation, 428); +// ASSERT_EQ(velocity, 0); +// ASSERT_EQ(heading, 304); +// ASSERT_EQ(grade, 0); +// ASSERT_EQ(fuel_consumption, 25); + }else{ +// ASSERT(0); + } + rowIndex++; + } + taos_free_result(pRes); + + return code; +} + int main(int argc, char *argv[]) { int ret = 0; ret = smlProcess_influx_Test(); - if(ret) return ret; + ASSERT(!ret); ret = smlProcess_telnet_Test(); - if(ret) return ret; + ASSERT(!ret); ret = smlProcess_json1_Test(); - if(ret) return ret; + ASSERT(!ret); ret = smlProcess_json2_Test(); - if(ret) return ret; + ASSERT(!ret); ret = smlProcess_json3_Test(); - if(ret) return ret; + ASSERT(!ret); ret = smlProcess_json4_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_TD15662_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_TD15742_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_16384_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_oom_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_16368_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_dup_time_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_16960_Test(); - if(ret) return ret; + ASSERT(!ret); ret = sml_add_tag_col_Test(); + ASSERT(!ret); + ret = smlProcess_18784_Test(); + ASSERT(!ret); return ret; } diff --git a/tests/test/c/tmqDemo.c b/utils/test/c/tmqDemo.c similarity index 100% rename from tests/test/c/tmqDemo.c rename to utils/test/c/tmqDemo.c diff --git a/tests/test/c/tmqSim.c b/utils/test/c/tmqSim.c similarity index 95% rename from tests/test/c/tmqSim.c rename to utils/test/c/tmqSim.c index d39ade7e91495d2b3ff1924efdb78103d7b423cc..71b31ba1071c977d9fd3d2ceb046bdff02ca53df 100644 --- a/tests/test/c/tmqSim.c +++ b/utils/test/c/tmqSim.c @@ -492,7 +492,6 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* field, int32_t length, int32_t precision) { if (val == NULL) { - taosFprintfFile(pFile, "%s", TSDB_DATA_NULL_STR); return; } @@ -540,13 +539,34 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char* val, TAOS_FIELD* f case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_JSON: - memcpy(buf, val, length); - buf[length] = 0; - taosFprintfFile(pFile, "\'%s\'", buf); + { + char quotationStr[2]; + int32_t bufIndex = 0; + quotationStr[0] = 0; + quotationStr[1] = 0; + for (int32_t i = 0; i < length; i++) { + buf[bufIndex] = val[i]; + bufIndex++; + if (val[i] == '\"') { + buf[bufIndex] = val[i]; + bufIndex++; + quotationStr[0] = '\"'; + } + if (val[i] == ',') { + quotationStr[0] = '\"'; + } + } + buf[bufIndex] = 0; + if (length == 0) { + quotationStr[0] = '\"'; + } + + taosFprintfFile(pFile, "%s%s%s", quotationStr, buf, quotationStr); + } break; case TSDB_DATA_TYPE_TIMESTAMP: shellFormatTimestamp(buf, *(int64_t*)val, precision); - taosFprintfFile(pFile, "'%s'", buf); + taosFprintfFile(pFile, "%s", buf); break; default: break; diff --git a/tests/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c similarity index 53% rename from tests/test/c/tmq_taosx_ci.c rename to utils/test/c/tmq_taosx_ci.c index ee5af03f053d0e606ec2e06596e48c0e2f4aba69..f917b9159e9914682c277329ddcfa4e269dc4908 100644 --- a/tests/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -22,8 +22,17 @@ #include "types.h" static int running = 1; -TdFilePtr g_fp = NULL; -char dir[64]={0}; +TdFilePtr g_fp = NULL; +typedef struct{ + bool snapShot; + bool dropTable; + bool subTable; + int srcVgroups; + int dstVgroups; + char dir[64]; +}Config; + +Config g_conf = {0}; static TAOS* use_db(){ TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -41,7 +50,6 @@ static TAOS* use_db(){ } static void msg_process(TAOS_RES* msg) { - /*memset(buf, 0, 1024);*/ printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg)); printf("db: %s\n", tmq_get_db_name(msg)); printf("vg: %d\n", tmq_get_vgroup_id(msg)); @@ -51,8 +59,11 @@ static void msg_process(TAOS_RES* msg) { if (result) { printf("meta result: %s\n", result); } - taosFprintfFile(g_fp, result); - taosFprintfFile(g_fp, "\n"); + if(g_fp){ + taosFprintfFile(g_fp, result); + taosFprintfFile(g_fp, "\n"); + } + tmq_free_json_meta(result); } @@ -61,62 +72,10 @@ static void msg_process(TAOS_RES* msg) { int32_t ret = tmq_write_raw(pConn, raw); printf("write raw data: %s\n", tmq_err2str(ret)); -// else{ -// while(1){ -// int numOfRows = 0; -// void *pData = NULL; -// taos_fetch_raw_block(msg, &numOfRows, &pData); -// if(numOfRows == 0) break; -// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows); -// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg)); -// printf("write raw data: %s\n", tmq_err2str(ret)); -// } -// } - taos_close(pConn); } -int32_t init_env() { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - if (pConn == NULL) { - return -1; - } - - TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx"); - if (taos_errno(pRes) != 0) { - printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 1"); - if (taos_errno(pRes) != 0) { - printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "drop database if exists abc1"); - if (taos_errno(pRes) != 0) { - printf("error in drop db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); - if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - return -1; - } - taos_free_result(pRes); - +int buildDatabase(TAOS* pConn, TAOS_RES* pRes){ pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " "nchar(8), t4 bool)"); @@ -133,7 +92,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')"); + pRes = taos_query(pConn, "insert into ct0 values(1626006833400, 1, 2, 'a')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes)); return -1; @@ -168,7 +127,7 @@ int32_t init_env() { } taos_free_result(pRes); - pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); + pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833603, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')"); if (taos_errno(pRes) != 0) { printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes)); return -1; @@ -224,6 +183,22 @@ int32_t init_env() { } taos_free_result(pRes); + if(g_conf.dropTable){ + pRes = taos_query(pConn, "drop table ct3 ct1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop child table ct3, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + } + pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))"); if (taos_errno(pRes) != 0) { printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes)); @@ -273,6 +248,15 @@ int32_t init_env() { } taos_free_result(pRes); + if(g_conf.dropTable){ + pRes = taos_query(pConn, "drop table n1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop normal table n1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + } + pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)"); if (taos_errno(pRes) != 0) { printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes)); @@ -308,6 +292,129 @@ int32_t init_env() { } taos_free_result(pRes); + if(g_conf.dropTable){ + pRes = taos_query(pConn, + "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 " + "nchar(8), t4 bool)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop table st1"); + if (taos_errno(pRes) != 0) { + printf("failed to drop super table st1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + } + return 0; +} + +int buildStable(TAOS* pConn, TAOS_RES* pRes){ + pRes = taos_query(pConn, "CREATE STABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, `phase` FLOAT) TAGS (`groupid` INT, `location` VARCHAR(16))"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table meters, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table d0 using meters tags(1, 'San Francisco')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table d0, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table d1 using meters tags(2, 'Beijing')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table d1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create stream meters_summary_s into meters_summary as select _wstart, max(current) as current, groupid, location from meters partition by groupid, location interval(10m)"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table meters_summary, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into d0 (ts, current) values (now, 120)"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into table d0, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + return 0; +} + +int32_t init_env() { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx"); + if (taos_errno(pRes) != 0) { + printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + char sql[128] = {0}; + snprintf(sql, 128, "create database if not exists db_taosx vgroups %d", g_conf.dstVgroups); + pRes = taos_query(pConn, sql); + if (taos_errno(pRes) != 0) { + printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop topic if exists topic_db"); + if (taos_errno(pRes) != 0) { + printf("error in drop topic, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop topic if exists meters_summary_t1"); + if (taos_errno(pRes) != 0) { + printf("error in drop topic, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "drop database if exists abc1"); + if (taos_errno(pRes) != 0) { + printf("error in drop db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + snprintf(sql, 128, "create database if not exists abc1 vgroups %d", g_conf.srcVgroups); + pRes = taos_query(pConn, sql); + if (taos_errno(pRes) != 0) { + printf("error in create db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "use abc1"); + if (taos_errno(pRes) != 0) { + printf("error in use db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + if(g_conf.subTable){ + buildStable(pConn, pRes); + }else{ + buildDatabase(pConn, pRes); + } + taos_close(pConn); return 0; } @@ -327,12 +434,21 @@ int32_t create_topic() { } taos_free_result(pRes); - pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1"); - if (taos_errno(pRes) != 0) { - printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes)); - return -1; + if(g_conf.subTable){ + pRes = taos_query(pConn, "create topic meters_summary_t1 with meta as stable meters_summary"); + if (taos_errno(pRes) != 0) { + printf("failed to create topic meters_summary_t1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + }else{ + pRes = taos_query(pConn, "create topic topic_db with meta as database abc1"); + if (taos_errno(pRes) != 0) { + printf("failed to create topic topic_db, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); } - taos_free_result(pRes); taos_close(pConn); return 0; @@ -343,17 +459,6 @@ void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { } tmq_t* build_consumer() { -#if 0 - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - assert(pConn != NULL); - - TAOS_RES* pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - } - taos_free_result(pRes); -#endif - tmq_conf_t* conf = tmq_conf_new(); tmq_conf_set(conf, "group.id", "tg2"); tmq_conf_set(conf, "client.id", "my app 1"); @@ -363,7 +468,9 @@ tmq_t* build_consumer() { tmq_conf_set(conf, "enable.auto.commit", "true"); tmq_conf_set(conf, "enable.heartbeat.background", "true"); - /*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/ + if(g_conf.snapShot){ + tmq_conf_set(conf, "experimental.snapshot.enable", "true"); + } tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); @@ -374,8 +481,11 @@ tmq_t* build_consumer() { tmq_list_t* build_topic_list() { tmq_list_t* topic_list = tmq_list_new(); - tmq_list_append(topic_list, "topic_ctb_column"); - /*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/ + if(g_conf.subTable){ + tmq_list_append(topic_list, "meters_summary_t1"); + }else{ + tmq_list_append(topic_list, "topic_db"); + } return topic_list; } @@ -393,12 +503,7 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) { if (tmqmessage) { cnt++; msg_process(tmqmessage); - /*if (cnt >= 2) break;*/ - /*printf("get data\n");*/ taos_free_result(tmqmessage); - /*} else {*/ - /*break;*/ - /*tmq_commit_sync(tmq, NULL);*/ }else{ break; } @@ -411,52 +516,18 @@ void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) { fprintf(stderr, "%% Consumer closed\n"); } -void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) { - static const int MIN_COMMIT_COUNT = 1; - - int msg_count = 0; - int32_t code; - - if ((code = tmq_subscribe(tmq, topics))) { - fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); - return; - } - - tmq_list_t* subList = NULL; - tmq_subscription(tmq, &subList); - char** subTopics = tmq_list_to_c_array(subList); - int32_t sz = tmq_list_get_size(subList); - printf("subscribed topics: "); - for (int32_t i = 0; i < sz; i++) { - printf("%s, ", subTopics[i]); - } - printf("\n"); - tmq_list_destroy(subList); - - while (running) { - TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000); - if (tmqmessage) { - msg_process(tmqmessage); - taos_free_result(tmqmessage); - - /*tmq_commit_sync(tmq, NULL);*/ - /*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/ - } - } - - code = tmq_consumer_close(tmq); - if (code) - fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code)); - else - fprintf(stderr, "%% Consumer closed\n"); -} - void initLogFile() { char f1[256] = {0}; char f2[256] = {0}; - sprintf(f1, "%s/../log/tmq_taosx_tmp.source", dir); - sprintf(f2, "%s/../log/tmq_taosx_tmp.result", dir); + if(g_conf.snapShot){ + sprintf(f1, "%s/../log/tmq_taosx_tmp_snapshot.source", g_conf.dir); + sprintf(f2, "%s/../log/tmq_taosx_tmp_snapshot.result", g_conf.dir); + }else{ + sprintf(f1, "%s/../log/tmq_taosx_tmp.source", g_conf.dir); + sprintf(f2, "%s/../log/tmq_taosx_tmp.result", g_conf.dir); + } + TdFilePtr pFile = taosOpenFile(f1, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM); if (NULL == pFile) { fprintf(stderr, "Failed to open %s for save result\n", f1); @@ -469,44 +540,76 @@ void initLogFile() { fprintf(stderr, "Failed to open %s for save result\n", f2); exit(-1); } - char *result[] = { - "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", - "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", - "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}", - "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}", - "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}", - "{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}", - "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}", - "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}", - "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", - "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", - "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}" - }; - - for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ - taosFprintfFile(pFile2, result[i]); - taosFprintfFile(pFile2, "\n"); + + if(g_conf.snapShot){ + char *result[] = { + "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":64},{\"name\":\"c4\",\"type\":5}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1},{\"name\":\"t2\",\"type\":8,\"length\":64}]}", + "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", + "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", + "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[]}", + "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":4,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":5000}]}", + "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c2\",\"type\":10,\"length\":8},{\"name\":\"cc3\",\"type\":5}],\"tags\":[]}", + "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", + "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}", + }; + + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } + }else{ + char *result[] = { + "{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}", + "{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}", + "{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}", + "{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}", + "{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}", + "{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}", + "{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}", + "{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}", + "{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}", + "{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}", + "{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}" + }; + + for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){ + taosFprintfFile(pFile2, result[i]); + taosFprintfFile(pFile2, "\n"); + } } + taosCloseFile(&pFile2); } int main(int argc, char* argv[]) { - if(argc == 3 && strcmp(argv[1], "-c") == 0) { - strcpy(dir, argv[2]); - }else{ -// strcpy(dir, "../../../sim/psim/cfg"); - strcpy(dir, "/var/log"); + for (int32_t i = 1; i < argc; i++) { + if(strcmp(argv[i], "-c") == 0){ + strcpy(g_conf.dir, argv[++i]); + }else if(strcmp(argv[i], "-s") == 0){ + g_conf.snapShot = true; + }else if(strcmp(argv[i], "-d") == 0){ + g_conf.dropTable = true; + }else if(strcmp(argv[i], "-sv") == 0){ + g_conf.srcVgroups = atol(argv[++i]); + }else if(strcmp(argv[i], "-dv") == 0){ + g_conf.dstVgroups = atol(argv[++i]); + }else if(strcmp(argv[i], "-t") == 0){ + g_conf.subTable = true; + } } printf("env init\n"); - initLogFile(); + if(strlen(g_conf.dir) != 0){ + initLogFile(); + } if (init_env() < 0) { return -1; @@ -516,6 +619,5 @@ int main(int argc, char* argv[]) { tmq_t* tmq = build_consumer(); tmq_list_t* topic_list = build_topic_list(); basic_consume_loop(tmq, topic_list); - /*sync_consume_loop(tmq, topic_list);*/ taosCloseFile(&g_fp); } diff --git a/tests/tsim/CMakeLists.txt b/utils/tsim/CMakeLists.txt similarity index 100% rename from tests/tsim/CMakeLists.txt rename to utils/tsim/CMakeLists.txt diff --git a/tests/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h similarity index 100% rename from tests/tsim/inc/simInt.h rename to utils/tsim/inc/simInt.h diff --git a/tests/tsim/inc/simParse.h b/utils/tsim/inc/simParse.h similarity index 100% rename from tests/tsim/inc/simParse.h rename to utils/tsim/inc/simParse.h diff --git a/tests/tsim/src/simExe.c b/utils/tsim/src/simExe.c similarity index 99% rename from tests/tsim/src/simExe.c rename to utils/tsim/src/simExe.c index b993a8dbf1377c57af81d767173f5bfd27b688e3..16732ff9a191576d871584253f2c70e9187b6d2f 100644 --- a/tests/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -464,7 +464,10 @@ void simStoreSystemContentResult(SScript *script, char *filename) { taosCloseFile(&pFile); char rmCmd[MAX_FILE_NAME_LEN] = {0}; sprintf(rmCmd, "rm -f %s", filename); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" system(rmCmd); +#pragma GCC diagnostic pop } } diff --git a/tests/tsim/src/simMain.c b/utils/tsim/src/simMain.c similarity index 100% rename from tests/tsim/src/simMain.c rename to utils/tsim/src/simMain.c diff --git a/tests/tsim/src/simParse.c b/utils/tsim/src/simParse.c similarity index 100% rename from tests/tsim/src/simParse.c rename to utils/tsim/src/simParse.c diff --git a/tests/tsim/src/simSystem.c b/utils/tsim/src/simSystem.c similarity index 100% rename from tests/tsim/src/simSystem.c rename to utils/tsim/src/simSystem.c