提交 eafe8666 编写于 作者: L Liu Jicong

merge 3.0

...@@ -39,9 +39,9 @@ TDengine 是一款开源、高性能、云原生的时序数据库 (Time-Series ...@@ -39,9 +39,9 @@ TDengine 是一款开源、高性能、云原生的时序数据库 (Time-Series
# 构建 # 构建
TDengine 目前可以在 Linux、 Windows 等平台上安装和运行。任何 OS 的应用也可以选择 taosAdapter 的 RESTful 接口连接服务端 taosd。CPU 支持 X64/ARM64,后续会支持 MIPS64、Alpha64、ARM32、RISC-V 等 CPU 架构。 TDengine 目前可以在 Linux、 Windows、macOS 等平台上安装和运行。任何 OS 的应用也可以选择 taosAdapter 的 RESTful 接口连接服务端 taosd。CPU 支持 X64/ARM64,后续会支持 MIPS64、Alpha64、ARM32、RISC-V 等 CPU 架构。
用户可根据需求选择通过源码、[容器](https://docs.taosdata.com/get-started/docker/)[安装包](https://docs.taosdata.com/get-started/package/)[Kubenetes](https://docs.taosdata.com/deployment/k8s/)来安装。本快速指南仅适用于通过源码安装。 用户可根据需求选择通过源码、[容器](https://docs.taosdata.com/get-started/docker/)[安装包](https://docs.taosdata.com/get-started/package/)[Kubernetes](https://docs.taosdata.com/deployment/k8s/)来安装。本快速指南仅适用于通过源码安装。
TDengine 还提供一组辅助工具软件 taosTools,目前它包含 taosBenchmark(曾命名为 taosdemo)和 taosdump 两个软件。默认 TDengine 编译不包含 taosTools, 您可以在编译 TDengine 时使用`cmake .. -DBUILD_TOOLS=true` 来同时编译 taosTools。 TDengine 还提供一组辅助工具软件 taosTools,目前它包含 taosBenchmark(曾命名为 taosdemo)和 taosdump 两个软件。默认 TDengine 编译不包含 taosTools, 您可以在编译 TDengine 时使用`cmake .. -DBUILD_TOOLS=true` 来同时编译 taosTools。
...@@ -104,6 +104,12 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco ...@@ -104,6 +104,12 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
sudo yum config-manager --set-enabled Powertools sudo yum config-manager --set-enabled Powertools
``` ```
### macOS
```
sudo brew install argp-standalone pkgconfig
```
### 设置 golang 开发环境 ### 设置 golang 开发环境
TDengine 包含数个使用 Go 语言开发的组件,比如taosAdapter, 请参考 golang.org 官方文档设置 go 开发环境。 TDengine 包含数个使用 Go 语言开发的组件,比如taosAdapter, 请参考 golang.org 官方文档设置 go 开发环境。
...@@ -210,14 +216,14 @@ cmake .. -G "NMake Makefiles" ...@@ -210,14 +216,14 @@ cmake .. -G "NMake Makefiles"
nmake nmake
``` ```
<!-- ### macOS 系统 ### macOS 系统
安装 Xcode 命令行工具和 cmake. 在 Catalina 和 Big Sur 操作系统上,需要安装 XCode 11.4+ 版本。 安装 XCode 命令行工具和 cmake. 在 Catalina 和 Big Sur 操作系统上,需要安装 XCode 11.4+ 版本。
```bash ```bash
mkdir debug && cd debug mkdir debug && cd debug
cmake .. && cmake --build . cmake .. && cmake --build .
``` --> ```
# 安装 # 安装
...@@ -263,6 +269,24 @@ nmake install ...@@ -263,6 +269,24 @@ nmake install
sudo make install sudo make install
``` ```
用户可以在[文件目录结构](https://docs.taosdata.com/reference/directory/)中了解更多在操作系统中生成的目录或文件。
从源代码安装也会为 TDengine 配置服务管理 ,用户也可以选择[从安装包中安装](https://docs.taosdata.com/get-started/package/)
安装成功后,可以在应用程序中双击 TDengine 图标启动服务,或者在终端中启动 TDengine 服务:
```bash
launchctl start taosd
```
用户可以使用 TDengine CLI 来连接 TDengine 服务,在终端中,输入:
```bash
taos
```
如果 TDengine CLI 连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印出错误消息。
## 快速运行 ## 快速运行
如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ): 如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ):
......
...@@ -19,7 +19,7 @@ English | [简体中文](README-CN.md) | [Learn more about TSDB](https://tdengin ...@@ -19,7 +19,7 @@ English | [简体中文](README-CN.md) | [Learn more about TSDB](https://tdengin
# What is TDengine? # What is TDengine?
TDengine is an open source, high-performance, cloud native [time-series database](https://tdengine.com/tsdb/) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. TDengine differentiates itself from other time-seires databases with the following advantages: TDengine is an open source, high-performance, cloud native [time-series database](https://tdengine.com/tsdb/) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. TDengine differentiates itself from other time-series databases with the following advantages:
- **[High Performance](https://tdengine.com/tdengine/high-performance-time-series-database/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression. - **[High Performance](https://tdengine.com/tdengine/high-performance-time-series-database/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression.
...@@ -41,7 +41,7 @@ For user manual, system design and architecture, please refer to [TDengine Docum ...@@ -41,7 +41,7 @@ For user manual, system design and architecture, please refer to [TDengine Docum
# Building # Building
At the moment, TDengine server supports running on Linux and Windows systems. Any application can also choose the RESTful interface provided by taosAdapter to connect the taosd service . TDengine supports X64/ARM64 CPU, and it will support MIPS64, Alpha64, ARM32, RISC-V and other CPU architectures in the future. At the moment, TDengine server supports running on Linux/Windows/macOS systems. Any application can also choose the RESTful interface provided by taosAdapter to connect the taosd service . TDengine supports X64/ARM64 CPU, and it will support MIPS64, Alpha64, ARM32, RISC-V and other CPU architectures in the future.
You can choose to install through source code, [container](https://docs.tdengine.com/get-started/docker/), [installation package](https://docs.tdengine.com/get-started/package/) or [Kubernetes](https://docs.tdengine.com/deployment/k8s/). This quick guide only applies to installing from source. You can choose to install through source code, [container](https://docs.tdengine.com/get-started/docker/), [installation package](https://docs.tdengine.com/get-started/package/) or [Kubernetes](https://docs.tdengine.com/deployment/k8s/). This quick guide only applies to installing from source.
...@@ -105,6 +105,12 @@ If the PowerTools installation fails, you can try to use: ...@@ -105,6 +105,12 @@ If the PowerTools installation fails, you can try to use:
sudo yum config-manager --set-enabled powertools sudo yum config-manager --set-enabled powertools
``` ```
### macOS
```
sudo brew install argp-standalone pkgconfig
```
### Setup golang environment ### Setup golang environment
TDengine includes a few components like taosAdapter developed by Go language. Please refer to golang.org official documentation for golang environment setup. TDengine includes a few components like taosAdapter developed by Go language. Please refer to golang.org official documentation for golang environment setup.
...@@ -213,14 +219,14 @@ cmake .. -G "NMake Makefiles" ...@@ -213,14 +219,14 @@ cmake .. -G "NMake Makefiles"
nmake nmake
``` ```
<!-- ### On macOS platform ### On macOS platform
Please install XCode command line tools and cmake. Verified with XCode 11.4+ on Catalina and Big Sur. Please install XCode command line tools and cmake. Verified with XCode 11.4+ on Catalina and Big Sur.
```shell ```shell
mkdir debug && cd debug mkdir debug && cd debug
cmake .. && cmake --build . cmake .. && cmake --build .
``` --> ```
# Installing # Installing
...@@ -258,7 +264,7 @@ After building successfully, TDengine can be installed by: ...@@ -258,7 +264,7 @@ After building successfully, TDengine can be installed by:
nmake install nmake install
``` ```
<!--
## On macOS platform ## On macOS platform
After building successfully, TDengine can be installed by: After building successfully, TDengine can be installed by:
...@@ -266,7 +272,24 @@ After building successfully, TDengine can be installed by: ...@@ -266,7 +272,24 @@ After building successfully, TDengine can be installed by:
```bash ```bash
sudo make install sudo make install
``` ```
-->
Users can find more information about directories installed on the system in the [directory and files](https://docs.tdengine.com/reference/directory/) section.
Installing from source code will also configure service management for TDengine.Users can also choose to [install from packages](https://docs.tdengine.com/get-started/package/) for it.
To start the service after installation, double-click the /applications/TDengine to start the program, or in a terminal, use:
```bash
launchctl start taosd
```
Then users can use the TDengine CLI to connect the TDengine server. In a terminal, use:
```bash
taos
```
If TDengine CLI connects the server successfully, welcome messages and version info are printed. Otherwise, an error message is shown.
## Quick Run ## Quick Run
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# taos-tools # taos-tools
ExternalProject_Add(taos-tools ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG 70f5a1c GIT_TAG 85179e9
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR "" BINARY_DIR ""
#BUILD_IN_SOURCE TRUE #BUILD_IN_SOURCE TRUE
......
...@@ -50,7 +50,7 @@ taos> ...@@ -50,7 +50,7 @@ taos>
After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance: After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a Linux or Windows terminal. Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a terminal.
```bash ```bash
taosBenchmark taosBenchmark
......
...@@ -7,7 +7,7 @@ import Tabs from "@theme/Tabs"; ...@@ -7,7 +7,7 @@ import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem"; import TabItem from "@theme/TabItem";
import PkgListV3 from "/components/PkgListV3"; import PkgListV3 from "/components/PkgListV3";
This document describes how to install TDengine on Linux and Windows and perform queries and inserts. This document describes how to install TDengine on Linux/Windows/macOS and perform queries and inserts.
- The easiest way to explore TDengine is through [TDengine Cloud](http://cloud.tdengine.com). - The easiest way to explore TDengine is through [TDengine Cloud](http://cloud.tdengine.com).
- To get started with TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). - To get started with TDengine on Docker, see [Quick Install on Docker](../../get-started/docker).
...@@ -17,7 +17,7 @@ The full package of TDengine includes the TDengine Server (`taosd`), TDengine Cl ...@@ -17,7 +17,7 @@ The full package of TDengine includes the TDengine Server (`taosd`), TDengine Cl
The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download the Lite package that includes only `taosd` and the C/C++ connector. The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download the Lite package that includes only `taosd` and the C/C++ connector.
The TDengine Community Edition is released as Deb and RPM packages. The Deb package can be installed on Debian, Ubuntu, and derivative systems. The RPM package can be installed on CentOS, RHEL, SUSE, and derivative systems. A .tar.gz package is also provided for enterprise customers, and you can install TDengine over `apt-get` as well. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the Deb or RPM package, download and install taosTools separately. TDengine can also be installed on 64-bit Windows. The TDengine Community Edition is released as Deb and RPM packages. The Deb package can be installed on Debian, Ubuntu, and derivative systems. The RPM package can be installed on CentOS, RHEL, SUSE, and derivative systems. A .tar.gz package is also provided for enterprise customers, and you can install TDengine over `apt-get` as well. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the Deb or RPM package, download and install taosTools separately. TDengine can also be installed on x64 Windows and x64/m1 macOS.
## Installation ## Installation
...@@ -111,6 +111,13 @@ Note: TDengine only supports Windows Server 2016/2019 and Windows 10/11 on the W ...@@ -111,6 +111,13 @@ Note: TDengine only supports Windows Server 2016/2019 and Windows 10/11 on the W
<PkgListV3 type={3}/> <PkgListV3 type={3}/>
2. Run the downloaded package to install TDengine. 2. Run the downloaded package to install TDengine.
</TabItem>
<TabItem label="macOS" value="macos">
1. Download the macOS installation package.
<PkgListV3 type={7}/>
2. Run the downloaded package to install TDengine.
</TabItem> </TabItem>
</Tabs> </Tabs>
...@@ -178,12 +185,33 @@ The following `systemctl` commands can help you manage TDengine service: ...@@ -178,12 +185,33 @@ The following `systemctl` commands can help you manage TDengine service:
After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengine Server. After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengine Server.
</TabItem>
<TabItem label="macOS" value="macos">
After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start taosd` to start TDengine Server.
The following `launchctl` commands can help you manage TDengine service:
- Start TDengine Server: `launchctl start taosd`
- Stop TDengine Server: `launchctl stop taosd`
- Check TDengine Server status: `launchctl list | grep taosd`
:::info
- The `launchctl` command does not require _root_ privileges. You don't need to use the `sudo` command.
- The first content returned by the `launchctl list | grep taosd` command is the PID of the program, if '-' indicates that the TDengine service is not running.
:::
</TabItem> </TabItem>
</Tabs> </Tabs>
## Command Line Interface (CLI) ## Command Line Interface (CLI)
You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in the Linux terminal where TDengine is installed, or you can run `taos.exe` in the `C:\TDengine` directory of the Windows terminal where TDengine is installed to start the TDengine command line. You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in the Linux/macOS terminal where TDengine is installed, or you can run `taos.exe` in the `C:\TDengine` directory of the Windows terminal where TDengine is installed to start the TDengine command line.
```bash ```bash
taos taos
...@@ -213,13 +241,13 @@ SELECT * FROM t; ...@@ -213,13 +241,13 @@ SELECT * FROM t;
Query OK, 2 row(s) in set (0.003128s) Query OK, 2 row(s) in set (0.003128s)
``` ```
You can also can monitor the deployment status, add and remove user accounts, and manage running instances. You can run the TDengine CLI on either Linux or Windows machines. For more information, see [TDengine CLI](../../reference/taos-shell/). You can also can monitor the deployment status, add and remove user accounts, and manage running instances. You can run the TDengine CLI on either machines. For more information, see [TDengine CLI](../../reference/taos-shell/).
## Test data insert performance ## Test data insert performance
After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance: After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a Linux or Windows terminal. Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a terminal.
```bash ```bash
taosBenchmark taosBenchmark
......
...@@ -3,7 +3,7 @@ title: Get Started ...@@ -3,7 +3,7 @@ title: Get Started
description: This article describes how to install TDengine and test its performance. description: This article describes how to install TDengine and test its performance.
--- ---
You can install and run TDengine on Linux and Windows machines as well as Docker containers. You can also deploy TDengine as a managed service with TDengine Cloud. You can install and run TDengine on Linux/Windows/macOS machines as well as Docker containers. You can also deploy TDengine as a managed service with TDengine Cloud.
The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter). The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter).
......
...@@ -11,7 +11,7 @@ SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW ...@@ -11,7 +11,7 @@ SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW
SELECT [DISTINCT] select_list SELECT [DISTINCT] select_list
from_clause from_clause
[WHERE condition] [WHERE condition]
[PARTITION BY tag_list] [partition_by_clause]
[window_clause] [window_clause]
[group_by_clause] [group_by_clause]
[order_by_clasue] [order_by_clasue]
...@@ -52,6 +52,9 @@ window_clause: { ...@@ -52,6 +52,9 @@ window_clause: {
| STATE_WINDOW(col) | STATE_WINDOW(col)
| INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)]
partition_by_clause:
PARTITION BY expr [, expr] ...
group_by_clause: group_by_clause:
GROUP BY expr [, expr] ... HAVING condition GROUP BY expr [, expr] ... HAVING condition
......
...@@ -6,7 +6,7 @@ title: Problem Diagnostics ...@@ -6,7 +6,7 @@ title: Problem Diagnostics
When a TDengine client is unable to access a TDengine server, the network connection between the client side and the server side must be checked to find the root cause and resolve problems. When a TDengine client is unable to access a TDengine server, the network connection between the client side and the server side must be checked to find the root cause and resolve problems.
Diagnostics for network connections can be executed between Linux and Linux or between Linux and Windows. Diagnostics for network connections can be executed between Linux/Windows/macOS.
Diagnostic steps: Diagnostic steps:
......
...@@ -13,11 +13,13 @@ After TDengine server or client installation, `taos.h` is located at ...@@ -13,11 +13,13 @@ After TDengine server or client installation, `taos.h` is located at
- Linux:`/usr/local/taos/include` - Linux:`/usr/local/taos/include`
- Windows:`C:\TDengine\include` - Windows:`C:\TDengine\include`
- macOS:`/usr/local/include`
The dynamic libraries for the TDengine client driver are located in. The dynamic libraries for the TDengine client driver are located in.
- Linux: `/usr/local/taos/driver/libtaos.so` - Linux: `/usr/local/taos/driver/libtaos.so`
- Windows: `C:\TDengine\taos.dll` - Windows: `C:\TDengine\taos.dll`
- macOS: `/usr/local/lib/libtaos.dylib`
## Supported platforms ## Supported platforms
...@@ -119,7 +121,7 @@ This section shows sample code for standard access methods to TDengine clusters ...@@ -119,7 +121,7 @@ This section shows sample code for standard access methods to TDengine clusters
:::info :::info
More example code and downloads are available at [GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/c). More example code and downloads are available at [GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/c).
You can find it in the installation directory under the `examples/c` path. This directory has a makefile and can be compiled under Linux by executing `make` directly. You can find it in the installation directory under the `examples/c` path. This directory has a makefile and can be compiled under Linux/macOS by executing `make` directly.
**Hint:** When compiling in an ARM environment, please remove `-msse4.2` from the makefile. This option is only supported on the x64/x86 hardware platforms. **Hint:** When compiling in an ARM environment, please remove `-msse4.2` from the makefile. This option is only supported on the x64/x86 hardware platforms.
::: :::
......
...@@ -120,13 +120,13 @@ Connection conn = DriverManager.getConnection(jdbcUrl); ...@@ -120,13 +120,13 @@ Connection conn = DriverManager.getConnection(jdbcUrl);
In the above example, TSDBDriver, which uses a JDBC native connection, establishes a connection to a hostname `taosdemo.com`, port `6030` (the default port for TDengine), and a database named `test`. In this URL, the user name `user` is specified as `root`, and the `password` is `taosdata`. In the above example, TSDBDriver, which uses a JDBC native connection, establishes a connection to a hostname `taosdemo.com`, port `6030` (the default port for TDengine), and a database named `test`. In this URL, the user name `user` is specified as `root`, and the `password` is `taosdata`.
Note: With JDBC native connections, taos-jdbcdriver relies on the client driver (`libtaos.so` on Linux; `taos.dll` on Windows). Note: With JDBC native connections, taos-jdbcdriver relies on the client driver (`libtaos.so` on Linux; `taos.dll` on Windows; `libtaos.dylib` on macOS).
The configuration parameters in the URL are as follows: The configuration parameters in the URL are as follows:
- user: Log in to the TDengine username. The default value is 'root'. - user: Log in to the TDengine username. The default value is 'root'.
- password: User login password, the default value is 'taosdata'. - password: User login password, the default value is 'taosdata'.
- cfgdir: client configuration file directory path, default '/etc/taos' on Linux OS, 'C:/TDengine/cfg' on Windows OS. - cfgdir: client configuration file directory path, default '/etc/taos' on Linux OS, 'C:/TDengine/cfg' on Windows OS, '/etc/taos' on macOS.
- charset: The character set used by the client, the default value is the system character set. - charset: The character set used by the client, the default value is the system character set.
- locale: Client locale, by default, use the system's current locale. - locale: Client locale, by default, use the system's current locale.
- timezone: The time zone used by the client, the default value is the system's current time zone. - timezone: The time zone used by the client, the default value is the system's current time zone.
...@@ -172,7 +172,7 @@ In the above example, JDBC uses the client's configuration file to establish a c ...@@ -172,7 +172,7 @@ In the above example, JDBC uses the client's configuration file to establish a c
In TDengine, as long as one node in firstEp and secondEp is valid, the connection to the cluster can be established normally. In TDengine, as long as one node in firstEp and secondEp is valid, the connection to the cluster can be established normally.
The configuration file here refers to the configuration file on the machine where the application that calls the JDBC Connector is located, the default path is `/etc/taos/taos.cfg` on Linux, and the default path is `C://TDengine/cfg/taos.cfg` on Windows. The configuration file here refers to the configuration file on the machine where the application that calls the JDBC Connector is located, the default path is `/etc/taos/taos.cfg` on Linux, the default path is `C://TDengine/cfg/taos.cfg` on Windows, and the default path is `/etc/taos/taos.cfg` on macOS.
</TabItem> </TabItem>
<TabItem value="rest" label="REST connection"> <TabItem value="rest" label="REST connection">
...@@ -261,7 +261,7 @@ The configuration parameters in properties are as follows. ...@@ -261,7 +261,7 @@ The configuration parameters in properties are as follows.
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'. - TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false. - TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sql. false: no longer execute any statement after the failed SQL. The default value is: false. - TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sql. false: no longer execute any statement after the failed SQL. The default value is: false.
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS. - TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS, default value `/etc/taos` on macOS.
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set. - TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale. - TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone. - TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
...@@ -896,7 +896,7 @@ The source code of the sample application is under `TDengine/examples/JDBC`: ...@@ -896,7 +896,7 @@ The source code of the sample application is under `TDengine/examples/JDBC`:
**Cause**: The program did not find the dependent native library `taos`. **Cause**: The program did not find the dependent native library `taos`.
**Solution**: On Windows you can copy `C:\TDengine\driver\taos.dll` to the `C:\Windows\System32` directory, on Linux the following soft link will be created `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` will work. **Solution**: On Windows you can copy `C:\TDengine\driver\taos.dll` to the `C:\Windows\System32` directory, on Linux the following soft link will be created `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` will work, on macOS the lib soft link will be `/usr/local/lib/libtaos.dylib`.
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform 3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
......
...@@ -186,7 +186,7 @@ All arguments of the `connect()` function are optional keyword arguments. The fo ...@@ -186,7 +186,7 @@ All arguments of the `connect()` function are optional keyword arguments. The fo
- `user` : The TDengine user name. The default value is `root`. - `user` : The TDengine user name. The default value is `root`.
- `password` : TDengine user password. The default value is `taosdata`. - `password` : TDengine user password. The default value is `taosdata`.
- `port` : The starting port of the data node to connect to, i.e., the serverPort configuration. The default value is 6030, which will only take effect if the host parameter is provided. - `port` : The starting port of the data node to connect to, i.e., the serverPort configuration. The default value is 6030, which will only take effect if the host parameter is provided.
- `config` : The path to the client configuration file. On Windows systems, the default is `C:\TDengine\cfg`. The default is `/etc/taos/` on Linux systems. - `config` : The path to the client configuration file. On Windows systems, the default is `C:\TDengine\cfg`. The default is `/etc/taos/` on Linux/macOS.
- `timezone` : The timezone used to convert the TIMESTAMP data in the query results to python `datetime` objects. The default is the local timezone. - `timezone` : The timezone used to convert the TIMESTAMP data in the query results to python `datetime` objects. The default is the local timezone.
:::warning :::warning
......
...@@ -13,11 +13,13 @@ After TDengine client or server is installed, `taos.h` is located at: ...@@ -13,11 +13,13 @@ After TDengine client or server is installed, `taos.h` is located at:
- Linux:`/usr/local/taos/include` - Linux:`/usr/local/taos/include`
- Windows:`C:\TDengine\include` - Windows:`C:\TDengine\include`
- macOS:`/usr/local/include`
TDengine client driver is located at: TDengine client driver is located at:
- Linux: `/usr/local/taos/driver/libtaos.so` - Linux: `/usr/local/taos/driver/libtaos.so`
- Windows: `C:\TDengine\taos.dll` - Windows: `C:\TDengine\taos.dll`
- macOS:`/usr/local/lib/libtaos.dylib`
## Supported Platforms ## Supported Platforms
......
...@@ -6,5 +6,6 @@ Since the TDengine client driver is written in C, using the native connection re ...@@ -6,5 +6,6 @@ Since the TDengine client driver is written in C, using the native connection re
- libtaos.so: After successful installation of TDengine on a Linux system, the dependent Linux version of the client driver `libtaos.so` file will be automatically linked to `/usr/lib/libtaos.so`, which is included in the Linux scannable path and does not need to be specified separately. - libtaos.so: After successful installation of TDengine on a Linux system, the dependent Linux version of the client driver `libtaos.so` file will be automatically linked to `/usr/lib/libtaos.so`, which is included in the Linux scannable path and does not need to be specified separately.
- taos.dll: After installing the client on Windows, the dependent Windows version of the client driver taos.dll file will be automatically copied to the system default search path C:/Windows/System32, again without the need to specify it separately. - taos.dll: After installing the client on Windows, the dependent Windows version of the client driver taos.dll file will be automatically copied to the system default search path C:/Windows/System32, again without the need to specify it separately.
- libtaos.dylib: After successful installation of TDengine on a mac system, the dependent macOS version of the client driver `libtaos.dylib` file will be automatically linked to `/usr/local/lib/libtaos.dylib`, which is included in the macOS scannable path and does not need to be specified separately.
::: :::
...@@ -8,13 +8,15 @@ TDengine provides a rich set of APIs (application development interface). To fac ...@@ -8,13 +8,15 @@ TDengine provides a rich set of APIs (application development interface). To fac
## Supported platforms ## Supported platforms
Currently, TDengine's native interface connectors can support platforms such as x64 and ARM hardware platforms and Linux and Windows development environments. The comparison matrix is as follows. Currently, TDengine's native interface connectors can support platforms such as x64 and ARM hardware platforms and Linux/Windows/macOS development environments. The comparison matrix is as follows.
| **CPU** | **OS** | **Java** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ | | **CPU** | **OS** | **Java** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ |
| -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- | | -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- |
| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● | | **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● |
| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● | | **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● |
| **X86 64bit** | **macOS** | ○ | ● | ● | ○ | ○ | ● | ● |
| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | | **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● |
| **ARM64** | **macOS** | ○ | ● | ● | ○ | ○ | ● | ● |
Where ● means the official test verification passed, ○ means the unofficial test verification passed, -- means no assurance. Where ● means the official test verification passed, ○ means the unofficial test verification passed, -- means no assurance.
......
...@@ -196,7 +196,8 @@ Support InfluxDB query parameters as follows. ...@@ -196,7 +196,8 @@ Support InfluxDB query parameters as follows.
- `u` TDengine user name - `u` TDengine user name
- `p` TDengine password - `p` TDengine password
Note: InfluxDB token authorization is not supported at present. Only Basic authorization and query parameter validation are supported. Note: InfluxDB token authorization is not supported at present. Only Basic authorization and query parameter validation are supported.
Example: curl --request POST http://127.0.0.1:6041/influxdb/v1/write?db=test --user "root:taosdata" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
### OpenTSDB ### OpenTSDB
......
...@@ -12,7 +12,7 @@ If executed on the TDengine server-side, there is no need for additional install ...@@ -12,7 +12,7 @@ If executed on the TDengine server-side, there is no need for additional install
## Execution ## Execution
To access the TDengine CLI, you can execute `taos` command-line utility from a Linux terminal or Windows terminal. To access the TDengine CLI, you can execute `taos` command-line utility from a terminal.
```bash ```bash
taos taos
......
...@@ -5,28 +5,28 @@ description: "List of platforms supported by TDengine server, client, and connec ...@@ -5,28 +5,28 @@ description: "List of platforms supported by TDengine server, client, and connec
## List of supported platforms for TDengine server ## List of supported platforms for TDengine server
| | **Windows Server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** | | | **Windows Server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** | **macOS** |
| ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | | ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | --------- |
| X64 | ● | ● | ● | ● | | X64 | ● | ● | ● | ● | ● |
| ARM64 | | | ● | | | ARM64 | | | ● | | ● |
Note: ● means officially tested and verified, ○ means unofficially tested and verified. Note: ● means officially tested and verified, ○ means unofficially tested and verified.
## List of supported platforms for TDengine clients and connectors ## List of supported platforms for TDengine clients and connectors
TDengine's connector can support a wide range of platforms, including X64/X86/ARM64/ARM32/MIPS/Alpha hardware platforms and Linux/Win64/Win32 development environments. TDengine's connector can support a wide range of platforms, including X64/X86/ARM64/ARM32/MIPS/Alpha hardware platforms and Linux/Win64/Win32/macOS development environments.
The comparison matrix is as follows. The comparison matrix is as follows.
| **CPU** | **X64 64bit** | **X64 64bit** | **ARM64** | | **CPU** | **X64 64bit** | **X64 64bit** | **ARM64** | **X64 64bit** | **ARM64** |
| ----------- | ------------- | ------------- | --------- | | ----------- | ------------- | ------------- | --------- | ------------- | --------- |
| **OS** | **Linux** | **Win64** | **Linux** | | **OS** | **Linux** | **Win64** | **Linux** | **macOS** | **macOS** |
| **C/C++** | ● | ● | ● | | **C/C++** | ● | ● | ● | ● | ● |
| **JDBC** | ● | ● | ● | | **JDBC** | ● | ● | ● | ○ | ○ |
| **Python** | ● | ● | ● | | **Python** | ● | ● | ● | ● | ● |
| **Go** | ● | ● | ● | | **Go** | ● | ● | ● | ● | ● |
| **NodeJs** | ● | ● | ● | | **NodeJs** | ● | ● | ● | ○ | ○ |
| **C#** | ● | ● | ○ | | **C#** | ● | ● | ○ | ○ | ○ |
| **RESTful** | ● | ● | ● | | **RESTful** | ● | ● | ● | ● | ● |
Note: ● means the official test is verified, ○ means the unofficial test is verified, -- means not verified. Note: ● means the official test is verified, ○ means the unofficial test is verified, -- means not verified.
...@@ -205,7 +205,7 @@ The parameters described in this document by the effect that they have on the sy ...@@ -205,7 +205,7 @@ The parameters described in this document by the effect that they have on the sy
:::info :::info
To handle the data insertion and data query from multiple timezones, Unix Timestamp is used and stored in TDengine. The timestamp generated from any timezones at same time is same in Unix timestamp. Note that Unix timestamps are converted and recorded on the client side. To make sure the time on client side can be converted to Unix timestamp correctly, the timezone must be set properly. To handle the data insertion and data query from multiple timezones, Unix Timestamp is used and stored in TDengine. The timestamp generated from any timezones at same time is same in Unix timestamp. Note that Unix timestamps are converted and recorded on the client side. To make sure the time on client side can be converted to Unix timestamp correctly, the timezone must be set properly.
On Linux system, TDengine clients automatically obtain timezone from the host. Alternatively, the timezone can be configured explicitly in configuration file `taos.cfg` like below. For example: On Linux/macOS, TDengine clients automatically obtain timezone from the host. Alternatively, the timezone can be configured explicitly in configuration file `taos.cfg` like below. For example:
``` ```
timezone UTC-8 timezone UTC-8
...@@ -248,9 +248,9 @@ To avoid the problems of using time strings, Unix timestamp can be used directly ...@@ -248,9 +248,9 @@ To avoid the problems of using time strings, Unix timestamp can be used directly
:::info :::info
A specific type "nchar" is provided in TDengine to store non-ASCII characters such as Chinese, Japanese, and Korean. The characters to be stored in nchar type are firstly encoded in UCS4-LE before sending to server side. Note that the correct encoding is determined by the user. To store non-ASCII characters correctly, the encoding format of the client side needs to be set properly. A specific type "nchar" is provided in TDengine to store non-ASCII characters such as Chinese, Japanese, and Korean. The characters to be stored in nchar type are firstly encoded in UCS4-LE before sending to server side. Note that the correct encoding is determined by the user. To store non-ASCII characters correctly, the encoding format of the client side needs to be set properly.
The characters input on the client side are encoded using the default system encoding, which is UTF-8 on Linux, or GB18030 or GBK on some systems in Chinese, POSIX in docker, CP936 on Windows in Chinese. The encoding of the operating system in use must be set correctly so that the characters in nchar type can be converted to UCS4-LE. The characters input on the client side are encoded using the default system encoding, which is UTF-8 on Linux/macOS, or GB18030 or GBK on some systems in Chinese, POSIX in docker, CP936 on Windows in Chinese. The encoding of the operating system in use must be set correctly so that the characters in nchar type can be converted to UCS4-LE.
The locale definition standard on Linux is: <Language\>\_<Region\>.<charset\>, for example, in "zh_CN.UTF-8", "zh" means Chinese, "CN" means China mainland, "UTF-8" means charset. The charset indicates how to display the characters. On Linux and Mac OSX, the charset can be set by locale in the system. On Windows system another configuration parameter `charset` must be used to configure charset because the locale used on Windows is not POSIX standard. Of course, `charset` can also be used on Linux to specify the charset. The locale definition standard on Linux/macOS is: <Language\>\_<Region\>.<charset\>, for example, in "zh_CN.UTF-8", "zh" means Chinese, "CN" means China mainland, "UTF-8" means charset. The charset indicates how to display the characters. On Linux/macOS, the charset can be set by locale in the system. On Windows system another configuration parameter `charset` must be used to configure charset because the locale used on Windows is not POSIX standard. Of course, `charset` can also be used on Linux/macOS to specify the charset.
::: :::
...@@ -263,9 +263,9 @@ The locale definition standard on Linux is: <Language\>\_<Region\>.<charset\>, f ...@@ -263,9 +263,9 @@ The locale definition standard on Linux is: <Language\>\_<Region\>.<charset\>, f
| Default Value | charset set in the system | | Default Value | charset set in the system |
:::info :::info
On Linux, if `charset` is not set in `taos.cfg`, when `taos` is started, the charset is obtained from system locale. If obtaining charset from system locale fails, `taos` would fail to start. On Linux/macOS, if `charset` is not set in `taos.cfg`, when `taos` is started, the charset is obtained from system locale. If obtaining charset from system locale fails, `taos` would fail to start.
So on Linux system, if system locale is set properly, it's not necessary to set `charset` in `taos.cfg`. For example: So on Linux/macOS, if system locale is set properly, it's not necessary to set `charset` in `taos.cfg`. For example:
``` ```
locale zh_CN.UTF-8 locale zh_CN.UTF-8
...@@ -279,7 +279,7 @@ charset CP936 ...@@ -279,7 +279,7 @@ charset CP936
Refer to the documentation for your operating system before changing the charset. Refer to the documentation for your operating system before changing the charset.
On a Linux system, if the charset contained in `locale` is not consistent with that set by `charset`, the later setting in the configuration file takes precedence. On a Linux/macOS, if the charset contained in `locale` is not consistent with that set by `charset`, the later setting in the configuration file takes precedence.
``` ```
locale zh_CN.UTF-8 locale zh_CN.UTF-8
...@@ -675,7 +675,7 @@ To prevent system resource from being exhausted by multiple concurrent streams, ...@@ -675,7 +675,7 @@ To prevent system resource from being exhausted by multiple concurrent streams,
| Meaning | Whether to generate core file when server crashes | | Meaning | Whether to generate core file when server crashes |
| Value Range | 0: false, 1: true | | Value Range | 0: false, 1: true |
| Default Value | 1 | | Default Value | 1 |
| Note | The core file is generated under root directory `systemctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux Shell. | | Note | The core file is generated under root directory `systemctl/launchctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux/macOS Shell. |
### udf ### udf
......
...@@ -55,14 +55,16 @@ This error indicates that the client could not connect to the server. Perform th ...@@ -55,14 +55,16 @@ This error indicates that the client could not connect to the server. Perform th
7. If you are using the Python, Java, Go, Rust, C#, or Node.js connector on Linux to connect to the server, verify that `libtaos.so` is in the `/usr/local/taos/driver` directory and `/usr/local/taos/driver` is in the `LD_LIBRARY_PATH` environment variable. 7. If you are using the Python, Java, Go, Rust, C#, or Node.js connector on Linux to connect to the server, verify that `libtaos.so` is in the `/usr/local/taos/driver` directory and `/usr/local/taos/driver` is in the `LD_LIBRARY_PATH` environment variable.
8. If you are using Windows, verify that `C:\TDengine\driver\taos.dll` is in the `PATH` environment variable. If possible, move `taos.dll` to the `C:\Windows\System32` directory. 8. If you are using macOS, verify that `libtaos.dylib` is in the `/usr/local/lib` directory and `/usr/local/lib` is in the `LD_LIBRARY_PATH` environment variable..
9. On Linux systems, you can use the `nc` tool to check whether a port is accessible: 9. If you are using Windows, verify that `C:\TDengine\driver\taos.dll` is in the `PATH` environment variable. If possible, move `taos.dll` to the `C:\Windows\System32` directory.
10. On Linux/macOS, you can use the `nc` tool to check whether a port is accessible:
- To check whether a UDP port is open, run `nc -vuz {hostIP} {port}`. - To check whether a UDP port is open, run `nc -vuz {hostIP} {port}`.
- To check whether a TCP port on the server side is open, run `nc -l {port}`. - To check whether a TCP port on the server side is open, run `nc -l {port}`.
- To check whether a TCP port on client side is open, run `nc {hostIP} {port}`. - To check whether a TCP port on client side is open, run `nc {hostIP} {port}`.
10. On Windows systems, you can run `Test-NetConnection -ComputerName {fqdn} -Port {port}` in PowerShell to check whether a port on the server side is accessible. On Windows systems, you can run `Test-NetConnection -ComputerName {fqdn} -Port {port}` in PowerShell to check whether a port on the server side is accessible.
11. You can also use the TDengine CLI to diagnose network issues. For more information, see [Problem Diagnostics](https://docs.tdengine.com/operation/diagnose/). 11. You can also use the TDengine CLI to diagnose network issues. For more information, see [Problem Diagnostics](https://docs.tdengine.com/operation/diagnose/).
......
...@@ -46,7 +46,7 @@ taos> ...@@ -46,7 +46,7 @@ taos>
可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。 可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。
启动 TDengine 的服务,在 Linux 或 Windows 终端执行 `taosBenchmark`(曾命名为 `taosdemo`): 启动 TDengine 的服务,在终端执行 `taosBenchmark`(曾命名为 `taosdemo`):
```bash ```bash
$ taosBenchmark $ taosBenchmark
......
...@@ -10,11 +10,11 @@ import PkgListV3 from "/components/PkgListV3"; ...@@ -10,11 +10,11 @@ import PkgListV3 from "/components/PkgListV3";
您可以[用 Docker 立即体验](../../get-started/docker/) TDengine。如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装. 您可以[用 Docker 立即体验](../../get-started/docker/) TDengine。如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
TDengine 完整的软件包包括服务端(taosd)、应用驱动(taosc)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、命令行程序(CLI,taos)和一些工具软件。目前 taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../../reference/taosadapter/) 提供 [RESTful 接口](../../connector/rest-api/) TDengine 完整的软件包包括服务端(taosd)、应用驱动(taosc)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、命令行程序(CLI,taos)和一些工具软件。目前 taosdump、TDinsight 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../../reference/taosadapter/) 提供 [RESTful 接口](../../connector/rest-api/)
为方便使用,标准的服务端安装包包含了 taosd、taosAdapter、taosc、taos、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 Lite 版本的安装包。 为方便使用,标准的服务端安装包包含了 taosd、taosAdapter、taosc、taos、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 Lite 版本的安装包。
在 Linux 系统上,TDengine 社区版提供 Deb 和 RPM 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 Deb 支持 Debian/Ubuntu 及其衍生系统,RPM 支持 CentOS/RHEL/SUSE 及其衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。需要注意的是,RPM 和 Deb 包不含 `taosdump` 和 TDinsight 安装脚本,这些工具需要通过安装 taosTool 包获得。TDengine 也提供 Windows x64 平台的安装包。 在 Linux 系统上,TDengine 社区版提供 Deb 和 RPM 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 Deb 支持 Debian/Ubuntu 及其衍生系统,RPM 支持 CentOS/RHEL/SUSE 及其衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。需要注意的是,RPM 和 Deb 包不含 `taosdump` 和 TDinsight 安装脚本,这些工具需要通过安装 taosTools 包获得。TDengine 也提供 Windows x64 平台和 macOS x64/m1 平台的安装包。
## 安装 ## 安装
...@@ -110,6 +110,13 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统。 ...@@ -110,6 +110,13 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统。
<PkgListV3 type={3}/> <PkgListV3 type={3}/>
2. 运行可执行程序来安装 TDengine。 2. 运行可执行程序来安装 TDengine。
</TabItem>
<TabItem label="macOS 安装" value="macos">
1. 从列表中下载获得 pkg 安装程序;
<PkgListV3 type={7}/>
2. 运行可执行程序来安装 TDengine。
</TabItem> </TabItem>
</Tabs> </Tabs>
...@@ -177,12 +184,33 @@ Active: inactive (dead) ...@@ -177,12 +184,33 @@ Active: inactive (dead)
安装后,在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。 安装后,在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。
</TabItem>
<TabItem label="macOS 系统" value="macos">
安装后,在应用程序目录下,双击 TDengine 图标来启动程序,也可以运行 `launchctl start taosd` 来启动 TDengine 服务进程。
如下 `launchctl` 命令可以帮助你管理 TDengine 服务:
- 启动服务进程:`launchctl start taosd`
- 停止服务进程:`launchctl stop taosd`
- 查看服务状态:`launchctl list | grep taosd`
:::info
- `launchctl` 命令不需要管理员权限,请不要在前面加 `sudo`
- `launchctl list | grep taosd` 指令返回的第一个内容是程序的 PID,若为 `-` 则说明 TDengine 服务未运行。
:::
</TabItem> </TabItem>
</Tabs> </Tabs>
## TDengine 命令行(CLI) ## TDengine 命令行(CLI)
为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可,也可以在安装有 TDengine 的 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。 为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux、macOS 终端执行 `taos` 即可,也可以在安装有 TDengine 的 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。
```bash ```bash
taos taos
...@@ -212,13 +240,13 @@ SELECT * FROM t; ...@@ -212,13 +240,13 @@ SELECT * FROM t;
Query OK, 2 row(s) in set (0.003128s) Query OK, 2 row(s) in set (0.003128s)
``` ```
除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [TDengine 命令行](../../reference/taos-shell/) 除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在机器上运行,更多细节请参考 [TDengine 命令行](../../reference/taos-shell/)
## 使用 taosBenchmark 体验写入速度 ## 使用 taosBenchmark 体验写入速度
可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。 可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。
启动 TDengine 的服务,在 Linux 或 Windows 终端执行 `taosBenchmark`(曾命名为 `taosdemo`): 启动 TDengine 服务,然后在终端执行 `taosBenchmark`(曾命名为 `taosdemo`):
```bash ```bash
$ taosBenchmark $ taosBenchmark
...@@ -249,7 +277,7 @@ SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters; ...@@ -249,7 +277,7 @@ SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
查询 location = "California.SanFrancisco" 的记录总条数: 查询 location = "California.SanFrancisco" 的记录总条数:
```sql ```sql
SELECT COUNT(*) FROM test.meters WHERE location = "Calaifornia.SanFrancisco"; SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
``` ```
查询 groupId = 10 的所有记录的平均值、最大值、最小值等: 查询 groupId = 10 的所有记录的平均值、最大值、最小值等:
......
...@@ -67,6 +67,10 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 ...@@ -67,6 +67,10 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0
</TabItem> </TabItem>
</Tabs> </Tabs>
## 查询示例 ## SQL查询示例
比如查询 location=California.LosAngeles,groupid=2 子表的数据可以通过如下sql: - meters 是插入数据的超级表名
select * from meters where location=California.LosAngeles and groupid=2 - 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles,groupid=2` 可以通过如下sql:
``` cmd
select * from meters where location="California.LosAngeles" and groupid=2
```
...@@ -81,6 +81,10 @@ taos> select tbname, * from `meters.current`; ...@@ -81,6 +81,10 @@ taos> select tbname, * from `meters.current`;
t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco | t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco |
Query OK, 4 row(s) in set (0.005399s) Query OK, 4 row(s) in set (0.005399s)
``` ```
## 查询示例:
想要查询 location=California.LosAngeles groupid=3 的数据,可以通过如下sql: ## SQL查询示例
select * from `meters.voltage` where location="California.LosAngeles" and groupid=3 - `meters.current` 是插入数据的超级表名
- 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles groupid=3` 可以通过如下sql:
``` cmd
select * from `meters.current` where location="California.LosAngeles" and groupid=3
```
...@@ -96,6 +96,9 @@ taos> select * from `meters.current`; ...@@ -96,6 +96,9 @@ taos> select * from `meters.current`;
Query OK, 2 row(s) in set (0.004076s) Query OK, 2 row(s) in set (0.004076s)
``` ```
## 查询示例 ## SQL查询示例
想要查询"tags": {"location": "California.LosAngeles", "groupid": 1} 的数据,可以通过如下sql: - `meters.voltage` 是插入数据的超级表名
- 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles groupid=1` 可以通过如下sql:
``` cmd
select * from `meters.voltage` where location="California.LosAngeles" and groupid=1 select * from `meters.voltage` where location="California.LosAngeles" and groupid=1
```
...@@ -70,7 +70,7 @@ insert into d1004 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000); ...@@ -70,7 +70,7 @@ insert into d1004 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000);
### 查询以观察结果 ### 查询以观察结果
```sql ```sql
taos> select start, end, max_current from current_stream_output_stb; taos> select start, wend, max_current from current_stream_output_stb;
start | wend | max_current | start | wend | max_current |
=========================================================================== ===========================================================================
2018-10-03 14:38:05.000 | 2018-10-03 14:38:10.000 | 10.30000 | 2018-10-03 14:38:05.000 | 2018-10-03 14:38:10.000 | 10.30000 |
......
...@@ -74,7 +74,7 @@ http://<fqdn>:<port>/rest/sql/[db_name] ...@@ -74,7 +74,7 @@ http://<fqdn>:<port>/rest/sql/[db_name]
参数说明: 参数说明:
- fqnd: 集群中的任一台主机 FQDN 或 IP 地址。 - fqdn: 集群中的任一台主机 FQDN 或 IP 地址。
- port: 配置文件中 httpPort 配置项,缺省为 6041。 - port: 配置文件中 httpPort 配置项,缺省为 6041。
- db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。 - db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。
......
...@@ -13,11 +13,13 @@ TDengine 服务端或客户端安装后,`taos.h` 位于: ...@@ -13,11 +13,13 @@ TDengine 服务端或客户端安装后,`taos.h` 位于:
- Linux:`/usr/local/taos/include` - Linux:`/usr/local/taos/include`
- Windows:`C:\TDengine\include` - Windows:`C:\TDengine\include`
- macOS:`/usr/local/include`
TDengine 客户端驱动的动态库位于: TDengine 客户端驱动的动态库位于:
- Linux: `/usr/local/taos/driver/libtaos.so` - Linux: `/usr/local/taos/driver/libtaos.so`
- Windows: `C:\TDengine\taos.dll` - Windows: `C:\TDengine\taos.dll`
- macOS: `/usr/local/lib/libtaos.dylib`
## 支持的平台 ## 支持的平台
...@@ -119,7 +121,7 @@ TDengine 客户端驱动的安装请参考 [安装指南](../#安装步骤) ...@@ -119,7 +121,7 @@ TDengine 客户端驱动的安装请参考 [安装指南](../#安装步骤)
:::info :::info
更多示例代码及下载请见 [GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/c)。 更多示例代码及下载请见 [GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/c)。
也可以在安装目录下的 `examples/c` 路径下找到。 该目录下有 makefile,在 Linux 环境下,直接执行 make 就可以编译得到执行文件。 也可以在安装目录下的 `examples/c` 路径下找到。 该目录下有 makefile,在 Linux/macOS 环境下,直接执行 make 就可以编译得到执行文件。
**提示:**在 ARM 环境下编译时,请将 makefile 中的 `-msse4.2` 去掉,这个选项只有在 x64/x86 硬件平台上才能支持。 **提示:**在 ARM 环境下编译时,请将 makefile 中的 `-msse4.2` 去掉,这个选项只有在 x64/x86 硬件平台上才能支持。
::: :::
......
...@@ -120,7 +120,7 @@ Connection conn = DriverManager.getConnection(jdbcUrl); ...@@ -120,7 +120,7 @@ Connection conn = DriverManager.getConnection(jdbcUrl);
以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。
**注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll)。 **注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll;macOS 下是 libtaos.dylib)。
url 中的配置参数如下: url 中的配置参数如下:
...@@ -898,7 +898,7 @@ public static void main(String[] args) throws Exception { ...@@ -898,7 +898,7 @@ public static void main(String[] args) throws Exception {
**原因**:程序没有找到依赖的本地函数库 taos。 **原因**:程序没有找到依赖的本地函数库 taos。
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib`
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform 3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
......
...@@ -186,7 +186,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()" ...@@ -186,7 +186,7 @@ curl -u root:taosdata http://<FQDN>:<PORT>/rest/sql -d "select server_version()"
- `user` :TDengine 用户名。 默认值是 root。 - `user` :TDengine 用户名。 默认值是 root。
- `password` : TDengine 用户密码。 默认值是 taosdata。 - `password` : TDengine 用户密码。 默认值是 taosdata。
- `port` : 要连接的数据节点的起始端口,即 serverPort 配置。默认值是 6030。只有在提供了 host 参数的时候,这个参数才生效。 - `port` : 要连接的数据节点的起始端口,即 serverPort 配置。默认值是 6030。只有在提供了 host 参数的时候,这个参数才生效。
- `config` : 客户端配置文件路径。 在 Windows 系统上默认是 `C:\TDengine\cfg`。 在 Linux 系统上默认是 `/etc/taos/`。 - `config` : 客户端配置文件路径。 在 Windows 系统上默认是 `C:\TDengine\cfg`。 在 Linux/macOS 系统上默认是 `/etc/taos/`。
- `timezone` : 查询结果中 TIMESTAMP 类型的数据,转换为 python 的 datetime 对象时使用的时区。默认为本地时区。 - `timezone` : 查询结果中 TIMESTAMP 类型的数据,转换为 python 的 datetime 对象时使用的时区。默认为本地时区。
:::warning :::warning
......
...@@ -13,11 +13,13 @@ TDengine 服务端或客户端安装后,`taos.h` 位于: ...@@ -13,11 +13,13 @@ TDengine 服务端或客户端安装后,`taos.h` 位于:
- Linux:`/usr/local/taos/include` - Linux:`/usr/local/taos/include`
- Windows:`C:\TDengine\include` - Windows:`C:\TDengine\include`
- macOS:`/usr/local/include`
TDengine 客户端驱动的动态库位于: TDengine 客户端驱动的动态库位于:
- Linux: `/usr/local/taos/driver/libtaos.so` - Linux: `/usr/local/taos/driver/libtaos.so`
- Windows: `C:\TDengine\taos.dll` - Windows: `C:\TDengine\taos.dll`
- macOS:`/usr/local/lib/libtaos.dylib`
## 支持的平台 ## 支持的平台
......
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
- libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 - libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。
- taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 - taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。
- libtaos.dylib: 在 macOS 系统中成功安装 TDengine 后,依赖的 macOS 版客户端驱动 libtaos.dylib 文件会被自动拷贝至 /usr/local/lib/libtaos.dylib,该目录包含在 macOS 自动扫描路径上,无需单独指定。
::: :::
...@@ -12,7 +12,7 @@ SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW ...@@ -12,7 +12,7 @@ SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW
SELECT [DISTINCT] select_list SELECT [DISTINCT] select_list
from_clause from_clause
[WHERE condition] [WHERE condition]
[PARTITION BY tag_list] [partition_by_clause]
[window_clause] [window_clause]
[group_by_clause] [group_by_clause]
[order_by_clasue] [order_by_clasue]
...@@ -53,6 +53,9 @@ window_clause: { ...@@ -53,6 +53,9 @@ window_clause: {
| STATE_WINDOW(col) | STATE_WINDOW(col)
| INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)]
partition_by_clause:
PARTITION BY expr [, expr] ...
group_by_clause: group_by_clause:
GROUP BY expr [, expr] ... HAVING condition GROUP BY expr [, expr] ... HAVING condition
......
...@@ -4,9 +4,9 @@ title: 特色查询 ...@@ -4,9 +4,9 @@ title: 特色查询
description: TDengine 提供的时序数据特有的查询功能 description: TDengine 提供的时序数据特有的查询功能
--- ---
TDengine 是专为时序数据而研发的大数据平台,存储和计算都针对时序数据的特定进行了量身定制,在支持标准 SQL 的基础之上,还提供了一系列贴合时序业务场景的特色查询语法,极大的方便时序场景的应用开发 TDengine 在支持标准 SQL 的基础之上,还提供了一系列满足时序业务场景需求的特色查询语法,这些语法能够为时序场景的应用的开发带来极大的便利
TDengine 提供的特色查询包括数据切分查询和窗口切分查询。 TDengine 提供的特色查询包括数据切分查询和时间窗口切分查询。
## 数据切分查询 ## 数据切分查询
...@@ -31,7 +31,7 @@ select max(current) from meters partition by location interval(10m) ...@@ -31,7 +31,7 @@ select max(current) from meters partition by location interval(10m)
## 窗口切分查询 ## 窗口切分查询
TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。窗口切分查询语法如下: TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。窗口切分查询语法如下:
```sql ```sql
SELECT select_list FROM tb_name SELECT select_list FROM tb_name
...@@ -132,6 +132,10 @@ SELECT * FROM (SELECT COUNT(*) AS cnt, FIRST(ts) AS fst, status FROM temp_tb_1 S ...@@ -132,6 +132,10 @@ SELECT * FROM (SELECT COUNT(*) AS cnt, FIRST(ts) AS fst, status FROM temp_tb_1 S
SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
``` ```
### 时间戳伪列
窗口聚合查询结果中,如果 SQL 语句中没有指定输出查询结果中的时间戳列,那么最终结果中不会自动包含窗口的时间列信息。如果需要在结果中输出聚合结果所对应的时间窗口信息,需要在 SELECT 子句中使用时间戳相关的伪列: 时间窗口起始时间 (\_WSTART), 时间窗口结束时间 (\_WEND), 时间窗口持续时间 (\_WDURATION), 以及查询整体窗口相关的伪列: 查询窗口起始时间(\_QSTART) 和查询窗口结束时间(\_QEND)。需要注意的是时间窗口起始时间和结束时间均是闭区间,时间窗口持续时间是数据当前时间分辨率下的数值。例如,如果当前数据库的时间分辨率是毫秒,那么结果中 500 就表示当前时间窗口的持续时间是 500毫秒 (500 ms)。
### 示例 ### 示例
智能电表的建表语句如下: 智能电表的建表语句如下:
...@@ -143,8 +147,10 @@ CREATE TABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS ...@@ -143,8 +147,10 @@ CREATE TABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS
针对智能电表采集的数据,以 10 分钟为一个阶段,计算过去 24 小时的电流数据的平均值、最大值、电流的中位数。如果没有计算值,用前一个非 NULL 值填充。使用的查询语句如下: 针对智能电表采集的数据,以 10 分钟为一个阶段,计算过去 24 小时的电流数据的平均值、最大值、电流的中位数。如果没有计算值,用前一个非 NULL 值填充。使用的查询语句如下:
``` ```
SELECT AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters SELECT _WSTART, _WEND, AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters
WHERE ts>=NOW-1d and ts<=now WHERE ts>=NOW-1d and ts<=now
INTERVAL(10m) INTERVAL(10m)
FILL(PREV); FILL(PREV);
``` ```
...@@ -189,7 +189,7 @@ AllowWebSockets ...@@ -189,7 +189,7 @@ AllowWebSockets
/influxdb/v1/write /influxdb/v1/write
``` ```
支持 InfluxDB 查询参数如下: 支持 InfluxDB 参数如下:
- `db` 指定 TDengine 使用的数据库名 - `db` 指定 TDengine 使用的数据库名
- `precision` TDengine 使用的时间精度 - `precision` TDengine 使用的时间精度
...@@ -197,7 +197,7 @@ AllowWebSockets ...@@ -197,7 +197,7 @@ AllowWebSockets
- `p` TDengine 密码 - `p` TDengine 密码
注意: 目前不支持 InfluxDB 的 token 验证方式,仅支持 Basic 验证和查询参数验证。 注意: 目前不支持 InfluxDB 的 token 验证方式,仅支持 Basic 验证和查询参数验证。
示例: curl --request POST http://127.0.0.1:6041/influxdb/v1/write?db=test --user "root:taosdata" --data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
### OpenTSDB ### OpenTSDB
您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://<fqdn>:6041/<APIEndPoint>` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下: 您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://<fqdn>:6041/<APIEndPoint>` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下:
......
...@@ -12,7 +12,7 @@ TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine ...@@ -12,7 +12,7 @@ TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine
## 执行 ## 执行
要进入 TDengine CLI,您只要在 Linux 终端或 Windows 终端执行 `taos` 即可。 要进入 TDengine CLI,您只要在终端执行 `taos` 即可。
```bash ```bash
taos taos
......
...@@ -5,29 +5,30 @@ description: "TDengine 服务端、客户端和连接器支持的平台列表" ...@@ -5,29 +5,30 @@ description: "TDengine 服务端、客户端和连接器支持的平台列表"
## TDengine 服务端支持的平台列表 ## TDengine 服务端支持的平台列表
| | **Windows server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | | | **Windows server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **macOS** |
| ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | ------------ | ----------------- | ---------------- | | ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | ------------ | ----------------- | ---------------- | --------- |
| X64 | ● | ● | ● | ● | ● | ● | ● | | X64 | ● | ● | ● | ● | ● | ● | ● | ● |
| 树莓派 ARM64 | | | ● | | | | | | 树莓派 ARM64 | | | ● | | | | | |
| 华为云 ARM64 | | | | ● | | | | | 华为云 ARM64 | | | | ● | | | | |
| M1 | | | | | | | | ● |
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。 注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。
## TDengine 客户端和连接器支持的平台列表 ## TDengine 客户端和连接器支持的平台列表
目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。 目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32/macOS 等开发环境。
对照矩阵如下: 对照矩阵如下:
| **CPU** | **X64 64bit** | **X64 64bit** | **ARM64** | | **CPU** | **X64 64bit** | **X64 64bit** | **ARM64** | **X64 64bit** | **ARM64** |
| ----------- | ------------- | ------------- | --------- | | ----------- | ------------- | ------------- | --------- | ------------- | --------- |
| **OS** | **Linux** | **Win64** | **Linux** | | **OS** | **Linux** | **Win64** | **Linux** | **macOS** | **macOS** |
| **C/C++** | ● | ● | ● | | **C/C++** | ● | ● | ● | ● | ● |
| **JDBC** | ● | ● | ● | | **JDBC** | ● | ● | ● | ○ | ○ |
| **Python** | ● | ● | ● | | **Python** | ● | ● | ● | ● | ● |
| **Go** | ● | ● | ● | | **Go** | ● | ● | ● | ● | ● |
| **NodeJs** | ● | ● | ● | | **NodeJs** | ● | ● | ● | ○ | ○ |
| **C#** | ● | ● | ○ | | **C#** | ● | ● | ○ | ○ | ○ |
| **RESTful** | ● | ● | ● | | **RESTful** | ● | ● | ● | ● | ● |
注:● 表示官方测试验证通过,○ 表示非官方测试验证通过,-- 表示未经验证。 注:● 表示官方测试验证通过,○ 表示非官方测试验证通过,-- 表示未经验证。
...@@ -205,7 +205,7 @@ taos --dump-config ...@@ -205,7 +205,7 @@ taos --dump-config
:::info :::info
为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。
在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: 在 Linux/macOS 中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如:
``` ```
timezone UTC-8 timezone UTC-8
...@@ -248,9 +248,9 @@ SELECT count(*) FROM table_name WHERE TS<1554984068000; ...@@ -248,9 +248,9 @@ SELECT count(*) FROM table_name WHERE TS<1554984068000;
:::info :::info
TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。
客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux/macOS 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。
在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 在 Linux/macOS 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux/macOS 可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux/macOS 中也可以使用 charset 来指定字符编码。
::: :::
...@@ -263,9 +263,9 @@ TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提 ...@@ -263,9 +263,9 @@ TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提
| 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 |
:::info :::info
如果配置文件中不设置 charset,在 Linux 系统中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。 如果配置文件中不设置 charset,在 Linux/macOS 中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。
在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: 在 Linux/macOS 中,locale 信息包含了字符编码信息,因此正确设置了 Linux/macOS 的 locale 以后可以不用再单独设置 charset。例如:
``` ```
locale zh_CN.UTF-8 locale zh_CN.UTF-8
...@@ -279,7 +279,7 @@ charset CP936 ...@@ -279,7 +279,7 @@ charset CP936
如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。
在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 在 Linux/macOS 中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。
``` ```
locale zh_CN.UTF-8 locale zh_CN.UTF-8
......
...@@ -7,7 +7,7 @@ description: 一些常见问题的诊断技巧 ...@@ -7,7 +7,7 @@ description: 一些常见问题的诊断技巧
当出现客户端应用无法访问服务端时,需要确认客户端与服务端之间网络的各端口连通情况,以便有针对性地排除故障。 当出现客户端应用无法访问服务端时,需要确认客户端与服务端之间网络的各端口连通情况,以便有针对性地排除故障。
目前网络连接诊断支持在:Linux 与 Linux,Linux 与 Windows 之间进行诊断测试。 目前网络连接诊断支持在:Linux/Windows/macOS 之间进行诊断测试。
诊断步骤: 诊断步骤:
......
...@@ -56,7 +56,7 @@ description: 一些常见问题的解决方法汇总 ...@@ -56,7 +56,7 @@ description: 一些常见问题的解决方法汇总
3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd* 3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd*
4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html) 4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux/macOS 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)
5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。 5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。
...@@ -64,18 +64,20 @@ description: 一些常见问题的解决方法汇总 ...@@ -64,18 +64,20 @@ description: 一些常见问题的解决方法汇总
7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH* 7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*
8. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_) 8. 对于 macOS 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.dylib*在目录*/usr/local/lib*里, 并且*/usr/local/lib*在系统库函数搜索路径*LD_LIBRARY_PATH*
9. 如果仍不能排除连接故障 9. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_)
- Linux 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅 10. 如果仍不能排除连接故障
- Linux/macOS 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅
检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} ` 检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} `
检查服务器侧 TCP 端口连接是否工作:`nc -l {port}` 检查服务器侧 TCP 端口连接是否工作:`nc -l {port}`
检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}` 检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}`
- Windows 系统请使用 PowerShell 命令 Test-NetConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问 - Windows 系统请使用 PowerShell 命令 Test-NetConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问
10. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅:[诊断及其他](https://docs.taosdata.com/3.0-preview/operation/diagnose/) 11. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅:[诊断及其他](https://docs.taosdata.com/3.0-preview/operation/diagnose/)
### 5. 遇到错误 Unable to resolve FQDN” 怎么办? ### 5. 遇到错误 Unable to resolve FQDN” 怎么办?
......
...@@ -49,7 +49,7 @@ typedef struct { ...@@ -49,7 +49,7 @@ typedef struct {
TSKEY ts; TSKEY ts;
} SWinKey; } SWinKey;
static inline int SWinKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) { static inline int sWinKeyCmprImpl(const void* pKey1, const void* pKey2) {
SWinKey* pWin1 = (SWinKey*)pKey1; SWinKey* pWin1 = (SWinKey*)pKey1;
SWinKey* pWin2 = (SWinKey*)pKey2; SWinKey* pWin2 = (SWinKey*)pKey2;
...@@ -68,6 +68,10 @@ static inline int SWinKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, i ...@@ -68,6 +68,10 @@ static inline int SWinKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, i
return 0; return 0;
} }
static inline int winKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
return sWinKeyCmprImpl(pKey1, pKey2);
}
typedef struct { typedef struct {
uint64_t groupId; uint64_t groupId;
TSKEY ts; TSKEY ts;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
extern "C" { extern "C" {
#endif #endif
typedef struct SBuffer SBuffer;
typedef struct SSchema SSchema; typedef struct SSchema SSchema;
typedef struct STColumn STColumn; typedef struct STColumn STColumn;
typedef struct STSchema STSchema; typedef struct STSchema STSchema;
...@@ -56,6 +57,18 @@ const static uint8_t BIT2_MAP[4][4] = {{0b00000000, 0b00000001, 0b00000010, 0}, ...@@ -56,6 +57,18 @@ const static uint8_t BIT2_MAP[4][4] = {{0b00000000, 0b00000001, 0b00000010, 0},
#define SET_BIT2(p, i, v) ((p)[(i) >> 2] = (p)[(i) >> 2] & N1(BIT2_MAP[(i)&3][3]) | BIT2_MAP[(i)&3][(v)]) #define SET_BIT2(p, i, v) ((p)[(i) >> 2] = (p)[(i) >> 2] & N1(BIT2_MAP[(i)&3][3]) | BIT2_MAP[(i)&3][(v)])
#define GET_BIT2(p, i) (((p)[(i) >> 2] >> BIT2_MAP[(i)&3][3]) & ((uint8_t)3)) #define GET_BIT2(p, i) (((p)[(i) >> 2] >> BIT2_MAP[(i)&3][3]) & ((uint8_t)3))
// SBuffer ================================
struct SBuffer {
int64_t nBuf;
uint8_t *pBuf;
};
#define tBufferCreate() \
(SBuffer) { .nBuf = 0, .pBuf = NULL }
void tBufferDestroy(SBuffer *pBuffer);
int32_t tBufferInit(SBuffer *pBuffer, int64_t size);
int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData);
// STSchema ================================ // STSchema ================================
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema); int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
void tTSchemaDestroy(STSchema *pTSchema); void tTSchemaDestroy(STSchema *pTSchema);
......
...@@ -38,9 +38,9 @@ extern "C" { ...@@ -38,9 +38,9 @@ extern "C" {
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" #define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
#define TD_TMP_DIR_PATH "/tmp/taosd/" #define TD_TMP_DIR_PATH "/tmp/taosd/"
#define TD_CFG_DIR_PATH "/usr/local/etc/taos/" #define TD_CFG_DIR_PATH "/etc/taos/"
#define TD_DATA_DIR_PATH "/usr/local/var/lib/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/"
#define TD_LOG_DIR_PATH "/usr/local/var/log/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/"
#else #else
#define TD_TMP_DIR_PATH "/tmp/" #define TD_TMP_DIR_PATH "/tmp/"
#define TD_CFG_DIR_PATH "/etc/taos/" #define TD_CFG_DIR_PATH "/etc/taos/"
......
...@@ -288,6 +288,13 @@ void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_ ...@@ -288,6 +288,13 @@ void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_
char* taosShowStrArray(const SArray* pArray); char* taosShowStrArray(const SArray* pArray);
/**
* swap array
* @param a
* @param b
* @return
*/
void taosArraySwap(SArray* a, SArray* b);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -23,7 +23,7 @@ extern "C" { ...@@ -23,7 +23,7 @@ extern "C" {
#endif #endif
TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param); TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param);
bool taosDestoryThread(TdThread* pthread); bool taosDestroyThread(TdThread* pthread);
bool taosThreadRunning(TdThread* pthread); bool taosThreadRunning(TdThread* pthread);
typedef void *(*ThreadFp)(void *param); typedef void *(*ThreadFp)(void *param);
......
#!/usr/bin/env bash
function showAlertMessage(){
osascript <<EOF
set buttonStr to "${3}"
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set buttonList to every text item of buttonStr
set AppleScript's text item delimiters to oldDelimiters
get buttonList
set btns to buttonList
display dialog "${1}" with title "${2}" buttons btns with icon ${4}
get result
EOF
}
taosd_status=`Launchctl list | grep taosd | head -n 1 | awk '{print $1}'`
if [ "$taosd_status"x = "-"x ]; then
launchctl start taosd
showAlertMessage "Taosd is running!" "TDengine" "ok" "note"
else
choose_result=`showAlertMessage "Taosd is running!\nDo you want to close it?" "TDengine" "yes,cancel" "stop"`
if [ "$choose_result"x = "button returned:yes"x ]; then
launchctl stop taosd
fi
fi
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>taosd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/taosd</string>
</array>
<key>ProcessType</key>
<string>Interactive</string>
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<false/>
<key>LaunchOnlyOnce</key>
<false/>
<key>SessionCreate</key>
<true/>
<key>ExitTimeOut</key>
<integer>600</integer>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
<key>AfterInitialDemand</key>
<true/>
</dict>
<key>Program</key>
<string>/usr/local/bin/taosd</string>
</dict>
</plist>
\ No newline at end of file
TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data.
To configure TDengine : edit /etc/taos/taos.cfg
To start service : launchctl start taosd
To access TDengine : use taos in shell
\ No newline at end of file
此差异已折叠。
...@@ -7,27 +7,52 @@ ...@@ -7,27 +7,52 @@
iplist="" iplist=""
serverFqdn="" serverFqdn=""
# -----------------------Variables definition--------------------- osType=`uname`
script_dir=$(dirname $(readlink -f "$0"))
# Dynamic directory # Dynamic directory
data_dir="/var/lib/taos" data_dir="/var/lib/taos"
log_dir="/var/log/taos" log_dir="/var/log/taos"
data_link_dir="/usr/local/taos/data" cfg_install_dir="/etc/taos"
log_link_dir="/usr/local/taos/log"
install_main_dir="/usr/local/taos"
# static directory if [ "$osType" != "Darwin" ]; then
cfg_dir="/usr/local/taos/cfg" script_dir=$(dirname $(readlink -f "$0"))
bin_dir="/usr/local/taos/bin" verNumber=""
lib_dir="/usr/local/taos/driver" lib_file_ext="so"
init_d_dir="/usr/local/taos/init.d"
inc_dir="/usr/local/taos/include" bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include"
install_main_dir="/usr/local/taos"
else
script_dir=${source_dir}/packaging/tools
verNumber=`ls tdengine/driver | grep -E "libtaos\.[0-9]\.[0-9]" | sed "s/libtaos.//g" | sed "s/.dylib//g" | head -n 1`
lib_file_ext="dylib"
bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/local/lib"
lib64_link_dir="/usr/local/lib"
inc_link_dir="/usr/local/include"
if [ -d "/usr/local/Cellar/" ];then
install_main_dir="/usr/local/Cellar/tdengine/${verNumber}"
elif [ -d "/opt/homebrew/Cellar/" ];then
install_main_dir="/opt/homebrew/Cellar/tdengine/${verNumber}"
else
install_main_dir="/usr/local/taos"
fi
fi
cfg_install_dir="/etc/taos" data_link_dir="${install_main_dir}/data"
bin_link_dir="/usr/bin" log_link_dir="${install_main_dir}/log"
lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64" # static directory
inc_link_dir="/usr/include" cfg_dir="${install_main_dir}/cfg"
bin_dir="${install_main_dir}/bin"
lib_dir="${install_main_dir}/driver"
init_d_dir="${install_main_dir}/init.d"
inc_dir="${install_main_dir}/include"
service_config_dir="/etc/systemd/system" service_config_dir="/etc/systemd/system"
...@@ -40,8 +65,10 @@ GREEN_UNDERLINE='\033[4;32m' ...@@ -40,8 +65,10 @@ GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m' NC='\033[0m'
csudo="" csudo=""
csudouser=""
if command -v sudo > /dev/null; then if command -v sudo > /dev/null; then
csudo="sudo " csudo="sudo "
csudouser="sudo -u ${USER} "
fi fi
initd_mod=0 initd_mod=0
...@@ -63,6 +90,14 @@ elif $(which service &> /dev/null); then ...@@ -63,6 +90,14 @@ elif $(which service &> /dev/null); then
else else
service_mod=2 service_mod=2
fi fi
if [ "$osType" = "Darwin" ]; then
if [ -d "${install_main_dir}" ];then
${csudo}rm -rf ${install_main_dir}
fi
${csudo}mkdir -p ${install_main_dir}
${csudo}rm -rf ${install_main_dir}
${csudo}cp -rf tdengine ${install_main_dir}
fi
function kill_taosadapter() { function kill_taosadapter() {
# ${csudo}pkill -f taosadapter || : # ${csudo}pkill -f taosadapter || :
...@@ -96,22 +131,24 @@ function install_lib() { ...@@ -96,22 +131,24 @@ function install_lib() {
${csudo}rm -f ${lib_link_dir}/libtaos* || : ${csudo}rm -f ${lib_link_dir}/libtaos* || :
${csudo}rm -f ${lib64_link_dir}/libtaos* || : ${csudo}rm -f ${lib64_link_dir}/libtaos* || :
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || : [ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || :
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || : [ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1
${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
[ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so ||: [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||:
if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then
${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || :
${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || :
[ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} || :
fi fi
${csudo}ldconfig if [ "$osType" != "Darwin" ]; then
${csudo}ldconfig
fi
} }
function install_bin() { function install_bin() {
...@@ -138,6 +175,7 @@ function install_bin() { ...@@ -138,6 +175,7 @@ function install_bin() {
[ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
[ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || : [ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || :
[ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || : [ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || :
[ -x ${bin_dir}/remove.sh ] && ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || :
} }
function add_newHostname_to_hosts() { function add_newHostname_to_hosts() {
...@@ -466,6 +504,14 @@ function install_service_on_systemd() { ...@@ -466,6 +504,14 @@ function install_service_on_systemd() {
${csudo}systemctl enable taosd ${csudo}systemctl enable taosd
} }
function install_service_on_launchctl() {
if [ -f ${install_main_dir}/service/com.taosdata.taosd.plist ]; then
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
${csudo}cp ${install_main_dir}/service/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist || :
${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || :
fi
}
function install_taosadapter_service() { function install_taosadapter_service() {
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
[ -f ${script_dir}/../cfg/taosadapter.service ] &&\ [ -f ${script_dir}/../cfg/taosadapter.service ] &&\
...@@ -476,6 +522,7 @@ function install_taosadapter_service() { ...@@ -476,6 +522,7 @@ function install_taosadapter_service() {
} }
function install_service() { function install_service() {
if [ "$osType" != "Darwin" ]; then
if ((${service_mod}==0)); then if ((${service_mod}==0)); then
install_service_on_systemd install_service_on_systemd
elif ((${service_mod}==1)); then elif ((${service_mod}==1)); then
...@@ -485,6 +532,25 @@ function install_service() { ...@@ -485,6 +532,25 @@ function install_service() {
kill_taosadapter kill_taosadapter
kill_taosd kill_taosd
fi fi
else
install_service_on_launchctl
fi
}
function install_app() {
if [ "$osType" = "Darwin" ]; then
if [ -f ${install_main_dir}/service/TDengine ]; then
${csudo}rm -rf /Applications/TDengine.app &&
${csudo}mkdir -p /Applications/TDengine.app/Contents/MacOS/ &&
${csudo}cp ${install_main_dir}/service/TDengine /Applications/TDengine.app/Contents/MacOS/ &&
echo "<plist><dict></dict></plist>" | ${csudo}tee /Applications/TDengine.app/Contents/Info.plist > /dev/null &&
${csudo}sips -i ${install_main_dir}/service/logo.png > /dev/null &&
DeRez -only icns ${install_main_dir}/service/logo.png | ${csudo}tee /Applications/TDengine.app/mac_logo.rsrc > /dev/null &&
${csudo}rez -append /Applications/TDengine.app/mac_logo.rsrc -o $'/Applications/TDengine.app/Icon\r' &&
${csudo}SetFile -a C /Applications/TDengine.app/ &&
${csudo}rm /Applications/TDengine.app/mac_logo.rsrc
fi
fi
} }
function install_TDengine() { function install_TDengine() {
...@@ -492,7 +558,7 @@ function install_TDengine() { ...@@ -492,7 +558,7 @@ function install_TDengine() {
#install log and data dir , then ln to /usr/local/taos #install log and data dir , then ln to /usr/local/taos
${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir}
${csudo}mkdir -p ${data_dir} ${csudo}mkdir -p ${data_dir} && ${csudo}chmod 777 ${data_dir}
${csudo}rm -rf ${log_link_dir} || : ${csudo}rm -rf ${log_link_dir} || :
${csudo}rm -rf ${data_link_dir} || : ${csudo}rm -rf ${data_link_dir} || :
...@@ -508,6 +574,7 @@ function install_TDengine() { ...@@ -508,6 +574,7 @@ function install_TDengine() {
install_taosadapter_config install_taosadapter_config
install_taosadapter_service install_taosadapter_service
install_service install_service
install_app
# Ask if to start the service # Ask if to start the service
#echo #echo
......
...@@ -6,12 +6,31 @@ set -e ...@@ -6,12 +6,31 @@ set -e
#set -x #set -x
verMode=edge verMode=edge
osType=`uname`
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
NC='\033[0m' NC='\033[0m'
installDir="/usr/local/taos" if [ "$osType" != "Darwin" ]; then
installDir="/usr/local/taos"
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include"
else
if [ -d "/usr/local/Cellar/" ];then
installDir="/usr/local/Cellar/tdengine/${verNumber}"
elif [ -d "/opt/homebrew/Cellar/" ];then
installDir="/opt/homebrew/Cellar/tdengine/${verNumber}"
else
installDir="/usr/local/taos"
fi
bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/local/lib"
lib64_link_dir="/usr/local/lib"
inc_link_dir="/usr/local/include"
fi
serverName="taosd" serverName="taosd"
clientName="taos" clientName="taos"
uninstallScript="rmtaos" uninstallScript="rmtaos"
...@@ -22,11 +41,8 @@ install_main_dir=${installDir} ...@@ -22,11 +41,8 @@ install_main_dir=${installDir}
data_link_dir=${installDir}/data data_link_dir=${installDir}/data
log_link_dir=${installDir}/log log_link_dir=${installDir}/log
cfg_link_dir=${installDir}/cfg cfg_link_dir=${installDir}/cfg
bin_link_dir="/usr/bin"
local_bin_link_dir="/usr/local/bin" local_bin_link_dir="/usr/local/bin"
lib_link_dir="/usr/lib"
lib64_link_dir="/usr/lib64"
inc_link_dir="/usr/include"
service_config_dir="/etc/systemd/system" service_config_dir="/etc/systemd/system"
taos_service_name=${serverName} taos_service_name=${serverName}
...@@ -82,6 +98,7 @@ function clean_bin() { ...@@ -82,6 +98,7 @@ function clean_bin() {
# Remove link # Remove link
${csudo}rm -f ${bin_link_dir}/${clientName} || : ${csudo}rm -f ${bin_link_dir}/${clientName} || :
${csudo}rm -f ${bin_link_dir}/${serverName} || : ${csudo}rm -f ${bin_link_dir}/${serverName} || :
${csudo}rm -f ${bin_link_dir}/udfd || :
${csudo}rm -f ${bin_link_dir}/taosadapter || : ${csudo}rm -f ${bin_link_dir}/taosadapter || :
${csudo}rm -f ${bin_link_dir}/taosBenchmark || : ${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${bin_link_dir}/taosdemo || :
...@@ -103,7 +120,7 @@ function clean_lib() { ...@@ -103,7 +120,7 @@ function clean_lib() {
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || : [ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
${csudo}rm -f ${lib64_link_dir}/libtaos.* || : ${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
[ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || : [ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
#${csudo}rm -rf ${v15_java_app_dir} || : #${csudo}rm -rf ${v15_java_app_dir} || :
} }
...@@ -195,12 +212,20 @@ function clean_service_on_sysvinit() { ...@@ -195,12 +212,20 @@ function clean_service_on_sysvinit() {
fi fi
} }
function clean_service_on_launchctl() {
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
${csudo}rm /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
}
function clean_service() { function clean_service() {
if ((${service_mod} == 0)); then if ((${service_mod} == 0)); then
clean_service_on_systemd clean_service_on_systemd
elif ((${service_mod} == 1)); then elif ((${service_mod} == 1)); then
clean_service_on_sysvinit clean_service_on_sysvinit
else else
if [ "$osType" = "Darwin" ]; then
clean_service_on_launchctl
fi
kill_taosadapter kill_taosadapter
kill_taosd kill_taosd
kill_tarbitrator kill_tarbitrator
...@@ -241,6 +266,9 @@ elif echo $osinfo | grep -qwi "centos"; then ...@@ -241,6 +266,9 @@ elif echo $osinfo | grep -qwi "centos"; then
# echo "this is centos system" # echo "this is centos system"
${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || : ${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || :
fi fi
if [ "$osType" = "Darwin" ]; then
${csudo}rm -rf /Applications/TDengine.app
fi
echo -e "${GREEN}${productName} is removed successfully!${NC}" echo -e "${GREEN}${productName} is removed successfully!${NC}"
echo echo
...@@ -20,6 +20,30 @@ ...@@ -20,6 +20,30 @@
#include "tdatablock.h" #include "tdatablock.h"
#include "tlog.h" #include "tlog.h"
// SBuffer ================================
void tBufferDestroy(SBuffer *pBuffer) {
tFree(pBuffer->pBuf);
pBuffer->pBuf = NULL;
}
int32_t tBufferInit(SBuffer *pBuffer, int64_t size) {
pBuffer->nBuf = 0;
return tRealloc(&pBuffer->pBuf, size);
}
int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData) {
int32_t code = 0;
code = tRealloc(&pBuffer->pBuf, pBuffer->nBuf + nData);
if (code) return code;
memcpy(pBuffer->pBuf + pBuffer->nBuf, pData, nData);
pBuffer->nBuf += nData;
return code;
}
// ================================
static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson); static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson);
#pragma pack(push, 1) #pragma pack(push, 1)
......
...@@ -374,8 +374,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { ...@@ -374,8 +374,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4); tsNumOfVnodeStreamThreads = TMAX(tsNumOfVnodeStreamThreads, 4);
if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1; if (cfgAddInt32(pCfg, "numOfVnodeStreamThreads", tsNumOfVnodeStreamThreads, 4, 1024, 0) != 0) return -1;
tsNumOfVnodeFetchThreads = 1; // tsNumOfVnodeFetchThreads = 1;
if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1024, 0) != 0) return -1; // if (cfgAddInt32(pCfg, "numOfVnodeFetchThreads", tsNumOfVnodeFetchThreads, 1, 1, 0) != 0) return -1;
tsNumOfVnodeWriteThreads = tsNumOfCores; tsNumOfVnodeWriteThreads = tsNumOfCores;
tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1); tsNumOfVnodeWriteThreads = TMAX(tsNumOfVnodeWriteThreads, 1);
...@@ -497,6 +497,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { ...@@ -497,6 +497,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
pItem->stype = stype; pItem->stype = stype;
} }
/*
pItem = cfgGetItem(tsCfg, "numOfVnodeFetchThreads"); pItem = cfgGetItem(tsCfg, "numOfVnodeFetchThreads");
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
tsNumOfVnodeFetchThreads = numOfCores / 4; tsNumOfVnodeFetchThreads = numOfCores / 4;
...@@ -504,6 +505,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { ...@@ -504,6 +505,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
pItem->i32 = tsNumOfVnodeFetchThreads; pItem->i32 = tsNumOfVnodeFetchThreads;
pItem->stype = stype; pItem->stype = stype;
} }
*/
pItem = cfgGetItem(tsCfg, "numOfVnodeWriteThreads"); pItem = cfgGetItem(tsCfg, "numOfVnodeWriteThreads");
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
...@@ -703,7 +705,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { ...@@ -703,7 +705,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32; tsNumOfVnodeStreamThreads = cfgGetItem(pCfg, "numOfVnodeStreamThreads")->i32;
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32; // tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32; tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32;
tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32; tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32;
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32; tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
...@@ -953,8 +955,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { ...@@ -953,8 +955,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
} else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) { } else if (strcasecmp("numOfVnodeQueryThreads", name) == 0) {
tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32;
/*
} else if (strcasecmp("numOfVnodeFetchThreads", name) == 0) { } else if (strcasecmp("numOfVnodeFetchThreads", name) == 0) {
tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32; tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32;
*/
} else if (strcasecmp("numOfVnodeWriteThreads", name) == 0) { } else if (strcasecmp("numOfVnodeWriteThreads", name) == 0) {
tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32; tsNumOfVnodeWriteThreads = cfgGetItem(pCfg, "numOfVnodeWriteThreads")->i32;
} else if (strcasecmp("numOfVnodeSyncThreads", name) == 0) { } else if (strcasecmp("numOfVnodeSyncThreads", name) == 0) {
......
...@@ -135,7 +135,7 @@ _OVER: ...@@ -135,7 +135,7 @@ _OVER:
if (content != NULL) taosMemoryFree(content); if (content != NULL) taosMemoryFree(content);
if (root != NULL) cJSON_Delete(root); if (root != NULL) cJSON_Delete(root);
if (pFile != NULL) taosCloseFile(&pFile); if (pFile != NULL) taosCloseFile(&pFile);
if (*ppCfgs == NULL && pCfgs != NULL) taosMemoryFree(pCfgs); if (code != 0) taosMemoryFree(pCfgs);
terrno = code; terrno = code;
return code; return code;
...@@ -157,6 +157,11 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) { ...@@ -157,6 +157,11 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
int32_t numOfVnodes = 0; int32_t numOfVnodes = 0;
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes); SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
if (pVnodes == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
ret = -1;
goto _OVER;
}
int32_t len = 0; int32_t len = 0;
int32_t maxLen = MAX_CONTENT_LEN; int32_t maxLen = MAX_CONTENT_LEN;
......
...@@ -384,7 +384,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) { ...@@ -384,7 +384,7 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) {
for (int32_t v = 0; v < numOfVnodes; ++v) { for (int32_t v = 0; v < numOfVnodes; ++v) {
int32_t t = v % threadNum; int32_t t = v % threadNum;
SVnodeThread *pThread = &threads[t]; SVnodeThread *pThread = &threads[t];
if (pThread->ppVnodes != NULL) { if (pThread->ppVnodes != NULL && ppVnodes != NULL) {
pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v]; pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v];
} }
} }
......
...@@ -77,7 +77,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) { ...@@ -77,7 +77,7 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
SSdbRaw *pRaw = mndAcctActionEncode(&acctObj); SSdbRaw *pRaw = mndAcctActionEncode(&acctObj);
if (pRaw == NULL) return -1; if (pRaw == NULL) return -1;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
mInfo("acct:%s, will be created when deploying, raw:%p", acctObj.acct, pRaw); mInfo("acct:%s, will be created when deploying, raw:%p", acctObj.acct, pRaw);
......
...@@ -231,7 +231,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) { ...@@ -231,7 +231,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
SSdbRaw *pRaw = mndClusterActionEncode(&clusterObj); SSdbRaw *pRaw = mndClusterActionEncode(&clusterObj);
if (pRaw == NULL) return -1; if (pRaw == NULL) return -1;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
mInfo("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw); mInfo("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw);
...@@ -248,7 +248,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) { ...@@ -248,7 +248,7 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
...@@ -326,7 +326,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) { ...@@ -326,7 +326,7 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
......
...@@ -730,7 +730,7 @@ static int32_t mndSetAlterDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pOl ...@@ -730,7 +730,7 @@ static int32_t mndSetAlterDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pOl
return -1; return -1;
} }
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
return 0; return 0;
} }
...@@ -742,7 +742,7 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p ...@@ -742,7 +742,7 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
return 0; return 0;
} }
...@@ -938,7 +938,7 @@ static int32_t mndSetDropDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD ...@@ -938,7 +938,7 @@ static int32_t mndSetDropDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
return -1; return -1;
} }
sdbSetRawStatus(pVgRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pVgRaw, SDB_STATUS_DROPPED);
} }
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
...@@ -956,7 +956,7 @@ static int32_t mndSetDropDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD ...@@ -956,7 +956,7 @@ static int32_t mndSetDropDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
sdbRelease(pSdb, pStbRaw); sdbRelease(pSdb, pStbRaw);
return -1; return -1;
} }
sdbSetRawStatus(pStbRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pStbRaw, SDB_STATUS_DROPPED);
} }
sdbRelease(pSdb, pStb); sdbRelease(pSdb, pStb);
...@@ -1052,7 +1052,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) { ...@@ -1052,7 +1052,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
goto _OVER; goto _OVER;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
} }
int32_t rspLen = 0; int32_t rspLen = 0;
......
...@@ -101,7 +101,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { ...@@ -101,7 +101,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
dnodeObj.createdTime = taosGetTimestampMs(); dnodeObj.createdTime = taosGetTimestampMs();
dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.updateTime = dnodeObj.createdTime;
dnodeObj.port = tsServerPort; dnodeObj.port = tsServerPort;
memcpy(&dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN); tstrncpy(dnodeObj.fqdn, tsLocalFqdn, TSDB_FQDN_LEN);
dnodeObj.fqdn[TSDB_FQDN_LEN - 1] = 0;
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode"); pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, NULL, "create-dnode");
...@@ -110,7 +111,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { ...@@ -110,7 +111,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
pRaw = mndDnodeActionEncode(&dnodeObj); pRaw = mndDnodeActionEncode(&dnodeObj);
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
...@@ -190,7 +191,10 @@ _OVER: ...@@ -190,7 +191,10 @@ _OVER:
static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) { static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode) {
mTrace("dnode:%d, perform insert action, row:%p", pDnode->id, pDnode); mTrace("dnode:%d, perform insert action, row:%p", pDnode->id, pDnode);
pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED; pDnode->offlineReason = DND_REASON_STATUS_NOT_RECEIVED;
snprintf(pDnode->ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port);
char ep[TSDB_EP_LEN] = {0};
snprintf(ep, TSDB_EP_LEN - 1, "%s:%u", pDnode->fqdn, pDnode->port);
tstrncpy(pDnode->ep, ep, TSDB_EP_LEN);
return 0; return 0;
} }
...@@ -275,7 +279,7 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) { ...@@ -275,7 +279,7 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeEps) {
SDnodeEp dnodeEp = {0}; SDnodeEp dnodeEp = {0};
dnodeEp.id = pDnode->id; dnodeEp.id = pDnode->id;
dnodeEp.ep.port = pDnode->port; dnodeEp.ep.port = pDnode->port;
memcpy(dnodeEp.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN); tstrncpy(dnodeEp.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN);
sdbRelease(pSdb, pDnode); sdbRelease(pSdb, pDnode);
dnodeEp.isMnode = 0; dnodeEp.isMnode = 0;
...@@ -485,7 +489,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC ...@@ -485,7 +489,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
dnodeObj.createdTime = taosGetTimestampMs(); dnodeObj.createdTime = taosGetTimestampMs();
dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.updateTime = dnodeObj.createdTime;
dnodeObj.port = pCreate->port; dnodeObj.port = pCreate->port;
memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); tstrncpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN);
snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port); snprintf(dnodeObj.ep, TSDB_EP_LEN - 1, "%s:%u", dnodeObj.fqdn, dnodeObj.port);
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode"); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_GLOBAL, pReq, "create-dnode");
...@@ -494,7 +498,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC ...@@ -494,7 +498,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
pRaw = mndDnodeActionEncode(&dnodeObj); pRaw = mndDnodeActionEncode(&dnodeObj);
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
...@@ -675,13 +679,13 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM ...@@ -675,13 +679,13 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
pRaw = mndDnodeActionEncode(pDnode); pRaw = mndDnodeActionEncode(pDnode);
if (pRaw == NULL) goto _OVER; if (pRaw == NULL) goto _OVER;
if (mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; if (mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING); (void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING);
pRaw = NULL; pRaw = NULL;
pRaw = mndDnodeActionEncode(pDnode); pRaw = mndDnodeActionEncode(pDnode);
if (pRaw == NULL) goto _OVER; if (pRaw == NULL) goto _OVER;
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
pRaw = NULL; pRaw = NULL;
if (pMObj != NULL) { if (pMObj != NULL) {
......
...@@ -259,17 +259,17 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) { ...@@ -259,17 +259,17 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc); SSdbRaw *pRedoRaw = mndFuncActionEncode(pFunc);
if (pRedoRaw == NULL) goto _OVER; if (pRedoRaw == NULL) goto _OVER;
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); (void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING);
SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc); SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc);
if (pUndoRaw == NULL) goto _OVER; if (pUndoRaw == NULL) goto _OVER;
if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER;
sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY);
SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc); SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc);
if (pCommitRaw == NULL) goto _OVER; if (pCommitRaw == NULL) goto _OVER;
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
......
...@@ -161,7 +161,7 @@ int32_t mndCreateOffsets(STrans *pTrans, const char *cgroup, const char *topicNa ...@@ -161,7 +161,7 @@ int32_t mndCreateOffsets(STrans *pTrans, const char *cgroup, const char *topicNa
if (pOffsetRaw == NULL) { if (pOffsetRaw == NULL) {
return -1; return -1;
} }
sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY);
// commit log or redo log? // commit log or redo log?
if (mndTransAppendRedolog(pTrans, pOffsetRaw) < 0) { if (mndTransAppendRedolog(pTrans, pOffsetRaw) < 0) {
return -1; return -1;
...@@ -208,7 +208,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) { ...@@ -208,7 +208,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) {
} }
pOffsetObj->offset = pOffset->offset; pOffsetObj->offset = pOffset->offset;
SSdbRaw *pOffsetRaw = mndOffsetActionEncode(pOffsetObj); SSdbRaw *pOffsetRaw = mndOffsetActionEncode(pOffsetObj);
sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pOffsetRaw, SDB_STATUS_READY);
mndTransAppendCommitlog(pTrans, pOffsetRaw); mndTransAppendCommitlog(pTrans, pOffsetRaw);
if (create) { if (create) {
taosMemoryFree(pOffsetObj); taosMemoryFree(pOffsetObj);
......
...@@ -420,7 +420,7 @@ int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) { ...@@ -420,7 +420,7 @@ int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream) {
mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr());
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
return 0; return 0;
} }
...@@ -431,7 +431,7 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr ...@@ -431,7 +431,7 @@ int32_t mndPersistDropStreamLog(SMnode *pMnode, STrans *pTrans, SStreamObj *pStr
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
return 0; return 0;
} }
...@@ -447,7 +447,7 @@ static int32_t mndSetStreamRecover(SMnode *pMnode, STrans *pTrans, const SStream ...@@ -447,7 +447,7 @@ static int32_t mndSetStreamRecover(SMnode *pMnode, STrans *pTrans, const SStream
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
return 0; return 0;
} }
......
...@@ -459,7 +459,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * ...@@ -459,7 +459,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (topicObj.ntbUid != 0) { if (topicObj.ntbUid != 0) {
STqCheckInfo info; STqCheckInfo info;
...@@ -596,7 +596,7 @@ static int32_t mndDropTopic(SMnode *pMnode, STrans *pTrans, SRpcMsg *pReq, SMqTo ...@@ -596,7 +596,7 @@ static int32_t mndDropTopic(SMnode *pMnode, STrans *pTrans, SRpcMsg *pReq, SMqTo
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
...@@ -777,7 +777,7 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl ...@@ -777,7 +777,7 @@ static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
int32_t cols = 0; int32_t cols = 0;
char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE + 5] = {0}; char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE + 5] = {0};
strcpy(varDataVal(topicName), mndGetDbStr(pTopic->name)); tstrncpy(varDataVal(topicName), mndGetDbStr(pTopic->name), sizeof(topicName) - 2);
/*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/ /*tNameFromString(&n, pTopic->name, T_NAME_ACCT | T_NAME_DB);*/
/*tNameGetDbName(&n, varDataVal(topicName));*/ /*tNameGetDbName(&n, varDataVal(topicName));*/
varDataSetLen(topicName, strlen(varDataVal(topicName))); varDataSetLen(topicName, strlen(varDataVal(topicName)));
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "mndTrans.h" #include "mndTrans.h"
#include "mndConsumer.h" #include "mndConsumer.h"
#include "mndDb.h" #include "mndDb.h"
#include "mndStb.h"
#include "mndPrivilege.h" #include "mndPrivilege.h"
#include "mndShow.h" #include "mndShow.h"
#include "mndStb.h"
#include "mndSync.h" #include "mndSync.h"
#include "mndUser.h" #include "mndUser.h"
...@@ -138,6 +138,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { ...@@ -138,6 +138,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT32(pRaw, dataPos, undoActionNum, _OVER) SDB_SET_INT32(pRaw, dataPos, undoActionNum, _OVER)
SDB_SET_INT32(pRaw, dataPos, commitActionNum, _OVER) SDB_SET_INT32(pRaw, dataPos, commitActionNum, _OVER)
int8_t unused = 0;
for (int32_t i = 0; i < redoActionNum; ++i) { for (int32_t i = 0; i < redoActionNum; ++i) {
STransAction *pAction = taosArrayGet(pTrans->redoActions, i); STransAction *pAction = taosArrayGet(pTrans->redoActions, i);
SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER)
...@@ -149,14 +150,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { ...@@ -149,14 +150,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER)
if (pAction->actionType == TRANS_ACTION_RAW) { if (pAction->actionType == TRANS_ACTION_RAW) {
int32_t len = sdbGetRawTotalSize(pAction->pRaw); int32_t len = sdbGetRawTotalSize(pAction->pRaw);
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->rawWritten*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, len, _OVER) SDB_SET_INT32(pRaw, dataPos, len, _OVER)
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
} else if (pAction->actionType == TRANS_ACTION_MSG) { } else if (pAction->actionType == TRANS_ACTION_MSG) {
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER) SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgSent*/, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgReceived*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER) SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
} else { } else {
...@@ -175,14 +176,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { ...@@ -175,14 +176,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER)
if (pAction->actionType == TRANS_ACTION_RAW) { if (pAction->actionType == TRANS_ACTION_RAW) {
int32_t len = sdbGetRawTotalSize(pAction->pRaw); int32_t len = sdbGetRawTotalSize(pAction->pRaw);
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->rawWritten*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, len, _OVER) SDB_SET_INT32(pRaw, dataPos, len, _OVER)
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
} else if (pAction->actionType == TRANS_ACTION_MSG) { } else if (pAction->actionType == TRANS_ACTION_MSG) {
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER) SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgSent*/, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgReceived*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER) SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
} else { } else {
...@@ -201,14 +202,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { ...@@ -201,14 +202,14 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER)
if (pAction->actionType == TRANS_ACTION_RAW) { if (pAction->actionType == TRANS_ACTION_RAW) {
int32_t len = sdbGetRawTotalSize(pAction->pRaw); int32_t len = sdbGetRawTotalSize(pAction->pRaw);
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->rawWritten*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, len, _OVER) SDB_SET_INT32(pRaw, dataPos, len, _OVER)
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
} else if (pAction->actionType == TRANS_ACTION_MSG) { } else if (pAction->actionType == TRANS_ACTION_MSG) {
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER) SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER) SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgSent*/, _OVER)
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER) SDB_SET_INT8(pRaw, dataPos, unused /*pAction->msgReceived*/, _OVER)
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER) SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
} else { } else {
...@@ -305,6 +306,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -305,6 +306,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
if (pTrans->undoActions == NULL) goto _OVER; if (pTrans->undoActions == NULL) goto _OVER;
if (pTrans->commitActions == NULL) goto _OVER; if (pTrans->commitActions == NULL) goto _OVER;
int8_t unused = 0;
for (int32_t i = 0; i < redoActionNum; ++i) { for (int32_t i = 0; i < redoActionNum; ++i) {
memset(&action, 0, sizeof(action)); memset(&action, 0, sizeof(action));
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
...@@ -317,7 +319,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -317,7 +319,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
action.stage = stage; action.stage = stage;
SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER)
if (action.actionType == TRANS_ACTION_RAW) { if (action.actionType == TRANS_ACTION_RAW) {
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.rawWritten*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
action.pRaw = taosMemoryMalloc(dataLen); action.pRaw = taosMemoryMalloc(dataLen);
if (action.pRaw == NULL) goto _OVER; if (action.pRaw == NULL) goto _OVER;
...@@ -328,8 +330,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -328,8 +330,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
} else if (action.actionType == TRANS_ACTION_MSG) { } else if (action.actionType == TRANS_ACTION_MSG) {
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER); SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER) SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgSent*/, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgReceived, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgReceived*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER)
action.pCont = taosMemoryMalloc(action.contLen); action.pCont = taosMemoryMalloc(action.contLen);
if (action.pCont == NULL) goto _OVER; if (action.pCont == NULL) goto _OVER;
...@@ -353,7 +355,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -353,7 +355,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
action.stage = stage; action.stage = stage;
SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER)
if (action.actionType == TRANS_ACTION_RAW) { if (action.actionType == TRANS_ACTION_RAW) {
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.rawWritten*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
action.pRaw = taosMemoryMalloc(dataLen); action.pRaw = taosMemoryMalloc(dataLen);
if (action.pRaw == NULL) goto _OVER; if (action.pRaw == NULL) goto _OVER;
...@@ -364,8 +366,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -364,8 +366,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
} else if (action.actionType == TRANS_ACTION_MSG) { } else if (action.actionType == TRANS_ACTION_MSG) {
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER); SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER) SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgSent*/, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgReceived, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgReceived*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER)
action.pCont = taosMemoryMalloc(action.contLen); action.pCont = taosMemoryMalloc(action.contLen);
if (action.pCont == NULL) goto _OVER; if (action.pCont == NULL) goto _OVER;
...@@ -389,7 +391,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -389,7 +391,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
action.stage = stage; action.stage = stage;
SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER)
if (action.actionType) { if (action.actionType) {
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.rawWritten*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
action.pRaw = taosMemoryMalloc(dataLen); action.pRaw = taosMemoryMalloc(dataLen);
if (action.pRaw == NULL) goto _OVER; if (action.pRaw == NULL) goto _OVER;
...@@ -400,8 +402,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { ...@@ -400,8 +402,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
} else if (action.actionType == TRANS_ACTION_MSG) { } else if (action.actionType == TRANS_ACTION_MSG) {
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER); SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER) SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgSent*/, _OVER)
SDB_GET_INT8(pRaw, dataPos, &action.msgReceived, _OVER) SDB_GET_INT8(pRaw, dataPos, &unused /*&action.msgReceived*/, _OVER)
SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER)
action.pCont = taosMemoryMalloc(action.contLen); action.pCont = taosMemoryMalloc(action.contLen);
if (action.pCont == NULL) goto _OVER; if (action.pCont == NULL) goto _OVER;
...@@ -435,7 +437,9 @@ _OVER: ...@@ -435,7 +437,9 @@ _OVER:
return NULL; return NULL;
} }
mTrace("trans:%d, decode from raw:%p, row:%p", pTrans->id, pRaw, pTrans); if (pTrans != NULL) {
mTrace("trans:%d, decode from raw:%p, row:%p", pTrans->id, pRaw, pTrans);
}
return pRow; return pRow;
} }
...@@ -769,7 +773,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { ...@@ -769,7 +773,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
mError("trans:%d, failed to encode while sync trans since %s", pTrans->id, terrstr()); mError("trans:%d, failed to encode while sync trans since %s", pTrans->id, terrstr());
return -1; return -1;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
mInfo("trans:%d, sync to other mnodes, stage:%s", pTrans->id, mndTransStr(pTrans->stage)); mInfo("trans:%d, sync to other mnodes, stage:%s", pTrans->id, mndTransStr(pTrans->stage));
int32_t code = mndSyncPropose(pMnode, pRaw, pTrans->id); int32_t code = mndSyncPropose(pMnode, pRaw, pTrans->id);
...@@ -816,7 +820,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { ...@@ -816,7 +820,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true;
} }
if (pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { if (pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; // for stb if (mndCheckDbConflict(pNew->stbname, pTrans)) conflict = true; // for stb
} }
} }
...@@ -825,9 +829,8 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { ...@@ -825,9 +829,8 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
pNew->id, pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pNew->id, pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname,
pTrans->conflict); pTrans->conflict);
} else { } else {
mInfo("trans:%d, db:%s stb:%s type:%d, not conflict with trans:%d db:%s stb:%s type:%d", pNew->id, mInfo("trans:%d, db:%s stb:%s type:%d, not conflict with trans:%d db:%s stb:%s type:%d", pNew->id, pNew->dbname,
pNew->dbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pNew->stbname, pNew->conflict, pTrans->id, pTrans->dbname, pTrans->stbname, pTrans->conflict);
pTrans->conflict);
} }
sdbRelease(pMnode->pSdb, pTrans); sdbRelease(pMnode->pSdb, pTrans);
} }
...@@ -930,7 +933,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { ...@@ -930,7 +933,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i); SRpcHandleInfo *pInfo = taosArrayGet(pTrans->pRpcArray, i);
if (pInfo->handle != NULL) { if (pInfo->handle != NULL) {
mInfo("trans:%d, send rsp, code:0x%x stage:%s app:%p", pTrans->id, code, mndTransStr(pTrans->stage), mInfo("trans:%d, send rsp, code:0x%x stage:%s app:%p", pTrans->id, code, mndTransStr(pTrans->stage),
pInfo->ahandle); pInfo->ahandle);
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL; code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
} }
...@@ -1013,8 +1016,8 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { ...@@ -1013,8 +1016,8 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
pAction->errCode = pRsp->code; pAction->errCode = pRsp->code;
} }
mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage),
mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode); action, pRsp->code, pAction->acceptableCode, pAction->retryCode);
mndTransExecute(pMnode, pTrans); mndTransExecute(pMnode, pTrans);
_OVER: _OVER:
...@@ -1030,7 +1033,7 @@ static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pA ...@@ -1030,7 +1033,7 @@ static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pA
pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) {
pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps;
mInfo("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), mInfo("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage),
pAction->id, pAction->epSet.inUse); pAction->id, pAction->epSet.inUse);
} else { } else {
mInfo("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), pAction->id); mInfo("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), pAction->id);
} }
...@@ -1060,7 +1063,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi ...@@ -1060,7 +1063,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
pAction->errCode = 0; pAction->errCode = 0;
code = 0; code = 0;
mInfo("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id, mInfo("trans:%d, %s:%d write to sdb, type:%s status:%s", pTrans->id, mndTransStr(pAction->stage), pAction->id,
sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status)); sdbTableName(pAction->pRaw->type), sdbStatusName(pAction->pRaw->status));
mndSetTransLastAction(pTrans, pAction); mndSetTransLastAction(pTrans, pAction);
} else { } else {
...@@ -1261,7 +1264,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) ...@@ -1261,7 +1264,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
pTrans->code = 0; pTrans->code = 0;
pTrans->redoActionPos++; pTrans->redoActionPos++;
mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage), mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage),
pAction->id); pAction->id);
code = mndTransSync(pMnode, pTrans); code = mndTransSync(pMnode, pTrans);
if (code != 0) { if (code != 0) {
pTrans->code = terrno; pTrans->code = terrno;
...@@ -1280,7 +1283,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) ...@@ -1280,7 +1283,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
terrno = code; terrno = code;
pTrans->code = code; pTrans->code = code;
mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id, mInfo("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id,
mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes); mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes);
break; break;
} }
} }
...@@ -1431,7 +1434,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) { ...@@ -1431,7 +1434,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) {
mError("trans:%d, failed to encode while finish trans since %s", pTrans->id, terrstr()); mError("trans:%d, failed to encode while finish trans since %s", pTrans->id, terrstr());
return false; return false;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
int32_t code = sdbWrite(pMnode->pSdb, pRaw); int32_t code = sdbWrite(pMnode->pSdb, pRaw);
if (code != 0) { if (code != 0) {
......
...@@ -77,7 +77,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char ...@@ -77,7 +77,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
SSdbRaw *pRaw = mndUserActionEncode(&userObj); SSdbRaw *pRaw = mndUserActionEncode(&userObj);
if (pRaw == NULL) return -1; if (pRaw == NULL) return -1;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
mInfo("user:%s, will be created when deploying, raw:%p", userObj.user, pRaw); mInfo("user:%s, will be created when deploying, raw:%p", userObj.user, pRaw);
...@@ -94,7 +94,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char ...@@ -94,7 +94,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
...@@ -313,7 +313,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate ...@@ -313,7 +313,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
...@@ -397,7 +397,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc ...@@ -397,7 +397,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
...@@ -612,7 +612,7 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) { ...@@ -612,7 +612,7 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
return -1; return -1;
} }
sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
if (mndTransPrepare(pMnode, pTrans) != 0) { if (mndTransPrepare(pMnode, pTrans) != 0) {
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
......
...@@ -1115,14 +1115,14 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, ...@@ -1115,14 +1115,14 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
{ {
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) return -1; if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) return -1;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
} }
{ {
SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); SSdbRaw *pRaw = mndVgroupActionEncode(&newVg);
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
} }
...@@ -1304,14 +1304,14 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, ...@@ -1304,14 +1304,14 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
{ {
pRaw = mndVgroupActionEncode(&newVg); pRaw = mndVgroupActionEncode(&newVg);
if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
} }
{ {
pRaw = mndVgroupActionEncode(&newVg); pRaw = mndVgroupActionEncode(&newVg);
if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
pRaw = NULL; pRaw = NULL;
} }
...@@ -1579,7 +1579,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S ...@@ -1579,7 +1579,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
return -1; return -1;
} }
sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
} }
{ {
...@@ -1589,7 +1589,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S ...@@ -1589,7 +1589,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
return -1; return -1;
} }
sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
} }
} }
...@@ -1704,7 +1704,7 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD ...@@ -1704,7 +1704,7 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
return -1; return -1;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
} }
{ {
...@@ -1713,7 +1713,7 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD ...@@ -1713,7 +1713,7 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
return -1; return -1;
} }
sdbSetRawStatus(pRaw, SDB_STATUS_READY); (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
} }
mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica); mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica);
......
...@@ -619,8 +619,8 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i ...@@ -619,8 +619,8 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i
int32_t code = 0; int32_t code = 0;
if (!isApply) { if (!isApply) {
sdbCloseIter(pIter);
mInfo("sdbiter:%p, not apply to sdb", pIter); mInfo("sdbiter:%p, not apply to sdb", pIter);
sdbCloseIter(pIter);
return 0; return 0;
} }
......
...@@ -96,11 +96,11 @@ void metaReaderClear(SMetaReader *pReader); ...@@ -96,11 +96,11 @@ void metaReaderClear(SMetaReader *pReader);
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
int metaGetTableEntryByName(SMetaReader *pReader, const char *name); int metaGetTableEntryByName(SMetaReader *pReader, const char *name);
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags);
int32_t metaGetTableTagsByUids(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags); int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHashObj *tags);
int32_t metaReadNext(SMetaReader *pReader); int32_t metaReadNext(SMetaReader *pReader);
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid); int metaGetTableUidByName(void *meta, char *tbName, int64_t *uid);
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType); int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType);
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
......
...@@ -202,7 +202,7 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { ...@@ -202,7 +202,7 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) {
return 0; return 0;
} }
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) { int metaGetTableUidByName(void *meta, char *tbName, int64_t *uid) {
int code = 0; int code = 0;
SMetaReader mr = {0}; SMetaReader mr = {0};
metaReaderInit(&mr, (SMeta *)meta, 0); metaReaderInit(&mr, (SMeta *)meta, 0);
...@@ -1134,7 +1134,7 @@ END: ...@@ -1134,7 +1134,7 @@ END:
return ret; return ret;
} }
static int32_t metaGetTableTagByUid(SMeta *pMeta, uint64_t suid, uint64_t uid, void **tag, int32_t *len, bool lock) { static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, void **tag, int32_t *len, bool lock) {
int ret = 0; int ret = 0;
if (lock) { if (lock) {
metaRLock(pMeta); metaRLock(pMeta);
...@@ -1148,7 +1148,7 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, uint64_t suid, uint64_t uid, v ...@@ -1148,7 +1148,7 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, uint64_t suid, uint64_t uid, v
return ret; return ret;
} }
int32_t metaGetTableTagsByUids(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags) { int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHashObj *tags) {
const int32_t LIMIT = 128; const int32_t LIMIT = 128;
int32_t isLock = false; int32_t isLock = false;
...@@ -1169,6 +1169,9 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, uint64_t suid, SArray *uidList, SHa ...@@ -1169,6 +1169,9 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, uint64_t suid, SArray *uidList, SHa
if (metaGetTableTagByUid(pMeta, suid, *id, &val, &len, false) == 0) { if (metaGetTableTagByUid(pMeta, suid, *id, &val, &len, false) == 0) {
taosHashPut(tags, id, sizeof(tb_uid_t), val, len); taosHashPut(tags, id, sizeof(tb_uid_t), val, len);
tdbFree(val); tdbFree(val);
} else {
metaError("vgId:%d, failed to table IDs, suid: %" PRId64 ", uid: %" PRId64 "", TD_VID(pMeta->pVnode), suid,
*id);
} }
} }
} }
......
...@@ -608,8 +608,6 @@ typedef struct SStreamIntervalOperatorInfo { ...@@ -608,8 +608,6 @@ typedef struct SStreamIntervalOperatorInfo {
SArray* pDelWins; // SWinRes SArray* pDelWins; // SWinRes
int32_t delIndex; int32_t delIndex;
SSDataBlock* pDelRes; SSDataBlock* pDelRes;
SSDataBlock* pUpdateRes;
bool returnUpdate;
SPhysiNode* pPhyNode; // create new child SPhysiNode* pPhyNode; // create new child
SHashObj* pPullDataMap; SHashObj* pPullDataMap;
SArray* pPullWins; // SPullWindowInfo SArray* pPullWins; // SPullWindowInfo
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
#include "executorimpl.h" #include "executorimpl.h"
#include "tcompression.h" #include "tcompression.h"
static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond); static int32_t removeInvalidTable(SArray* list, SHashObj* tags);
static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond, SHashObj* tags);
static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond); static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond);
void initResultRowInfo(SResultRowInfo* pResultRowInfo) { void initResultRowInfo(SResultRowInfo* pResultRowInfo) {
...@@ -373,7 +374,7 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara ...@@ -373,7 +374,7 @@ static int32_t createResultData(SDataType* pType, int32_t numOfRows, SScalarPara
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray* uidList, SNode* pTagCond) { static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray* uidList, SNode* pTagCond) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
SArray* pBlockList = NULL; SArray* pBlockList = NULL;
SSDataBlock* pResBlock = NULL; SSDataBlock* pResBlock = NULL;
...@@ -411,7 +412,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray ...@@ -411,7 +412,7 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
// int64_t stt = taosGetTimestampUs(); // int64_t stt = taosGetTimestampUs();
tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); tags = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
int32_t filter = optimizeTbnameInCond(metaHandle, suid, uidList, pTagCond); int32_t filter = optimizeTbnameInCond(metaHandle, suid, uidList, pTagCond, tags);
if (filter == -1) { if (filter == -1) {
code = metaGetTableTags(metaHandle, suid, uidList, tags); code = metaGetTableTags(metaHandle, suid, uidList, tags);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
...@@ -419,10 +420,17 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray ...@@ -419,10 +420,17 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
terrno = code; terrno = code;
goto end; goto end;
} }
} else {
metaGetTableTagsByUids(metaHandle, suid, uidList, tags);
qInfo("succ to get table from meta idx, suid:%" PRIu64, suid);
} }
/*else {
code = metaGetTableTagsByUids(metaHandle, suid, uidList, tags);
if (code != 0) {
terrno = code;
qError("failed to get table from meta idx, reason: %s, suid:%" PRId64, tstrerror(code), suid);
goto end;
} else {
qInfo("succ to get table from meta idx, suid:%" PRId64, suid);
}
}*/
int32_t rows = taosArrayGetSize(uidList); int32_t rows = taosArrayGetSize(uidList);
if (rows == 0) { if (rows == 0) {
...@@ -760,13 +768,18 @@ static int tableUidCompare(const void* a, const void* b) { ...@@ -760,13 +768,18 @@ static int tableUidCompare(const void* a, const void* b) {
} }
return u1 < u2 ? -1 : 1; return u1 < u2 ? -1 : 1;
} }
static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* cond) { static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list, SNode* cond, SHashObj* tags) {
int32_t ret = -1;
if (nodeType(cond) == QUERY_NODE_OPERATOR) { if (nodeType(cond) == QUERY_NODE_OPERATOR) {
return optimizeTbnameInCondImpl(metaHandle, suid, list, cond); ret = optimizeTbnameInCondImpl(metaHandle, suid, list, cond);
if (ret != -1) {
metaGetTableTagsByUids(metaHandle, suid, list, tags);
removeInvalidTable(list, tags);
}
} }
if (nodeType(cond) != QUERY_NODE_LOGIC_CONDITION || ((SLogicConditionNode*)cond)->condType != LOGIC_COND_TYPE_AND) { if (nodeType(cond) != QUERY_NODE_LOGIC_CONDITION || ((SLogicConditionNode*)cond)->condType != LOGIC_COND_TYPE_AND) {
return -1; return ret;
} }
bool hasTbnameCond = false; bool hasTbnameCond = false;
...@@ -774,20 +787,44 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list ...@@ -774,20 +787,44 @@ static int32_t optimizeTbnameInCond(void* metaHandle, int64_t suid, SArray* list
SNodeList* pList = (SNodeList*)pNode->pParameterList; SNodeList* pList = (SNodeList*)pNode->pParameterList;
int32_t len = LIST_LENGTH(pList); int32_t len = LIST_LENGTH(pList);
if (len <= 0) return -1; if (len <= 0) return ret;
SListCell* cell = pList->pHead; SListCell* cell = pList->pHead;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (cell == NULL) break; if (cell == NULL) break;
if (optimizeTbnameInCondImpl(metaHandle, suid, list, cell->pNode) == 0) { if (optimizeTbnameInCondImpl(metaHandle, suid, list, cell->pNode) == 0) {
hasTbnameCond = true; hasTbnameCond = true;
break;
} }
cell = cell->pNext; cell = cell->pNext;
} }
taosArraySort(list, tableUidCompare); taosArraySort(list, tableUidCompare);
taosArrayRemoveDuplicate(list, tableUidCompare, NULL); taosArrayRemoveDuplicate(list, tableUidCompare, NULL);
return hasTbnameCond == true ? 0 : -1; if (hasTbnameCond) {
ret = metaGetTableTagsByUids(metaHandle, suid, list, tags);
removeInvalidTable(list, tags);
}
return ret;
}
/*
* handle invalid uid
*/
static int32_t removeInvalidTable(SArray* uids, SHashObj* tags) {
if (taosArrayGetSize(uids) <= 0) return 0;
SArray* validUid = taosArrayInit(taosArrayGetSize(uids), sizeof(int64_t));
for (int32_t i = 0; i < taosArrayGetSize(uids); i++) {
int64_t* uid = taosArrayGet(uids, i);
if (taosHashGet(tags, uid, sizeof(int64_t)) != NULL) {
taosArrayPush(validUid, uid);
}
}
taosArraySwap(uids, validUid);
taosArrayDestroy(validUid);
return 0;
} }
static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) { static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) {
if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) { if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) {
......
...@@ -1311,8 +1311,8 @@ void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* ...@@ -1311,8 +1311,8 @@ void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t*
colDataAppend(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false); colDataAppend(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false);
colDataAppend(pUidCol, pBlock->info.rows, (const char*)pUid, false); colDataAppend(pUidCol, pBlock->info.rows, (const char*)pUid, false);
colDataAppend(pGpCol, pBlock->info.rows, (const char*)pGp, false); colDataAppend(pGpCol, pBlock->info.rows, (const char*)pGp, false);
colDataAppendNULL(pCalStartCol, pBlock->info.rows); colDataAppend(pCalStartCol, pBlock->info.rows, (const char*)pStartTs, false);
colDataAppendNULL(pCalEndCol, pBlock->info.rows); colDataAppend(pCalEndCol, pBlock->info.rows, (const char*)pEndTs, false);
pBlock->info.rows++; pBlock->info.rows++;
} }
...@@ -1356,7 +1356,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock ...@@ -1356,7 +1356,7 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
} }
} }
static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock) { static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock, bool filter) {
SDataBlockInfo* pBlockInfo = &pInfo->pRes->info; SDataBlockInfo* pBlockInfo = &pInfo->pRes->info;
SOperatorInfo* pOperator = pInfo->pStreamScanOp; SOperatorInfo* pOperator = pInfo->pStreamScanOp;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
...@@ -1410,7 +1410,9 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock ...@@ -1410,7 +1410,9 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
} }
} }
doFilter(pInfo->pCondition, pInfo->pRes, NULL); if (filter) {
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
}
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
blockDataFreeRes((SSDataBlock*)pBlock); blockDataFreeRes((SSDataBlock*)pBlock);
return 0; return 0;
...@@ -1446,7 +1448,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { ...@@ -1446,7 +1448,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
continue; continue;
} }
setBlockIntoRes(pInfo, &block); setBlockIntoRes(pInfo, &block, true);
if (pBlockInfo->rows > 0) { if (pBlockInfo->rows > 0) {
return pInfo->pRes; return pInfo->pRes;
...@@ -1487,7 +1489,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { ...@@ -1487,7 +1489,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) {
tqNextBlock(pInfo->tqReader, &ret); tqNextBlock(pInfo->tqReader, &ret);
if (ret.fetchType == FETCH_TYPE__DATA) { if (ret.fetchType == FETCH_TYPE__DATA) {
blockDataCleanup(pInfo->pRes); blockDataCleanup(pInfo->pRes);
if (setBlockIntoRes(pInfo, &ret.data) < 0) { if (setBlockIntoRes(pInfo, &ret.data, true) < 0) {
ASSERT(0); ASSERT(0);
} }
if (pInfo->pRes->info.rows > 0) { if (pInfo->pRes->info.rows > 0) {
...@@ -1751,6 +1753,7 @@ FETCH_NEXT_BLOCK: ...@@ -1751,6 +1753,7 @@ FETCH_NEXT_BLOCK:
// printDataBlock(pSDB, "stream scan update"); // printDataBlock(pSDB, "stream scan update");
return pSDB; return pSDB;
} }
blockDataCleanup(pInfo->pUpdateDataRes);
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE; pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
} break; } break;
default: default:
...@@ -1801,7 +1804,7 @@ FETCH_NEXT_BLOCK: ...@@ -1801,7 +1804,7 @@ FETCH_NEXT_BLOCK:
continue; continue;
} }
setBlockIntoRes(pInfo, &block); setBlockIntoRes(pInfo, &block, false);
if (updateInfoIgnore(pInfo->pUpdateInfo, &pInfo->pRes->info.window, pInfo->pRes->info.groupId, if (updateInfoIgnore(pInfo->pUpdateInfo, &pInfo->pRes->info.window, pInfo->pRes->info.groupId,
pInfo->pRes->info.version)) { pInfo->pRes->info.version)) {
...@@ -1810,11 +1813,30 @@ FETCH_NEXT_BLOCK: ...@@ -1810,11 +1813,30 @@ FETCH_NEXT_BLOCK:
continue; continue;
} }
if (pBlockInfo->rows > 0) { if (pInfo->pUpdateInfo) {
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->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_DELETE_DATA;
}
}
}
doFilter(pInfo->pCondition, pInfo->pRes, NULL);
blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
break; break;
} }
} }
if (pBlockInfo->rows > 0) { if (pBlockInfo->rows > 0 || pInfo->pUpdateDataRes->info.rows > 0) {
break; break;
} else { } else {
pInfo->tqReader->pMsg = NULL; pInfo->tqReader->pMsg = NULL;
...@@ -1828,32 +1850,16 @@ FETCH_NEXT_BLOCK: ...@@ -1828,32 +1850,16 @@ FETCH_NEXT_BLOCK:
pOperator->resultInfo.totalRows += pBlockInfo->rows; pOperator->resultInfo.totalRows += pBlockInfo->rows;
// printDataBlock(pInfo->pRes, "stream scan"); // printDataBlock(pInfo->pRes, "stream scan");
if (pBlockInfo->rows == 0) {
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
/*pOperator->status = OP_EXEC_DONE;*/
} else if (pInfo->pUpdateInfo) {
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->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_DELETE_DATA;
}
}
}
qDebug("scan rows: %d", pBlockInfo->rows); qDebug("scan rows: %d", pBlockInfo->rows);
if (pBlockInfo->rows > 0) { if (pBlockInfo->rows > 0) {
return pInfo->pRes; return pInfo->pRes;
} else {
goto NEXT_SUBMIT_BLK;
} }
/*return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;*/
if (pInfo->pUpdateDataRes->info.rows > 0) {
goto FETCH_NEXT_BLOCK;
}
goto NEXT_SUBMIT_BLK;
} else { } else {
ASSERT(0); ASSERT(0);
return NULL; return NULL;
...@@ -3077,6 +3083,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { ...@@ -3077,6 +3083,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
STagScanInfo* pInfo = pOperator->info; STagScanInfo* pInfo = pOperator->info;
SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[0]; SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[0];
SSDataBlock* pRes = pInfo->pRes; SSDataBlock* pRes = pInfo->pRes;
blockDataCleanup(pRes);
int32_t size = taosArrayGetSize(pInfo->pTableList->pTableList); int32_t size = taosArrayGetSize(pInfo->pTableList->pTableList);
if (size == 0) { if (size == 0) {
......
...@@ -584,7 +584,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma ...@@ -584,7 +584,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
assert(numOfRes >= numOfRows); assert(numOfRes >= numOfRows);
} else { // reach the end of data } else { // reach the end of data
if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) ||
(ekey1 > pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { (ekey1 >= pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) {
return 0; return 0;
} }
numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding, numOfRes = taosTimeCountInterval(ekey1, pFillInfo->currentKey, pFillInfo->interval.sliding,
...@@ -706,6 +706,9 @@ void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) { ...@@ -706,6 +706,9 @@ void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) {
pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols); pFillSup->pAllColInfo = destroyFillColumnInfo(pFillSup->pAllColInfo, pFillSup->numOfFillCols, pFillSup->numOfAllCols);
tSimpleHashCleanup(pFillSup->pResMap); tSimpleHashCleanup(pFillSup->pResMap);
pFillSup->pResMap = NULL; pFillSup->pResMap = NULL;
streamStateReleaseBuf(NULL, NULL, pFillSup->cur.pRowVal);
pFillSup->cur.pRowVal = NULL;
taosMemoryFree(pFillSup); taosMemoryFree(pFillSup);
return NULL; return NULL;
} }
...@@ -722,6 +725,7 @@ void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) { ...@@ -722,6 +725,7 @@ void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) {
taosMemoryFreeClear(pFillInfo->pResRow); taosMemoryFreeClear(pFillInfo->pResRow);
} }
pFillInfo->pLinearInfo = destroyStreamFillLinearInfo(pFillInfo->pLinearInfo); pFillInfo->pLinearInfo = destroyStreamFillLinearInfo(pFillInfo->pLinearInfo);
taosArrayDestroy(pFillInfo->delRanges);
taosMemoryFree(pFillInfo); taosMemoryFree(pFillInfo);
return NULL; return NULL;
} }
...@@ -732,6 +736,8 @@ void destroyStreamFillOperatorInfo(void* param) { ...@@ -732,6 +736,8 @@ void destroyStreamFillOperatorInfo(void* param) {
pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup); pInfo->pFillSup = destroyStreamFillSupporter(pInfo->pFillSup);
pInfo->pRes = blockDataDestroy(pInfo->pRes); pInfo->pRes = blockDataDestroy(pInfo->pRes);
pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock); pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock);
pInfo->pPrevSrcBlock = blockDataDestroy(pInfo->pPrevSrcBlock);
pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes);
pInfo->pColMatchColInfo = taosArrayDestroy(pInfo->pColMatchColInfo); pInfo->pColMatchColInfo = taosArrayDestroy(pInfo->pColMatchColInfo);
taosMemoryFree(pInfo); taosMemoryFree(pInfo);
} }
...@@ -743,6 +749,7 @@ static void resetFillWindow(SResultRowData* pRowData) { ...@@ -743,6 +749,7 @@ static void resetFillWindow(SResultRowData* pRowData) {
void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, SStreamState* pState) { void resetPrevAndNextWindow(SStreamFillSupporter* pFillSup, SStreamState* pState) {
resetFillWindow(&pFillSup->prev); resetFillWindow(&pFillSup->prev);
streamStateReleaseBuf(NULL, NULL, pFillSup->cur.pRowVal);
resetFillWindow(&pFillSup->cur); resetFillWindow(&pFillSup->cur);
resetFillWindow(&pFillSup->next); resetFillWindow(&pFillSup->next);
resetFillWindow(&pFillSup->nextNext); resetFillWindow(&pFillSup->nextNext);
...@@ -753,12 +760,12 @@ void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupI ...@@ -753,12 +760,12 @@ void getCurWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupI
resetPrevAndNextWindow(pFillSup, pState); resetPrevAndNextWindow(pFillSup, pState);
SWinKey key = {.ts = ts, .groupId = groupId}; SWinKey key = {.ts = ts, .groupId = groupId};
void* curVal = NULL; // void* curVal = NULL;
int32_t curVLen = 0; int32_t curVLen = 0;
int32_t code = streamStateFillGet(pState, &key, (void**)&curVal, &curVLen); int32_t code = streamStateFillGet(pState, &key, (void**)&pFillSup->cur.pRowVal, &curVLen);
ASSERT(code == TSDB_CODE_SUCCESS); ASSERT(code == TSDB_CODE_SUCCESS);
pFillSup->cur.key = key.ts; pFillSup->cur.key = key.ts;
pFillSup->cur.pRowVal = curVal; // pFillSup->cur.pRowVal = curVal;
} }
void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) { void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, SStreamFillSupporter* pFillSup) {
...@@ -777,11 +784,9 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, ...@@ -777,11 +784,9 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId,
SWinKey preKey = {.groupId = groupId}; SWinKey preKey = {.groupId = groupId};
void* preVal = NULL; void* preVal = NULL;
int32_t preVLen = 0; int32_t preVLen = 0;
if (pCur) { code = streamStateGetGroupKVByCur(pCur, &preKey, (const void**)&preVal, &preVLen);
code = streamStateGetGroupKVByCur(pCur, &preKey, (const void**)&preVal, &preVLen);
}
if (pCur && code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
pFillSup->prev.key = preKey.ts; pFillSup->prev.key = preKey.ts;
pFillSup->prev.pRowVal = preVal; pFillSup->prev.pRowVal = preVal;
...@@ -790,35 +795,36 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId, ...@@ -790,35 +795,36 @@ void getWindowFromDiscBuf(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId,
code = streamStateCurNext(pState, pCur); code = streamStateCurNext(pState, pCur);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
streamStateFreeCur(pCur);
pCur = NULL; pCur = NULL;
} }
} else { } else {
streamStateFreeCur(pCur);
pCur = streamStateFillSeekKeyNext(pState, &key); pCur = streamStateFillSeekKeyNext(pState, &key);
} }
if (pCur) { SWinKey nextKey = {.groupId = groupId};
SWinKey nextKey = {.groupId = groupId}; void* nextVal = NULL;
void* nextVal = NULL; int32_t nextVLen = 0;
int32_t nextVLen = 0; code = streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextVLen);
code = streamStateGetGroupKVByCur(pCur, &nextKey, (const void**)&nextVal, &nextVLen); if (code == TSDB_CODE_SUCCESS) {
if (code == TSDB_CODE_SUCCESS) { pFillSup->next.key = nextKey.ts;
pFillSup->next.key = nextKey.ts; pFillSup->next.pRowVal = nextVal;
pFillSup->next.pRowVal = nextVal; if (pFillSup->type == TSDB_FILL_PREV || pFillSup->type == TSDB_FILL_NEXT) {
if (pFillSup->type == TSDB_FILL_PREV || pFillSup->type == TSDB_FILL_NEXT) { code = streamStateCurNext(pState, pCur);
code = streamStateCurNext(pState, pCur); if (code == TSDB_CODE_SUCCESS) {
SWinKey nextNextKey = {.groupId = groupId};
void* nextNextVal = NULL;
int32_t nextNextVLen = 0;
code = streamStateGetGroupKVByCur(pCur, &nextNextKey, (const void**)&nextNextVal, &nextNextVLen);
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
SWinKey nextNextKey = {.groupId = groupId}; pFillSup->nextNext.key = nextNextKey.ts;
void* nextNextVal = NULL; pFillSup->nextNext.pRowVal = nextNextVal;
int32_t nextNextVLen = 0;
code = streamStateGetGroupKVByCur(pCur, &nextNextKey, (const void**)&nextNextVal, &nextNextVLen);
if (code == TSDB_CODE_SUCCESS) {
pFillSup->nextNext.key = nextNextKey.ts;
pFillSup->nextNext.pRowVal = nextNextVal;
}
} }
} }
} }
} }
streamStateFreeCur(pCur);
} }
static bool hasPrevWindow(SStreamFillSupporter* pFillSup) { return pFillSup->prev.key != INT64_MIN; } static bool hasPrevWindow(SStreamFillSupporter* pFillSup) { return pFillSup->prev.key != INT64_MIN; }
...@@ -1388,6 +1394,7 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) { ...@@ -1388,6 +1394,7 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) {
} }
pInfo->srcDelRowIndex++; pInfo->srcDelRowIndex++;
} }
streamStateFreeCur(pCur);
doDeleteFillResultImpl(pOperator, ts, endTs, groupId); doDeleteFillResultImpl(pOperator, ts, endTs, groupId);
} }
pFillInfo->current = pFillInfo->end + 1; pFillInfo->current = pFillInfo->end + 1;
...@@ -1538,9 +1545,12 @@ static int32_t initResultBuf(SStreamFillSupporter* pFillSup) { ...@@ -1538,9 +1545,12 @@ static int32_t initResultBuf(SStreamFillSupporter* pFillSup) {
pFillSup->next.key = INT64_MIN; pFillSup->next.key = INT64_MIN;
pFillSup->nextNext.key = INT64_MIN; pFillSup->nextNext.key = INT64_MIN;
pFillSup->prev.key = INT64_MIN; pFillSup->prev.key = INT64_MIN;
pFillSup->cur.key = INT64_MIN;
pFillSup->next.pRowVal = NULL; pFillSup->next.pRowVal = NULL;
pFillSup->nextNext.pRowVal = NULL; pFillSup->nextNext.pRowVal = NULL;
pFillSup->prev.pRowVal = NULL; pFillSup->prev.pRowVal = NULL;
pFillSup->cur.pRowVal = NULL;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -1251,12 +1251,12 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1251,12 +1251,12 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
} }
} }
} else if (type == TSDB_DATA_TYPE_FLOAT) { } else if (type == TSDB_DATA_TYPE_FLOAT) {
double prev = 0; float prev = 0;
GET_TYPED_DATA(prev, double, type, &pBuf->v); GET_TYPED_DATA(prev, float, type, &pBuf->v);
double val = GET_DOUBLE_VAL(tval); float val = GET_DOUBLE_VAL(tval);
if ((prev < val) ^ isMinFunc) { if ((prev < val) ^ isMinFunc) {
*(double*)&pBuf->v = val; *(float*)&pBuf->v = val;
} }
if (pCtx->subsidiaries.num > 0) { if (pCtx->subsidiaries.num > 0) {
......
...@@ -959,8 +959,8 @@ int32_t udfdInitResidentFuncs() { ...@@ -959,8 +959,8 @@ int32_t udfdInitResidentFuncs() {
char* pSave = tsUdfdResFuncs; char* pSave = tsUdfdResFuncs;
char* token; char* token;
while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { while ((token = strtok_r(pSave, ",", &pSave)) != NULL) {
char func[TSDB_FUNC_NAME_LEN] = {0}; char func[TSDB_FUNC_NAME_LEN+1] = {0};
strncpy(func, token, sizeof(func)); strncpy(func, token, TSDB_FUNC_NAME_LEN);
taosArrayPush(global.residentFuncs, func); taosArrayPush(global.residentFuncs, func);
} }
......
...@@ -32,7 +32,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF ...@@ -32,7 +32,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
} }
sprintf(streamPath, "%s/%s", pMeta->path, "checkpoints"); sprintf(streamPath, "%s/%s", pMeta->path, "checkpoints");
mkdir(streamPath, 0755); taosMulModeMkDir(streamPath, 0755);
taosMemoryFree(streamPath); taosMemoryFree(streamPath);
if (tdbTbOpen("task.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pTaskDb) < 0) { if (tdbTbOpen("task.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pTaskDb) < 0) {
......
...@@ -24,7 +24,7 @@ typedef struct SStateKey { ...@@ -24,7 +24,7 @@ typedef struct SStateKey {
int64_t opNum; int64_t opNum;
} SStateKey; } SStateKey;
static inline int SStateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) { static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
SStateKey* pWin1 = (SStateKey*)pKey1; SStateKey* pWin1 = (SStateKey*)pKey1;
SStateKey* pWin2 = (SStateKey*)pKey2; SStateKey* pWin2 = (SStateKey*)pKey2;
...@@ -68,12 +68,12 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { ...@@ -68,12 +68,12 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) {
} }
// open state storage backend // open state storage backend
if (tdbTbOpen("state.db", sizeof(SStateKey), -1, SStateKeyCmpr, pState->db, &pState->pStateDb) < 0) { if (tdbTbOpen("state.db", sizeof(SStateKey), -1, stateKeyCmpr, pState->db, &pState->pStateDb) < 0) {
goto _err; goto _err;
} }
// todo refactor // todo refactor
if (tdbTbOpen("func.state.db", sizeof(SWinKey), -1, SWinKeyCmpr, pState->db, &pState->pFillStateDb) < 0) { if (tdbTbOpen("func.state.db", sizeof(SWinKey), -1, winKeyCmpr, pState->db, &pState->pFillStateDb) < 0) {
goto _err; goto _err;
} }
...@@ -197,6 +197,7 @@ int32_t streamStateClear(SStreamState* pState) { ...@@ -197,6 +197,7 @@ int32_t streamStateClear(SStreamState* pState) {
SStreamStateCur* pCur = streamStateSeekKeyNext(pState, &key); SStreamStateCur* pCur = streamStateSeekKeyNext(pState, &key);
SWinKey delKey = {0}; SWinKey delKey = {0};
int32_t code = streamStateGetKVByCur(pCur, &delKey, NULL, 0); int32_t code = streamStateGetKVByCur(pCur, &delKey, NULL, 0);
streamStateFreeCur(pCur);
if (code == 0) { if (code == 0) {
streamStateDel(pState, &delKey); streamStateDel(pState, &delKey);
} else { } else {
...@@ -226,6 +227,9 @@ int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void* ...@@ -226,6 +227,9 @@ int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void*
int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal) { int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal) {
// todo refactor // todo refactor
if (!pVal) {
return 0;
}
streamFreeVal(pVal); streamFreeVal(pVal);
return 0; return 0;
} }
...@@ -237,7 +241,7 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) { ...@@ -237,7 +241,7 @@ SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) {
int32_t c; int32_t c;
SStateKey sKey = {.key = *key, .opNum = pState->number}; SStateKey sKey = {.key = *key, .opNum = pState->number};
tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c); tdbTbcMoveTo(pCur->pCur, &sKey, sizeof(SStateKey), &c);
if (c != 0) { if (c != 0) {
taosMemoryFree(pCur); taosMemoryFree(pCur);
return NULL; return NULL;
...@@ -254,7 +258,7 @@ SStreamStateCur* streamStateFillGetCur(SStreamState* pState, const SWinKey* key) ...@@ -254,7 +258,7 @@ SStreamStateCur* streamStateFillGetCur(SStreamState* pState, const SWinKey* key)
int32_t c; int32_t c;
tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c); tdbTbcMoveTo(pCur->pCur, key, sizeof(SWinKey), &c);
if (c != 0) { if (c != 0) {
taosMemoryFree(pCur); streamStateFreeCur(pCur);
return NULL; return NULL;
} }
return pCur; return pCur;
...@@ -267,6 +271,7 @@ SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key) { ...@@ -267,6 +271,7 @@ SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key) {
if (code == 0) { if (code == 0) {
return pCur; return pCur;
} }
streamStateFreeCur(pCur);
} }
return NULL; return NULL;
} }
...@@ -301,6 +306,9 @@ int32_t streamStateFillGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const vo ...@@ -301,6 +306,9 @@ int32_t streamStateFillGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const vo
} }
int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) {
if (!pCur) {
return -1;
}
uint64_t groupId = pKey->groupId; uint64_t groupId = pKey->groupId;
int32_t code = streamStateFillGetKVByCur(pCur, pKey, pVal, pVLen); int32_t code = streamStateFillGetKVByCur(pCur, pKey, pVal, pVLen);
if (code == 0) { if (code == 0) {
...@@ -361,7 +369,7 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key ...@@ -361,7 +369,7 @@ SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key
SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key) { SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key) {
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
if (pCur == NULL) { if (!pCur) {
return NULL; return NULL;
} }
if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) { if (tdbTbcOpen(pState->pFillStateDb, &pCur->pCur, NULL) < 0) {
...@@ -412,6 +420,9 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey* ...@@ -412,6 +420,9 @@ SStreamStateCur* streamStateFillSeekKeyPrev(SStreamState* pState, const SWinKey*
} }
int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur) { int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur) {
if (!pCur) {
return -1;
}
// //
return tdbTbcMoveToNext(pCur->pCur); return tdbTbcMoveToNext(pCur->pCur);
} }
......
...@@ -62,7 +62,7 @@ int32_t tdbOpen(const char *dbname, int32_t szPage, int32_t pages, TDB **ppDb) { ...@@ -62,7 +62,7 @@ int32_t tdbOpen(const char *dbname, int32_t szPage, int32_t pages, TDB **ppDb) {
} }
memset(pDb->pgrHash, 0, tsize); memset(pDb->pgrHash, 0, tsize);
mkdir(dbname, 0755); taosMulModeMkDir(dbname, 0755);
#ifdef USE_MAINDB #ifdef USE_MAINDB
// open main db // open main db
......
...@@ -121,6 +121,8 @@ int32_t taosMkDir(const char *dirname) { ...@@ -121,6 +121,8 @@ int32_t taosMkDir(const char *dirname) {
if (taosDirExist(dirname)) return 0; if (taosDirExist(dirname)) return 0;
#ifdef WINDOWS #ifdef WINDOWS
int32_t code = _mkdir(dirname, 0755); int32_t code = _mkdir(dirname, 0755);
#elif defined(DARWIN)
int32_t code = mkdir(dirname, 0777);
#else #else
int32_t code = mkdir(dirname, 0755); int32_t code = mkdir(dirname, 0755);
#endif #endif
...@@ -156,6 +158,8 @@ int32_t taosMulMkDir(const char *dirname) { ...@@ -156,6 +158,8 @@ int32_t taosMulMkDir(const char *dirname) {
*pos = '\0'; *pos = '\0';
#ifdef WINDOWS #ifdef WINDOWS
code = _mkdir(temp, 0755); code = _mkdir(temp, 0755);
#elif defined(DARWIN)
code = mkdir(dirname, 0777);
#else #else
code = mkdir(temp, 0755); code = mkdir(temp, 0755);
#endif #endif
...@@ -170,6 +174,8 @@ int32_t taosMulMkDir(const char *dirname) { ...@@ -170,6 +174,8 @@ int32_t taosMulMkDir(const char *dirname) {
if (*(pos - 1) != TD_DIRSEP[0]) { if (*(pos - 1) != TD_DIRSEP[0]) {
#ifdef WINDOWS #ifdef WINDOWS
code = _mkdir(temp, 0755); code = _mkdir(temp, 0755);
#elif defined(DARWIN)
code = mkdir(dirname, 0777);
#else #else
code = mkdir(temp, 0755); code = mkdir(temp, 0755);
#endif #endif
...@@ -179,7 +185,6 @@ int32_t taosMulMkDir(const char *dirname) { ...@@ -179,7 +185,6 @@ int32_t taosMulMkDir(const char *dirname) {
} }
} }
// int32_t code = mkdir(dirname, 0755);
if (code < 0 && errno == EEXIST) { if (code < 0 && errno == EEXIST) {
return 0; return 0;
} }
...@@ -215,6 +220,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) { ...@@ -215,6 +220,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) {
*pos = '\0'; *pos = '\0';
#ifdef WINDOWS #ifdef WINDOWS
code = _mkdir(temp, mode); code = _mkdir(temp, mode);
#elif defined(DARWIN)
code = mkdir(dirname, 0777);
#else #else
code = mkdir(temp, mode); code = mkdir(temp, mode);
#endif #endif
...@@ -229,6 +236,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) { ...@@ -229,6 +236,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) {
if (*(pos - 1) != TD_DIRSEP[0]) { if (*(pos - 1) != TD_DIRSEP[0]) {
#ifdef WINDOWS #ifdef WINDOWS
code = _mkdir(temp, mode); code = _mkdir(temp, mode);
#elif defined(DARWIN)
code = mkdir(dirname, 0777);
#else #else
code = mkdir(temp, mode); code = mkdir(temp, mode);
#endif #endif
......
...@@ -59,34 +59,18 @@ void osDefaultInit() { ...@@ -59,34 +59,18 @@ void osDefaultInit() {
if (tmpDir != NULL) { if (tmpDir != NULL) {
strcpy(tsTempDir, tmpDir); strcpy(tsTempDir, tmpDir);
} }
if (configDir[0] == 0) {
strcpy(configDir, "C:\\TDengine\\cfg");
}
strcpy(tsDataDir, "C:\\TDengine\\data");
strcpy(tsLogDir, "C:\\TDengine\\log");
strcpy(tsTempDir, "C:\\Windows\\Temp");
strcpy(tsOsName, "Windows"); strcpy(tsOsName, "Windows");
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
if (configDir[0] == 0) {
strcpy(configDir, "/usr/local/etc/taos");
}
strcpy(tsDataDir, "/usr/local/var/lib/taos");
strcpy(tsLogDir, "/usr/local/var/log/taos");
strcpy(tsTempDir, "/tmp/taosd");
strcpy(tsOsName, "Darwin"); strcpy(tsOsName, "Darwin");
#else #else
if (configDir[0] == 0) {
strcpy(configDir, "/etc/taos");
}
strcpy(tsDataDir, "/var/lib/taos");
strcpy(tsLogDir, "/var/log/taos");
strcpy(tsTempDir, "/tmp");
strcpy(tsOsName, "Linux"); strcpy(tsOsName, "Linux");
#endif #endif
if (configDir[0] == 0) {
strcpy(configDir, TD_CFG_DIR_PATH);
}
strcpy(tsDataDir, TD_DATA_DIR_PATH);
strcpy(tsLogDir, TD_LOG_DIR_PATH);
strcpy(tsTempDir, TD_TMP_DIR_PATH);
} }
void osUpdate() { void osUpdate() {
......
...@@ -154,8 +154,8 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { ...@@ -154,8 +154,8 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
return -1; return -1;
} }
char *line = NULL; char line[1024];
ssize_t _bytes = taosGetLineFile(pFile, &line); ssize_t _bytes = taosGetsFile(pFile, sizeof(line), line);
if ((_bytes < 0) || (line == NULL)) { if ((_bytes < 0) || (line == NULL)) {
taosCloseFile(&pFile); taosCloseFile(&pFile);
return -1; return -1;
...@@ -165,7 +165,6 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { ...@@ -165,7 +165,6 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system,
&cpuInfo->idle); &cpuInfo->idle);
if (line != NULL) taosMemoryFreeClear(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
#endif #endif
return 0; return 0;
...@@ -194,8 +193,8 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { ...@@ -194,8 +193,8 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
return -1; return -1;
} }
char *line = NULL; char line[1024];
ssize_t _bytes = taosGetLineFile(pFile, &line); ssize_t _bytes = taosGetsFile(pFile, sizeof(line), line);
if ((_bytes < 0) || (line == NULL)) { if ((_bytes < 0) || (line == NULL)) {
taosCloseFile(&pFile); taosCloseFile(&pFile);
return -1; return -1;
...@@ -210,7 +209,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { ...@@ -210,7 +209,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
} }
} }
if (line != NULL) taosMemoryFreeClear(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
#endif #endif
return 0; return 0;
...@@ -286,14 +284,14 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) { ...@@ -286,14 +284,14 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
snprintf(releaseName, maxLen, "Windows"); snprintf(releaseName, maxLen, "Windows");
return 0; return 0;
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
char *line = NULL; char line[1024];
size_t size = 0; size_t size = 0;
int32_t code = -1; int32_t code = -1;
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return false; if (pFile == NULL) return false;
while ((size = taosGetLineFile(pFile, &line)) != -1) { while ((size = taosGetsFile(pFile, sizeof(line), line)) != -1) {
line[size - 1] = '\0'; line[size - 1] = '\0';
if (strncmp(line, "PRETTY_NAME", 11) == 0) { if (strncmp(line, "PRETTY_NAME", 11) == 0) {
const char *p = strchr(line, '=') + 1; const char *p = strchr(line, '=') + 1;
...@@ -307,18 +305,17 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) { ...@@ -307,18 +305,17 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
} }
} }
if (line != NULL) taosMemoryFree(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return code; return code;
#else #else
char *line = NULL; char line[1024];
size_t size = 0; size_t size = 0;
int32_t code = -1; int32_t code = -1;
TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile("/etc/os-release", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return false; if (pFile == NULL) return false;
while ((size = taosGetLineFile(pFile, &line)) != -1) { while ((size = taosGetsFile(pFile, sizeof(line), line)) != -1) {
line[size - 1] = '\0'; line[size - 1] = '\0';
if (strncmp(line, "PRETTY_NAME", 11) == 0) { if (strncmp(line, "PRETTY_NAME", 11) == 0) {
const char *p = strchr(line, '=') + 1; const char *p = strchr(line, '=') + 1;
...@@ -332,7 +329,6 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) { ...@@ -332,7 +329,6 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
} }
} }
if (line != NULL) taosMemoryFree(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return code; return code;
#endif #endif
...@@ -374,7 +370,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { ...@@ -374,7 +370,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
return code; return code;
#else #else
char *line = NULL; char line[1024];
size_t size = 0; size_t size = 0;
int32_t done = 0; int32_t done = 0;
int32_t code = -1; int32_t code = -1;
...@@ -383,7 +379,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { ...@@ -383,7 +379,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) return code; if (pFile == NULL) return code;
while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) { while (done != 3 && (size = taosGetsFile(pFile, sizeof(line), line)) != -1) {
line[size - 1] = '\0'; line[size - 1] = '\0';
if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) { if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) {
const char *v = strchr(line, ':') + 2; const char *v = strchr(line, ':') + 2;
...@@ -398,7 +394,6 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { ...@@ -398,7 +394,6 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
if (strncmp(line, "processor", 9) == 0) coreCount += 1; if (strncmp(line, "processor", 9) == 0) coreCount += 1;
} }
if (line != NULL) taosMemoryFree(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
if (code != 0 && (done & 1) == 0) { if (code != 0 && (done & 1) == 0) {
...@@ -517,9 +512,9 @@ int32_t taosGetProcMemory(int64_t *usedKB) { ...@@ -517,9 +512,9 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
} }
ssize_t _bytes = 0; ssize_t _bytes = 0;
char *line = NULL; char line[1024];
while (!taosEOFFile(pFile)) { while (!taosEOFFile(pFile)) {
_bytes = taosGetLineFile(pFile, &line); _bytes = taosGetsFile(pFile, sizeof(line), line);
if ((_bytes < 0) || (line == NULL)) { if ((_bytes < 0) || (line == NULL)) {
break; break;
} }
...@@ -537,7 +532,6 @@ int32_t taosGetProcMemory(int64_t *usedKB) { ...@@ -537,7 +532,6 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
char tmp[10]; char tmp[10];
sscanf(line, "%s %" PRId64, tmp, usedKB); sscanf(line, "%s %" PRId64, tmp, usedKB);
if (line != NULL) taosMemoryFreeClear(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return 0; return 0;
#endif #endif
...@@ -631,12 +625,12 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int ...@@ -631,12 +625,12 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
if (pFile == NULL) return -1; if (pFile == NULL) return -1;
ssize_t _bytes = 0; ssize_t _bytes = 0;
char *line = NULL; char line[1024];
char tmp[24]; char tmp[24];
int readIndex = 0; int readIndex = 0;
while (!taosEOFFile(pFile)) { while (!taosEOFFile(pFile)) {
_bytes = taosGetLineFile(pFile, &line); _bytes = taosGetsFile(pFile, sizeof(line), line);
if (_bytes < 10 || line == NULL) { if (_bytes < 10 || line == NULL) {
break; break;
} }
...@@ -658,7 +652,6 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int ...@@ -658,7 +652,6 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
if (readIndex >= 4) break; if (readIndex >= 4) break;
} }
if (line != NULL) taosMemoryFreeClear(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
if (readIndex < 4) { if (readIndex < 4) {
...@@ -709,7 +702,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) { ...@@ -709,7 +702,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
if (pFile == NULL) return -1; if (pFile == NULL) return -1;
ssize_t _bytes = 0; ssize_t _bytes = 0;
char *line = NULL; char line[1024];
while (!taosEOFFile(pFile)) { while (!taosEOFFile(pFile)) {
int64_t o_rbytes = 0; int64_t o_rbytes = 0;
...@@ -724,7 +717,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) { ...@@ -724,7 +717,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
int64_t nouse6 = 0; int64_t nouse6 = 0;
char nouse0[200] = {0}; char nouse0[200] = {0};
_bytes = taosGetLineFile(pFile, &line); _bytes = taosGetsFile(pFile, sizeof(line), line);
if (_bytes < 0) { if (_bytes < 0) {
break; break;
} }
...@@ -743,7 +736,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) { ...@@ -743,7 +736,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
*transmit_bytes = o_tbytes; *transmit_bytes = o_tbytes;
} }
if (line != NULL) taosMemoryFreeClear(line);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return 0; return 0;
......
...@@ -468,12 +468,11 @@ static int32_t taosArrayPartition(SArray* pArray, int32_t i, int32_t j, __ext_co ...@@ -468,12 +468,11 @@ static int32_t taosArrayPartition(SArray* pArray, int32_t i, int32_t j, __ext_co
return i; return i;
} }
static void taosArrayQuicksortHelper(SArray* pArray, int32_t low, int32_t high, __ext_compar_fn_t fn, static void taosArrayQuicksortImpl(SArray* pArray, int32_t low, int32_t high, __ext_compar_fn_t fn, const void* param) {
const void* param) {
if (low < high) { if (low < high) {
int32_t idx = taosArrayPartition(pArray, low, high, fn, param); int32_t idx = taosArrayPartition(pArray, low, high, fn, param);
taosArrayQuicksortHelper(pArray, low, idx - 1, fn, param); taosArrayQuicksortImpl(pArray, low, idx - 1, fn, param);
taosArrayQuicksortHelper(pArray, idx + 1, high, fn, param); taosArrayQuicksortImpl(pArray, idx + 1, high, fn, param);
} }
} }
...@@ -481,7 +480,7 @@ static void taosArrayQuickSort(SArray* pArray, __ext_compar_fn_t fn, const void* ...@@ -481,7 +480,7 @@ static void taosArrayQuickSort(SArray* pArray, __ext_compar_fn_t fn, const void*
if (pArray->size <= 1) { if (pArray->size <= 1) {
return; return;
} }
taosArrayQuicksortHelper(pArray, 0, (int32_t)(taosArrayGetSize(pArray) - 1), fn, param); taosArrayQuicksortImpl(pArray, 0, (int32_t)(taosArrayGetSize(pArray) - 1), fn, param);
} }
static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void* param) { static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void* param) {
...@@ -564,3 +563,21 @@ char* taosShowStrArray(const SArray* pArray) { ...@@ -564,3 +563,21 @@ char* taosShowStrArray(const SArray* pArray) {
} }
return res; return res;
} }
void taosArraySwap(SArray* a, SArray* b) {
if (a == NULL || b == NULL) return;
size_t t = a->size;
a->size = b->size;
b->size = t;
uint32_t cap = a->capacity;
a->capacity = b->capacity;
b->capacity = cap;
uint32_t elem = a->elemSize;
a->elemSize = b->elemSize;
b->elemSize = elem;
void* data = a->pData;
a->pData = b->pData;
b->pData = data;
}
...@@ -714,7 +714,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) { ...@@ -714,7 +714,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
} }
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
char *line = NULL, *name, *value, *value2, *value3; char line[1024], *name, *value, *value2, *value3;
int32_t olen, vlen, vlen2, vlen3; int32_t olen, vlen, vlen2, vlen3;
int32_t code = 0; int32_t code = 0;
ssize_t _bytes = 0; ssize_t _bytes = 0;
...@@ -743,7 +743,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { ...@@ -743,7 +743,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
name = value = value2 = value3 = NULL; name = value = value2 = value3 = NULL;
olen = vlen = vlen2 = vlen3 = 0; olen = vlen = vlen2 = vlen3 = 0;
_bytes = taosGetLineFile(pFile, &line); _bytes = taosGetsFile(pFile, sizeof(line), line);
if (_bytes <= 0) { if (_bytes <= 0) {
break; break;
} }
...@@ -775,14 +775,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { ...@@ -775,14 +775,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
} }
taosCloseFile(&pFile); taosCloseFile(&pFile);
if (line != NULL) taosMemoryFreeClear(line);
uInfo("load from env cfg file %s success", filepath); uInfo("load from env cfg file %s success", filepath);
return 0; return 0;
} }
int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
char *line = NULL, *name, *value, *value2, *value3; char line[1024], *name, *value, *value2, *value3;
int32_t olen, vlen, vlen2, vlen3; int32_t olen, vlen, vlen2, vlen3;
ssize_t _bytes = 0; ssize_t _bytes = 0;
int32_t code = 0; int32_t code = 0;
...@@ -804,7 +803,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { ...@@ -804,7 +803,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
name = value = value2 = value3 = NULL; name = value = value2 = value3 = NULL;
olen = vlen = vlen2 = vlen3 = 0; olen = vlen = vlen2 = vlen3 = 0;
_bytes = taosGetLineFile(pFile, &line); _bytes = taosGetsFile(pFile, sizeof(line), line);
if (_bytes <= 0) { if (_bytes <= 0) {
break; break;
} }
...@@ -836,7 +835,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { ...@@ -836,7 +835,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
} }
taosCloseFile(&pFile); taosCloseFile(&pFile);
if (line != NULL) taosMemoryFreeClear(line);
if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) { if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) {
uInfo("load from cfg file %s success", filepath); uInfo("load from cfg file %s success", filepath);
......
...@@ -31,7 +31,7 @@ TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) { ...@@ -31,7 +31,7 @@ TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) {
return pthread; return pthread;
} }
bool taosDestoryThread(TdThread* pthread) { bool taosDestroyThread(TdThread* pthread) {
if (pthread == NULL) return false; if (pthread == NULL) return false;
if (taosThreadRunning(pthread)) { if (taosThreadRunning(pthread)) {
taosThreadCancel(*pthread); taosThreadCancel(*pthread);
......
...@@ -39,8 +39,8 @@ int32_t tGenIdPI32(void) { ...@@ -39,8 +39,8 @@ int32_t tGenIdPI32(void) {
int64_t tGenIdPI64(void) { int64_t tGenIdPI64(void) {
if (tUUIDHashId == 0) { if (tUUIDHashId == 0) {
char uid[64]; char uid[65] = {0};
int32_t code = taosGetSystemUUID(uid, tListLen(uid)); int32_t code = taosGetSystemUUID(uid, 64);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
} else { } else {
......
...@@ -19,10 +19,9 @@ from util.dnodes import * ...@@ -19,10 +19,9 @@ from util.dnodes import *
class TDTestCase: class TDTestCase:
def caseDescription(self): def caseDescription(self):
''' """
[TD-11510] taosBenchmark test cases [TD-11510] taosBenchmark test cases
''' """
return
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
...@@ -31,19 +30,19 @@ class TDTestCase: ...@@ -31,19 +30,19 @@ class TDTestCase:
def getPath(self, tool="taosBenchmark"): def getPath(self, tool="taosBenchmark"):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): if "community" in selfPath:
projPath = selfPath[:selfPath.find("community")] projPath = selfPath[: selfPath.find("community")]
else: else:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[: selfPath.find("tests")]
paths = [] paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ((tool) in files): if (tool) in files:
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if "packaging" not in rootRealPath:
paths.append(os.path.join(root, tool)) paths.append(os.path.join(root, tool))
break break
if (len(paths) == 0): if len(paths) == 0:
tdLog.exit("taosBenchmark not found!") tdLog.exit("taosBenchmark not found!")
return return
else: else:
...@@ -52,14 +51,15 @@ class TDTestCase: ...@@ -52,14 +51,15 @@ class TDTestCase:
def run(self): def run(self):
binPath = self.getPath() binPath = self.getPath()
cmd = "%s -f ./5-taos-tools/taosbenchmark/json/default.json" %binPath cmd = "%s -f ./5-taos-tools/taosbenchmark/json/default.json" % binPath
tdLog.info("%s" % cmd) tdLog.info("%s" % cmd)
os.system("%s" % cmd) os.system("%s" % cmd)
tdSql.execute("reset query cache") tdSql.execute("reset query cache")
tdSql.query("select count(*) from (select distinct(tbname) from db.stb)") tdSql.query("select count(*) from (select distinct(tbname) from db.stb)")
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
tdSql.query("select count(*) from db.stb") tdSql.query("select count(*) from db.stb")
tdSql.checkData(0, 0, 100) if len(tdSql.queryResult):
tdLog.exit("query result is %d" % len(tdSql.queryResult))
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -795,12 +795,34 @@ if $data81 != 4 then ...@@ -795,12 +795,34 @@ if $data81 != 4 then
endi endi
# desc fill query # desc fill query
print asc fill query
sql select _wstart,count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by _wstart asc;
if $rows != 12 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data01 != 1 then
return -1
endi
print desc fill query print desc fill query
sql select count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10); sql select _wstart,count(*) from m_fl_tb0 where ts>='2018-9-17 9:0:0' and ts<='2018-9-17 9:11:00' interval(1m) fill(value,10) order by _wstart desc;
if $rows != 12 then if $rows != 12 then
return -1 return -1
endi endi
if $data00 != @18-09-17 09:11:00.000@ then
return -1
endi
if $data01 != 10 then
return -1
endi
print =====================> aggregation + arithmetic + fill, need to add cases TODO print =====================> aggregation + arithmetic + fill, need to add cases TODO
#sql select avg(cpu_taosd) - first(cpu_taosd) from dn1 where ts<'2020-11-13 11:00:00' and ts>'2020-11-13 10:50:00' interval(10s) fill(value, 99) #sql select avg(cpu_taosd) - first(cpu_taosd) from dn1 where ts<'2020-11-13 11:00:00' and ts>'2020-11-13 10:50:00' interval(10s) fill(value, 99)
#sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(value, 99); #sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(value, 99);
......
...@@ -622,4 +622,56 @@ if $data12 != 2 then ...@@ -622,4 +622,56 @@ if $data12 != 2 then
goto loop3 goto loop3
endi endi
sql create database test4 vgroups 1;
sql use test4;
sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams4 trigger at_once into streamt4 as select _wstart, count(*) c1 from t1 where a > 5 interval(10s);
sql insert into t1 values(1648791213000,1,2,3,1.0);
sleep 200
sql select * from streamt4;
# row 0
if $rows != 0 then
print =====rows=$rows
return -1
endi
sql insert into t1 values(1648791213000,6,2,3,1.0);
$loop_count = 0
loop4:
sleep 200
sql select * from streamt4;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $data01 != 1 then
print =====data01=$data01
goto loop4
endi
sql insert into t1 values(1648791213000,2,2,3,1.0);
$loop_count = 0
loop5:
sleep 200
sql select * from streamt4;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 0 then
print =====rows=$rows
goto loop5
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -3,12 +3,15 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,12 +3,15 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 50 sleep 50
sql connect sql connect
sql create dnode $hostname2 port 7200 sql create dnode $hostname2 port 7200
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
#==system sh/exec.sh -n dnode2 -s start -v
print ===== step1 print ===== step1
$x = 0 $x = 0
...@@ -232,4 +235,41 @@ endi ...@@ -232,4 +235,41 @@ endi
print loop3 over print loop3 over
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==system sh/exec.sh -n dnode2 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode2
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
...@@ -4,6 +4,8 @@ looptest: ...@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200 sleep 200
sql connect sql connect
...@@ -353,6 +355,22 @@ endi ...@@ -353,6 +355,22 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
sql drop stream if exists streams0; sql drop stream if exists streams0;
......
...@@ -4,6 +4,8 @@ looptest: ...@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200 sleep 200
sql connect sql connect
...@@ -671,6 +673,22 @@ endi ...@@ -671,6 +673,22 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
sql drop stream if exists streams0; sql drop stream if exists streams0;
......
...@@ -4,6 +4,8 @@ looptest: ...@@ -4,6 +4,8 @@ looptest:
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200 sleep 200
sql connect sql connect
...@@ -1011,6 +1013,21 @@ endi ...@@ -1011,6 +1013,21 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
......
...@@ -4,6 +4,7 @@ looptest: ...@@ -4,6 +4,7 @@ looptest:
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
#==system sh/exec.sh -n dnode1 -s start -v
sleep 200 sleep 200
sql connect sql connect
...@@ -463,6 +464,20 @@ endi ...@@ -463,6 +464,20 @@ endi
#==system sh/exec.sh -n dnode1 -s stop -x SIGINT
#==print =============== check
#==$null=
#==system_content sh/checkValgrind.sh -n dnode1
#==print cmd return result ----> [ $system_content ]
#==if $system_content > 0 then
#== return -1
#==endi
#==if $system_content == $null then
#== return -1
#==endi
#==return 1
......
...@@ -587,8 +587,6 @@ sleep 300 ...@@ -587,8 +587,6 @@ sleep 300
sql delete from st where ts = 1648791223000; sql delete from st where ts = 1648791223000;
sql select * from test.streamt5;
$loop_count = 0 $loop_count = 0
loop15: loop15:
...@@ -604,11 +602,10 @@ if $rows != 4 then ...@@ -604,11 +602,10 @@ if $rows != 4 then
print =====rows=$rows print =====rows=$rows
print =====rows=$rows print =====rows=$rows
print =====rows=$rows print =====rows=$rows
# goto loop15 #goto loop15
endi endi
$loop_all = $loop_all + 1 $loop_all = $loop_all + 1
print ============loop_all=$loop_all print ============loop_all=$loop_all
......
...@@ -5,15 +5,15 @@ sleep 50 ...@@ -5,15 +5,15 @@ sleep 50
sql connect sql connect
print =============== create database print =============== create database
sql create database test vgroups 1 sql create database test vgroups 1;
sql select * from information_schema.ins_databases sql select * from information_schema.ins_databases;
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
print $data00 $data01 $data02 print $data00 $data01 $data02
sql use test sql use test;
sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int); 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 t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2); sql create table t2 using st tags(2,2,2);
...@@ -48,8 +48,9 @@ if $loop_count == 10 then ...@@ -48,8 +48,9 @@ if $loop_count == 10 then
return -1 return -1
endi endi
print step 0
sql select * from streamt sql select * from streamt;
# row 0 # row 0
if $data01 != 1 then if $data01 != 1 then
...@@ -97,7 +98,7 @@ endi ...@@ -97,7 +98,7 @@ endi
print step 1 print step 1
sql select * from streamt2 sql select * from streamt2;
# row 0 # row 0
if $data01 != 1 then if $data01 != 1 then
...@@ -239,6 +240,67 @@ if $data32 != 6 then ...@@ -239,6 +240,67 @@ if $data32 != 6 then
goto loop0 goto loop0
endi endi
print step 3.1
sql insert into t1 values(1648791216001,2,2,3,1.1);
$loop_count = 0
loop00:
sleep 300
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt2;
# row 0
if $data01 != 1 then
print =====data01=$data01
goto loop00
endi
if $data02 != 1 then
print =====data02=$data02
goto loop00
endi
# row 1
if $data11 != 3 then
print =====data11=$data11
goto loop00
endi
if $data12 != 5 then
print =====data12=$data12
goto loop00
endi
# row 2
if $data21 != 3 then
print =====data21=$data21
goto loop00
endi
if $data22 != 7 then
print =====data22=$data22
goto loop00
endi
# row 3
if $data31 != 1 then
print =====data31=$data31
goto loop00
endi
if $data32 != 3 then
print =====data32=$data32
goto loop00
endi
print step 4 print step 4
sql create database test1 vgroups 1 sql create database test1 vgroups 1
...@@ -513,6 +575,8 @@ endi ...@@ -513,6 +575,8 @@ endi
$loop_count = 0 $loop_count = 0
print step 7
loop4: loop4:
sleep 100 sleep 100
......
...@@ -64,7 +64,7 @@ class TDTestCase: ...@@ -64,7 +64,7 @@ class TDTestCase:
ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
tdLog.info("restart taosd to ensure that the data falls into the disk") tdLog.info("flush database to ensure that the data falls into the disk")
# tdDnodes.stop(1) # tdDnodes.stop(1)
# tdDnodes.start(1) # tdDnodes.start(1)
tdSql.query("flush database %s"%(paraDict['dbName'])) tdSql.query("flush database %s"%(paraDict['dbName']))
...@@ -87,7 +87,7 @@ class TDTestCase: ...@@ -87,7 +87,7 @@ class TDTestCase:
'rowsPerTbl': 1000, 'rowsPerTbl': 1000,
'batchNum': 100, 'batchNum': 100,
'startTs': 1640966400000, # 2022-01-01 00:00:00.000 'startTs': 1640966400000, # 2022-01-01 00:00:00.000
'pollDelay': 5, 'pollDelay': 10,
'showMsg': 1, 'showMsg': 1,
'showRow': 1, 'showRow': 1,
'snapshot': 0} 'snapshot': 0}
......
IF (TD_WEBSOCKET) IF (TD_WEBSOCKET)
IF (TD_LINUX)
SET(websocket_lib_file "libtaosws.so")
ELSEIF (TD_DARWIN)
SET(websocket_lib_file "libtaosws.dylib")
ENDIF ()
MESSAGE("${Green} use libtaos-ws${ColourReset}") MESSAGE("${Green} use libtaos-ws${ColourReset}")
IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD") IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD")
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(taosws-rs ExternalProject_Add(taosws-rs
PREFIX "taosws-rs" PREFIX "taosws-rs"
...@@ -15,7 +20,7 @@ IF (TD_WEBSOCKET) ...@@ -15,7 +20,7 @@ IF (TD_WEBSOCKET)
COMMAND cargo build --release -p taos-ws-sys COMMAND cargo build --release -p taos-ws-sys
COMMAND ./taos-ws-sys/ci/package.sh COMMAND ./taos-ws-sys/ci/package.sh
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
) )
...@@ -34,7 +39,7 @@ IF (TD_WEBSOCKET) ...@@ -34,7 +39,7 @@ IF (TD_WEBSOCKET)
COMMAND cargo build --release -p taos-ws-sys COMMAND cargo build --release -p taos-ws-sys
COMMAND ./taos-ws-sys/ci/package.sh COMMAND ./taos-ws-sys/ci/package.sh
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
) )
......
...@@ -6,6 +6,10 @@ IF (TD_LINUX AND TD_WEBSOCKET) ...@@ -6,6 +6,10 @@ IF (TD_LINUX AND TD_WEBSOCKET)
ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws)
SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws")
ADD_DEPENDENCIES(shell taosws-rs) ADD_DEPENDENCIES(shell taosws-rs)
ELSEIF (TD_DARWIN AND TD_WEBSOCKET)
ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include)
SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib")
ADD_DEPENDENCIES(shell taosws-rs)
ELSE () ELSE ()
SET(LINK_WEBSOCKET "") SET(LINK_WEBSOCKET "")
ENDIF () ENDIF ()
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __SHELL_AUTO__
#define __SHELL_AUTO__
#define TAB_KEY 0x09
// press tab key
void pressTabKey(SShellCmd* cmd);
// press othr key
void pressOtherKey(char c);
// init shell auto funciton , shell start call once
bool shellAutoInit();
// set conn
void shellSetConn(TAOS* conn);
// exit shell auto funciton, shell exit call once
void shellAutoExit();
// callback autotab module
void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
// introduction
void printfIntroduction();
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册